Example #1
0
        public async Task <bool> RunGetGPSAndConvertNxNyAndWriteAddr(string url, string urlParameters, string address)
        {
            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 + ")"
                              );
            AddressIniManager aiManager = new AddressIniManager();

            aiManager.WriteAddress(address, nxny.x, nxny.y);

            return(true);
        }
Example #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;
            }
        }
Example #3
0
        private void 삭제ToolStripMenuItem_Click(object sender, EventArgs e)
        {
            if (currentSelectedIndex.Contains("f"))
            {
                // 기본적으로 fwjournal.ini 는 삭제못하도록 함.

                /*
                 * FwjournalIniManager fiManager = new FwjournalIniManager();
                 * fiManager.DeleteAddressByIndexNo(currentSelectedIndex);
                 */
                MessageBox.Show("영농일지 관련 데이터(fwjournal.ini)는 삭제할 수 없습니다");
            }
            else
            {
                // 해당 작업 멈추고 삭제
                JobKey jobKey = JobKey.Create(currentSelectedIndex);
                cManager.schedulerForAddr.PauseJob(jobKey);
                cManager.schedulerForAddr.DeleteJob(jobKey);

                // address.ini 에서 삭제
                AddressIniManager aiManager = new AddressIniManager();
                aiManager.DeleteAddressByIndexNo(currentSelectedIndex);

                // 공통 로그파일에 삭제로그 남기기
                L4Logger l4Logger = new L4Logger("common.log");
                l4Logger.Add(currentSelectedIndex + " is deleted");
                l4Logger.Close();

                // 삭제할 인덱스 저장
                // string indexForDelete = currentSelectedIndex;

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

                // 툴바 초기화
                ResetToolBar();

                // 로그 출력창 설정
                loManagerForAddress.StopOutput();
                loManagerForAddress = new LogOutputManager(currentSelectedIndex, textBoxPrivateLog);

                // 개별 로그파일 삭제
                // UtilManager.DeleteLogFile(indexForDelete + ".log");
            }
        }
Example #4
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();
        }
        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();
            }
        }
Example #6
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();
        }
Example #7
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();
        }
Example #8
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();
        }