Skip to content

Commit

Permalink
Auto update check
Browse files Browse the repository at this point in the history
  • Loading branch information
hanel2527 committed Jul 13, 2019
1 parent 74713ed commit 2208137
Show file tree
Hide file tree
Showing 3 changed files with 39 additions and 25 deletions.
29 changes: 15 additions & 14 deletions Form1.Designer.cs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

19 changes: 13 additions & 6 deletions Form1.cs
Original file line number Diff line number Diff line change
Expand Up @@ -26,18 +26,20 @@ private void Form1_Load(object sender, EventArgs e)
this.AutoSize = true;
this.AutoSizeMode = AutoSizeMode.GrowAndShrink;
this.updateLinkLabel.Text = "현재 버전: " + version;
hdc.GallchangrankingCrawler tempGcrk = new GallchangrankingCrawler();
tempGcrk.NewVersionUpdateExist += UpdateUpdateLinkLabel;
tempGcrk.UpdateChecker(this.version);

}
private void UpdateConsole(object text, EventArgs e)
private void UpdateUpdateLinkLabel(object text, EventArgs e)
{
textConsole.AppendText((string)text);
updateLinkLabel.Text = (string)text;
}
private void gallCheckBtn_Click(object sender, EventArgs e)
{
hdc.GallchangrankingCrawler tempGcrk = new hdc.GallchangrankingCrawler(1, 2, gallIdTextBox.Text, isMinor.Checked);
tempGcrk.GallCheck(tempGcrk.gallUrl);
textConsole.AppendText(tempGcrk.gallName);
tempGcrk.NewVersionUpdateExist += UpdateConsole;
tempGcrk.UpdateChecker();
}

private void NewPageUpdate(object sender, EventArgs e)
Expand Down Expand Up @@ -166,13 +168,18 @@ private void button1_Click(object sender, EventArgs e)
private void linkLabel1_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e)
{
this.linkLabel1.LinkVisited = true;
System.Diagnostics.Process.Start("https://github.com/hanel2527/dcinisde-crawler.ver.2");
System.Diagnostics.Process.Start("https://gall.dcinside.com/board/view/?id=retouching&no=7413");
}

private void linkLabel2_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e)
{
this.linkLabel2.LinkVisited = true;
System.Diagnostics.Process.Start("https://gall.dcinside.com/board/lists?id=retouching");
}

private void updateLinkLabel_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e)
{
this.updateLinkLabel.LinkVisited = true;
System.Diagnostics.Process.Start("https://github.com/hanel2527/dcinisde-crawler.ver.2/releases/latest");
}
}
}
16 changes: 11 additions & 5 deletions gallchangranking.cs
Original file line number Diff line number Diff line change
Expand Up @@ -286,19 +286,25 @@ int GetOnlyInt(string str)
}
else { return -1; }
}
public string UpdateChecker() //구현
public void UpdateChecker(string currentVersion) //구현
{
string github = "https://github.com/hanel2527/dcinisde-crawler.ver.2/";
string github = "https://github.com/hanel2527/dcinisde-crawler.ver.2/blob/master/versions.txt";
var client = new WebClient();
client.Encoding = System.Text.Encoding.UTF8;
string text = client.DownloadString(github);
hap.HtmlDocument doc = new hap.HtmlDocument();
doc.LoadHtml(text);
if(NewVersionUpdateExist != null)
hap.HtmlNode myVersions = doc.DocumentNode.
SelectSingleNode("//table[@class='highlight tab-size js-file-line-container']");
text = myVersions.InnerText.Trim();
string[] versions = text.Split(new[] { ' ', '\r', '\n', '\t' }, StringSplitOptions.RemoveEmptyEntries);
if (NewVersionUpdateExist != null)
{
NewVersionUpdateExist(text, null);
if (versions[0].Equals(currentVersion))
NewVersionUpdateExist("최신 버전입니다: " + versions[0], null);
else
NewVersionUpdateExist("새로운 업데이트가 있습니다(클릭): " + versions[0], null);
}
return "최신 버전입니다";
}
public void Crawler()
{
Expand Down

0 comments on commit 2208137

Please sign in to comment.