This commit is contained in:
2014-10-08 09:37:02 +00:00
parent 1fac360745
commit ddc18468dc
3 changed files with 1584 additions and 42 deletions

51
Form1.Designer.cs generated
View File

@@ -28,14 +28,20 @@
/// </summary> /// </summary>
private void InitializeComponent() private void InitializeComponent()
{ {
this.components = new System.ComponentModel.Container();
System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(Form1));
this.Process = new System.Windows.Forms.CheckBox(); this.Process = new System.Windows.Forms.CheckBox();
this.tbURL = new System.Windows.Forms.TextBox(); this.tbURL = new System.Windows.Forms.TextBox();
this.notifyIcon1 = new System.Windows.Forms.NotifyIcon(this.components);
this.lbReqCnt = new System.Windows.Forms.Label();
this.lbRespCnt = new System.Windows.Forms.Label();
this.lbStatus = new System.Windows.Forms.Label();
this.SuspendLayout(); this.SuspendLayout();
// //
// Process // Process
// //
this.Process.Appearance = System.Windows.Forms.Appearance.Button; this.Process.Appearance = System.Windows.Forms.Appearance.Button;
this.Process.Location = new System.Drawing.Point(104, 65); this.Process.Location = new System.Drawing.Point(12, 49);
this.Process.Name = "Process"; this.Process.Name = "Process";
this.Process.Size = new System.Drawing.Size(139, 77); this.Process.Size = new System.Drawing.Size(139, 77);
this.Process.TabIndex = 0; this.Process.TabIndex = 0;
@@ -51,15 +57,54 @@
this.tbURL.Size = new System.Drawing.Size(343, 21); this.tbURL.Size = new System.Drawing.Size(343, 21);
this.tbURL.TabIndex = 1; this.tbURL.TabIndex = 1;
// //
// notifyIcon1
//
this.notifyIcon1.Icon = ((System.Drawing.Icon)(resources.GetObject("notifyIcon1.Icon")));
this.notifyIcon1.Text = "notifyIcon1";
this.notifyIcon1.Visible = true;
this.notifyIcon1.MouseClick += new System.Windows.Forms.MouseEventHandler(this.notifyIcon1_MouseClick);
//
// lbReqCnt
//
this.lbReqCnt.AutoSize = true;
this.lbReqCnt.Location = new System.Drawing.Point(12, 151);
this.lbReqCnt.Name = "lbReqCnt";
this.lbReqCnt.Size = new System.Drawing.Size(47, 12);
this.lbReqCnt.TabIndex = 2;
this.lbReqCnt.Text = "요청 : 0";
//
// lbRespCnt
//
this.lbRespCnt.AutoSize = true;
this.lbRespCnt.Location = new System.Drawing.Point(12, 168);
this.lbRespCnt.Name = "lbRespCnt";
this.lbRespCnt.Size = new System.Drawing.Size(47, 12);
this.lbRespCnt.TabIndex = 3;
this.lbRespCnt.Text = "응답 : 0";
//
// lbStatus
//
this.lbStatus.AutoSize = true;
this.lbStatus.Location = new System.Drawing.Point(12, 184);
this.lbStatus.Name = "lbStatus";
this.lbStatus.Size = new System.Drawing.Size(65, 12);
this.lbStatus.TabIndex = 4;
this.lbStatus.Text = "상태 : 대기";
//
// Form1 // Form1
// //
this.AutoScaleDimensions = new System.Drawing.SizeF(7F, 12F); this.AutoScaleDimensions = new System.Drawing.SizeF(7F, 12F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.ClientSize = new System.Drawing.Size(367, 212); this.ClientSize = new System.Drawing.Size(367, 212);
this.Controls.Add(this.lbStatus);
this.Controls.Add(this.lbRespCnt);
this.Controls.Add(this.lbReqCnt);
this.Controls.Add(this.tbURL); this.Controls.Add(this.tbURL);
this.Controls.Add(this.Process); this.Controls.Add(this.Process);
this.Name = "Form1"; this.Name = "Form1";
this.Text = "Form1"; this.Text = "Form1";
this.FormClosing += new System.Windows.Forms.FormClosingEventHandler(this.Form1_FormClosing);
this.Resize += new System.EventHandler(this.Form1_Resize);
this.ResumeLayout(false); this.ResumeLayout(false);
this.PerformLayout(); this.PerformLayout();
@@ -69,6 +114,10 @@
private System.Windows.Forms.CheckBox Process; private System.Windows.Forms.CheckBox Process;
private System.Windows.Forms.TextBox tbURL; private System.Windows.Forms.TextBox tbURL;
private System.Windows.Forms.NotifyIcon notifyIcon1;
private System.Windows.Forms.Label lbReqCnt;
private System.Windows.Forms.Label lbRespCnt;
private System.Windows.Forms.Label lbStatus;
} }
} }

101
Form1.cs
View File

