Beispiel #1
0
        public virtual Task Execute(IJobExecutionContext context)
        {
            // fwjournal.ini 수집작업 모두 멈춤
            JobDataMap dataMap       = context.JobDetail.JobDataMap;
            IScheduler crawScheduler = (IScheduler)dataMap.Get("crawlScheduler");

            if (null != crawScheduler)
            {
                crawScheduler.PauseAll();
            }

            // 영농일지 DB에서 주소 얻기
            FwjournalIniManager fwjIniManager = new FwjournalIniManager();

            fwjIniManager.ReadIni();
            List <string> addresses = new List <string>();
            DbManager     dm2       = new DbManager(fwjIniManager.IpAddress, fwjIniManager.DbName, fwjIniManager.CollectionName, fwjIniManager.Id, fwjIniManager.Pw);

            if (dm2.Connect())
            {
                addresses = dm2.ReadFwjournalLands();
            }
            else
            {
                MessageBox.Show("영농일지 DB에 접속할 수 없습니다");
            }

            // fwjournal.ini와 영농일지 DB의 주소(addresses)를 비교하여 크기가 다른 경우 fwjournal.ini 업데이트
            fwjIniManager.ReadAddress();

            if (addresses.Count > fwjIniManager.Addresses.Count ||
                addresses.Count < fwjIniManager.Addresses.Count)
            {
                // fwjournal.ini의 주소정보 모두 지움
                fwjIniManager.DeleteAddressLine();

                // 영농일지 주소 읽어서 fwjournal.ini에 주소 쓰기
                var result = RunGetGPSAndConvertNxNyAndWriteFI(addresses);
            }

            // fwjournal.ini 수집작업 모두 재가동
            if (null != crawScheduler)
            {
                crawScheduler.ResumeAll();
            }

            return(Task.FromResult(0));
        }
Beispiel #2
0
        // 현재 주소 버튼 메뉴 초기화
        private void InitializeContextMenuStripAddress()
        {
            // 이미 메뉴에 아이템이 생성되어 있다면 모두 지움
            if (0 < contextMenuStripAddress.Items.Count)
            {
                contextMenuStripAddress.Items.Clear();
            }

            // fwjournal.ini 읽어서 주소 메뉴에 추가
            FwjournalIniManager fiManager = new FwjournalIniManager();

            fiManager.ReadAddress();
            foreach (var address in fiManager.Addresses)
            {
                /*
                 * ToolStripItem addressItem = contextMenuStripAddress.Items.Add(address.Address + "               " +
                 *                                                     UtilManager.ConvertCrawlTerm(address.CrawlTerm) + "               " +
                 *                                                     UtilManager.ConvertCrawlStatus(address.CrawlStatus));
                 */
                ToolStripItem addressItem = contextMenuStripAddress.Items.Add(address.Address.PadRight(25, '-') +
                                                                              UtilManager.ConvertCrawlTerm(address.CrawlTerm).PadRight(25, '-') +
                                                                              UtilManager.ConvertCrawlStatus(address.CrawlStatus));
                addressItem.Tag       = address;
                addressItem.Click    += new EventHandler(addressItem_Click);
                addressItem.ForeColor = Color.White;
            }

            // address.ini 읽어서 메뉴에 추가
            AddressIniManager aiManager = new AddressIniManager();

            aiManager.ReadAddress();
            foreach (var address in aiManager.Addresses)
            {
                /*
                 * ToolStripItem addressItem = contextMenuStripAddress.Items.Add(address.Address + "               " +
                 *                                                     UtilManager.ConvertCrawlTerm(address.CrawlTerm) + "               " +
                 *                                                     UtilManager.ConvertCrawlStatus(address.CrawlStatus));
                 */
                ToolStripItem addressItem = contextMenuStripAddress.Items.Add(address.Address.PadRight(25, '-') +
                                                                              UtilManager.ConvertCrawlTerm(address.CrawlTerm).PadRight(25, '-') +
                                                                              UtilManager.ConvertCrawlStatus(address.CrawlStatus));
                addressItem.Tag       = address;
                addressItem.Click    += new EventHandler(addressItem_Click);
                addressItem.ForeColor = Color.White;
            }
        }
Beispiel #3
0
        // 주소 추가 버튼
        private void buttonAddAddress_Click(object sender, EventArgs e)
        {
            // address.ini & fwjournal.ini에 동일한 주소 있는지 체크
            AddressIniManager   aiManager = new AddressIniManager();
            FwjournalIniManager fiManager = new FwjournalIniManager();

            if (aiManager.IsExistSameAddress(formedAddress) || fiManager.IsExistSameAddress(formedAddress))
            {
                MessageBox.Show("이미 존재하는 주소입니다");
            }
            else
            {
                // address.ini에 주소 추가
                RunGetGPSAndConvertNxNyAndWriteAddr(formedAddress);
            }

            this.Close();
        }
