/// <summary>
        /// Creates a history record of the upload attempt
        /// </summary>
        private void InsertHistoryRecord()
        {
            string           userID      = _userID;
            Guid             historyCode = Guid.NewGuid();
            InputFileHistory ifh         = new InputFileHistory()
            {
                Code                         = historyCode,
                Filename                     = (UniqueFileName != null ? UniqueFileName.Substring(UniqueFileName.LastIndexOf('\\') + 1) : "Not Found"),
                FileType                     = _fileType,
                LoadedBy                     = userID,
                LoadedDate                   = DateTime.Now,
                NumberOfErrorRecords         = 0,
                NumberOfInformationalRecords = 0,
                NumberOfRecords              = 0,
                NumberOfValidRecords         = 0,
                NumberOfWarningRecords       = 0,
                ProviderOrganisationKeyValue = ProviderKey,
                RowIdentifier                = new byte[0],
                Status                       = "Loading",
                TransferDate                 = DateTime.Parse("01/01/2000"),
                UploadDecision               = -2,
                ValidatedLoadDate            = null
            };

            inputFileHistoryRepository.Add(ifh);
            inputFileHistoryRepository.SaveChanges();

            //retrieve the History Record for further updates throughout this class
            _inputFileHistoryRow  = inputFileHistoryRepository.First(x => x.Code == historyCode);
            _inputFileHistoryCode = _inputFileHistoryRow.Code;
            _errorCode            = 0;
            _isSchemaValid        = true;
            _isBusinessValid      = true;
        }
Esempio n. 2
0
        public override int RunJob()
        {
            try
            {
                FileLock(true);
                _deleteParticipantDataTimeout             = Convert.ToInt32(DataAccessUtilities.GetSystemParameterByName("DeleteParticipantDataTimeout"));
                _deleteInputFileErrorsOver1YearOldTimeout = Convert.ToInt32(DataAccessUtilities.GetSystemParameterByName("DeleteOldInputFileErrorsTimeout"));
                int jobReturnCode = ClearUpload();

                InputFileHistory ifh = inputFileHistoryRepository.Find(x => x.Code == _inputFileHistoryCode).First();
                ifh.Status = "Cancelled";
                inputFileHistoryRepository.Update(ifh);

                //unlock the File provider for future uploads
                FileLock(false);

                return(jobReturnCode);
            }
            catch (Exception e)
            {
                if (CurrentStep != null)
                {
                    CurrentStep.Finish(false);
                }
                UnhandledException = e;
                spRunner2.PublishError("Clear Participant Data", 3, e.Message, _inputFileHistoryCode, null, null);
                //Log error to db for debug purposes.

                //unlock the File provider for future uploads
                FileLock(false);
                return(1);
            }
        }
Esempio n. 3
0
        public IQueryable <InputFileHistory> GetInputFileHistoryAndPreviousByProviderKey(string providerKey)
        {
            InputFileHistory ifh         = inputFileHistoryRepository.Find(x => x.ProviderOrganisationKeyValue == providerKey && x.Status == "Business Validated").OrderByDescending(x => x.LoadedDate).First();
            InputFileHistory previousIfh = inputFileHistoryRepository.Find(x => x.ProviderOrganisationKeyValue == ifh.ProviderOrganisationKeyValue &&
                                                                           x.LoadedDate <= ifh.LoadedDate && x.Status.StartsWith("Validated")).OrderByDescending(x => x.LoadedDate).FirstOrDefault();
            List <InputFileHistory> HistoryList = new List <InputFileHistory>();

            HistoryList.Add(ifh);
            if (previousIfh != null)
            {
                HistoryList.Add(previousIfh);
            }
            return(HistoryList.AsQueryable());
        }
