コード例 #1
0
ファイル: ProcessManager.cs プロジェクト: Roballen/WebGrab
        public static CountyPull Process(IWebsiteAutomater automater)
        {
            var pull = new CountyPull {County = automater.Config().County};

            if (! NeedtoCheck( automater.Config(), ObjectFactory.GetInstance<IRepository>() ))
            {
                pull.Status = CountyPullStatus.DailyMaximumReached;
                return pull;
            }

            try
                {
                    automater.NavigateToLeadList();
                    pull.Leads = automater.ProcessMultiple();
                }
                catch (Exception e)
                {
                    pull.Status = CountyPullStatus.Error;
                    pull.Messages.Add(new Message() { Content = e.Message, Messagetype = MessageType.Error });
                }

            return pull;
        }
コード例 #2
0
ファイル: Program.cs プロジェクト: Roballen/WebGrab
        private static void SaveLeadsToExcelFile( CountyPull pull)
        {
            var business = new Collection<string>();
            var residence = new Collection<string>();
            business.Add("\"name\",\"address\",\"city\",\"state\",\"zip\",\"four\",\"phone\",\"amount\",\"date\",\"type\",");
            residence.Add("\"first\",\"middle\"\"last\",\"address\",\"city\",\"state\",\"zip\",\"four\",\"type\",\"amount\",\"date\",");
            foreach (var lead in pull.Leads)
            {
                if (lead.Businessname.IsEmpty())
                {
                    residence.Add("\" " + lead.First + " \",\"" + lead.Middle + "\"\"" + lead.Last + "\",\"" + lead.Address.Streetaddress1 + "\",\"" + lead.Address.City + "\",\"" + lead.Address.State + "\",\"" + lead.Address.Zip + "\",\"" + lead.LeadType + "\",\"" + lead.Debt + "\",\"" + lead.Recordeddate + "\",");
                }
                else
                {
                    business.Add("\" " + lead.Businessname + " \",\" " + lead.Address.Streetaddress1 + " \",\" " + lead.Address.City + " \",\" " + lead.Address.State + " \",\" " + lead.Address.Zip + " \",\"\",\" " + "" + " \",\" " + lead.Debt + " \",\" " + lead.Recordeddate + " \",\" " + lead.LeadType+ " \",");
                }
            }

            FileTools.SSaveArrayToFile(Path.Combine(Properties.Settings.Default.exceloutput, pull.County + "_" + pull.Time + "_buiness.csv"  ), business);
            FileTools.SSaveArrayToFile(Path.Combine(Properties.Settings.Default.exceloutput, pull.County + "_" + pull.Time + "_residence.csv"), residence);
        }
コード例 #3
0
ファイル: Program.cs プロジェクト: Roballen/WebGrab
 private static void SaveCountyToDb(CountyPull pull)
 {
     bool success = false;
     int retries = 5;
     int tries = 0;
     int wait = 750;
     while (!success && tries < retries)
     {
         var db = ObjectFactory.GetInstance<IObjectContainer>();
         try
         {
             db.Store(pull);
             db.Commit();
             db.Close();
             success = true;
         }
         catch (Exception e)
         {
             Thread.Sleep(wait);
         }
     }
 }