Пример #1
0
        private void button_DBInsert_Click(object sender, EventArgs e)
        {
            if (comboBox_SelectAuthor.SelectedIndex <= 0)
            {
                MessageBox.Show("권리사를 선택 해주세요.");
                return;
            }

            if (comboBox_SelectChannel.SelectedIndex <= 0)
            {
                MessageBox.Show("채널을 선택 해주세요.");
                return;
            }

            if (comboBox_ExcelFrom.SelectedIndex <= 0)
            {
                MessageBox.Show("엑셀 폼을 선택해 주세요.");
                return;
            }

            LQCrawlerBase pLQCrawlerBase = CrawlerManager.Instance.GetCrawler();
            LQCrawlerInfo pLQCrawlerInfo = CrawlerManager.Instance.GetCrawlerInfo();

            if (pLQCrawlerBase == null || pLQCrawlerInfo == null)
            {
                MessageBox.Show("크롤러가 생성되지 않았습니다.");
                return;
            }

            // 상품 정보 읽어오기
            SqlHelper pMySqlDB = new SqlHelper();
            pMySqlDB.Connect(CrawlerInfoManager.Instance.method_, CrawlerInfoManager.Instance.dbip_, CrawlerInfoManager.Instance.dbport_, CrawlerInfoManager.Instance.dbname_
                , CrawlerInfoManager.Instance.dbaccount_, CrawlerInfoManager.Instance.dbpw_, CrawlerInfoManager.Instance.sshhostname_
                , CrawlerInfoManager.Instance.sshuser_, CrawlerInfoManager.Instance.sshpw_);

            DBFunctions.SelectStateTable(pMySqlDB);
            DBFunctions.GetGoodsTable(pMySqlDB, pLQCrawlerInfo.Channel_Idx_, pLQCrawlerInfo.AuthoritySeq_);
            Dictionary<Int32, ChannelGoodInfo> pGoodInfoList = CrawlerManager.Instance.GetGoodsInfo();

            DBFunctions.Select_tblOrder(pMySqlDB, pLQCrawlerInfo.Channel_Idx_);
            DBFunctions.Select_tblOrderWr(pMySqlDB, pLQCrawlerInfo.Channel_Idx_);

            pLQCrawlerBase.Login();
            pLQCrawlerBase.Combine_DB_And_Excel(false);
            pLQCrawlerBase.Process_RefundData(pMySqlDB);
            pLQCrawlerBase.Process_ExpiredData();

            // 채널에 상품처리// 채널에 취소처리  // 채널에 반품처리
            pLQCrawlerBase.Process_Use_Cancel_Refund();

            // DB 에 처리
            SqlHelper pMySqlDB2 = new SqlHelper();
            pMySqlDB2.Connect(CrawlerInfoManager.Instance.method_, CrawlerInfoManager.Instance.dbip_, CrawlerInfoManager.Instance.dbport_, CrawlerInfoManager.Instance.dbname_
                , CrawlerInfoManager.Instance.dbaccount_, CrawlerInfoManager.Instance.dbpw_, CrawlerInfoManager.Instance.sshhostname_
                , CrawlerInfoManager.Instance.sshuser_, CrawlerInfoManager.Instance.sshpw_);
            pLQCrawlerBase.Process_DB(pMySqlDB2);

            if (pMySqlDB2.Close() == false)
            {
                LogManager.Instance.Log("<<< 삭제 실패 2 >>>");
            }

            pMySqlDB2 = null;

            MessageBox.Show("크롤링이 끝났습니다.");
        }
Пример #2
0
        // DB 에서 정보 로드 하기
        public bool DB_GetInfos()
        {
            bool bResult = true;

            try
            {
                SqlHelper pMySqlDB = new SqlHelper();

                pMySqlDB.Connect(CINIManager.Instance.method_, CINIManager.Instance.dbip_, CINIManager.Instance.dbport_, CINIManager.Instance.dbname_
                    , CINIManager.Instance.dbaccount_, CINIManager.Instance.dbpw_, CINIManager.Instance.sshhostname_
                    , CINIManager.Instance.sshuser_, CINIManager.Instance.sshpw_);

                bResult = DB_GetChannelInfo(pMySqlDB);

                if (bResult)
                    ProcessStateManager.Instance.ChannelName_ = LQCrawlerInfo_.ChannelName_;

                if (bResult)
                    bResult = DB_GetStateTable(pMySqlDB);

                if (bResult)
                    bResult = DB_GetGoodsInfo(pMySqlDB);

                if (bResult)
                    bResult = DB_SelectData(pMySqlDB);

                pMySqlDB.Close();
                pMySqlDB = null;

            }
            catch (System.Exception ex)
            {
                NewLogManager2.Instance.Log(string.Format("Error public bool DB_GetInfos() {0}", ex.Message));
                bResult = false;
            }

            return bResult;
        }
