 |
|
C# WipApp ช่วยออกแบบโค้ด ให้หน่อยครับ (อีกแล้วครับ) |
|
 |
|
|
 |
 |
|
เขียนเป็น ชุดโมดูลไว้ครับ และ ซุ่มแค่จะใช้โมดูลไหนมาใช้
|
 |
 |
 |
 |
Date :
2019-03-20 07:09:48 |
By :
Chaidhanan |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
โค้ดสำหรับโหลดรูป เนื้อหาการเรียนในเว็บ
http://http://www.skktutor.com
เผื่อใครสนใจ เก็บไว้อ่านครับ
Code (C#)
string IDMpath = Microsoft.Win32.Registry.GetValue(@"HKEY_CURRENT_USER\Software\DownloadManager", "ExePath", true).ToString();
new System.Threading.Thread(() =>
{
new System.Threading.Thread(() =>
{
for (int i = 1; i < 100; i++)
{
for (int a = 1; a < 2000; a++)
{
string url = "http://www.skktutor.com/index.php?module=course&op=listall&category_id="+i+"&course_id=" + a;
this.Invoke(new Action(() => this.Text = url));
foreach (Match myMatch in new Regex(@"""text-align:left"" ><a href='(\?module=course&op=detail&id=.*?)'>", RegexOptions.None)
.Matches(Program.getHTML(url)))
{
foreach (Match _myMatch in new Regex(@"src=""(/ckfinder/userfiles/images/.*?.[jpgpn]{3,})""", RegexOptions.None).Matches(Program.getHTML("http://www.skktutor.com/" + myMatch.Groups[1].Value)))
{
var uriDecoded = Uri.UnescapeDataString(_myMatch.Groups[1].Value);
string _file = @"skktutor\" + System.IO.Path.GetFileName(System.IO.Path.GetDirectoryName(uriDecoded)) + "\\" + System.IO.Path.GetFileName(uriDecoded);
_file = _file.Replace("?", "");
System.Diagnostics.Process.Start(IDMpath, "/a /n /d " + "http://www.skktutor.com" + _myMatch.Groups[1].Value + " /f \"" + _file + "\"");
// richTextBox1.Invoke(new Action(() => richTextBox1.Text += "\n http://www.skktutor.com" + _myMatch.Groups[1].Value));
}
}
}
}
}).Start();
ปล.โค้ดใช้ IDM ในการโหลดนะครับ
จะโหลดผ่าน WebClient ก็ได้ ครับ
Code (C#)
using (WebClient webClient = new WebClient())
{
try
{
webClient.DownloadFileAsync(new Uri(myMatch.Groups[1].Value), _file);
}
catch (Exception ex)
{
this.Invoke(new Action(() => { this.Text = ex.Message; }));
}
}
|
 |
 |
 |
 |
Date :
2019-03-20 15:05:00 |
By :
lamaka.tor |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
จาก #NO 5
มันช่วยปลุกผมให้ตื่น (ทำให้ผมมีกำลังใจเพิ่มมากขึ้น) แน่นอนว่าผมต้องเหนื่อยสุดสุดสุด อีกครั้งหนึ่ง
ผมตัดสินใจเด็ดขาด เปลี่ยนแปลงโค๊ดของตัวเองให้เป็นดังนี้
---1. จาก Bootstrap3 ก็จะเปลี่ยนเป็น Bootstrap4
---2. จาก WebForms ก็จะเปลี่ยนเป็น MVC
---3. จาก VB.NET ก็จะเปลี่ยนเป็น C# (เฉพาะ Core หลัก)
---และจาก 1-3 ผมก็จะเอาขึ้น .>= NET Core 2.2
---4. จะเอา Python มารวมกับ 1-3
อันนี้แจ๋วและแจ่มแมวจริงฯ ผมเตรียมเอาไว้แล้วและจะต้องใช้งานในอนาคต
Code (C#)
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using Microsoft.AspNetCore.Razor.TagHelpers;
using System.ComponentModel.DataAnnotations;
using System.ComponentModel;
using HtmlAgilityPack;
using Microsoft.Extensions.Caching.Memory;
using System.Text.Encodings.Web;
/*
This TH was written by Francisco Rodriguez
Usage:
<html-extraction html-local-path="pathname" html-attribute="class" html-attribute-value="content-wrapper">
</html-extraction
*/
namespace AdminLTE.NETCore.TagHelpers
{
/// <summary>
/// TagHelper used to extract section of a local html file.
/// </summary>
[HtmlTargetElement("html-extraction")]
public class HtmlExtractionTagHelper : TagHelper //Microsoft.AspNetCore.Mvc.TagHelpers.CacheTagHelper //
{
//Not working, need to revisit.
//public HtmlExtractionTagHelper(IMemoryCache memoryCache, HtmlEncoder htmlEncoder) : base(memoryCache, htmlEncoder)
//{
// //Need to look at making this configurable.
// ExpiresSliding = TimeSpan.FromMinutes(5);
//}
/// <summary>
/// Currently only looking at local html files.
/// </summary>
[HtmlAttributeName("html-local-path")]
public string HtmlLocalPath { get; set; }
/// <summary>
/// Type of Attribute looking for example "class"
/// </summary>
[HtmlAttributeName("html-attribute")]
public string HtmlAttribute { get; set; } = "class";
/// <summary>
/// Type of Attribute looking for example "content-wrapper"
/// </summary>
[HtmlAttributeName("html-attribute-value")]
public string HtmlAttributeValue { get; set; } = "content-wrapper";
/// <summary>
/// String replacement format {,} where the first element is the value to look for
/// and the second is the value to replace with
/// </summary>
[HtmlAttributeName("html-replacement")]
public string HtmlReplacement { get; set; }
public override void Process(TagHelperContext context, TagHelperOutput output)
{
//Clear the TagName as it is only used for calling this taghelper
output.TagName = "";
//Don't do anything if this value is not provided
if (!String.IsNullOrEmpty(HtmlLocalPath)
&& !(String.IsNullOrEmpty(HtmlAttribute))
&& !(String.IsNullOrEmpty(HtmlAttributeValue)))
{
//Todo: Add caching
try
{
HtmlDocument document2 = new HtmlDocument();
document2.Load(new System.IO.MemoryStream(System.IO.File.ReadAllBytes(HtmlLocalPath)));
var root = document2.DocumentNode;
var p = root.Descendants()
.Where(n => n.GetAttributeValue(HtmlAttribute, "").Equals(HtmlAttributeValue))
.Single();
//Make this configurable.
var content = p.InnerHtml.Replace("dist/img/", "/lib/AdminLTE-2.3.11/dist/img/");
if (!String.IsNullOrEmpty(HtmlReplacement))
{
try
{
//TODO: Need an elegant way to split {},{}... and split the contents with comma.
//Right now only handling one
var splititem = HtmlReplacement.Split('{', '}');
if (splititem != null && splititem.Length > 0)
{
var replacement = splititem[1].Split(',');
content = content.Replace(replacement[0], replacement[1]);
}
}
catch
{
}
}
output.Content.SetHtmlContent(content);
}
catch //Possibly not found or other error
{ }
}
}
}
}
|
 |
 |
 |
 |
Date :
2019-03-22 15:51:00 |
By :
หน้าฮี |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|

|
 |
 |
 |
 |
Date :
2019-03-22 16:04:42 |
By :
หน้าฮี |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
และผมก็หลบไม่พ้น NoodeJS

|
 |
 |
 |
 |
Date :
2019-03-22 16:20:20 |
By :
หน้าฮี |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
จาก #NO8
ผมใช้แค่ 1.x
แต่ทุกวันนี้มันวิ่งไปไกลถึง 7.x
+55555
|
 |
 |
 |
 |
Date :
2019-03-22 16:23:09 |
By :
หน้าฮี |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
จาก #NO6 - รายงานความสำเร็จ
--1. จาก Bootstrap3 ก็จะเปลี่ยนเป็น Bootstrap4
------ OK ผมทำได้แล้ว
---2. จาก WebForms ก็จะเปลี่ยนเป็น MVC
------ OK ผมทำได้แล้ว
---3. จาก VB.NET ก็จะเปลี่ยนเป็น C# (เฉพาะ Core หลัก)
------ OK ผมทำได้แล้ว
ขั้นตอนผมทำดังนี้
1. เปิด Visual Studio 2017 Communitity(Free)
2. สร้างโปรเจค
--- 2.1 เลือกภาษา C#
--- 2.2 เลือก MVC Template
--- 2.3 หลับหูหลับตา Next... จนเสร็จสิ้น
3. ลอง ดีบั๊ก (ไปที่ที่เมนู Debug --> Debuging
--- OK ผ่าน
|
 |
 |
 |
 |
Date :
2019-03-23 20:26:03 |
By :
หน้าฮี |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
จาก #NO10 - ผมไปดาวโหลดตัว Bootstrap4 จากที่นี่
--- https://coreui.io
------ ผลของความพยายามมันได้ดังนี้



|
 |
 |
 |
 |
Date :
2019-03-23 20:40:29 |
By :
หน้าฮี |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
จาก #NO11
ผมใช้้คำว่า "ถีบ" ภาษา C#/VB/etc... ออกไปให้หมด
--- จากรูปภาพด้านล่างช่วยยืนยันการ "ถีบ"

+55555
|
 |
 |
 |
 |
Date :
2019-03-23 21:03:36 |
By :
หน้าฮี |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
|
|