コード例 #1
0
ファイル: FilesCopy.cs プロジェクト: amitthanki/mvcdemo
        public ExceptionTypes StartFilesCopy(ExcelCreationConfig objExcelCreationConfig)
        {
            Console.WriteLine("Copying Files Started...");
            ExceptionTypes result = ExceptionTypes.Success;

            try
            {
                //copy filtered pdf files in objExcelCreationConfig.LstPdffiles to destination location
                foreach (var file in objExcelCreationConfig.LstPdffiles)
                {
                    try
                    {
                        if (File.Exists(objExcelCreationConfig.NewFilesLocation + file.Name))//If same file already exists then delete to replace
                        {
                            File.Delete(objExcelCreationConfig.NewFilesLocation + file.Name);
                        }

                        //move file
                        File.Move(file.FullName, objExcelCreationConfig.NewFilesLocation + file.Name);
                        Console.WriteLine("Copied File : " + file.Name);
                    }
                    catch (IOException ex)
                    {
                        //catch IO exception to check for duplicate file
                        //check if file exists
                        bool exists = File.Exists(objExcelCreationConfig.NewFilesLocation + file.Name);
                        if (!exists)//if file does not exist throw exception
                        {
                            throw ex;
                        }
                        Console.WriteLine("Error : " + ex.Message);
                        //if file exists log and continue copying other files
                        BLCommon.LogError(StartBackgroundProcess.CurrentMasterUserId, MethodBase.GetCurrentMethod().Name, (long)ErrorModuleName.BGPFDRSubmission, (long)ExceptionTypes.Uncategorized, "Exception PDF file" + file.Name + " already exists in location", ex.StackTrace.ToString());
                    }
                }
                Console.WriteLine("Copying Files Completed.");
            }
            catch (Exception ex)
            {
                //log any other exception other than duplicate file
                Console.WriteLine("Error : " + ex.Message);
                result = ExceptionTypes.Exception;
                BLCommon.LogError(StartBackgroundProcess.CurrentMasterUserId, MethodBase.GetCurrentMethod().Name, (long)ErrorModuleName.BGPFDRSubmission, (long)ExceptionTypes.Uncategorized, "Exception Copying PDF File", ex.StackTrace.ToString());
            }
            //return result of files copy
            return(result);
        }
