public override void DoJob(TargetRecord jobInfo) { this.jobInfo = jobInfo; if (isBusy) return; isBusy = true; this.zcbFileDb = new FileDbEngine<ZcbFileDb>("ZcbDb", ".xml").LoadFileDB(); Thread thread = new Thread(new ThreadStart(DoJobInternal)); thread.IsBackground = true; thread.Start(); }
public PageProcessor(int pageIndex, TargetRecord jobInfo, PageLoader pageLoader, FileDb db, MaxiPageMgr maxiPageMgr, Speaker speaker) { this.speaker = speaker; this.maxiPageMgr = maxiPageMgr; this.db = db; this.pageLoader = pageLoader; this.pageIndex = pageIndex; this.jobInfo = jobInfo; }
protected void SendMessage(TargetRecord jobInfo) { System.Net.Mail.MailMessage msg = new System.Net.Mail.MailMessage(); msg.To.Add("*****@*****.**"); msg.From = new MailAddress("*****@*****.**", "Nx-Daigou Luebeck", System.Text.Encoding.UTF8); msg.Subject = jobInfo.Name + "==" + jobInfo.LastStatus; msg.SubjectEncoding = System.Text.Encoding.UTF8; msg.Body = msg.Subject; var client = new SmtpClient(this.db.EmailConfig.GmailSmtp, this.db.EmailConfig.GmailPort) { Credentials = new NetworkCredential(this.db.EmailConfig.GmailAccount, this.db.EmailConfig.GmailPassword), EnableSsl = true }; client.Send(msg); }
protected void StartProcess(TargetRecord jobInfo) { try { string pageHtml = GetPageHtml(jobInfo.Url, false,Encoding.Default); HtmlNode priceblock_ourprice = GetPriceBlock(pageHtml); string currentStatus = GetCurrentStatus(priceblock_ourprice); if (jobInfo.LastStatus.IsNullOrEmpty()) { jobInfo.LastStatus = currentStatus; } else { if (jobInfo.LastStatus != currentStatus) { jobInfo.LastStatus = currentStatus; jobInfo.LastChangedTime = DateTime.Now; if (jobInfo.HistoryItems == null) jobInfo.HistoryItems = new List<HistoryItem>(); jobInfo.HistoryItems.Add(new HistoryItem() { Status = jobInfo.LastStatus, Time = DateTime.Now }); SendMessage(jobInfo); } else { // the same as before . // do nothing. } } } catch (WebException webEx) { Console.WriteLine(webEx.Message.ToString()); } }
public PageProcessor BuildPageProcessor(int pageIndex,TargetRecord jobInfo ) { return this.container.Resolve<PageProcessor>( new ParameterOverride("pageIndex",pageIndex), new ParameterOverride("jobInfo", jobInfo)); }
public abstract void DoJob(TargetRecord jobInfo);
public override void DoJob(TargetRecord jobInfo) { this.jobInfo = jobInfo; this.StartProcess(jobInfo); }