Пример #3
0
        // DB 에 데이터 Insert
        public bool DB_InsertData()
        {
            try
            {
                SqlHelper pMySqlDB = new SqlHelper();

                pMySqlDB.Connect(CINIManager.Instance.method_, CINIManager.Instance.dbip_, CINIManager.Instance.dbport_, CINIManager.Instance.dbname_
                    , CINIManager.Instance.dbaccount_, CINIManager.Instance.dbpw_, CINIManager.Instance.sshhostname_
                    , CINIManager.Instance.sshuser_, CINIManager.Instance.sshpw_);

                ProcessStateManager.Instance.NeedDBProcessCount_ = DBProccess_List_.Count;
                Int32 nTempSeq = 0;
                Int32 nStartSeq = 0;
                Int32 nEndSeq = 0;
                String nTempPinCode = "";

                foreach (var pData in DBProccess_List_)
                {
                    COrderData pOrder = pData.Value;

                    if (pOrder.goodsPassType == "2")
                    {
                        bool bResult = DBInterface.Insert_tblOrder_test(pMySqlDB, pOrder.goodsSeq_, pOrder.channelSeq_
                             , pOrder.channelOrderCode_, pOrder.orderSettlePrice_, 1, pOrder.orderID_, pOrder.orderName_
                             , pOrder.orderPhone_, pOrder.State_, pOrder.ExData_Option_, pOrder.ExData_OptionOriginal_
                             , pOrder.BuyDate_, ref nTempSeq, ref nTempPinCode);
                    }
                    else
                    {
                        bool bResult = DBInterface.Insert_Order_Channel(pMySqlDB, pOrder.goodsSeq_, pOrder.channelSeq_
                             , pOrder.channelOrderCode_, pOrder.orderSettlePrice_,  pOrder.orderName_
                             , pOrder.orderPhone_, pOrder.State_, pOrder.BuyDate_, ref nTempSeq, ref nTempPinCode);
                    }

                    if (nTempSeq > 0)
                    {
                        if(pOrder.goodsSendType_ == 2){
                            QrCodeImageCreate(nTempPinCode, nTempSeq);
                        }
                        else if (pOrder.goodsSendType_ == 3)
                        {
                            BarCodeImageCreate(nTempPinCode, nTempSeq);
                        }

                        if (nStartSeq == 0)
                        {
                            nEndSeq = nStartSeq = nTempSeq;
                        }
                        else
                        {
                            nEndSeq = nTempSeq;
                        }
                    }

                    ProcessStateManager.Instance.CurDBProcessCount_++;
                }

                bool bSMSOn = true;

                if (nStartSeq > 0 && nEndSeq > 0 && bSMSOn == true)
                {
                    DBInterface.Insert_SMS(pMySqlDB, nStartSeq, nEndSeq);
                }

                // 매칭 되지 않은 데이터 넣기
                foreach (var pData in DBProccess_List_Wrong_)
                {
                    COrderData pOrder = pData.Value;

                    bool bResult = DBInterface.Insert_tblOrderWr(pMySqlDB, pOrder.goodsSeq_, pOrder.channelSeq_
                           , pOrder.channelOrderCode_, pOrder.orderSettlePrice_, 1, pOrder.orderID_, pOrder.orderName_
                           , pOrder.orderPhone_, pOrder.State_, pOrder.ExData_GoodsName_, pOrder.ExData_GoodsNick_, pOrder.ExData_Option_, pOrder.ExData_OptionOriginal_
                           , pOrder.BuyDate_, ref nTempSeq);
                }

                pMySqlDB.Close();
                pMySqlDB = null;
            }
            catch (System.Exception ex)
            {
                NewLogManager2.Instance.Log(string.Format("Error DB_InsertData {0}", ex.Message));
                return false;
            }

            return true;
        }