コード例 #2
0
        public ExceptionTypes StartExcelCreation(ExcelCreationConfig objExcelCreationConfig, out long lRecordsProcessed, out List <long> CaseIds)
        {
            CaseIds = new List <long>();
            Console.WriteLine("Excel Creation Started...");
            ExceptionTypes result = ExceptionTypes.Success;

            lRecordsProcessed = 0;//variable to keep track of total records processed
            try
            {
                BLCommon objBLCommon = new BLCommon();

                //List of excel sheets
                List <FDRSubmissionSheetData> lstExcelSheets = new List <FDRSubmissionSheetData>();

                //check for submission category
                if (objExcelCreationConfig.SubmissionCategory == FDRSubmissionCategory.SCC)
                {
                    FDRSubmissionSheetData SCCSheet = new FDRSubmissionSheetData();

                    //assign sheet position in workbook for all sheets
                    SCCSheet.ISheetNumber = (int)SCCFDRSubmissionExcelSheets.SCC;

                    //assign startting rows for each excel sheet
                    SCCSheet.IStartRow = objExcelCreationConfig.StartingRows[SCCSheet.ISheetNumber - 2];

                    //popualate data in excel sheets
                    //for each pdf file add row in one of the excel sheet data objects
                    foreach (var item in objExcelCreationConfig.LstPdffiles)
                    {
                        //create object to insert in BGP process details for each row created in excel sheet
                        DOCMN_BackgroundProcessDetails objDOCMN_BackgroundProcessDetails = new DOCMN_BackgroundProcessDetails();
                        objDOCMN_BackgroundProcessDetails.CMN_BackgroundProcessMasterRef = objExcelCreationConfig.LbgpMasterId;
                        objDOCMN_BackgroundProcessDetails.UploadFileName = item.Name;

                        //get contract name and HICN from Pdf file name
                        string[] arrContractHicn = item.Name.Replace(".pdf", "").Split('-');
                        //get create row for Contract and HICN
                        result = CreateRowData(arrContractHicn[0], arrContractHicn[1], objExcelCreationConfig.SubmissionCategory, out FDRSubmissionRow newRow, out long lActionRequeseted, out string errorMessage);

                        //if row is created succesfully
                        if (result == ExceptionTypes.Success)
                        {
                            SCCSheet.LstRowData.Add(newRow);
                            //add details to BGP deatils
                            objDOCMN_BackgroundProcessDetails.BGPRecordStatusLkup = (long)BackgroundProcessRecordStatus.Success;
                            objDOCMN_BackgroundProcessDetails.GEN_QueueRef        = newRow.GEN_QueueId;
                            //increase count of total records processed
                            lRecordsProcessed++;
                            CaseIds.Add(newRow.GEN_QueueId);
                        }
                        else
                        {
                            //if row creation failed update BGP deatils with fail result
                            objDOCMN_BackgroundProcessDetails.BGPRecordStatusLkup = (long)BackgroundProcessRecordStatus.Failed;
                            objDOCMN_BackgroundProcessDetails.GEN_QueueRef        = 0;
                            objDOCMN_BackgroundProcessDetails.FailureReason       = errorMessage;
                        }
                        //insert into BGP details table
                        objBLCommon.InsertBackgroundProcessDetails(objDOCMN_BackgroundProcessDetails, out errorMessage);
                    }
                    //once finished processing and creating rows for all the pdf files
                    //add excel sheets to list Excel Sheets if there are rows in the Sheet data
                    if (SCCSheet.LstRowData.Count > 0)
                    {
                        lstExcelSheets.Add(SCCSheet);
                    }
                }
                else
                {
                    //excel sheets objects based on action requested
                    FDRSubmissionSheetData RetDisenrlSheet = new FDRSubmissionSheetData();
                    FDRSubmissionSheetData PBPSheet        = new FDRSubmissionSheetData();
                    FDRSubmissionSheetData RetEnrlSheet    = new FDRSubmissionSheetData();
                    FDRSubmissionSheetData ReInstmtSheet   = new FDRSubmissionSheetData();

                    //assign sheet position in workbook for all sheets
                    RetDisenrlSheet.ISheetNumber = (int)FDRSubmissionExcelSheets.Ret_Disenrl;
                    PBPSheet.ISheetNumber        = (int)FDRSubmissionExcelSheets.PBP;
                    RetEnrlSheet.ISheetNumber    = (int)FDRSubmissionExcelSheets.Ret_Enrl;
                    ReInstmtSheet.ISheetNumber   = (int)FDRSubmissionExcelSheets.REINSTMT;

                    //assign startting rows for each excel sheet
                    RetDisenrlSheet.IStartRow = objExcelCreationConfig.StartingRows[RetDisenrlSheet.ISheetNumber - 2];
                    PBPSheet.IStartRow        = objExcelCreationConfig.StartingRows[PBPSheet.ISheetNumber - 2];
                    RetEnrlSheet.IStartRow    = objExcelCreationConfig.StartingRows[RetEnrlSheet.ISheetNumber - 2];
                    ReInstmtSheet.IStartRow   = objExcelCreationConfig.StartingRows[ReInstmtSheet.ISheetNumber - 2];

                    //popualate data in excel sheets
                    //for each pdf file add row in one of the excel sheet data objects
                    foreach (var item in objExcelCreationConfig.LstPdffiles)
                    {
                        //create object to insert in BGP process details for each row created in excel sheet
                        DOCMN_BackgroundProcessDetails objDOCMN_BackgroundProcessDetails = new DOCMN_BackgroundProcessDetails();
                        objDOCMN_BackgroundProcessDetails.CMN_BackgroundProcessMasterRef = objExcelCreationConfig.LbgpMasterId;
                        objDOCMN_BackgroundProcessDetails.UploadFileName = item.Name;

                        //get contract name and HICN from Pdf file name
                        string[] arrContractHicn = item.Name.Replace(".pdf", "").Split('-');
                        //get create row for Contract and HICN
                        result = CreateRowData(arrContractHicn[0], arrContractHicn[1], objExcelCreationConfig.SubmissionCategory, out FDRSubmissionRow newRow, out long lResolution, out string errorMessage);

                        //if row is created succesfully
                        if (result == ExceptionTypes.Success)
                        {
                            //add row to one of excel sheet based on action requested
                            switch (lResolution)
                            {
                            case (long)RPRResolution.PlanErrorReinstatement:
                            case (long)RPRResolution.ReinstatementDeathABTerm:
                            case (long)RPRResolution.ReinstatementOther:
                            case (long)RPRResolution.ReinstatementTRC14:
                                ReInstmtSheet.LstRowData.Add(newRow);
                                break;

                            case (long)RPRResolution.EffectiveDateChange:
                            case (long)RPRResolution.RetroEnrollment:
                                RetEnrlSheet.LstRowData.Add(newRow);
                                break;

                            case (long)RPRResolution.DisenrollmentDateChangeDODError:
                            case (long)RPRResolution.EnrollmentCancellation:
                            case (long)RPRResolution.RetroDisenrollment:
                                RetDisenrlSheet.LstRowData.Add(newRow);
                                break;

                            case (long)RPRResolution.PBPChange:
                                PBPSheet.LstRowData.Add(newRow);
                                break;
                            }

                            //add details to BGP deatils
                            objDOCMN_BackgroundProcessDetails.BGPRecordStatusLkup = (long)BackgroundProcessRecordStatus.Success;
                            objDOCMN_BackgroundProcessDetails.GEN_QueueRef        = newRow.GEN_QueueId;
                            //increase count of total records processed
                            lRecordsProcessed++;
                            CaseIds.Add(newRow.GEN_QueueId);
                        }
                        else
                        {
                            //if row creation failed update BGP deatils with fail result
                            objDOCMN_BackgroundProcessDetails.BGPRecordStatusLkup = (long)BackgroundProcessRecordStatus.Failed;
                            objDOCMN_BackgroundProcessDetails.GEN_QueueRef        = 0;
                            objDOCMN_BackgroundProcessDetails.FailureReason       = errorMessage;
                        }
                        //insert into BGP details table
                        objBLCommon.InsertBackgroundProcessDetails(objDOCMN_BackgroundProcessDetails, out errorMessage);
                    }
                    //once finished processing and creating rows for all the pdf files
                    //add excel sheets to list Excel Sheets if there are rows in the Sheet data
                    if (RetDisenrlSheet.LstRowData.Count > 0)
                    {
                        lstExcelSheets.Add(RetDisenrlSheet);
                    }
                    if (PBPSheet.LstRowData.Count > 0)
                    {
                        lstExcelSheets.Add(PBPSheet);
                    }
                    if (RetEnrlSheet.LstRowData.Count > 0)
                    {
                        lstExcelSheets.Add(RetEnrlSheet);
                    }
                    if (ReInstmtSheet.LstRowData.Count > 0)
                    {
                        lstExcelSheets.Add(ReInstmtSheet);
                    }
                }
                //create excel workbook and save from list of excel sheets
                result = CreateExcel(lstExcelSheets, objExcelCreationConfig);
            }
            catch (Exception ex)
            {
                //log if any exception
                Console.WriteLine("Error : " + ex.Message);
                result = ExceptionTypes.Exception;
                BLCommon.LogError(_lCurrentMasterUserId, MethodBase.GetCurrentMethod().Name, (long)ErrorModuleName.BGPFDRSubmission, (long)ExceptionTypes.Uncategorized, "Exception Starting Excel Creation", ex.StackTrace.ToString());
            }

            return(result);
        }
