public override Int32 SplitDealAndInsertExcelData(tblOrderData pExcelData, string comparesitename = "") { string optionstring = pExcelData.ExData_Option_; Int32 nBuycount = 0; Int32 nTotalcount = 0; string optionname = ""; //레저큐 이즈웰 정규식 string regstring = ""; if (pExcelData.authoritySeq_ != 26) { regstring = @"(?<OptionName>\S+),\S+수량(?<Count>\d+)개"; } else { regstring = @"(?<OptionName>\S+)"; } //오타이어 정규식 //string regstring = @"(?<OptionName>\S+):수량(?<Count>\d+)개"; string[] optionarray = System.Text.RegularExpressions.Regex.Split(optionstring, "(],)"); foreach (string curoption in optionarray) { optionstring = curoption.Replace("],", "]"); optionstring = optionstring.Replace(" ", ""); Regex re = new Regex(regstring, RegexOptions.IgnoreCase | RegexOptions.Singleline); MatchCollection oe = re.Matches(optionstring); foreach (Match mat in oe) { GroupCollection group = mat.Groups; optionname = Convert.ToString(group["OptionName"].Value); optionname = Regex.Replace(optionname, @"[^a-zA-Z0-9가-힣]", ""); if (pExcelData.BuyCount_ != 0) { nBuycount = pExcelData.BuyCount_; } else { nBuycount = Convert.ToInt32(group["Count"].Value); } for (Int32 i = 0; i < nBuycount; i++) { nTotalcount++; tblOrderData tempExcelData = new tblOrderData(); tempExcelData.CopyFrom(pExcelData); tempExcelData.bFindInExcel_ = true; tempExcelData.ExData_Option_ = optionname; tempExcelData.channelOrderCode_ = string.Format("{0}_{1}", pExcelData.channelOrderCode_, nTotalcount); OrderManager.Instance.AddExcelData(tempExcelData); } } } return(nTotalcount); }
public override Int32 SplitDealAndInsertExcelData(tblOrderData pExcelData, string comparesitename = "") { string optionstring = pExcelData.ExData_Option_; Int32 nBuycount = 0; Int32 nTotalcount = 0; string optionname = ""; // string regstring = @"(?<OptionName>\S+),\S+(?<Count>\d+)개"; string regstring = @"(?<OptionName>\S+)-\S+"; optionstring = optionstring.Replace(" ", ""); Regex re = new Regex(regstring, RegexOptions.IgnoreCase | RegexOptions.Singleline); MatchCollection oe = re.Matches(optionstring); foreach (Match mat in oe) { GroupCollection group = mat.Groups; optionname = Convert.ToString(group["OptionName"].Value); optionname = Regex.Replace(optionname, @"[^a-zA-Z0-9가-힣]", ""); nBuycount = pExcelData.BuyCount_; for (Int32 i = 0; i < nBuycount; i++) { nTotalcount++; tblOrderData tempExcelData = new tblOrderData(); tempExcelData.CopyFrom(pExcelData); tempExcelData.bFindInExcel_ = true; tempExcelData.ExData_Option_ = optionname; tempExcelData.channelOrderCode_ = string.Format("{0}_{1}", pExcelData.channelOrderCode_, nTotalcount); OrderManager.Instance.AddExcelData(tempExcelData); } } return(nTotalcount); }
public override Int32 SplitDealAndInsertExcelData(tblOrderData pExcelData, string comparesitename = "") { string optionstring = pExcelData.ExData_Option_; string optionPhone = pExcelData.orderPhone_.Replace(" ", ""); Int32 nBuycount = 0; Int32 nTotalcount = 0; string optionname = ""; // string regstring = @"(?<OptionName>\S+),\S+(?<Count>\d+)개"; string[] optionarray = System.Text.RegularExpressions.Regex.Split(optionstring, "\n"); foreach (string curoption in optionarray) { optionstring = curoption.Replace(" ", ""); optionname = optionstring; nBuycount = pExcelData.BuyCount_; optionname = Regex.Replace(optionname, @"[^a-zA-Z0-9가-힣]", ""); for (Int32 i = 0; i < nBuycount; i++) { nTotalcount++; tblOrderData tempExcelData = new tblOrderData(); tempExcelData.CopyFrom(pExcelData); tempExcelData.bFindInExcel_ = true; tempExcelData.ExData_Option_ = optionname; tempExcelData.orderPhone_ = optionPhone; tempExcelData.channelOrderCode_ = string.Format("{0}_{1}", pExcelData.channelOrderCode_, nTotalcount); OrderManager.Instance.AddExcelData(tempExcelData); } } return(nTotalcount); }
public static bool Select_tblOrderWr(SqlHelper dbHelper, Int32 xchannelSeq) { bool bResult = true; try { // 2014.06.05 Dictionary <string, object> argdic = new Dictionary <string, object>(); argdic.Add("xChannelIdx", xchannelSeq); MySqlDataReader datareader = dbHelper.call_proc("sp_select_OrderWrInfo", argdic); while (datareader.Read()) { tblOrderData pOrderData = new tblOrderData(); pOrderData.channelOrderCode_ = Convert.ToString(datareader["channelOrderCode"]); pOrderData.NeedDBProc_ = tblOrderData.NeedDBProc.None; OrderManager.Instance.AddWrongData(pOrderData); } datareader.Close(); datareader.Dispose(); datareader = null; } catch (System.Exception ex) { LogManager.Instance.Log(ex.Message); bResult = false; } return(bResult); }
// DB에는 있으나 엑셀에서 찾지 못한것들 처리 public virtual bool Process_RefundData(SqlHelper MySqlDB) { Dictionary <string, tblOrderData> pOrderList = OrderManager.Instance.GetOrderList(); Dictionary <Int32, ChannelGoodInfo> pInfoList = CrawlerManager.Instance.GetGoodsInfo(); foreach (var pData in pOrderList) { tblOrderData p = pData.Value; if (p.bFindInExcel_ == false) { if (pInfoList.ContainsKey(p.goodsSeq_) == true) { if (p.State_ == DealStateManager.Instance.StateString_[(Int32)DealStateEnum.FINISH_BUY]) { // bool bResult = DBFunctions.Update_CancelOrderInfo(MySqlDB, (Int32)p.seq_, p.channelOrderCode_); } //else if (p.State_ == DealStateManager.Instance.StateString_[(Int32)DealStateEnum.FINISH_RESERVED]) //{ // p.State_ = DealStateManager.Instance.StateString_[(Int32)DealStateEnum.BLACK]; //} else { continue; } //p.NeedDBProc_ = tblOrderData.NeedDBProc.Update; } } } return(true); }
public override Int32 SplitDealAndInsertExcelData(tblOrderData pExcelData, string comparesitename = "") { if (string.IsNullOrEmpty(comparesitename) == true) { return(0); } if (comparesitename.IndexOf(str_sitecompare_) < 0) { return(0); } //string optionstring = Regex.Replace(pExcelData.ExData_Option_, @"[^a-zA-Z0-9가-힣]", ""); string optionstring = Regex.Replace(pExcelData.ExData_Option_, @" ", ""); Int32 nBuycount = 0; Int32 nTotalcount = 0; string optionname = ""; optionname = Convert.ToString(Regex.Replace(pExcelData.ExData_Option_, @"[^a-zA-Z0-9가-힣]", "")); nBuycount = pExcelData.BuyCount_; for (Int32 i = 0; i < nBuycount; i++) { nTotalcount++; tblOrderData tempExcelData = new tblOrderData(); tempExcelData.CopyFrom(pExcelData); tempExcelData.ExData_Option_ = optionname; tempExcelData.channelOrderCode_ = string.Format("{0}_{1}", pExcelData.channelOrderCode_, nTotalcount); tempExcelData.bFindInExcel_ = true; OrderManager.Instance.AddExcelData(tempExcelData); } return(nTotalcount); }
public override void MakeDBData(tblOrderData pExcelData) { Dictionary <string, tblOrderData> pOrderList = OrderManager.Instance.GetOrderList(); LQStructures.LQCrawlerInfo pCrawler = CrawlerManager.Instance.GetCrawlerInfo(); // DB에 저장되어 있던 값이 아니면 들어온 값이라면 if (pOrderList.ContainsKey(pExcelData.channelOrderCode_) == false) { pExcelData.State_ = DealStateManager.Instance.StateString_[(Int32)DealStateEnum.FINISH_BUY]; // 신규 데이터라면 일단 DB에 넣는다. pExcelData.NeedDBProc_ = tblOrderData.NeedDBProc.Insert; pOrderList.Add(pExcelData.channelOrderCode_, pExcelData); } else { tblOrderData pDBData = pOrderList[pExcelData.channelOrderCode_]; if (pDBData.State_ == DealStateManager.Instance.StateString_[(Int32)DealStateEnum.FINISH_BUY]) { } else if (pDBData.State_ == DealStateManager.Instance.StateString_[(Int32)DealStateEnum.USED]) { // 사용 처리된 상태인데, 뭔가 해줘야 할게 있는가? } } }
// 하나의 딜을 여러개로 나눌 필요가 있는가? 있다면 나눠서 넣고 없다면 그냥 넣는다. // 일반적인 경우에 1개만 한다. public virtual Int32 SplitDealAndInsertExcelData(tblOrderData pExcelData, string comparesitename = "") { pExcelData.bFindInExcel_ = true; pExcelData.ExData_Option_ = Regex.Replace(pExcelData.ExData_Option_, @"[^a-zA-Z0-9가-힣]", ""); OrderManager.Instance.AddExcelData(pExcelData); return(1); }
public override Int32 SplitDealAndInsertExcelData(tblOrderData pExcelData, string comparesitename = "") { string optionstring = pExcelData.ExData_Option_; string optionPhone = pExcelData.orderPhone_.Replace(" ", ""); Int32 nBuycount = 0; Int32 nTotalcount = 0; string optionname = ""; // string regstring = @"(?<OptionName>\S+),\S+(?<Count>\d+)개"; string regstring = @"(?<OptionName>\S+)"; string regstringPhone = @"연락처\:(?<OrderPhone>\S+)|MS\S+\(\S+\):(?<OrderPhone>\S+)"; string[] optionarray = System.Text.RegularExpressions.Regex.Split(optionstring, "\n"); foreach (string curoption in optionarray) { optionstring = curoption.Replace(" ", ""); Regex re = new Regex(regstring, RegexOptions.IgnoreCase | RegexOptions.Singleline); Regex rePhone = new Regex(regstringPhone, RegexOptions.IgnoreCase | RegexOptions.Singleline); MatchCollection oe = re.Matches(optionstring); if (optionPhone.Contains("MMS") == true) { MatchCollection oePhone = rePhone.Matches(optionPhone); GroupCollection group2 = oePhone[0].Groups; optionPhone = Convert.ToString(group2["OrderPhone"].Value); } nBuycount = pExcelData.BuyCount_; foreach (Match mat in oe) { GroupCollection group = mat.Groups; optionname = Convert.ToString(group["OptionName"].Value); optionname = Regex.Replace(optionname, @"[^a-zA-Z0-9가-힣]", ""); optionPhone = Regex.Replace(optionPhone, @"^(01[016789]{1}|02|0[3-9]{1}[0-9]{1})-?([0-9]{3,4})-?([0-9]{4})$", @"$1-$2-$3"); for (Int32 i = 0; i < nBuycount; i++) { nTotalcount++; tblOrderData tempExcelData = new tblOrderData(); tempExcelData.CopyFrom(pExcelData); tempExcelData.bFindInExcel_ = true; tempExcelData.ExData_Option_ = optionname; tempExcelData.orderPhone_ = optionPhone; tempExcelData.channelOrderCode_ = string.Format("{0}_{1}", pExcelData.channelOrderCode_, nTotalcount); OrderManager.Instance.AddExcelData(tempExcelData); } } } return(nTotalcount); }
public bool AddExcelData(tblOrderData pData) { if (OrderExcelList_.ContainsKey(pData.channelOrderCode_) == true) { return(false); } OrderExcelList_.Add(pData.channelOrderCode_, pData); return(true); }
public bool AddWrongData(tblOrderData pData) { if (WrongOrderList_.ContainsKey(pData.channelOrderCode_) == true) { return(false); } WrongOrderList_.Add(pData.channelOrderCode_, pData); return(true); }
public bool Combine_DB_And_Excel(bool bWithGoodsName) { Dictionary <string, tblOrderData> pExcelList = OrderManager.Instance.GetExcelOrderList(); Dictionary <string, tblOrderData> pDBList = OrderManager.Instance.GetOrderList(); Dictionary <string, tblOrderData> pWrongList = OrderManager.Instance.GetWrongOrderList(); Dictionary <Int32, ChannelGoodInfo> pGoodsList = CrawlerManager.Instance.GetGoodsInfo(); foreach (var pData in pExcelList) { tblOrderData pExcelData = pData.Value; ChannelGoodInfo pChannelGoodInfo = null; if (bWithGoodsName == true) { pChannelGoodInfo = CrawlerManager.Instance.GetGoodSeqByOptionNameAndGoodName(pExcelData.ExData_Option_, pExcelData.ExData_GoodsName_); } else { pChannelGoodInfo = CrawlerManager.Instance.GetGoodInfoByOptionName(pExcelData.ExData_Option_); } if (pChannelGoodInfo == null) {// 매칭되는 상품명이 없음. if (pDBList.ContainsKey(pExcelData.channelOrderCode_) == false && pWrongList.ContainsKey(pExcelData.channelOrderCode_) == false) {// 근데 DB에 주문해둔것에 있다면 있다가 사라진거니까 아무것도 하지 말고 넘어가자. pExcelData.goodsSeq_ = 0; pExcelData.NeedDBProc_ = tblOrderData.NeedDBProc.Insert; pWrongList.Add(pExcelData.channelOrderCode_, pExcelData); } continue; } pExcelData.ExData_GoodsName_ = pChannelGoodInfo.GoodsName_; pExcelData.goodsSeq_ = pChannelGoodInfo.Idx_; pExcelData.goodsCode_ = pChannelGoodInfo.Goods_Code_; if (IsNeedCheck(pExcelData) == true) { MakeDBData(pExcelData); } } pExcelList.Clear(); // 더이상 액셀 데이터를 쓸일이 없으니 삭제하자. return(true); }
// 체크해야 하는 데이터인가? 채널별로 하지 않아도 되는것이 있다. public virtual bool IsNeedCheck(tblOrderData pExcelData) { // 이미 리스트에 들어있고 Dictionary <string, tblOrderData> pOrderList = OrderManager.Instance.GetOrderList(); if (pOrderList.ContainsKey(pExcelData.channelOrderCode_) == true) { tblOrderData pData = pOrderList[pExcelData.channelOrderCode_]; if (pData.bProcessed_ == true) { return(false); } } return(true); }
// DB에서 사용처리 해야하는 테이블 로드 public static bool Select_tblOrder(SqlHelper dbHelper, Int32 xchannelSeq) { bool bResult = true; try { // 2014.06.05 Dictionary <string, object> argdic = new Dictionary <string, object>(); argdic.Add("xChannelIdx", xchannelSeq); MySqlDataReader datareader = dbHelper.call_proc("sp_select_OrderInfo", argdic); while (datareader.Read()) { tblOrderData pOrderData = new tblOrderData(); pOrderData.NeedDBProc_ = tblOrderData.NeedDBProc.None; pOrderData.seq_ = Convert.ToInt64(datareader["seq"]); pOrderData.goodsSeq_ = Convert.ToInt32(datareader["goodsSeq"]); pOrderData.memberSeq_ = Convert.ToInt32(datareader["memberSeq"]); pOrderData.channelSeq_ = Convert.ToInt32(datareader["channelSeq"]); pOrderData.channelOrderCode_ = Convert.ToString(datareader["channelOrderCode"]); pOrderData.orderReserveCode_ = Convert.ToString(datareader["orderCode"]); pOrderData.orderID_ = Convert.ToString(datareader["orderId"]); pOrderData.orderSettlePrice_ = Convert.ToInt32(datareader["orderSettlePrice"]); pOrderData.orderName_ = Convert.ToString(datareader["orderName"]); pOrderData.orderPhone_ = Convert.ToString(datareader["orderPhone"]); //pOrderData.orderMethod_ = Convert.ToString(datareader["orderMethod"]); pOrderData.State_ = Convert.ToString(datareader["State"]); OrderManager.Instance.AddOrderData(pOrderData); } datareader.Close(); datareader.Dispose(); datareader = null; } catch (System.Exception ex) { LogManager.Instance.Log(ex.Message); bResult = false; } return(bResult); }
public override void MakeDBData(tblOrderData pExcelData) { Dictionary <string, tblOrderData> pOrderList = OrderManager.Instance.GetOrderList(); LQStructures.LQCrawlerInfo pCrawler = CrawlerManager.Instance.GetCrawlerInfo(); // DB에 저장되어 있던 값이 아니면 들어온 값이라면 if (pOrderList.ContainsKey(pExcelData.channelOrderCode_) == false) { //if (pExcelData.ExData_Use_ == pCrawler.ExData_UseCheck_) //{ // pExcelData.State_ = DealStateManager.Instance.StateString_[(Int32)DealStateEnum.USED]; //} //else if (pExcelData.ExData_Cancel_ == pCrawler.ExData_CancelCheck_) //{ // pExcelData.State_ = DealStateManager.Instance.StateString_[(Int32)DealStateEnum.CANCEL]; //} //else //{ //} pExcelData.State_ = DealStateManager.Instance.StateString_[(Int32)DealStateEnum.FINISH_BUY]; // 신규 데이터라면 일단 DB에 넣는다. pExcelData.NeedDBProc_ = tblOrderData.NeedDBProc.Insert; pExcelData.bFindInExcel_ = true; pExcelData.bProcessed_ = true; pOrderList.Add(pExcelData.channelOrderCode_, pExcelData); } else { tblOrderData pDBData = pOrderList[pExcelData.channelOrderCode_]; if (pExcelData.State_ == pDBData.State_) { return; } pDBData.bFindInExcel_ = true; pDBData.bProcessed_ = true; } }
public override Int32 SplitDealAndInsertExcelData(tblOrderData pExcelData, string comparesitename = "") { Int32 nBuycount = 0; Int32 nTotalcount = 0; nBuycount = pExcelData.BuyCount_; pExcelData.ExData_Option_ = Regex.Replace(pExcelData.ExData_Option_, @"[^a-zA-Z0-9가-힣]", ""); for (Int32 i = 0; i < nBuycount; i++) { nTotalcount++; tblOrderData tempExcelData = new tblOrderData(); tempExcelData.CopyFrom(pExcelData); tempExcelData.bFindInExcel_ = true; tempExcelData.ExData_Option_ = pExcelData.ExData_Option_; tempExcelData.channelOrderCode_ = string.Format("{0}_{1}", pExcelData.channelOrderCode_, nTotalcount); OrderManager.Instance.AddExcelData(tempExcelData); } return(nTotalcount); }
public override Int32 SplitDealAndInsertExcelData(tblOrderData pExcelData, string comparesitename = "") { if (string.IsNullOrEmpty(comparesitename) == true) { return(0); } if (comparesitename.IndexOf(str_sitecompare_) < 0) { return(0); } //string optionstring = Regex.Replace(pExcelData.ExData_Option_, @"[^a-zA-Z0-9가-힣]", ""); string optionstring = Regex.Replace(pExcelData.ExData_Option_, @" ", ""); Int32 nBuycount = 0; Int32 nTotalcount = 0; string optionname = ""; string regstring = @"(?<OptionName>\S+)/\S+/(?<Count>\d+)개|(?<OptionName>\S+)/(?<Count>\d+)개"; // 옵션명 개수 빼기 Regex re = new Regex(regstring, RegexOptions.IgnoreCase | RegexOptions.Singleline); MatchCollection oe = re.Matches(optionstring); optionname = Convert.ToString(Regex.Replace(oe[0].Groups["OptionName"].Value, @"[^a-zA-Z0-9가-힣]", "")); nBuycount = Convert.ToInt32(oe[0].Groups["Count"].Value); for (Int32 i = 0; i < nBuycount; i++) { nTotalcount++; tblOrderData tempExcelData = new tblOrderData(); tempExcelData.CopyFrom(pExcelData); tempExcelData.ExData_Option_ = optionname; tempExcelData.channelOrderCode_ = string.Format("{0}_{1}", pExcelData.channelOrderCode_, nTotalcount); tempExcelData.bFindInExcel_ = true; OrderManager.Instance.AddExcelData(tempExcelData); } return(nTotalcount); }
// 유효기간이 지난 딜은 모두 사용처리로 바꿔준다. // 이 함수에서 예약됨으로 바꿔두면 사용처리한다. public virtual bool Process_ExpiredData() { try { DateTime curDateTime = DateTime.Now; Dictionary <Int32, ChannelGoodInfo> pGoodsInfo = CrawlerManager.Instance.GetGoodsInfo(); Dictionary <string, tblOrderData> pDBOrderList = OrderManager.Instance.GetOrderList(); foreach (var pData in pDBOrderList) { tblOrderData p = pData.Value; if (pGoodsInfo.ContainsKey(p.goodsSeq_) == false) { LogManager.Instance.Log(string.Format("Process_ExpiredData : 상품키가 없다. {0}", p.goodsSeq_)); continue; } ChannelGoodInfo pgoodinfo = pGoodsInfo[p.goodsSeq_]; if (p.State_ == DealStateManager.Instance.StateString_[(Int32)DealStateEnum.FINISH_BUY] && pgoodinfo != null) { if (pgoodinfo.Expired_ == true && curDateTime > pgoodinfo.availableDateTime_) { p.State_ = DealStateManager.Instance.StateString_[(Int32)DealStateEnum.FINISH_RESERVED]; } } } } catch (System.Exception ex) { LogManager.Instance.Log(string.Format("Process_ExpiredData() 에서 에러났쪄엄 {0}", ex.Message)); return(false); } return(true); }
// DB 에 처리 public void Process_DB(SqlHelper MySqlDB) { Int32 nTempSeq = 0; Int32 nStartSeq = 0; Int32 nEndSeq = 0; string emptyCheckCode = ""; // 매칭이 정상적인 데이터 넣기 Dictionary <string, tblOrderData> pOrderList = OrderManager.Instance.GetOrderList(); foreach (var pData in pOrderList) { tblOrderData pOrder = pData.Value; if (pOrder.NeedDBProc_ == tblOrderData.NeedDBProc.Insert) { bool bResult = DBFunctions.Insert_tblOrder(MySqlDB, 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); LogManager.Instance.Log(string.Format("DB Insert {0}", pOrder.channelOrderCode_)); if (bResult == true) { CrawlerManager.Instance.GetResultData().Inserted_++; } else { CrawlerManager.Instance.GetResultData().ErrorCount_++; CrawlerManager.Instance.GetResultData().TotalErrorCount_++; } if (nTempSeq > 0) { if (nStartSeq == 0) { nEndSeq = nStartSeq = nTempSeq; } else { nEndSeq = nTempSeq; } } if (pOrder.channelSeq_ == 11 || pOrder.channelSeq_ == 12 || pOrder.channelSeq_ == 14 || pOrder.authoritySeq_ == 26) { int goodsSeq = 0; string cpcode = ""; string goodscode = ""; goodsSeq = pOrder.goodsSeq_; cpcode = pOrder.channelOrderCode_; goodscode = pOrder.goodsCode_; if (cpcode.Contains(emptyCheckCode) != true || emptyCheckCode == "") {//이베이(옥션,지마켓),굿바이셀리는 선 사용처리 First_UseData(goodsSeq, cpcode, goodscode); } string[] cpcodeArray = cpcode.Split('_'); emptyCheckCode = cpcodeArray[0]; } } else if (pOrder.NeedDBProc_ == tblOrderData.NeedDBProc.Update) { bool bResult = DBFunctions.Update_OrderInfo(MySqlDB, (Int32)pOrder.seq_, pOrder.State_); LogManager.Instance.Log(string.Format("DB Update {0}", pOrder.channelOrderCode_)); if (bResult == true) { CrawlerManager.Instance.GetResultData().Updated_++; } else { CrawlerManager.Instance.GetResultData().ErrorCount_++; CrawlerManager.Instance.GetResultData().TotalErrorCount_++; } } } bool bSMSOn = true; if (nStartSeq > 0 && nEndSeq > 0 && bSMSOn == true) { DBFunctions.Insert_SMS(MySqlDB, nStartSeq, nEndSeq); } // 매칭이 비정상적인 데이터 넣기 Dictionary <string, tblOrderData> pWrongOrderList = OrderManager.Instance.GetWrongOrderList(); foreach (var pData in pWrongOrderList) { tblOrderData pOrder = pData.Value; if (pOrder.NeedDBProc_ == tblOrderData.NeedDBProc.Insert) { bool bResult = DBFunctions.Insert_tblOrder(MySqlDB, 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); LogManager.Instance.Log(string.Format("DB Wrong Insert {0}", pOrder.channelOrderCode_)); } } }
public override bool LoadExcelAndInsertList(string filepath, Int32 GoodsAttrType, bool bFixedType, string goodsname) { LQStructures.LQCrawlerInfo pCrawlerInfo = CrawlerManager.Instance.GetCrawlerInfo(); Microsoft.Office.Interop.Excel.Application ap = null; Workbook wb = null; Worksheet ws = null; HKExcelHelper.GetWorkSheet(filepath, ref ap, ref wb, ref ws); Range tRange = null; string tempString = ""; string comparesitename = ""; string beforeOrderCode = ""; Int32 nCurrentRow = 0; Int32 ExData_Option = 0; Int32 ExData_Coupncode = 0; Int32 ExData_Buyer = 0; Int32 ExData_Cancel = 0; Int32 ExData_Use = 0; Int32 ExData_Buyphone = 0; Int32 ExData_Price = 0; Int32 ExData_BuyDate = 0; Int32 ExData_BuyCount = 0; if (bFixedType == true) {// 레저큐 양식일때는 고정값으로 nCurrentRow = 2; ExData_Option = 4; ExData_Coupncode = 3; ExData_Buyer = 1; ExData_Cancel = 6; ExData_Use = 6; ExData_Buyphone = 2; ExData_Price = 5; ExData_BuyDate = 7; ExData_BuyCount = 8; } else { nCurrentRow = pCrawlerInfo.ExData_Start_; ExData_Option = pCrawlerInfo.ExData_Option_; ExData_Coupncode = pCrawlerInfo.ExData_Coupncode_; ExData_Buyer = pCrawlerInfo.ExData_Buyer_; ExData_Cancel = pCrawlerInfo.ExData_Cancel_; ExData_Use = pCrawlerInfo.ExData_Use_; ExData_Buyphone = pCrawlerInfo.ExData_Buyphone_; ExData_Price = pCrawlerInfo.ExData_Price_; ExData_BuyDate = pCrawlerInfo.ExData_Buydate_; ExData_BuyCount = pCrawlerInfo.ExData_Count_; // 티몬을 위한 변경 if (GoodsAttrType == 1) { nCurrentRow = 3; ExData_Option = 6; ExData_Coupncode = 3; ExData_Buyer = 1; ExData_Cancel = 8; ExData_Use = 8; ExData_Buyphone = 2; ExData_Price = 7; ExData_BuyDate = 9; } } while (true) { try { tRange = ws.Cells[nCurrentRow, 1]; comparesitename = Convert.ToString(tRange.Value2); tRange = ws.Cells[nCurrentRow, ExData_Option]; tempString = Convert.ToString(tRange.Value2); if (tempString == null) { break; } string SecondOrderCode = ""; Int32 tempgoodSeq = -1; tblOrderData pExcelData = new tblOrderData(); pExcelData.channelSeq_ = pCrawlerInfo.Channel_Idx_; pExcelData.authoritySeq_ = pCrawlerInfo.AuthoritySeq_; pExcelData.goodsSeq_ = tempgoodSeq; pExcelData.ExData_Option_ = tempString; pExcelData.ExData_OptionOriginal_ = tempString; if (string.IsNullOrEmpty(goodsname) == false) { pExcelData.ExData_GoodsName_ = goodsname; } tRange = ws.Cells[nCurrentRow, ExData_Coupncode]; if (tRange == null) { break; } pExcelData.channelOrderCode_ = Convert.ToString(tRange.Value2); if (pExcelData.channelOrderCode_ == null) { break; } pExcelData.channelOrderCode_ = pExcelData.channelOrderCode_.Replace("'", ""); pExcelData.channelOrderCode_ = pExcelData.channelOrderCode_.Trim(); // 공백 제거 pExcelData.channelOrderCode_ = pExcelData.channelOrderCode_ + "_" + comparesitename; //Second CouponCode tRange = ws.Cells[nCurrentRow, 2]; SecondOrderCode = Convert.ToString(tRange.Value2); pExcelData.channelOrderCode_ = pExcelData.channelOrderCode_ + "_" + SecondOrderCode; tRange = ws.Cells[nCurrentRow, ExData_Buyer]; pExcelData.orderName_ = Convert.ToString(tRange.Value2); pExcelData.orderName_ = pExcelData.orderName_.Trim(); Regex regex = new Regex(@"\((?<OrderName>\S+)\)"); Match mc = regex.Match(pExcelData.orderName_); if (mc.Success) { pExcelData.orderName_ = Convert.ToString(mc.Groups["OrderName"].Value); } if (pExcelData.orderName_ == null) { pExcelData.orderName_ = ""; } tRange = ws.Cells[nCurrentRow, ExData_Cancel]; pExcelData.ExData_Cancel_ = tRange.Value2; if (pExcelData.ExData_Cancel_ == null) { pExcelData.ExData_Cancel_ = ""; } tRange = ws.Cells[nCurrentRow, ExData_Use]; pExcelData.ExData_Use_ = tRange.Value2; if (pExcelData.ExData_Use_ == null) { pExcelData.ExData_Use_ = ""; } tRange = ws.Cells[nCurrentRow, ExData_Buyphone]; pExcelData.orderPhone_ = Convert.ToString(tRange.Value2); pExcelData.orderPhone_ = "0" + pExcelData.orderPhone_; if (pExcelData.orderPhone_ == null) { pExcelData.orderPhone_ = ""; } pExcelData.orderPhone_ = Regex.Replace(pExcelData.orderPhone_, @"^(01[016789]{1}|02|0[3-9]{1}[0-9]{1})-?([0-9]{3,4})-?([0-9]{4})$", @"$1-$2-$3"); if (ExData_Price != 0) { tRange = ws.Cells[nCurrentRow, ExData_Price]; if (tRange.Value2 != null) {// 돈에 , 가 있으면 제거하자. tempString = Convert.ToString(tRange.Value2); tempString = tempString.Replace(",", ""); pExcelData.orderSettlePrice_ = Convert.ToInt32(tempString); } } tRange = ws.Cells[nCurrentRow, ExData_BuyDate]; DateTime dta = Convert.ToDateTime(tRange.Value2); pExcelData.BuyDate_ = dta.ToString("u"); pExcelData.BuyDate_ = pExcelData.BuyDate_.Replace("Z", ""); if (ExData_BuyCount != 0)// 구매갯수를 따로 뽑아야 하는 채널에서만 { tRange = ws.Cells[nCurrentRow, ExData_BuyCount]; pExcelData.BuyCount_ = Convert.ToInt32(tRange.Value2); } SplitDealAndInsertExcelData(pExcelData, comparesitename); } catch (System.Exception ex) { LogManager.Instance.Log(string.Format("엑셀 파싱 에러 : {0}", ex.Message)); nCurrentRow++; continue; } nCurrentRow++; } wb.Close(false, Type.Missing, Type.Missing); ap.Quit(); Marshal.FinalReleaseComObject(ws); Marshal.FinalReleaseComObject(wb); Marshal.FinalReleaseComObject(ap); ws = null; wb = null; ap = null; GC.Collect(); return(true); }
public virtual void MakeDBData(tblOrderData pExcelData) { Dictionary <string, tblOrderData> pOrderList = OrderManager.Instance.GetOrderList(); LQStructures.LQCrawlerInfo pCrawler = CrawlerManager.Instance.GetCrawlerInfo(); // DB에 저장되어 있던 값이 아니면 들어온 값이라면 if (pOrderList.ContainsKey(pExcelData.channelOrderCode_) == false) { // 상태값 변경 if (pExcelData.ExData_Use_ == pCrawler.ExData_UseCheck_) { pExcelData.State_ = DealStateManager.Instance.StateString_[(Int32)DealStateEnum.A]; } else if (pExcelData.ExData_Cancel_ == pCrawler.ExData_CancelCheck_) { pExcelData.State_ = DealStateManager.Instance.StateString_[(Int32)DealStateEnum.FINISH_REFUND]; } else if (pExcelData.ExData_Use_ == "정산완료" || pExcelData.ExData_Cancel_ == "정산완료") { pExcelData.State_ = DealStateManager.Instance.StateString_[(Int32)DealStateEnum.A]; } else { pExcelData.State_ = DealStateManager.Instance.StateString_[(Int32)DealStateEnum.FINISH_BUY]; } // 신규 데이터라면 일단 DB에 넣는다. pExcelData.NeedDBProc_ = tblOrderData.NeedDBProc.Insert; pExcelData.bFindInExcel_ = true; pExcelData.bProcessed_ = true; pOrderList.Add(pExcelData.channelOrderCode_, pExcelData); } else { tblOrderData pDBData = pOrderList[pExcelData.channelOrderCode_]; if (pExcelData.State_ == pDBData.State_) { return; } pDBData.bFindInExcel_ = true; pDBData.bProcessed_ = true; if (pDBData.State_ == DealStateManager.Instance.StateString_[(Int32)DealStateEnum.FINISH_RESERVED]) {// 예약한 상태 사용처리 해야함 } else if (pDBData.State_ == DealStateManager.Instance.StateString_[(Int32)DealStateEnum.USER_WANT_REFUND]) {// 사용 취소를 요청한 상태 사용취소처리 해야함 } else if (pDBData.State_ == DealStateManager.Instance.StateString_[(Int32)DealStateEnum.FINISH_BUY]) {// DB 에는 구매만 한 상태인데, 엑셀에는 취소 요청을 해둔 상태라면 환불이다. if (pExcelData.ExData_Cancel_ == pCrawler.ExData_CancelCheck_) { pDBData.State_ = DealStateManager.Instance.StateString_[(Int32)DealStateEnum.USER_WANT_REFUND]; } } else if (pDBData.State_ == DealStateManager.Instance.StateString_[(Int32)DealStateEnum.USED]) { // 사용 처리된 상태인데, 뭔가 해줘야 할게 있는가? } else if (pDBData.State_ == DealStateManager.Instance.StateString_[(Int32)DealStateEnum.FINISH_REFUND]) {// 환불이 끝난 상태 아무것도 하지 않는다. } else { //pCrawler.ExData_UseCheck_ if (pExcelData.ExData_Use_.IndexOf(pCrawler.ExData_UseCheck_) >= 0) { pDBData.State_ = DealStateManager.Instance.StateString_[(Int32)DealStateEnum.A]; pDBData.NeedDBProc_ = tblOrderData.NeedDBProc.Update; LogManager.Instance.Log(string.Format("채널에서 이미 사용처리 되어 있어서 DB 값만 바꾸자.{0}", pDBData.channelOrderCode_)); } else { string log = string.Format("C:{0}, CP:{1}, S:{2}, {3}, {4} " , pDBData.channelSeq_, pDBData.channelOrderCode_, pDBData.State_, pExcelData.ExData_Cancel_, pExcelData.ExData_Use_); LogManager.Instance.Log(log); } } } }
public override bool LoadExcelAndInsertList(string filepath, Int32 GoodsAttrType, bool bFixedType, string goodsname) { LQStructures.LQCrawlerInfo pCrawlerInfo = CrawlerManager.Instance.GetCrawlerInfo(); Microsoft.Office.Interop.Excel.Application ap = null; Workbook wb = null; Worksheet ws = null; HKExcelHelper.GetWorkSheet(filepath, ref ap, ref wb, ref ws); Range tRange = null; string tempString = ""; string comparesitename = ""; Int32 nCurrentRow = 0; Int32 ExData_Option = 0; Int32 ExData_Coupncode = 0; Int32 ExData_Buyer = 0; Int32 ExData_Cancel = 0; Int32 ExData_Use = 0; Int32 ExData_Buyphone = 0; Int32 ExData_Price = 0; Int32 ExData_BuyDate = 0; Int32 ExData_BuyCount = 0; if (bFixedType == true) {// 레저큐 양식일때는 고정값으로 nCurrentRow = 2; ExData_Option = 4; ExData_Coupncode = 3; ExData_Buyer = 1; ExData_Cancel = 6; ExData_Use = 6; ExData_Buyphone = 2; ExData_Price = 5; ExData_BuyDate = 7; ExData_BuyCount = 8; } else { nCurrentRow = pCrawlerInfo.ExData_Start_; ExData_Option = pCrawlerInfo.ExData_Option_; ExData_Coupncode = pCrawlerInfo.ExData_Coupncode_; ExData_Buyer = pCrawlerInfo.ExData_Buyer_; ExData_Cancel = pCrawlerInfo.ExData_Cancel_; ExData_Use = pCrawlerInfo.ExData_Use_; ExData_Buyphone = pCrawlerInfo.ExData_Buyphone_; ExData_Price = pCrawlerInfo.ExData_Price_; ExData_BuyDate = pCrawlerInfo.ExData_Buydate_; ExData_BuyCount = pCrawlerInfo.ExData_Count_; // 티몬을 위한 변경 if (GoodsAttrType == 1) { nCurrentRow = 3; ExData_Option = 6; ExData_Coupncode = 3; ExData_Buyer = 1; ExData_Cancel = 8; ExData_Use = 8; ExData_Buyphone = 2; ExData_Price = 7; ExData_BuyDate = 9; } } while (true) { try { tRange = ws.Cells[nCurrentRow, 1]; comparesitename = Convert.ToString(tRange.Value2); tRange = ws.Cells[nCurrentRow, ExData_Option]; if (tRange == null) { break; } tempString = tRange.Value2; if (tempString == null) { break; } Int32 tempgoodSeq = -1; tblOrderData pExcelData = new tblOrderData(); pExcelData.channelSeq_ = pCrawlerInfo.Channel_Idx_; pExcelData.authoritySeq_ = pCrawlerInfo.AuthoritySeq_; //pExcelData.goodsCode_ = pGoodInfo.Goods_Code_; pExcelData.goodsSeq_ = tempgoodSeq; pExcelData.ExData_Option_ = tempString; pExcelData.ExData_OptionOriginal_ = tempString; if (string.IsNullOrEmpty(goodsname) == false) { pExcelData.ExData_GoodsName_ = goodsname; } tRange = ws.Cells[nCurrentRow, ExData_Coupncode]; if (tRange == null) { break; } pExcelData.channelOrderCode_ = Convert.ToString(tRange.Value2); if (pExcelData.channelOrderCode_ == null) { break; } pExcelData.channelOrderCode_ = pExcelData.channelOrderCode_.Replace("'", ""); pExcelData.channelOrderCode_ = pExcelData.channelOrderCode_.Trim(); // 공백 제거 tRange = ws.Cells[nCurrentRow, ExData_Buyer]; pExcelData.orderName_ = Convert.ToString(tRange.Value2); if (pExcelData.orderName_ == null) { pExcelData.orderName_ = ""; } tRange = ws.Cells[nCurrentRow, ExData_Cancel]; pExcelData.ExData_Cancel_ = tRange.Value2; if (pExcelData.ExData_Cancel_ == null) { pExcelData.ExData_Cancel_ = ""; } tRange = ws.Cells[nCurrentRow, ExData_Use]; pExcelData.ExData_Use_ = tRange.Value2; if (pExcelData.ExData_Use_ == null) { pExcelData.ExData_Use_ = ""; } tRange = ws.Cells[nCurrentRow, ExData_Buyphone]; pExcelData.orderPhone_ = Convert.ToString(tRange.Value2); if (pExcelData.orderPhone_ == null || pExcelData.orderPhone_ == "") { tRange = ws.Cells[nCurrentRow, 15]; pExcelData.orderPhone_ = Convert.ToString(tRange.Value2); } pExcelData.orderPhone_ = pExcelData.orderPhone_.Replace("'", ""); if (ExData_Price != 0) { tRange = ws.Cells[nCurrentRow, ExData_Price]; if (tRange.Value2 != null) {// 돈에 , 가 있으면 제거하자. tempString = Convert.ToString(tRange.Value2); tempString = tempString.Replace(",", ""); pExcelData.orderSettlePrice_ = Convert.ToInt32(tempString); } } tRange = ws.Cells[nCurrentRow, ExData_BuyDate]; if (pCrawlerInfo.Channel_Idx_ == 9 || pCrawlerInfo.Channel_Idx_ == 14 || pCrawlerInfo.Channel_Idx_ == 15 || pCrawlerInfo.Channel_Idx_ == 18) { double temp = Convert.ToDouble(tRange.Value2); DateTime dta = DateTime.FromOADate(temp); pExcelData.BuyDate_ = dta.ToString("u"); pExcelData.BuyDate_ = pExcelData.BuyDate_.Replace("Z", ""); } else if (pCrawlerInfo.Channel_Idx_ == 22 || pCrawlerInfo.Channel_Idx_ == 23) { pExcelData.BuyDate_ = Convert.ToString(tRange.Value2); pExcelData.BuyDate_ = pExcelData.BuyDate_ + " 00:00:00"; } else { pExcelData.BuyDate_ = Convert.ToString(tRange.Value2); } pExcelData.BuyDate_ = pExcelData.BuyDate_.Replace('.', '-'); if (ExData_BuyCount != 0)// 구매갯수를 따로 뽑아야 하는 채널에서만 { tRange = ws.Cells[nCurrentRow, ExData_BuyCount]; pExcelData.BuyCount_ = Convert.ToInt32(tRange.Value2); } SplitDealAndInsertExcelData(pExcelData, comparesitename); } catch (System.Exception ex) { LogManager.Instance.Log(string.Format("엑셀 파싱 에러 : {0}", ex.Message)); nCurrentRow++; continue; } nCurrentRow++; } wb.Close(false, Type.Missing, Type.Missing); ap.Quit(); Marshal.FinalReleaseComObject(ws); Marshal.FinalReleaseComObject(wb); Marshal.FinalReleaseComObject(ap); ws = null; wb = null; ap = null; GC.Collect(); return(true); }
// 체크해야 하는 데이터인가? 채널별로 하지 않아도 되는것이 있다. public override bool IsNeedCheck(tblOrderData pExcelData) { return(true); }
// 상품 사용/취소 처리 public bool Process_Use_Cancel_Refund() { Dictionary <string, tblOrderData> pOrderList = OrderManager.Instance.GetOrderList(); foreach (var pData in pOrderList) { tblOrderData pOrder = pData.Value; if (pOrder.State_ == DealStateManager.Instance.StateString_[(Int32)DealStateEnum.FINISH_RESERVED]) { if (Use_Deal(pOrder.goodsSeq_, pOrder.channelOrderCode_, pOrder.goodsCode_) == true) { CrawlerManager.Instance.GetResultData().TotalUseDeal_++; if (pOrder.NeedDBProc_ == tblOrderData.NeedDBProc.None) { pOrder.NeedDBProc_ = tblOrderData.NeedDBProc.Update; } pOrder.State_ = DealStateManager.Instance.StateString_[(Int32)DealStateEnum.USED]; } } else if (pOrder.State_ == DealStateManager.Instance.StateString_[(Int32)DealStateEnum.AR]) { if (Use_Deal(pOrder.goodsSeq_, pOrder.channelOrderCode_, pOrder.goodsCode_) == true) { CrawlerManager.Instance.GetResultData().TotalUseDeal_++; if (pOrder.NeedDBProc_ == tblOrderData.NeedDBProc.None) { pOrder.NeedDBProc_ = tblOrderData.NeedDBProc.Update; } pOrder.State_ = DealStateManager.Instance.StateString_[(Int32)DealStateEnum.A]; } } // 취소는 크롤러에서 처리하지 않음. //else if (pOrder.State_ == DealStateManager.Instance.StateString_[(Int32)DealStateEnum.NEED_CANCEL_USE]) //{ // if (Cancel_Use(pOrder.channelOrderCode_, pOrder.goodsCode_) == true) // { // if (pOrder.NeedDBProc_ == tblOrderData.NeedDBProc.None) // { // pOrder.NeedDBProc_ = tblOrderData.NeedDBProc.Update; // } // pOrder.State_ = DealStateManager.Instance.StateString_[(Int32)DealStateEnum.FINISH_BUY]; // CrawlerManager.Instance.GetResultData().TotalCancelDeal_++; // } //} // 환불 요청은 크롤러에서 처리하지 않음. //else if (pOrder.State_ == DealStateManager.Instance.StateString_[(Int32)DealStateEnum.USER_WANT_REFUND]) //{ // if (Refund(pOrder.channelOrderCode_) == true) // { // if (pOrder.NeedDBProc_ == tblOrderData.NeedDBProc.None) // { // pOrder.NeedDBProc_ = tblOrderData.NeedDBProc.Update; // } // pOrder.State_ = DealStateManager.Instance.StateString_[(Int32)DealStateEnum.FINISH_REFUND]; // CrawlerManager.Instance.GetResultData().TotalRefundDeal_++; // } //} } return(true); }