Esempio n. 4
0
        /// <summary>
        /// Copys the uploaded data to a validated area
        /// </summary>
        /// <param name="uploadDecision">The type of data to copy: 'ValidOnly','ValidAndInfo' or 'ValidInfoAndWarning'</param>
        /// <returns></returns>
        public int ClearUpload()
        {
            DeleteParticipantData();
            //UPDATE STATUS
            using (uow)
            {
                InputFileHistory ifh = inputFileHistoryRepository.Find(x => x.Code == _inputFileHistoryCode).First();
                ifh.Status         = "Cancelled";
                ifh.UploadDecision = -1;
                inputFileHistoryRepository.Update(ifh);
            }

            DeleteInputFileErrorsOver1YearOld();
            return(0);
        }
        public void ValidatePreviousLoad(Guid inputFileHistoryCode, string KeyValue, string fileType, int numberOfRecords, DateTime fileRunDate)
        {
            InputFileHistory PreviousRow = GetPreviousLoadedFile(KeyValue, fileType);

            if (PreviousRow != null)
            {
                if (PreviousRow.NumberOfRecords > numberOfRecords)
                {
                    spRunner2.PublishError("Business Validation", 2, "Fewer records exist than in previously loaded file", inputFileHistoryCode, null, null);
                }
                if (PreviousRow.TransferDate.Date >= fileRunDate.Date)
                {
                    spRunner2.PublishError("Business Validation", 2, "A File has already been loaded with this date or later.", inputFileHistoryCode, null, null);
                }
            }
        }
        /// <summary>
        /// Copys the uploaded data to a validated area
        /// </summary>
        /// <param name="uploadDecision">The type of data to copy: 'ValidOnly','ValidAndInfo' or 'ValidInfoAndWarning'</param>
        /// <returns></returns>
        public int ValidatedUpload(int maximumErrorLevel)
        {
            using (spRunner.Cn)
            {
                spRunner.Cn.Open();
                spRunner.IsOpen = true;
                using (SqlTransaction transact = spRunner.Cn.BeginTransaction())
                {
                    DeleteValidatedParticipantData(transact);
                    CopyValidatedParticipants(transact);
                    transact.Commit();
                }
                spRunner.Cn.Close();
                spRunner.IsOpen = false;
            }
            //Stamp number of records uploaded and remove lock of database
            using (uow = SimpleServiceLocator.Instance.Get <IUnitOfWork>("UcbManagementInformation"))
            {
                inputFileHistoryRepository = DataAccessUtilities.RepositoryLocator <IUcbManagementInformationRepository <InputFileHistory> >(uow.ObjectContext);
                providerRepository         = DataAccessUtilities.RepositoryLocator <IUcbManagementInformationRepository <ProviderOrganisation> >(uow.ObjectContext);
                InputFileHistory ifh = inputFileHistoryRepository.Find(x => x.Code == _inputFileHistoryCode).First();
                ifh.Status         = "Validated Loaded " + maximumErrorLevel.ToString();
                ifh.UploadDecision = maximumErrorLevel;
                //_inputFileHistoryRow.ValidatedLoadDate = DateTime.Now;
                inputFileHistoryRepository.Update(ifh);

                ProviderOrganisation po = providerRepository.First(x => x.KeyValue == ProviderKey && x.FileType == "Participant");
                po.CurrentValidatedFileCode = _inputFileHistoryCode;
                providerRepository.Update(po);

                uow.Commit();
            }

            DeleteParticipantData();
            //DeleteParticipantDataOver4HoursOld();
            DeleteInputFileErrorsOver1YearOld();
            return(0);
        }
Esempio n. 7
0
        private void ErrorReport(object item)
        {
            InputFileHistory uploadHistory = item as InputFileHistory;

            if (uploadHistory != null)
            {
                string UsernameParam             = "&" + "UserName" + "=" + WebContext.Current.User.Name;
                string InputFileHistoryCodeParam = "&InputFileHistoryCode=" + uploadHistory.Code.ToString();
                string ErrorLevelParam           = "";
                //if (errorLevel != null && Convert.ToInt32(errorLevel) >= 0)
                //{
                //    ErrorLevelParam = "&ErrorLevel=" + (Convert.ToInt32(errorLevel) + 1).ToString();
                //}
                string ErrorTypeParam = "";
                //if (errorType != null &&
                //    errorType != "")
                //{
                //    ErrorTypeParam = "&ErrorType=" + errorType;
                //}
                Uri reportUri = new Uri(App.Current.Host.Source, @"../ReportViewer2010.aspx?report=" + "ESF2007MIReports" + @"/" + "File Upload Error Report" + UsernameParam + InputFileHistoryCodeParam + ErrorLevelParam + ErrorTypeParam);

                HtmlPage.Window.Eval("var win = window.open('" + reportUri.AbsoluteUri + "', '_blank', 'toolbar=no,location=no,status=no,menubar=no,scrollbars=yes,resizable=yes');");
            }
        }
Esempio n. 8
0
 public void InsertProviderOrganisation(InputFileHistory inputFileHistoryItem)
 {
     inputFileHistoryRepository.Add(inputFileHistoryItem);
 }
 public static UploadMonitor WithInputFileHistory(this UploadMonitor uploadMonitor, InputFileHistory inputFileHistory)
 {
     uploadMonitor.InputFileHistory = inputFileHistory;
     return(uploadMonitor);
 }
