Esempio n. 1
0
        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();

        }
Esempio n. 2
0
 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;
 }
Esempio n. 3
0
        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);
        }
Esempio n. 4
0
        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());
            }

        }
Esempio n. 5
0
 public PageProcessor BuildPageProcessor(int pageIndex,TargetRecord jobInfo )
 {
     return this.container.Resolve<PageProcessor>(
             new ParameterOverride("pageIndex",pageIndex),
             new ParameterOverride("jobInfo", jobInfo));
 }
Esempio n. 6
0
 public abstract void DoJob(TargetRecord jobInfo);
Esempio n. 7
0
 public override void DoJob(TargetRecord jobInfo)
 {
     this.jobInfo = jobInfo;
     this.StartProcess(jobInfo);
 }