Exemple #1
0
        public String Run(string key, bool insert = true)
        {
            parameter.Key            = key;
            base.StartInfo.Arguments = parameter.Key + " " + this.parameterStr;

            IScrapingStatusDao dao    = FactoryDao.GetInstance().GetDao <IScrapingStatusDao>();
            ScrapingStatus     entity = new ScrapingStatus();

            entity.KeyCode   = parameter.Key;
            entity.SCode     = parameter.Code;
            entity.Sid       = parameter.Id;
            entity.StartTime = DateTime.Now;
            entity.Status    = "0";
            if (insert)
            {
                dao.Insert(entity);
            }
            else
            {
                dao.Update(entity);
            }
            parameter.Starttime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss.fff");
            base.Start();
            this.logger.Info("Scraper process Start " + this.parameter.ToString());
            return(parameter.Key);
        }
        public AbstractScrapFlow(ScrapBrowser browser, ScrapParameter param, bool login_mode)
        {
            Parameter       = param;
            this.browser    = browser;
            this.commondao  = FactoryDao.GetInstance().GetDao <IScrapingCommonDataDao>();
            this.packagedao = FactoryDao.GetInstance().GetDao <IScrapingPackageDataDao>();

            logger = LoggerBuilder.Init().Set(this.GetType());
            //this.browser.InitializeDownLoad(ExcelDownload);
            this.browser.ProgressChanged += (s, e) =>
            {
                //logger.Debug("CurrentProgress/MaximumProgress : " + e.CurrentProgress + "/" + e.MaximumProgress);
            };
        }
Exemple #3
0
        static void Main(string[] args)
        {
            Logger logger = null;

            try
            {
                if (Debug.IsDebug())
                {
                    args = new String[] { Debug.GetDebugKey(), Debug.GetDebugParam() };
                }
                if (args.Length != 2)
                {
                    throw new ScraperException("Parameter Length Error " + args.Length);
                }
                logger = LoggerBuilder.Init(LogTemplate.GetLogTemp(ConfigSystem.ReadConfig("Config", "Log", "WritePath") + "\\" + args[0] + ".log")).Set("Server").Info("Client Program Start");
                logger.Debug("arg[0] : " + args[0]);
                logger.Debug("arg[1] : " + args[1]);
                FactoryDao.CreateInstance(ConfigSystem.ReadConfig("Config", "DB", "Connection"), ConfigSystem.ReadConfig("Config", "Temp", "Path"));
                IScrapingStatusDao dao = FactoryDao.GetInstance().GetDao <IScrapingStatusDao>();
                if (!Debug.IsDebug())
                {
                    ScrapingStatus entity = dao.GetEntity(args[0]);

                    if (entity == null)
                    {
                        throw new ScraperException("Nothing entity " + args[0]);
                    }

                    if (entity.Status != "0")
                    {
                        throw new ScraperException("entity status" + args[0]);
                    }
                    entity.Status = "1";
                    dao.Update(entity);
                }
                Application.EnableVisualStyles();
                Application.SetCompatibleTextRenderingDefault(false);
                Application.Run(new ScraperContext(args[0], args[1]));
            }
            catch (Exception e)
            {
                if (logger != null)
                {
                    logger.Error(e.ToString());
                }
                Exit();
            }
        }