/// <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; }
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); } }
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()); }
/// <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); }
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');"); } }
public void InsertProviderOrganisation(InputFileHistory inputFileHistoryItem) { inputFileHistoryRepository.Add(inputFileHistoryItem); }
public static UploadMonitor WithInputFileHistory(this UploadMonitor uploadMonitor, InputFileHistory inputFileHistory) { uploadMonitor.InputFileHistory = inputFileHistory; return(uploadMonitor); }
public static InputFileHistory WithValidatedLoadDate(this InputFileHistory inputFileHistory, DateTime validatedLoadDate) { inputFileHistory.ValidatedLoadDate = validatedLoadDate; return(inputFileHistory); }
public void DeleteProviderOrganisation(InputFileHistory inputFileHistoryItem) { inputFileHistoryRepository.Delete(inputFileHistoryItem); }
public static InputFileHistory WithLoadedBy(this InputFileHistory inputFileHistory, String loadedBy) { inputFileHistory.LoadedBy = loadedBy; return(inputFileHistory); }
public static InputFileHistory WithLoadedDate(this InputFileHistory inputFileHistory, DateTime loadedDate) { inputFileHistory.LoadedDate = loadedDate; return(inputFileHistory); }
public static InputFileHistory WithProviderOrganisationKeyValue(this InputFileHistory inputFileHistory, String providerOrganisationKeyValue) { inputFileHistory.ProviderOrganisationKeyValue = providerOrganisationKeyValue; return(inputFileHistory); }
public static InputFileHistory WithInputFileErrors(this InputFileHistory inputFileHistory, ICollection <InputFileError> inputFileErrors) { inputFileHistory.InputFileErrors = inputFileErrors; return(inputFileHistory); }
public static InputFileHistory WithNumberOfWarningRecords(this InputFileHistory inputFileHistory, Int32 numberOfWarningRecords) { inputFileHistory.NumberOfWarningRecords = numberOfWarningRecords; return(inputFileHistory); }
public static InputFileHistory WithUploadDecision(this InputFileHistory inputFileHistory, Int32 uploadDecision) { inputFileHistory.UploadDecision = uploadDecision; return(inputFileHistory); }
public static InputFileHistory WithCode(this InputFileHistory inputFileHistory, Guid code) { inputFileHistory.Code = code; return(inputFileHistory); }
public static InputFileHistory WithUploadMonitors(this InputFileHistory inputFileHistory, ICollection <UploadMonitor> uploadMonitors) { inputFileHistory.UploadMonitors = uploadMonitors; return(inputFileHistory); }
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); }
public static InputFileHistory WithStatus(this InputFileHistory inputFileHistory, String status) { inputFileHistory.Status = status; return(inputFileHistory); }
public static InputFileHistory WithFilename(this InputFileHistory inputFileHistory, String filename) { inputFileHistory.Filename = filename; return(inputFileHistory); }
public static InputFileHistory WithNumberOfInformationalRecords(this InputFileHistory inputFileHistory, Int32 numberOfInformationalRecords) { inputFileHistory.NumberOfInformationalRecords = numberOfInformationalRecords; return(inputFileHistory); }
public static InputFileHistory WithTransferDate(this InputFileHistory inputFileHistory, DateTime transferDate) { inputFileHistory.TransferDate = transferDate; return(inputFileHistory); }
public static InputFileError WithInputFileHistory(this InputFileError inputFileError, InputFileHistory inputFileHistory) { inputFileError.InputFileHistory = inputFileHistory; return(inputFileError); }