Beispiel #4
0
        public async Task <bool> RunGetGPSAndConvertNxNyAndWriteFI(string url, string urlParameters, List <string> addresses)
        {
            foreach (var address in addresses)
            {
                // https://docs.microsoft.com/ko-kr/dotnet/csharp/programming-guide/concepts/async/
                GoogleMapsResult gmr = await GetGPSLocationAsync(url, urlParameters + address);

                NxNyManager nnm  = new NxNyManager();
                Coords      nxny = nnm.Dfs_xy_conv("toXY", gmr.results[0].geometry.location.lat, gmr.results[0].geometry.location.lng);
                Console.WriteLine("Address:" + address +
                                  ", LatLng:(" + gmr.results[0].geometry.location.lat + ", " + gmr.results[0].geometry.location.lng + ")" +
                                  ", NxNy:(" + nxny.x + ", " + nxny.y + ")"
                                  );

                FwjournalIniManager fiManager = new FwjournalIniManager();
                fiManager.WriteAddress(address, nxny.x, nxny.y);
            }

            return(true);
        }
Beispiel #5
0
        // 툴바 리셋
        void ResetToolBar()
        {
            // fwjournal.ini 읽기
            FwjournalIniManager fiManager = new FwjournalIniManager();

            fiManager.ReadAddress();

            // 현재주소 버튼
            labelAddr.Text = fiManager.Addresses[0].Address;

            // 수집옵션 버튼
            labelCrawlTerm.Text = "수집간격 - " + UtilManager.ConvertCrawlTerm(fiManager.Addresses[0].CrawlTerm);

            // 수집상태 버튼
            labelRunStatus.Text = Fonts.fa.recycle + "  " + UtilManager.ConvertCrawlStatus(fiManager.Addresses[0].CrawlStatus);

            // 변수 초기화
            currentSelectedIndex     = "f0";
            currentSelectedRunStatus = fiManager.Addresses[0].CrawlStatus;
        }
        public void RunTasks()
        {
            // fwjournal.ini 읽어서 수집시작
            FwjournalIniManager fIManager = new FwjournalIniManager();

            fIManager.ReadAddress();
            foreach (var address in fIManager.Addresses)
            {
                TaskFJJob(address.IndexNo, address.Address, address.Nx, address.Ny, address.CrawlTerm, address.CrawlStatus).GetAwaiter();
                // TaskFJJob(address.IndexNo, address.Address, address.CrawlTerm).GetAwaiter().GetResult();
            }

            // address.ini 읽어서 수집시작
            AddressIniManager aIManager = new AddressIniManager();

            aIManager.ReadAddress();
            foreach (var address in aIManager.Addresses)
            {
                TaskAddrJob(address.IndexNo, address.Address, address.Nx, address.Ny, address.CrawlTerm, address.CrawlStatus).GetAwaiter();
            }
        }
Beispiel #7
0
        private void 모든주소수집정지ToolStripMenuItem_Click(object sender, EventArgs e)
        {
            // 모든 작업 정지
            cManager.schedulerForFJ.PauseAll();
            cManager.schedulerForAddr.PauseAll();

            // *.ini 파일 업데이트
            FwjournalIniManager fjiManager = new FwjournalIniManager();
            AddressIniManager   aiManager  = new AddressIniManager();

            fjiManager.WriteAllCrawlStatus("S");
            aiManager.WriteAllCrawlStatus("S");

            // 현재 주소 리스트 초기화
            InitializeContextMenuStripAddress();

            // 로그
            L4Logger l4Logger = new L4Logger("common.log");

            l4Logger.Add("All tasks paused!");
            l4Logger.Close();
        }
Beispiel #8
0
        // 수집간격 옵션 클릭시 이벤트 함수
        void optionItem_Click(object sender, EventArgs e)
        {
            ToolStripItem clickedItem = sender as ToolStripItem;

            labelCrawlTerm.Text = "수집간격 - " + UtilManager.ConvertCrawlTerm(clickedItem.Tag.ToString());

            if (currentSelectedIndex.Contains("f"))
            {
                FwjournalIniManager fjiManager = new FwjournalIniManager();
                fjiManager.WriteCrawlTerm(currentSelectedIndex, clickedItem.Tag.ToString());
            }
            else
            {
                AddressIniManager aiManager = new AddressIniManager();
                aiManager.WriteCrawlTerm(currentSelectedIndex, clickedItem.Tag.ToString());
            }

            // 현재 주소 리스트 초기화
            InitializeContextMenuStripAddress();

            RunCrawlAndCheck();
        }