コード例 #3
0
        private ExceptionTypes CreateExcel(List <FDRSubmissionSheetData> lstExcelData, ExcelCreationConfig objExcelCreationConfig)
        {
            //check if there are any sheets in List of excel sheets to create excel
            if (lstExcelData.Count > 0)
            {
                try
                {
                    //read the template for creating new excel file
                    FileInfo reportTemplate = new FileInfo(objExcelCreationConfig.TemplateFilelocation + objExcelCreationConfig.TemplateFileName);
                    Console.WriteLine("Getting excel template : " + reportTemplate);
                    //parse template as excel workbook package for processing
                    ExcelPackage templatePackage = new ExcelPackage(reportTemplate);
                    //creating new file path at new location created at  begining of process
                    string strNewExcelFile = objExcelCreationConfig.NewFilesLocation + DateTime.UtcNow.ToString("yyyy.MM.dd ") + objExcelCreationConfig.NewExcelFileNamingConvention;
                    //create new excel file with new name
                    FileInfo newExcelFileInfo = new FileInfo(strNewExcelFile);
                    //if file with same name exists in location delete the file to replace with new file
                    if (newExcelFileInfo.Exists)
                    {
                        newExcelFileInfo.Delete();
                    }
                    //create new excel workbook package for new file
                    using (var package = new ExcelPackage(newExcelFileInfo))
                    {
                        Console.WriteLine("Creating RPC Submission Excel...");
                        //add 1st sheet (information sheet ) from template to new excel file
                        package.Workbook.Worksheets.Add(templatePackage.Workbook.Worksheets[1].Name, templatePackage.Workbook.Worksheets[1]);//adding information excel sheet
                        //Process each excel sheet in list of excel sheet to create excel sheet in workbook
                        foreach (FDRSubmissionSheetData item in lstExcelData)
                        {
                            //check if there are rows in excel sheet
                            if (item.LstRowData.Count > 0)
                            {
                                //get the location of the new excel sheet in workbook
                                int sheetNumber = (int)item.ISheetNumber;
                                //Get satrting row to add data in excel sheet skip two as Index start from 0 and 1 instruction excel sheet to skip
                                int iStartRow = item.IStartRow;
                                //adding sheet for each type of FDR submission action requested type
                                //add new sheet to new excel with name from template
                                ExcelWorksheet excelWorksheet = package.Workbook.Worksheets.Add(templatePackage.Workbook.Worksheets[sheetNumber].Name, templatePackage.Workbook.Worksheets[sheetNumber]);
                                //process each row to be added in excel sheet
                                foreach (FDRSubmissionRow rowData in item.LstRowData)
                                {
                                    //check for SCC Configuration
                                    if (objExcelCreationConfig.SubmissionCategory == FDRSubmissionCategory.SCC)
                                    {
                                        excelWorksheet.Cells[iStartRow, 1].LoadFromText(rowData.MemberContractID);
                                        excelWorksheet.Cells[iStartRow, 2].LoadFromText(rowData.MemberCurrentHICN);
                                        excelWorksheet.Cells[iStartRow, 3].LoadFromText(rowData.MemberLastName);
                                        excelWorksheet.Cells[iStartRow, 4].LoadFromText(rowData.MemberFirstName);
                                        excelWorksheet.Cells[iStartRow, 5].LoadFromText(rowData.EffectiveDate);
                                        excelWorksheet.Cells[iStartRow, 5].Style.Numberformat.Format = "MM/dd/yyyy";
                                        excelWorksheet.Cells[iStartRow, 6].LoadFromText(rowData.EndDate);
                                        excelWorksheet.Cells[iStartRow, 6].Style.Numberformat.Format = "MM/dd/yyyy";
                                        excelWorksheet.Cells[iStartRow, 7].LoadFromText(rowData.SCCRPRRequested);
                                        excelWorksheet.Cells[iStartRow, 7].Style.Numberformat.Format = "00000";
                                        excelWorksheet.Cells[iStartRow, 8].LoadFromText(rowData.SCCRPRRequestedZip);
                                        excelWorksheet.Cells[iStartRow, 8].Style.Numberformat.Format = "00000";
                                    }
                                    else
                                    {
                                        //based on sheet number ad row data with specific coloumn structure
                                        switch (sheetNumber)
                                        {
                                        case (int)FDRSubmissionExcelSheets.Ret_Disenrl:
                                            excelWorksheet.Cells[iStartRow, 1].LoadFromText(rowData.MemberContractID);
                                            excelWorksheet.Cells[iStartRow, 2].LoadFromText(rowData.MemberPBP);
                                            excelWorksheet.Cells[iStartRow, 2].Style.Numberformat.Format = "000";
                                            excelWorksheet.Cells[iStartRow, 3].LoadFromText(rowData.MemberCurrentHICN);
                                            excelWorksheet.Cells[iStartRow, 4].LoadFromText(rowData.MemberLastName);
                                            excelWorksheet.Cells[iStartRow, 5].LoadFromText(rowData.MemberFirstName);
                                            excelWorksheet.Cells[iStartRow, 6].LoadFromText(rowData.ElectionType);
                                            excelWorksheet.Cells[iStartRow, 7].LoadFromText(rowData.EffectiveDate);
                                            excelWorksheet.Cells[iStartRow, 7].Style.Numberformat.Format = "MM/dd/yyyy";
                                            break;

                                        case (int)FDRSubmissionExcelSheets.PBP:
                                        case (int)FDRSubmissionExcelSheets.Ret_Enrl:
                                            excelWorksheet.Cells[iStartRow, 1].LoadFromText(rowData.MemberContractID);
                                            excelWorksheet.Cells[iStartRow, 2].LoadFromText(rowData.MemberPBP);
                                            excelWorksheet.Cells[iStartRow, 2].Style.Numberformat.Format = "000";
                                            excelWorksheet.Cells[iStartRow, 3].LoadFromText("");
                                            excelWorksheet.Cells[iStartRow, 4].LoadFromText(rowData.MemberCurrentHICN);
                                            excelWorksheet.Cells[iStartRow, 5].LoadFromText(rowData.MemberLastName);
                                            excelWorksheet.Cells[iStartRow, 6].LoadFromText(rowData.MemberFirstName);
                                            excelWorksheet.Cells[iStartRow, 7].LoadFromText(rowData.ElectionType);
                                            excelWorksheet.Cells[iStartRow, 8].LoadFromText(rowData.EffectiveDate);
                                            excelWorksheet.Cells[iStartRow, 8].Style.Numberformat.Format = "MM/dd/yyyy";
                                            excelWorksheet.Cells[iStartRow, 9].LoadFromText(rowData.EndDate);
                                            excelWorksheet.Cells[iStartRow, 9].Style.Numberformat.Format = "MM/dd/yyyy";
                                            excelWorksheet.Cells[iStartRow, 10].LoadFromText(rowData.ApplicationDate);
                                            excelWorksheet.Cells[iStartRow, 10].Style.Numberformat.Format = "MM/dd/yyyy";
                                            break;

                                        case (int)FDRSubmissionExcelSheets.REINSTMT:
                                            excelWorksheet.Cells[iStartRow, 1].LoadFromText(rowData.MemberContractID);
                                            excelWorksheet.Cells[iStartRow, 2].LoadFromText(rowData.MemberPBP);
                                            excelWorksheet.Cells[iStartRow, 2].Style.Numberformat.Format = "000";
                                            excelWorksheet.Cells[iStartRow, 3].LoadFromText("");
                                            excelWorksheet.Cells[iStartRow, 4].LoadFromText(rowData.MemberCurrentHICN);
                                            excelWorksheet.Cells[iStartRow, 5].LoadFromText(rowData.MemberLastName);
                                            excelWorksheet.Cells[iStartRow, 6].LoadFromText(rowData.MemberFirstName);
                                            excelWorksheet.Cells[iStartRow, 7].LoadFromText(rowData.EffectiveDate);
                                            excelWorksheet.Cells[iStartRow, 7].Style.Numberformat.Format = "MM/dd/yyyy";
                                            excelWorksheet.Cells[iStartRow, 8].LoadFromText(rowData.EndDate);
                                            excelWorksheet.Cells[iStartRow, 8].Style.Numberformat.Format = "MM/dd/yyyy";
                                            break;
                                        }
                                    }
                                    //increment row number to set for next row in same excel sheet
                                    iStartRow++;
                                }
                            }
                        }
                        //save newly created excel workbook
                        package.Save();
                        Console.WriteLine("RPC Submission Excel Created :" + newExcelFileInfo.FullName);
                        return(ExceptionTypes.Success);
                    }
                }
                catch (Exception ex)
                {
                    //log exception if any
                    Console.WriteLine("Error : " + ex.Message);
                    BLCommon.LogError(_lCurrentMasterUserId, MethodBase.GetCurrentMethod().Name, (long)ErrorModuleName.BGPFDRSubmission, (long)ExceptionTypes.Uncategorized, "Exception Excel Creating", ex.StackTrace.ToString());
                    return(ExceptionTypes.Exception);
                }
            }
            //Log error when there were no records in ERS for pdf files
            Console.WriteLine("No records for creating excel...");
            string error = "No excel file created since no records found for pdf name HICN and Contract in ERS";

            BLCommon.LogError(_lCurrentMasterUserId, MethodBase.GetCurrentMethod().Name, (long)ErrorModuleName.BGPFDRSubmission, (long)ExceptionTypes.Uncategorized, error.ToString(), error.ToString());
            return(ExceptionTypes.Success);
        }
