Ejemplo n.º 1
0
        protected override bool Internal_ExcelCancel_Parsing(string filepath)
        {
            try
            {
                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;
                Int32 SiteColumn = 1;
                Int32 nCurrentRow = 2;
                Int32 CouponColumn = 2;
                Int32 CancelCountColumn = 16;

                if(filepath.IndexOf("_C_") > 0)
                {
                    SiteColumn = 1;
                    nCurrentRow = 2;
                    CouponColumn = 2;
                    CancelCountColumn = 16;
                }else{
                    SiteColumn = 1;
                    nCurrentRow = 2;
                    CouponColumn = 3;
                    CancelCountColumn = 13;
                }

                while (true)
                {
                    try
                    {
                        tRange = ws.Cells[nCurrentRow, SiteColumn];
                        if (tRange == null)
                            break;
                        string StringSite = tRange.Value2;
                        if (string.IsNullOrEmpty(StringSite) == true)
                            break;

                        if (StringSite.IndexOf("G") < 0)
                        {
                            nCurrentRow++;
                            continue;   // 옥션것만 넘기기
                        }

                        tRange = ws.Cells[nCurrentRow, CouponColumn];
                        if (tRange == null)
                            break;

                        CCancelData pCCancelData = new CCancelData();
                        pCCancelData.channelOrderCode_ = Convert.ToString(tRange.Value2);

                        if (string.IsNullOrEmpty(pCCancelData.channelOrderCode_) == true)
                        {
                            break;
                        }

                        tRange = ws.Cells[nCurrentRow, CancelCountColumn];
                        pCCancelData.CancelCount_ = Convert.ToInt32(tRange.Value2);

                        for(int i = 1; i <= pCCancelData.CancelCount_; i++ )
                        {
                            CCancelData tempExcelData = new CCancelData();
                            tempExcelData.channelOrderCode_ = string.Format("{0}_{1}", pCCancelData.channelOrderCode_, i);
                            tempExcelData.CancelCount_ = 1;
                            Excel_Cancel_List_.Add(tempExcelData.channelOrderCode_, tempExcelData);
                        }
                    }
                    catch (System.Exception ex)
                    {
                        NewLogManager2.Instance.Log(string.Format("Internal_ExcelCancel_Parsing 엑셀 파싱 에러 : {0}/{1}", filepath, 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();
            }
            catch (System.Exception ex)
            {
                NewLogManager2.Instance.Log(string.Format("Error override bool Internal_ExcelCancel_Parsing - {0}", ex.Message));
                return false;
            }

            return true;
        }
Ejemplo n.º 2
0
        protected override bool Internal_ExcelCancel_Parsing(string filepath)
        {
            try
            {
                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;
                Int32 nCurrentRow = 5;
                Int32 CouponColumn = 7;
                Int32 StateColumn = 13;

                while (true)
                {
                    try
                    {
                        tRange = ws.Cells[nCurrentRow, CouponColumn];
                        if (tRange == null)
                            break;

                        CCancelData pCCancelData = new CCancelData();
                        pCCancelData.channelOrderCode_ = Convert.ToString(tRange.Value2);
                        pCCancelData.CancelCount_ = 1;

                        if (string.IsNullOrEmpty(pCCancelData.channelOrderCode_) == true)
                        {
                            break;
                        }

                        tRange = ws.Cells[nCurrentRow, StateColumn];
                        pCCancelData.State_ = Convert.ToString(tRange.Value2);

                        Excel_Cancel_List_.Add(pCCancelData.channelOrderCode_, pCCancelData);
                    }
                    catch (System.Exception ex)
                    {
                        NewLogManager2.Instance.Log(string.Format("Internal_ExcelCancel_Parsing 엑셀 파싱 에러 : {0}/{1}", filepath, 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();
            }
            catch (System.Exception ex)
            {
                NewLogManager2.Instance.Log(string.Format("Error protected override bool Internal_ExcelCancel_Parsing - {0}", ex.Message));
                return false;
            }

            return true;
        }
Ejemplo n.º 3
0
        protected override bool Internal_ExcelCancel_Parsing(string filepath)
        {
            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;
            Int32 nCurrentRow = 3;
            Int32 CouponColumn = 4;
            Int32 CancelCountColumn = 10;
            Int32 StateColumn = 14;

            while (true)
            {
                try
                {
                    tRange = ws.Cells[nCurrentRow, CouponColumn];
                    if (tRange == null)
                        break;

                    CCancelData pCCancelData = new CCancelData();
                    pCCancelData.channelOrderCode_ = Convert.ToString(tRange.Value2);

                    if (string.IsNullOrEmpty(pCCancelData.channelOrderCode_) == true)
                    {
                        break;
                    }

                    // 혹시 중복해서 엑셀파일을 다운로드 받았다면 중복이 있을수 있다. 이건 그냥 지나쳐야 한다.
                    if (Excel_Cancel_List_.ContainsKey(pCCancelData.channelOrderCode_) == true)
                        break;

                    tRange = ws.Cells[nCurrentRow, CancelCountColumn];
                    pCCancelData.CancelCount_ = Convert.ToInt32(tRange.Value2);

                    tRange = ws.Cells[nCurrentRow, StateColumn];
                    pCCancelData.State_ = Convert.ToString(tRange.Value2);

                    for (int i = 1; i <= pCCancelData.CancelCount_; i++)
                    {
                        CCancelData tempExcelData = new CCancelData();
                        tempExcelData.channelOrderCode_ = string.Format("{0}_{1}", pCCancelData.channelOrderCode_, i);
                        tempExcelData.CancelCount_ = 1;
                        Excel_Cancel_List_.Add(tempExcelData.channelOrderCode_, tempExcelData);
                    }
                 }
                catch (System.Exception ex)
                {
                    NewLogManager2.Instance.Log(string.Format("Internal_ExcelCancel_Parsing 엑셀 파싱 에러 : {0}/{1}", filepath, 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;
        }