Exemple #1
0
        public bool InsertFDRBulkImport(DOGEN_FDR objDOGEN_FDR, out string errorMessage)
        {
            bool isSuccess = false;

            errorMessage = string.Empty;
            try
            {
                DALFDR objDAFDRUpload = new DALFDR();
                DOCMN_BackgroundProcessMaster bgpMaster = new DOCMN_BackgroundProcessMaster();

                ExceptionTypes result = objDAFDRUpload.InsertFDRBulkImport(objDOGEN_FDR, out errorMessage);

                if (result != ExceptionTypes.Success || !string.IsNullOrEmpty(errorMessage))
                {
                    return(isSuccess);
                }

                isSuccess = true;
            }
            catch (Exception ex)
            {
                BLCommon.LogError(2, MethodBase.GetCurrentMethod().Name, (long)ErrorModuleName.BulkUpload, (long)ExceptionTypes.Uncategorized, ex.Message.ToString(), errorMessage.ToString());
            }

            return(isSuccess);
        }
Exemple #2
0
        public bool UpdateBGPMaster(DOCMN_BackgroundProcessMaster objDOCMN_BackgroundProcessMaster)
        {
            bool isSuccess = false;
            //Insert BGP Master Row
            BLCommon objCommon = new BLCommon();

            //Insert BGP Master Row
            _retValue = objCommon.UpdateBackgroundProcessMaster(objDOCMN_BackgroundProcessMaster, out string errorMessage);

            if (_retValue == ExceptionTypes.Success && string.IsNullOrEmpty(errorMessage))
            {
                isSuccess = true;
            }

            return(isSuccess);
        }
Exemple #3
0
 public ExceptionTypes UpdateBackgroundProcessMaster(DOCMN_BackgroundProcessMaster objDOCMN_BackgroundProcessMaster, out string errorMessage)
 {
     return(retValue = _objDALCommon.UpdateBackgroundProcessMaster(objDOCMN_BackgroundProcessMaster, out errorMessage));
 }
Exemple #4
0
        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());
            }
        }