Example #1
0
        public void Set(ScrapParameter param)
        {
            if (!FlowMap.ContainsKey(param.Code))
            {
                throw new ScraperException("Code is not defined. Please check code of parameter. Code : " + param.Code);
            }
            FlowType type = FlowMap[param.Code];

            this.flow      = Activator.CreateInstance(type.Flow, this, param, type.LoginMode) as IScrapFlow;
            this.parameter = param;
            Gecko.LauncherDialog.Download += (sender, e) =>
            {
                String       tempPath  = ConfigSystem.ReadConfig("Config", "Temp", "Path");
                String       file      = Path.Combine(tempPath, DateTime.Now.ToString("yyyyMMddHHmmss") + e.Filename);
                nsILocalFile objTarget = (nsILocalFile)Xpcom.NewNativeLocalFile(file);
                e.HelperAppLauncher.SaveToDisk(objTarget, false);
                Action <String, String> action = flow.DownloadProcedure(e.Url);
                action(e.Url, file);
            };
            timer.Interval = 10 * 1000;
            timer.Tick    += (s, e) =>
            {
                Ping(parameter.Keycode);
            };
            timer.Start();
            this.Navigate(flow.StartPage());
        }
Example #2
0
 static void Main()
 {
     LoggerBuilder.Init(LogTemplate.GetLogTemp(ConfigSystem.ReadConfig("Config", "Log", "Path"))).Set("Server").Info("Server Program Start");
     FactoryDao.CreateInstance(ConfigSystem.ReadConfig("Config", "DB", "Connection"), ConfigSystem.ReadConfig("Config", "Log", "Path"));
     Application.EnableVisualStyles();
     Application.SetCompatibleTextRenderingDefault(false);
     Application.Run(new MainForm());
 }
 protected void UpdateData()
 {
     if (Debug.IsDebug())
     {
         try
         {
             foreach (var item in common_data_list)
             {
                 this.buffer.Append(item.KeyCode).Append("||");
                 this.buffer.Append(item.KeyIndex).Append("||");
                 this.buffer.Append(item.Data).Append("||");
                 this.buffer.Append(item.CreateDate).AppendLine();
             }
             String filepath = Path.Combine(ConfigSystem.ReadConfig("Config", "Temp", "Path"), DateTime.Now.ToString("yyyyMMddHHmmssfff") + ".csv");
             using (FileStream stream = new FileStream(filepath, FileMode.Create, FileAccess.Write))
             {
                 byte[] buffer = Encoding.UTF8.GetBytes(this.buffer.ToString());
                 stream.Write(buffer, 0, buffer.Length);
             }
             logger.Debug("common_data_list - " + filepath);
         }
         finally
         {
             this.buffer.Clear();
         }
         try
         {
             foreach (var item in package_data_list)
             {
                 this.buffer.Append(item.KeyCode).Append("||");
                 this.buffer.Append(item.KeyIndex).Append("||");
                 this.buffer.Append(item.Separation).Append("||");
                 this.buffer.Append(item.Data).Append("||");
                 this.buffer.Append(item.CreateDate).AppendLine();
             }
             String filepath = Path.Combine(ConfigSystem.ReadConfig("Config", "Temp", "Path"), DateTime.Now.ToString("yyyyMMddHHmmssfff") + ".csv");
             using (FileStream stream = new FileStream(filepath, FileMode.Create, FileAccess.Write))
             {
                 byte[] buffer = Encoding.UTF8.GetBytes(this.buffer.ToString());
                 stream.Write(buffer, 0, buffer.Length);
             }
             logger.Debug("package_data_list - " + filepath);
         }
         finally
         {
             this.buffer.Clear();
         }
         Finally();
     }
     else
     {
         commondao.InsertList(common_data_list);
         packagedao.InsertList(package_data_list);
     }
 }
Example #4
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();
            }
        }
Example #5
0
        static void Main()
        {
            string   mtxName = "WebScraping";
            Mutex    mtx     = new Mutex(true, mtxName);
            TimeSpan tsWait  = new TimeSpan(0, 0, 1);
            bool     success = mtx.WaitOne(tsWait);

            if (!success)
            {
                MessageBox.Show("이미실행중입니다.");
                return;
            }
            LoggerBuilder.Init(LogTemplate.GetLogTemp(ConfigSystem.ReadConfig("Config", "Log", "WritePath") + "\\Broker.log"));
            Application.EnableVisualStyles();
            Application.SetCompatibleTextRenderingDefault(false);
            Application.Run(new Main());
        }