コード例 #4
0
ファイル: FDRSubmission.cs プロジェクト: amitthanki/mvcdemo
        private void StartFDRSubmission(string[] arrConfig, string startRowsConfigName, long lBackgroundProcessType)
        {
            string         dayOfTheWeek      = string.Empty;
            string         fdrSubmissionPath = string.Empty;
            DateTime       startDate;
            ExceptionTypes objExceptionTypesResult;
            List <IncludeInTodaysSubmission> lstIncludeInTodaysSubmission = new List <IncludeInTodaysSubmission>();
            List <FileInfo> LstPdffiles = new List <FileInfo>();

            try
            {
                if (arrConfig.Length == 7)
                {
                    //Insert BGP Master Row
                    BLCommon objCommon = new BLCommon();
                    objCommon.InsertBackgroundProcessMaster(lBackgroundProcessType, _lCurrentMasterUserId, out long bgpMasterId, out string errorMessage);


                    objExceptionTypesResult = objBLFDR.GetIncludeInTodaysSubmission(out lstIncludeInTodaysSubmission, out string errorMsg);
                    if (objExceptionTypesResult != ExceptionTypes.Success)
                    {
                        BLCommon.LogError(_lCurrentMasterUserId, MethodBase.GetCurrentMethod().Name, (long)ErrorModuleName.BGPFDRSubmission, (long)ExceptionTypes.Uncategorized, errorMsg, errorMsg);
                    }

                    long lRecordsProcessed = 0;                                           //default value for records processed
                    long lBGPStatusLkup    = (long)BackgroundProcessRecordStatus.Success; //default status for process
                    startDate    = DateTime.UtcNow.AddDays(-Convert.ToInt32(arrConfig[5]));
                    dayOfTheWeek = startDate.DayOfWeek.NullToString();
                    switch (_lSubmissionCategory)
                    {
                    case (long)FDRSubmissionCategory.Category2:
                    case (long)FDRSubmissionCategory.SCC:
                        if (dayOfTheWeek == "Sunday" || dayOfTheWeek == "Saturday")    //sunday||Satday
                        {
                            startDate    = DateTime.UtcNow.AddDays(-(Convert.ToInt32(arrConfig[5]) + Convert.ToInt32(arrConfig[5])));
                            dayOfTheWeek = startDate.DayOfWeek.NullToString();
                        }
                        fdrSubmissionPath = arrConfig[0] + dayOfTheWeek;
                        break;

                    case (long)FDRSubmissionCategory.Category2CTM:
                        if (dayOfTheWeek == "Sunday")    //sunday
                        {
                            startDate    = DateTime.UtcNow.AddDays(-(Convert.ToInt32(arrConfig[5]) + Convert.ToInt32(arrConfig[5])));
                            dayOfTheWeek = startDate.DayOfWeek.NullToString();
                        }
                        fdrSubmissionPath = arrConfig[0] + dayOfTheWeek;
                        break;

                    case (long)FDRSubmissionCategory.ReSubmission:
                        if (dayOfTheWeek == "Sunday")                   //sunday
                        {
                            startDate    = DateTime.UtcNow.AddDays(-3); //Friday
                            dayOfTheWeek = startDate.DayOfWeek.NullToString();
                        }
                        fdrSubmissionPath = arrConfig[0] + dayOfTheWeek;
                        break;

                    case (long)FDRSubmissionCategory.Category3:
                        fdrSubmissionPath = arrConfig[0] + "Submission " + GetSubmissionNumberForCat3();
                        break;
                    }

                    //create Process configuration deatils object from config data
                    ExcelCreationConfig objExcelCreationConfig = new ExcelCreationConfig()
                    {
                        PdfFileslocation             = fdrSubmissionPath,
                        TemplateFilelocation         = arrConfig[1],
                        TemplateFileName             = arrConfig[2],
                        NewFilesLocation             = arrConfig[3],
                        NewExcelFileNamingConvention = arrConfig[4],
                        FilterStartDate    = DateTime.UtcNow.AddDays(-Convert.ToInt32(arrConfig[5])),
                        FilterEndDate      = DateTime.UtcNow.AddDays(-Convert.ToInt32(arrConfig[6])),
                        LstPdffiles        = new List <FileInfo>(),
                        LbgpMasterId       = bgpMasterId,
                        SubmissionCategory = (FDRSubmissionCategory)_lSubmissionCategory,
                        //StartingRows = AppConfigData.StartRowsForSheet.Split('|').Select(x => x.ToInt32()).ToList()
                        StartingRows = CacheUtility.GetConfigrationValueByConfigName(startRowsConfigName).Split('|').Select(x => x.ToInt32()).ToList()
                    };
                    DirectoryInfo info = new DirectoryInfo(objExcelCreationConfig.PdfFileslocation);

                    //filter files to be accessed based on number of PdfsRetrivalStartDay and PdfsRetrivalEndDay from config
                    objExcelCreationConfig.LstPdffiles = info.GetFiles("*-*.pdf").ToList();
                    //objExcelCreationConfig.LstPdffiles = info.GetFiles("*-*.pdf").ToList();

                    //Logic for include in todays submission
                    if (lstIncludeInTodaysSubmission.Count > 0)
                    {
                        info = new DirectoryInfo(arrConfig[0].NullToString());
                        foreach (var item in lstIncludeInTodaysSubmission)
                        {
                            if (info.GetFiles(item.SubmissionFileName, SearchOption.AllDirectories).Count() > 0)
                            {
                                objExcelCreationConfig.LstPdffiles.Add(info.GetFiles(item.SubmissionFileName, SearchOption.AllDirectories).FirstOrDefault());
                            }
                        }
                    }
                    //create new folder location
                    objExcelCreationConfig.NewFilesLocation = objExcelCreationConfig.NewFilesLocation + DateTime.UtcNow.ToString("yyyy/MM/dd") + "\\";

                    if (objExcelCreationConfig.LstPdffiles.Count > 0)
                    {
                        ExceptionTypes result;
                        Console.WriteLine("Creating directory..");
                        //create new folder for copying files and creating excels
                        Directory.CreateDirectory(objExcelCreationConfig.NewFilesLocation);
                        Console.WriteLine("New directory created : " + objExcelCreationConfig.NewFilesLocation);

                        FilesCopy objFilesCopy = new FilesCopy();
                        //copy files to new location
                        result = objFilesCopy.StartFilesCopy(objExcelCreationConfig);
                        if (result != ExceptionTypes.Success)
                        {
                            string ex = "Copying PDF Files Failed " + _strSubmissionCategory;
                            BLCommon.LogError(_lCurrentMasterUserId, MethodBase.GetCurrentMethod().Name, (long)ErrorModuleName.BGPFDRSubmission, (long)ExceptionTypes.Uncategorized, ex.ToString(), ex.ToString());
                        }

                        ExcelCreation objExcelCreation = new ExcelCreation();
                        //create FDR submission excel
                        result = objExcelCreation.StartExcelCreation(objExcelCreationConfig, out lRecordsProcessed, out List <long> CaseIds);

                        //if excel creation fails log error
                        if (result != ExceptionTypes.Success)
                        {
                            string ex = "Excel Creation Failed for " + _strSubmissionCategory;
                            BLCommon.LogError(_lCurrentMasterUserId, MethodBase.GetCurrentMethod().Name, (long)ErrorModuleName.BGPFDRSubmission, (long)ExceptionTypes.Uncategorized, ex.ToString(), ex.ToString());
                            lRecordsProcessed = 0;
                            lBGPStatusLkup    = (long)BackgroundProcessRecordStatus.Failed;
                        }
                        else if (lRecordsProcessed > 0 && CaseIds.Count > 0)
                        {
                            //update the FDRPackagedate and FDRSUbmissioncategorylkup fields for all ers case Ids.

                            result = objBLFDR.UpdateFDRPackageDate(CaseIds, objExcelCreationConfig.SubmissionCategory, _lCurrentMasterUserId, out errorMessage);
                            if (result != ExceptionTypes.Success)
                            {
                                string ex = "Updating FDR Package date failed for " + _strSubmissionCategory;
                                BLCommon.LogError(_lCurrentMasterUserId, MethodBase.GetCurrentMethod().Name, (long)ErrorModuleName.BGPFDRSubmission, (long)ExceptionTypes.Uncategorized, errorMessage, ex.ToString());
                            }
                        }
                    }
                    else
                    {
                        //if no pdf files in location to create FDR submission log error
                        lRecordsProcessed = 0;
                        lBGPStatusLkup    = (long)BackgroundProcessRecordStatus.Failed;
                        string ex = "No pdfs for " + _strSubmissionCategory + " at : " + objExcelCreationConfig.PdfFileslocation + " created between " + objExcelCreationConfig.FilterStartDate.ToShortDateString() + " and " + objExcelCreationConfig.FilterEndDate.ToShortDateString();
                        BLCommon.LogError(_lCurrentMasterUserId, MethodBase.GetCurrentMethod().Name, (long)ErrorModuleName.BGPFDRSubmission, (long)ExceptionTypes.Uncategorized, ex.ToString(), ex.ToString());
                        Console.WriteLine(ex);
                    }
                    //log BGP run status
                    DOCMN_BackgroundProcessMaster objDOCMN_BackgroundProcessMaster = new DOCMN_BackgroundProcessMaster();
                    objDOCMN_BackgroundProcessMaster.CMN_BackgroundProcessMasterId = bgpMasterId;
                    objDOCMN_BackgroundProcessMaster.TotalRecordProcessed          = lRecordsProcessed;
                    objDOCMN_BackgroundProcessMaster.BGPStatusLkup    = lBGPStatusLkup;
                    objDOCMN_BackgroundProcessMaster.LastUpdatedByRef = _lCurrentMasterUserId;
                    objCommon.UpdateBackgroundProcessMaster(objDOCMN_BackgroundProcessMaster, out errorMessage);
                }
                else
                {
                    //if app.config configuration for FDR submission is wrong
                    throw new InvalidDataException("Invalid App Configuration data for " + _strSubmissionCategory + " in app.config");
                }
            }
            catch (Exception ex)
            {
                //log exception if any
                BLCommon.LogError(_lCurrentMasterUserId, MethodBase.GetCurrentMethod().Name, (long)ErrorModuleName.BGPFDRSubmission, (long)ExceptionTypes.Uncategorized, "Exception Starting FDR Submission " + _strSubmissionCategory, ex.StackTrace.ToString());
            }
        }