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>
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.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();
//
// Process
//
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.Size = new System.Drawing.Size(139, 77);
this.Process.TabIndex = 0;
@@ -51,15 +57,54 @@
this.tbURL.Size = new System.Drawing.Size(343, 21);
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
//
this.AutoScaleDimensions = new System.Drawing.SizeF(7F, 12F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
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.Process);
this.Name = "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.PerformLayout();
@@ -69,6 +114,10 @@
private System.Windows.Forms.CheckBox Process;
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;
}
}

127
Form1.cs
View File

@@ -11,72 +11,84 @@ namespace WebChecker
{
public partial class Form1 : Form
{
const int CHECK_PERIOD = 30000;
WebBrowser wb = new WebBrowser();
string url = "http://me.sayclub.com/profile/home/view/ban8";
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()
{
InitializeComponent();
notifyIcon1.Visible = false;
tbURL.Text = url;
m_Timer.Interval = 5000;
m_Timer.Interval = 1000;
m_Timer.Tick += new EventHandler(m_Timer_Tick);
wb.ScriptErrorsSuppressed = true;
wb.DocumentCompleted += new WebBrowserDocumentCompletedEventHandler(wb_DocumentCompleted);
}
void wb_DocumentCompleted(object sender, WebBrowserDocumentCompletedEventArgs e)
{
HtmlDocument doc = wb.Document;
if(e.Url.Host != wb.Url.Host)
return;
HtmlElement element = doc.GetElementById("sbPersonalInfo");
element = element.Children[element.Children.Count-1];
element = element.Children[0];
element = element.GetElementsByTagName("IMG")[0];
string attr = element.GetAttribute("src");
if(attr.IndexOf("login") >= 0)
if((sender == wb) &&
(wb.ReadyState == WebBrowserReadyState.Complete || wb.ReadyState == WebBrowserReadyState.Interactive))
{
Process.Checked = false;
MessageBox.Show("loged in");
lbStatus.Text = "상태 : 응답 받고 체크 중";
m_iRespCnt++;
lbRespCnt.Text = "응답 : " + m_iRespCnt;
HtmlDocument doc = wb.Document;
HtmlElement element = doc.GetElementById("sbPersonalInfo");
element = element.Children[element.Children.Count-1];
element = element.Children[0];
element = element.GetElementsByTagName("IMG")[0];
string attr = element.GetAttribute("src");
if(attr.IndexOf("login") >= 0)
{
Process.Checked = false;
MessageBox.Show("logged in");
}
lbStatus.Text = "상태 : 체크 완료";
wb.Stop();
}
m_bProcessing = false;
//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)
{
if(m_bProcessing == false && wb.IsBusy == false)
if(wb.IsBusy == false)
{
m_bProcessing = true;
wb.Navigate(url);
TimeSpan span = DateTime.Now-m_LastCheckT;
if(span.TotalMilliseconds >= CHECK_PERIOD)
{
m_iReqCnt++;
lbReqCnt.Text = "요청 : " + m_iReqCnt;
lbStatus.Text = "상태 : 요청 중";
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)
{
m_LastCheckT = DateTime.Now - TimeSpan.FromMilliseconds(CHECK_PERIOD-1000);
m_Timer.Start();
url = tbURL.Text;
@@ -91,6 +105,12 @@ namespace WebChecker
}
else
{
m_iReqCnt = 0;
m_iRespCnt = 0;
lbReqCnt.Text = "요청 : 0";
lbRespCnt.Text = "응답 : 0";
lbStatus.Text = "상태 : 대기";
m_Timer.Stop();
tbURL.Enabled = true;
@@ -98,5 +118,30 @@ namespace WebChecker
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