Пример #4
0
        // 크롤링
        public virtual void Crawling(BackgroundWorker pWorker)
        {
            LogManager.Instance.Log(string.Format("<<< 크롤링 시작 {0}>>>", CrawlerManager.Instance.CrawlingCount()));
            pWorker.ReportProgress(1);
            bool bResult = true;

            // DB 접속
            SqlHelper pMySqlDB = new SqlHelper();
            pMySqlDB.Connect(CrawlerInfoManager.Instance.method_, CrawlerInfoManager.Instance.dbip_, CrawlerInfoManager.Instance.dbport_, CrawlerInfoManager.Instance.dbname_
                , CrawlerInfoManager.Instance.dbaccount_, CrawlerInfoManager.Instance.dbpw_, CrawlerInfoManager.Instance.sshhostname_
                , CrawlerInfoManager.Instance.sshuser_, CrawlerInfoManager.Instance.sshpw_);

            // DB에서 채널 정보 로드하기
            pWorker.ReportProgress(2);
            //bResult = DBFunctions.GetCrawlerInfo_Authority(pMySqlDB, CrawlerInfoManager.Instance.channelidx_, CrawlerInfoManager.Instance.partneridx_);
            bResult = DBFunctions.GetCrawlerInfo_Authority(pMySqlDB, CrawlerInfoManager.Instance.channelidx_, CrawlerInfoManager.Instance.partneridx_, CrawlerInfoManager.Instance.authorityseq_);
            if (bResult == false)
            {
                pWorker.ReportProgress(9);
                OrderManager.Instance.Init();
                LogManager.Instance.Log("<<< 크롤링 실패 : GetCrawlerInfo >>>");
                return;
            }
            // 주문별 상태 로드하기
            bResult = DBFunctions.SelectStateTable(pMySqlDB);
            if (bResult == false)
            {
                pWorker.ReportProgress(9);
                OrderManager.Instance.Init();
                LogManager.Instance.Log("<<< 크롤링 실패 : SelectStateTable >>>");
                return;
            }

            // DB에서 현재 가지고 있는 상품 정보 로드하기
            pWorker.ReportProgress(3);
            bResult = DBFunctions.GetGoodsTable(pMySqlDB, CrawlerInfoManager.Instance.channelseq_, CrawlerInfoManager.Instance.authorityseq_);
            if (bResult == false)
            {
                pWorker.ReportProgress(9);
                OrderManager.Instance.Init();
                LogManager.Instance.Log("<<< 크롤링 실패 : GetGoodsTable >>>");
                return;
            }

            // DB에서 현재 Insert된 상품 정보 로드 하기
            pWorker.ReportProgress(4);
            OrderManager.Instance.Init();
            bResult = DBFunctions.Select_tblOrder(pMySqlDB, CrawlerInfoManager.Instance.channelseq_);
            bResult = DBFunctions.Select_tblOrderWr(pMySqlDB, CrawlerInfoManager.Instance.channelseq_);

            if (bResult == false)
            {
                pWorker.ReportProgress(9);
                OrderManager.Instance.Init();
                LogManager.Instance.Log("<<< 크롤링 실패 : Select_tblOrder >>>");
                return;
            }

            CrawlerManager.Instance.GetResultData().DBSelected_ = OrderManager.Instance.GetOrderList().Count;

            // 채널 로그인
            pWorker.ReportProgress(5);
            bResult = Login();

            // 채널에서 상품 판매 정보 다운로드 // 데이터 가공
            pWorker.ReportProgress(6);
            bResult = DownloadExcelAndDataMake();
            if (bResult == false)
            {
                pWorker.ReportProgress(9);
                OrderManager.Instance.Init();
                LogManager.Instance.Log("<<< 크롤링 실패 >>>");
                return;
            }
            bResult = Combine_DB_And_Excel(false);
            //bResult = Process_RefundData(pMySqlDB);  // 당일 취소건에 대한것. 일단 막아두자.

            bResult = Process_ExpiredData();

            // 채널에 상품처리// 채널에 취소처리  // 채널에 반품처리
            pWorker.ReportProgress(7);
            bResult = Process_Use_Cancel_Refund();

            // 다운로드 받은파일 삭제
            //deletedownloadfile();

            if (pMySqlDB.Close() == false)
            {
                LogManager.Instance.Log("<<< 삭제 실패 1 >>>");
            }
            pMySqlDB = null;

            // DB 에 Insert or Update
            pWorker.ReportProgress(8);
            SqlHelper pMySqlDB2 = new SqlHelper();
            pMySqlDB2.Connect(CrawlerInfoManager.Instance.method_, CrawlerInfoManager.Instance.dbip_, CrawlerInfoManager.Instance.dbport_, CrawlerInfoManager.Instance.dbname_
                , CrawlerInfoManager.Instance.dbaccount_, CrawlerInfoManager.Instance.dbpw_, CrawlerInfoManager.Instance.sshhostname_
                , CrawlerInfoManager.Instance.sshuser_, CrawlerInfoManager.Instance.sshpw_);
            Process_DB(pMySqlDB2);

            if (pMySqlDB2.Close() == false)
            {
                LogManager.Instance.Log("<<< 삭제 실패 2 >>>");
            }
            pMySqlDB2 = null;

            // 완료
            CrawlerManager.Instance.AddCrawlingCount();
            pWorker.ReportProgress(9);
            LogManager.Instance.Log("<<< 크롤링 완료 >>>");
        }