@@ -11,25 +11,45 @@ namespace WebChecker
{ {
public partial class Form1 : Form public partial class Form1 : Form
{ {
const int CHECK_PERIOD = 30000;
WebBrowser wb = new WebBrowser(); WebBrowser wb = new WebBrowser();
string url = "http://me.sayclub.com/profile/home/view/ban8"; string url = "http://me.sayclub.com/profile/home/view/ban8";
Timer m_Timer = new Timer(); Timer m_Timer = new Timer();
bool m_bProcessing = false;
int m_iReqCnt = 0;
int m_iRespCnt = 0;
string m_strStatus = "";
DateTime m_LastCheckT;
public Form1() public Form1()
{ {
InitializeComponent(); InitializeComponent();
notifyIcon1.Visible = false;
tbURL.Text = url; tbURL.Text = url;
m_Timer.Interval = 5000; m_Timer.Interval = 1000;
m_Timer.Tick += new EventHandler(m_Timer_Tick); m_Timer.Tick += new EventHandler(m_Timer_Tick);
wb.ScriptErrorsSuppressed = true;
wb.DocumentCompleted += new WebBrowserDocumentCompletedEventHandler(wb_DocumentCompleted); wb.DocumentCompleted += new WebBrowserDocumentCompletedEventHandler(wb_DocumentCompleted);
} }
void wb_DocumentCompleted(object sender, WebBrowserDocumentCompletedEventArgs e) void wb_DocumentCompleted(object sender, WebBrowserDocumentCompletedEventArgs e)
{ {
if(e.Url.Host != wb.Url.Host)
return;
if((sender == wb) &&
(wb.ReadyState == WebBrowserReadyState.Complete || wb.ReadyState == WebBrowserReadyState.Interactive))
{
lbStatus.Text = "상태 : 응답 받고 체크 중";
m_iRespCnt++;
lbRespCnt.Text = "응답 : " + m_iRespCnt;
HtmlDocument doc = wb.Document; HtmlDocument doc = wb.Document;
HtmlElement element = doc.GetElementById("sbPersonalInfo"); HtmlElement element = doc.GetElementById("sbPersonalInfo");
@@ -42,41 +62,33 @@ namespace WebChecker
if(attr.IndexOf("login") >= 0) if(attr.IndexOf("login") >= 0)
{ {
Process.Checked = false; Process.Checked = false;
MessageBox.Show("loged in"); MessageBox.Show("logged in");
} }
m_bProcessing = false; lbStatus.Text = "상태 : 체크 완료";
wb.Stop();
}
//string strStatus = element.InnerText;
//string[] strList = strStatus.Split(':');
//strStatus = strList[1];
//strStatus = strStatus.Trim();
//HtmlElement element = doc.GetElementById("sbVisitedUser");
//string strCnt = (string)element.InnerText.Clone();
//strCnt = strCnt.Substring(0, strCnt.IndexOf("명"));
//strCnt = strCnt.Substring(strCnt.IndexOf("오늘")+"오늘".Length);
//strCnt = strCnt.Trim();
//int iCnt = Convert.ToInt32(strCnt);
//if(iCnt > 3)
// MessageBox.Show(iCnt + "명 : 확인해바라");
} }
void m_Timer_Tick(object sender, EventArgs e) void m_Timer_Tick(object sender, EventArgs e)
{ {
if(m_bProcessing == false && wb.IsBusy == false) if(wb.IsBusy == false)
{ {
m_bProcessing = true; TimeSpan span = DateTime.Now-m_LastCheckT;
if(span.TotalMilliseconds >= CHECK_PERIOD)
{
m_iReqCnt++;
lbReqCnt.Text = "요청 : " + m_iReqCnt;
lbStatus.Text = "상태 : 요청 중";
wb.Navigate(url); wb.Navigate(url);
m_LastCheckT = m_LastCheckT+TimeSpan.FromMilliseconds(CHECK_PERIOD);
}
else
{
lbStatus.Text = "상태 : 대기 (" + (int)(CHECK_PERIOD-span.TotalMilliseconds)/1000 + "초...)";
}
} }
} }
@@ -84,6 +96,8 @@ namespace WebChecker
{ {
if(Process.Checked == true) if(Process.Checked == true)
{ {
m_LastCheckT = DateTime.Now - TimeSpan.FromMilliseconds(CHECK_PERIOD-1000);
m_Timer.Start(); m_Timer.Start();
url = tbURL.Text; url = tbURL.Text;
@@ -91,6 +105,12 @@ namespace WebChecker
} }
else else
{ {
m_iReqCnt = 0;
m_iRespCnt = 0;
lbReqCnt.Text = "요청 : 0";
lbRespCnt.Text = "응답 : 0";
lbStatus.Text = "상태 : 대기";
m_Timer.Stop(); m_Timer.Stop();
tbURL.Enabled = true; tbURL.Enabled = true;
@@ -98,5 +118,30 @@ namespace WebChecker
wb.Stop(); wb.Stop();
} }
} }
private void Form1_Resize(object sender, EventArgs e)
{
if(this.WindowState == FormWindowState.Minimized)
{
notifyIcon1.Visible = true;
this.Hide();
}
else if(this.WindowState == FormWindowState.Normal)
{
notifyIcon1.Visible = false;
this.ShowInTaskbar = true;
}
}
private void Form1_FormClosing(object sender, FormClosingEventArgs e)
{
notifyIcon1.Visible = false;
}
private void notifyIcon1_MouseClick(object sender, MouseEventArgs e)
{
this.Show();
this.WindowState = FormWindowState.Normal;
}
} }
} }

1448
Form1.resx

File diff suppressed because it is too large Load Diff