Example #6
0
        static void Main(string[] args)
        {
            Logger logger = null;

            try
            {
                String arg = null;
                if (Debug.IsDebug())
                {
                    arg = Debug.GetDebugParam();
                }
                else
                {
                    if (args.Length != 1)
                    {
                        throw new ScraperException("Parameter Length Error " + args.Length);
                    }
                    byte[] buffer = Convert.FromBase64String(args[0]);
                    arg = Encoding.UTF8.GetString(buffer);
                }
                Parameter param = JsonConvert.DeserializeObject <Parameter>(arg);
                logger = LoggerBuilder.Init(LogTemplate.GetLogTemp(ConfigSystem.ReadConfig("Config", "Log", "WritePath") + "\\" + param.Key + ".log")).Set("Server").Info("Client Program Start");
                Application.EnableVisualStyles();
                Application.SetCompatibleTextRenderingDefault(false);
                if (Debug.IsDebug())
                {
                    Application.Run(new ScraperForm(param));
                }
                else
                {
                    Application.Run(new ScraperContext(param));
                }
            }
            catch (Exception e)
            {
                if (logger != null)
                {
                    logger.Error(e.ToString());
                }
                Exit();
            }
        }
Example #7
0
        public void Set(Parameter param)
        {
            if (!FlowMap.ContainsKey(param.MallCD))
            {
                throw new ScraperException("The code is not defined. Please check code of parameter. Code : " + param.MallCD);
            }
            Type type = FlowMap[param.MallCD];

            this.flow = Activator.CreateInstance(type, this, param) as IScrapFlow;
            this.flow.Initialize(flowModelData);
            this.parameter = param;

            Gecko.LauncherDialog.Download += (sender, e) =>
            {
                String       tempPath  = ConfigSystem.ReadConfig("Config", "Temp", "Path");
                String       file      = Path.Combine(tempPath, DateTime.Now.ToString("yyyyMMddHHmmss") + e.Filename);
                nsILocalFile objTarget = (nsILocalFile)Xpcom.NewNativeLocalFile(file);
                e.HelperAppLauncher.SaveToDisk(objTarget, false);
                Procedure(new Uri(e.Url), null, file);
            };
            this.Navigate(flow.StartPage(flowModelData));
        }
        private static void LoadSettingFile(string filePath)
        {
            if (filePath == null)
            {
                OpenFileDialog openFileDialog = new OpenFileDialog
                {
                    Filter           = "Setting File|config.ini",
                    InitialDirectory = AppDomain.CurrentDomain.BaseDirectory
                };
                if (openFileDialog.ShowDialog() == true)
                {
                    LoadSettingFile(openFileDialog.FileName);
                    return;
                }
            }
            var tempPortMain = ConfigSystem.ReadConfig(filePath, PaymapSettingKeys.SectionPort, PaymapSettingKeys.IntPortMain);

            if (!string.IsNullOrEmpty(tempPortMain))
            {
                int.TryParse(tempPortMain, out App.PaymapSettings.PortMain);
            }
            var tempPortRemote = ConfigSystem.ReadConfig(filePath, PaymapSettingKeys.SectionPort, PaymapSettingKeys.IntPortRemote);

            if (!string.IsNullOrEmpty(tempPortRemote))
            {
                int.TryParse(tempPortRemote, out App.PaymapSettings.PortRemote);
            }
            var tempPortDEVX = ConfigSystem.ReadConfig(filePath, PaymapSettingKeys.SectionPort, PaymapSettingKeys.IntPortDEVX);

            if (!string.IsNullOrEmpty(tempPortDEVX))
            {
                int.TryParse(tempPortDEVX, out App.PaymapSettings.PortDEVX);
            }
            var tempAuthLevel1 = ConfigSystem.ReadConfig(filePath, PaymapSettingKeys.SectionAuth, PaymapSettingKeys.BoolAuthLevel1);

            if (!string.IsNullOrEmpty(tempAuthLevel1))
            {
                bool.TryParse(tempAuthLevel1, out App.PaymapSettings.AuthLevel1);
            }
            var tempAuthLevel2 = ConfigSystem.ReadConfig(filePath, PaymapSettingKeys.SectionAuth, PaymapSettingKeys.BoolAuthLevel2);

            if (!string.IsNullOrEmpty(tempAuthLevel2))
            {
                bool.TryParse(tempAuthLevel2, out App.PaymapSettings.AuthLevel2);
            }
            var tempAuthLevel3 = ConfigSystem.ReadConfig(filePath, PaymapSettingKeys.SectionAuth, PaymapSettingKeys.BoolAuthLevel3);

            if (!string.IsNullOrEmpty(tempAuthLevel3))
            {
                bool.TryParse(tempAuthLevel3, out App.PaymapSettings.AuthLevel3);
            }
            var tempVersionLive = ConfigSystem.ReadConfig(filePath, PaymapSettingKeys.SectionVersion, PaymapSettingKeys.IntVersionLive);

            if (!string.IsNullOrEmpty(tempVersionLive))
            {
                int.TryParse(tempVersionLive, out App.PaymapSettings.VersionLive);
            }
            var tempVersionMin = ConfigSystem.ReadConfig(filePath, PaymapSettingKeys.SectionVersion, PaymapSettingKeys.IntVersionMin);

            if (!string.IsNullOrEmpty(tempVersionMin))
            {
                int.TryParse(tempVersionMin, out App.PaymapSettings.VersionMin);
            }
            var tempThreadDashboard = ConfigSystem.ReadConfig(filePath, PaymapSettingKeys.SectionThread, PaymapSettingKeys.BoolThreadDashboard);

            if (!string.IsNullOrEmpty(tempThreadDashboard))
            {
                bool.TryParse(tempThreadDashboard, out App.PaymapSettings.ThreadSwitchDashboard);
            }
            var tempThreadDashboardInterval = ConfigSystem.ReadConfig(filePath, PaymapSettingKeys.SectionThread, PaymapSettingKeys.IntThreadIntervalDashboard);

            if (!string.IsNullOrEmpty(tempThreadDashboardInterval))
            {
                int.TryParse(tempThreadDashboardInterval, out App.PaymapSettings.ThreadIntervalDashboard);
            }
            var tempThreadDEVX = ConfigSystem.ReadConfig(filePath, PaymapSettingKeys.SectionThread, PaymapSettingKeys.BoolThreadDEVX);

            if (!string.IsNullOrEmpty(tempThreadDEVX))
            {
                bool.TryParse(tempThreadDEVX, out App.PaymapSettings.ThreadSwitchDEVX);
            }
            var tempThreadDEVXInterval = ConfigSystem.ReadConfig(filePath, PaymapSettingKeys.SectionThread, PaymapSettingKeys.IntThreadIntervalDEVX);

            if (!string.IsNullOrEmpty(tempThreadDEVXInterval))
            {
                int.TryParse(tempThreadDEVXInterval, out App.PaymapSettings.ThreadIntervalDEVX);
            }
            var tempAPIFirebase = ConfigSystem.ReadConfig(filePath, PaymapSettingKeys.SectionAPI, PaymapSettingKeys.StringAPIFirebase);

            if (!string.IsNullOrEmpty(tempAPIFirebase))
            {
                App.PaymapSettings.APIFirebase = tempAPIFirebase;
            }
            var tempAPICatcher = ConfigSystem.ReadConfig(filePath, PaymapSettingKeys.SectionAPI, PaymapSettingKeys.StringAPICatcher);

            if (!string.IsNullOrEmpty(tempAPICatcher))
            {
                App.PaymapSettings.APICatcher = tempAPICatcher;
            }
            var tempAPIReviewer = ConfigSystem.ReadConfig(filePath, PaymapSettingKeys.SectionAPI, PaymapSettingKeys.StringAPIReviewer);

            if (!string.IsNullOrEmpty(tempAPIReviewer))
            {
                App.PaymapSettings.APIReviewer = tempAPIReviewer;
            }
            var tempDBLocation = ConfigSystem.ReadConfig(filePath, PaymapSettingKeys.SectionDB, PaymapSettingKeys.StringDBAddress);

            if (!string.IsNullOrEmpty(tempDBLocation))
            {
                App.PaymapSettings.DBAddress = tempDBLocation;
            }
            var tempDBPort = ConfigSystem.ReadConfig(filePath, PaymapSettingKeys.SectionDB, PaymapSettingKeys.IntDBPort);

            if (!string.IsNullOrEmpty(tempDBPort))
            {
                int.TryParse(tempDBPort, out App.PaymapSettings.DBPort);
            }
            var tempDEVXMaster = ConfigSystem.ReadConfig(filePath, PaymapSettingKeys.SectionDEVX, PaymapSettingKeys.BoolDEVXMaster);

            if (!string.IsNullOrEmpty(tempDEVXMaster))
            {
                bool.TryParse(tempDEVXMaster, out App.PaymapSettings.DEVXMaster);
            }
            var tempDEVXReport = ConfigSystem.ReadConfig(filePath, PaymapSettingKeys.SectionDEVX, PaymapSettingKeys.BoolDEVXReport);

            if (!string.IsNullOrEmpty(tempDEVXReport))
            {
                bool.TryParse(tempDEVXReport, out App.PaymapSettings.DEVXReport);
            }
            var tempDEVXCommand = ConfigSystem.ReadConfig(filePath, PaymapSettingKeys.SectionDEVX, PaymapSettingKeys.BoolDEVXCommand);

            if (!string.IsNullOrEmpty(tempDEVXCommand))
            {
                bool.TryParse(tempDEVXCommand, out App.PaymapSettings.DEVXCommand);
            }
            var tempLogLevel1 = ConfigSystem.ReadConfig(filePath, PaymapSettingKeys.SectionLog, PaymapSettingKeys.BoolLogLevel1);

            if (!string.IsNullOrEmpty(tempLogLevel1))
            {
                bool.TryParse(tempLogLevel1, out App.PaymapSettings.LogLevel1);
            }
            var tempLogLevel2 = ConfigSystem.ReadConfig(filePath, PaymapSettingKeys.SectionLog, PaymapSettingKeys.BoolLogLevel2);

            if (!string.IsNullOrEmpty(tempLogLevel2))
            {
                bool.TryParse(tempLogLevel2, out App.PaymapSettings.LogLevel2);
            }
            var tempLogLevel3 = ConfigSystem.ReadConfig(filePath, PaymapSettingKeys.SectionLog, PaymapSettingKeys.BoolLogLevel3);

            if (!string.IsNullOrEmpty(tempLogLevel3))
            {
                bool.TryParse(tempLogLevel3, out App.PaymapSettings.LogLevel3);
            }
            var tempLogLevel4 = ConfigSystem.ReadConfig(filePath, PaymapSettingKeys.SectionLog, PaymapSettingKeys.BoolLogLevel4);

            if (!string.IsNullOrEmpty(tempLogLevel4))
            {
                bool.TryParse(tempLogLevel4, out App.PaymapSettings.LogLevel4);
            }
            var tempLogLevel5 = ConfigSystem.ReadConfig(filePath, PaymapSettingKeys.SectionLog, PaymapSettingKeys.BoolLogLevel5);

            if (!string.IsNullOrEmpty(tempLogLevel5))
            {
                bool.TryParse(tempLogLevel5, out App.PaymapSettings.LogLevel5);
            }
            var tempLogFilterLevel1 = ConfigSystem.ReadConfig(filePath, PaymapSettingKeys.SectionLog, PaymapSettingKeys.BoolLogFilterLevel1);

            if (!string.IsNullOrEmpty(tempLogFilterLevel1))
            {
                bool.TryParse(tempLogFilterLevel1, out App.PaymapSettings.LogFilterLevel1);
            }
            var tempLogFilterLevel2 = ConfigSystem.ReadConfig(filePath, PaymapSettingKeys.SectionLog, PaymapSettingKeys.BoolLogFilterLevel2);

            if (!string.IsNullOrEmpty(tempLogFilterLevel2))
            {
                bool.TryParse(tempLogFilterLevel2, out App.PaymapSettings.LogFilterLevel2);
            }
            var tempLogFilterLevel3 = ConfigSystem.ReadConfig(filePath, PaymapSettingKeys.SectionLog, PaymapSettingKeys.BoolLogFilterLevel3);

            if (!string.IsNullOrEmpty(tempLogFilterLevel3))
            {
                bool.TryParse(tempLogFilterLevel3, out App.PaymapSettings.LogFilterLevel3);
            }
            var tempLogFilterLevel4 = ConfigSystem.ReadConfig(filePath, PaymapSettingKeys.SectionLog, PaymapSettingKeys.BoolLogFilterLevel4);

            if (!string.IsNullOrEmpty(tempLogFilterLevel4))
            {
                bool.TryParse(tempLogFilterLevel4, out App.PaymapSettings.LogFilterLevel4);
            }
            var tempLogFilterLevel5 = ConfigSystem.ReadConfig(filePath, PaymapSettingKeys.SectionLog, PaymapSettingKeys.BoolLogFilterLevel5);

            if (!string.IsNullOrEmpty(tempLogFilterLevel5))
            {
                bool.TryParse(tempLogFilterLevel5, out App.PaymapSettings.LogFilterLevel5);
            }
            var tempLogFilterType1 = ConfigSystem.ReadConfig(filePath, PaymapSettingKeys.SectionLog, PaymapSettingKeys.BoolLogFilterType1);

            if (!string.IsNullOrEmpty(tempLogFilterType1))
            {
                bool.TryParse(tempLogFilterType1, out App.PaymapSettings.LogFilterType1);
            }
            var tempLogFilterType2 = ConfigSystem.ReadConfig(filePath, PaymapSettingKeys.SectionLog, PaymapSettingKeys.BoolLogFilterType2);

            if (!string.IsNullOrEmpty(tempLogFilterType2))
            {
                bool.TryParse(tempLogFilterType2, out App.PaymapSettings.LogFilterType2);
            }
            var tempLogFilterType3 = ConfigSystem.ReadConfig(filePath, PaymapSettingKeys.SectionLog, PaymapSettingKeys.BoolLogFilterType3);

            if (!string.IsNullOrEmpty(tempLogFilterType3))
            {
                bool.TryParse(tempLogFilterType3, out App.PaymapSettings.LogFilterType3);
            }
            var tempLogFilterType4 = ConfigSystem.ReadConfig(filePath, PaymapSettingKeys.SectionLog, PaymapSettingKeys.BoolLogFilterType4);

            if (!string.IsNullOrEmpty(tempLogFilterType4))
            {
                bool.TryParse(tempLogFilterType4, out App.PaymapSettings.LogFilterType4);
            }
            var tempLogFilterType5 = ConfigSystem.ReadConfig(filePath, PaymapSettingKeys.SectionLog, PaymapSettingKeys.BoolLogFilterType5);

            if (!string.IsNullOrEmpty(tempLogFilterType5))
            {
                bool.TryParse(tempLogFilterType5, out App.PaymapSettings.LogFilterType5);
            }
            var tempLogFilterType6 = ConfigSystem.ReadConfig(filePath, PaymapSettingKeys.SectionLog, PaymapSettingKeys.BoolLogFilterType6);

            if (!string.IsNullOrEmpty(tempLogFilterType6))
            {
                bool.TryParse(tempLogFilterType6, out App.PaymapSettings.LogFilterType6);
            }
            var tempLogFilterType7 = ConfigSystem.ReadConfig(filePath, PaymapSettingKeys.SectionLog, PaymapSettingKeys.BoolLogFilterType7);

            if (!string.IsNullOrEmpty(tempLogFilterType7))
            {
                bool.TryParse(tempLogFilterType7, out App.PaymapSettings.LogFilterType7);
            }
            var tempLogFilterType8 = ConfigSystem.ReadConfig(filePath, PaymapSettingKeys.SectionLog, PaymapSettingKeys.BoolLogFilterType8);

            if (!string.IsNullOrEmpty(tempLogFilterType8))
            {
                bool.TryParse(tempLogFilterType8, out App.PaymapSettings.LogFilterType8);
            }
            RefreshSettingData();
        }