Esempio n. 10
0
 public static InputFileHistory WithValidatedLoadDate(this InputFileHistory inputFileHistory, DateTime validatedLoadDate)
 {
     inputFileHistory.ValidatedLoadDate = validatedLoadDate;
     return(inputFileHistory);
 }
Esempio n. 11
0
 public void DeleteProviderOrganisation(InputFileHistory inputFileHistoryItem)
 {
     inputFileHistoryRepository.Delete(inputFileHistoryItem);
 }
Esempio n. 12
0
 public static InputFileHistory WithLoadedBy(this InputFileHistory inputFileHistory, String loadedBy)
 {
     inputFileHistory.LoadedBy = loadedBy;
     return(inputFileHistory);
 }
Esempio n. 13
0
 public static InputFileHistory WithLoadedDate(this InputFileHistory inputFileHistory, DateTime loadedDate)
 {
     inputFileHistory.LoadedDate = loadedDate;
     return(inputFileHistory);
 }
Esempio n. 14
0
 public static InputFileHistory WithProviderOrganisationKeyValue(this InputFileHistory inputFileHistory, String providerOrganisationKeyValue)
 {
     inputFileHistory.ProviderOrganisationKeyValue = providerOrganisationKeyValue;
     return(inputFileHistory);
 }
Esempio n. 15
0
 public static InputFileHistory WithInputFileErrors(this InputFileHistory inputFileHistory, ICollection <InputFileError> inputFileErrors)
 {
     inputFileHistory.InputFileErrors = inputFileErrors;
     return(inputFileHistory);
 }
Esempio n. 16
0
 public static InputFileHistory WithNumberOfWarningRecords(this InputFileHistory inputFileHistory, Int32 numberOfWarningRecords)
 {
     inputFileHistory.NumberOfWarningRecords = numberOfWarningRecords;
     return(inputFileHistory);
 }
Esempio n. 17
0
 public static InputFileHistory WithUploadDecision(this InputFileHistory inputFileHistory, Int32 uploadDecision)
 {
     inputFileHistory.UploadDecision = uploadDecision;
     return(inputFileHistory);
 }
Esempio n. 18
0
 public static InputFileHistory WithCode(this InputFileHistory inputFileHistory, Guid code)
 {
     inputFileHistory.Code = code;
     return(inputFileHistory);
 }
Esempio n. 19
0
 public static InputFileHistory WithUploadMonitors(this InputFileHistory inputFileHistory, ICollection <UploadMonitor> uploadMonitors)
 {
     inputFileHistory.UploadMonitors = uploadMonitors;
     return(inputFileHistory);
 }
Esempio n. 20
0
 public static InputFileHistory WithProviderOrganisations(this InputFileHistory inputFileHistory, ICollection <ProviderOrganisation> providerOrganisations)
 {
     inputFileHistory.ProviderOrganisations = providerOrganisations;
     return(inputFileHistory);
 }
 public static ProviderOrganisation WithInputFileHistory(this ProviderOrganisation providerOrganisation, InputFileHistory inputFileHistory)
 {
     providerOrganisation.InputFileHistory = inputFileHistory;
     return(providerOrganisation);
 }
Esempio n. 22
0
 public static InputFileHistory WithStatus(this InputFileHistory inputFileHistory, String status)
 {
     inputFileHistory.Status = status;
     return(inputFileHistory);
 }
Esempio n. 23
0
 public static InputFileHistory WithFilename(this InputFileHistory inputFileHistory, String filename)
 {
     inputFileHistory.Filename = filename;
     return(inputFileHistory);
 }
Esempio n. 24
0
 public static InputFileHistory WithNumberOfInformationalRecords(this InputFileHistory inputFileHistory, Int32 numberOfInformationalRecords)
 {
     inputFileHistory.NumberOfInformationalRecords = numberOfInformationalRecords;
     return(inputFileHistory);
 }
Esempio n. 25
0
 public static InputFileHistory WithTransferDate(this InputFileHistory inputFileHistory, DateTime transferDate)
 {
     inputFileHistory.TransferDate = transferDate;
     return(inputFileHistory);
 }
Esempio n. 26
0
 public static InputFileError WithInputFileHistory(this InputFileError inputFileError, InputFileHistory inputFileHistory)
 {
     inputFileError.InputFileHistory = inputFileHistory;
     return(inputFileError);
 }