Beispiel #9
0
        // 수집 상태 토글 버튼
        private void buttonRunStatus_Click(object sender, EventArgs e)
        {
            // Console.WriteLine("buttonRunStatus_Click");
            FwjournalIniManager fjiManager = new FwjournalIniManager();
            AddressIniManager   aiManager  = new AddressIniManager();

            if ("R" == currentSelectedRunStatus)
            {
                PauseJob();
                labelRunStatus.Text      = Fonts.fa.hand_stop_o + "  " + UtilManager.ConvertCrawlStatus("S");
                currentSelectedRunStatus = "S";
                if (currentSelectedIndex.Contains("f"))
                {
                    fjiManager.WriteCrawlStatus(currentSelectedIndex, "S");
                }
                else
                {
                    aiManager.WriteCrawlStatus(currentSelectedIndex, "S");
                }
            }
            else
            {
                ResumeJob();
                labelRunStatus.Text      = Fonts.fa.recycle + "  " + UtilManager.ConvertCrawlStatus("R");
                currentSelectedRunStatus = "R";
                if (currentSelectedIndex.Contains("f"))
                {
                    fjiManager.WriteCrawlStatus(currentSelectedIndex, "R");
                }
                else
                {
                    aiManager.WriteCrawlStatus(currentSelectedIndex, "R");
                }
            }

            // 현재 주소 리스트 초기화
            InitializeContextMenuStripAddress();
        }
Beispiel #10
0
        // 툴바 초기화
        void InitializeToolBar()
        {
            // fwjournal.ini 읽기
            FwjournalIniManager fiManager = new FwjournalIniManager();

            fiManager.ReadAddress();

            // 현재주소 버튼
            labelCurrentAddr.Parent    = buttonAddr;
            labelCurrentAddr.BackColor = Color.Transparent;
            Fonts.Reload(16);
            labelCurrentAddr.Font        = Fonts.FontAwesome;
            labelCurrentAddr.Text        = "현재주소                       " + Fonts.fa.sort_down;
            labelCurrentAddr.MouseEnter += OnMouseEnterButtonAddr;
            labelCurrentAddr.MouseLeave += OnMouseLeaveButtonAddr;

            labelAddr.Parent      = buttonAddr;
            labelAddr.BackColor   = Color.Transparent;
            labelAddr.MouseEnter += OnMouseEnterButtonAddr;
            labelAddr.MouseLeave += OnMouseLeaveButtonAddr;

            buttonAddr.BackColor   = Color.FromArgb(45, 45, 48);
            buttonAddr.MouseEnter += OnMouseEnterButtonAddr;
            buttonAddr.MouseLeave += OnMouseLeaveButtonAddr;

            if (0 < fiManager.Addresses.Count)
            {
                labelAddr.Text = fiManager.Addresses[0].Address;
            }

            // 수집옵션 버튼
            labelCrawlOption.Parent      = buttonCrawlOption;
            labelCrawlOption.BackColor   = Color.Transparent;
            labelCrawlOption.Font        = Fonts.FontAwesome;
            labelCrawlOption.Text        = Fonts.fa.cogs + "  수집옵션";
            labelCrawlOption.MouseEnter += OnMouseEnterButtonCrawlOption;
            labelCrawlOption.MouseLeave += OnMouseLeaveButtonCrawlOption;

            labelCrawlTerm.Parent      = buttonCrawlOption;
            labelCrawlTerm.BackColor   = Color.Transparent;
            labelCrawlTerm.MouseEnter += OnMouseEnterButtonCrawlOption;
            labelCrawlTerm.MouseLeave += OnMouseLeaveButtonCrawlOption;

            buttonCrawlOption.BackColor   = Color.FromArgb(45, 45, 48);
            buttonCrawlOption.MouseEnter += OnMouseEnterButtonCrawlOption;
            buttonCrawlOption.MouseLeave += OnMouseLeaveButtonCrawlOption;

            if (0 < fiManager.Addresses.Count)
            {
                labelCrawlTerm.Text = "수집간격 - " + UtilManager.ConvertCrawlTerm(fiManager.Addresses[0].CrawlTerm);
            }

            // 수집상태 버튼
            labelRunStatus.Parent    = buttonRunStatus;
            labelRunStatus.BackColor = Color.Transparent;
            labelRunStatus.Font      = Fonts.FontAwesome;
            // labelRunStatus.Text = Fonts.fa.recycle + "  " + "수집중";
            labelRunStatus.MouseEnter += OnMouseEnterButtonRunStatus;
            labelRunStatus.MouseLeave += OnMouseLeaveButtonRunStatus;

            labelRunLastTime.Parent      = buttonRunStatus;
            labelRunLastTime.BackColor   = Color.Transparent;
            labelRunLastTime.MouseEnter += OnMouseEnterButtonRunStatus;
            labelRunLastTime.MouseLeave += OnMouseLeaveButtonRunStatus;

            buttonRunStatus.BackColor   = Color.FromArgb(45, 45, 48);
            buttonRunStatus.MouseEnter += OnMouseEnterButtonRunStatus;
            buttonRunStatus.MouseLeave += OnMouseLeaveButtonRunStatus;

            if (0 < fiManager.Addresses.Count)
            {
                labelRunStatus.Text = Fonts.fa.recycle + "  " + UtilManager.ConvertCrawlStatus(fiManager.Addresses[0].CrawlStatus);
            }

            // 변수 초기화
            currentSelectedIndex = "f0";
            if (0 < fiManager.Addresses.Count)
            {
                currentSelectedRunStatus = fiManager.Addresses[0].CrawlStatus;
            }
        }