private void OnDetectLoginTimer(object sender, EventArgs e) { if (!Alimama.IsOnline()) { Debugger.Log(0, null, "检测到掉线 " + DateTime.Now.ToString()); detectLoginTimer.Stop(); this.Show(); _bClicked = false; aliWebBrowser.Navigate(_loginURL); } else { TimeSpan delta = DateTime.Now - _lastLoginedTime; if (delta.TotalMinutes > 60) { detectLoginTimer.Interval = 60 * 1000; // 1分钟 } else { detectLoginTimer.Interval = 10 * 60 * 1000; // 10分钟 } Debugger.Log(0, null, "依旧在线 " + DateTime.Now.ToString()); } }
public void StartTranslateUrl(DbOperator database, Alimama alimama, string adzoneName, int startTime, int endTime, int interval) { StopThread = false; _qunfaThread = new Thread(QunfaThreadProc); QunfaParam param = new QunfaParam(this, database, alimama, adzoneName, startTime, endTime, interval); _qunfaThread.Start(param); }
public QunfaParam(ProductQunfa qunfa, DbOperator database, Alimama alimama, string adzoneName, int startTime, int endTime, int interval) { Qunfa = qunfa; Database = database; Mama = alimama; AdzoneName = adzoneName; StartTime = startTime; EndTime = endTime; Interval = interval; }
// 登录后获取推广位 private void getAdzoneButton_Click(object sender, EventArgs e) { if (!Alimama.IsOnline()) { MessageBox.Show("检测到掉线,正在尝试重连,请稍后重试..."); } else { List <string> adzoneList = _alimama.GetAdzone(); foreach (string item in adzoneList) { adzoneComboBox.Items.Add(item); } if (adzoneComboBox.Items.Count > 0) { adzoneComboBox.SelectedIndex = 0; qunfaButton.Enabled = true; translateButton.Enabled = true; } } }
// 转链 private void translateButton_Click(object sender, EventArgs e) { if (!Alimama.IsOnline()) { MessageBox.Show("检测到掉线,正在尝试重连,请稍后重试..."); } else { string url = urlTextBox.Text; if (url == "") { return; } string adzoneName = adzoneComboBox.Text; string imagePath, showContent; _alimama.TranslateURL(url, adzoneName, out imagePath, out showContent); TranslateLinkForm tlFrom = new TranslateLinkForm(); tlFrom.ImagePath = imagePath; tlFrom.ShowText = showContent; tlFrom.ShowDialog(); } }
private void OnDocumentComplete(object sender, WebBrowserDocumentCompletedEventArgs e) { string curURL = aliWebBrowser.Document.Url.ToString(); if (Alimama.IsOnline()) { if (curURL == Alimama._frontPage) { Debugger.Log(0, null, "登录成功"); _lastLoginedTime = DateTime.Now; IsLogined = true; this.Hide(); detectLoginTimer.Start(); } } else { HtmlElement he = aliWebBrowser.Document.GetElementById("J_SubmitQuick"); if (he != null) { Configure conf = MainForm.Database.loadConfigre(); if (!_bClicked && conf.Reconnect) // 设置了断线重连 { loginTimer.Interval = conf.ReconnectDelaySeconds * 1000; // 延时点快速登录按钮 loginTimer.Start(); } } else { _bClicked = false; aliWebBrowser.Navigate(_loginURL); } // if (curURL == _loginURL) // { // Configure conf = MainForm.Database.loadConfigre(); // if (!_bClicked && conf.Reconnect) // 设置了断线重连 // { // loginTimer.Interval = conf.ReconnectDelaySeconds * 1000; // 延时点快速登录按钮 // loginTimer.Start(); // } // } // else // { // _bClicked = false; // aliWebBrowser.Navigate(_loginURL); // } // if (curURL == "https://login.taobao.com/member/login.jhtml") // { // // 跳转到淘宝去了 // detectLoginTimer.Start(); // 需要再跳转到登录页面 // Debugger.Log(0, null, "重新跳转"); // } // else // { // Configure conf = MainForm.Database.loadConfigre(); // if (!_bClicked && conf.Reconnect) // 设置了断线重连 // { // loginTimer.Interval = conf.ReconnectDelaySeconds * 1000; // 延时 // loginTimer.Start(); // } // } } Debugger.Log(0, null, "OnDocumentComplete " + curURL); }