Esempio 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 nCurrentRow       = 7;
                Int32 StateColumn       = 2;
                Int32 CouponColumn      = 3;
                Int32 CouponColumn2     = 4;
                Int32 CancelCountColumn = 9;


                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;
                        }

                        tRange = ws.Cells[nCurrentRow, StateColumn];
                        if (tRange == null)
                        {
                            break;
                        }
                        pCCancelData.State_ = Convert.ToString(tRange.Value2);


                        tRange = ws.Cells[nCurrentRow, CouponColumn2];
                        if (tRange == null)
                        {
                            break;
                        }

                        pCCancelData.channelOrderCode_ = string.Format("{0}_{1}", pCCancelData.channelOrderCode_, Convert.ToString(tRange.Value2));

                        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;
                            tempExcelData.State_            = pCCancelData.State_;

                            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 protected override bool Internal_ExcelCancel_Parsing - {0}", ex.Message));
                return(false);
            }

            return(true);
        }
Esempio 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.GetWorkSheetFromText(filepath, ref ap, ref wb, ref ws);

                Range tRange       = null;
                Int32 nCurrentRow  = 2;
                Int32 CouponColumn = 1;

                Int32 wow = ws.UsedRange.Rows.Count;

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

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

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

                        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 public override bool Internal_ExcelCancel_Parsing - {0}", ex.Message));
                return(false);
            }

            return(true);
        }