public ExtractHistory GetLatest(Guid extractId, ExtractStatus status, ExtractStatus otherStatus) { return(DbSet .Where(x => x.ExtractId == extractId && (x.Status == status || x.Status == otherStatus)) .OrderByDescending(x => x.StatusDate) .FirstOrDefault()); }
public override ExtractStatus Import(String filePath, out T t) { TextFileReader reader = new TextFileReader(filePath); reader.FieldDelimiterChar = this.FieldDelimiterChar; t = null; ExtractStatus r = ExtractStatus.Success; try { if (null != base.OnImportStartHandler) { base.OnImportStartHandler(filePath, t); } r = this.RecordMapping.Import(reader); t = this.RecordMapping.Target; reader.Close(); if (null != base.OnImportFinishHandler) { base.OnImportFinishHandler(filePath, t); } } catch (Exception exc) { reader.Close();//by kittikun 2014-10-11 if (!(exc is EndOfStreamException)) { throw exc; } } return(r); }
public override ExtractStatus Extract(TextFileReader reader) { if (null == this.SignatureMapper) { throw new Exception(this.FieldInfo + " - Signature field mapper is empty."); } ExtractStatus r = this.SignatureMapper.Extract(reader); if (r != ExtractStatus.Success) { return(r); } this.Value = this.SignatureMapper.Target; if (this.Value == null) { if (this.IsMandatory) { throw new Exception(this.FieldInfo + " - Mandatory field is empty."); } r = ExtractStatus.Success; } else { if (null != this.PropertySetter) { this.PropertySetter(this, this.Target, this.Value); } r = base.ExtractValues(this.Value, reader); } return(r); }
public override ExtractStatus Extract(TextFileReader reader) { string valueString = null; try { valueString = reader.GetCSVFieldValue(this.ColumnNo); this.Value = this.FieldType.ConvertFromString(valueString); } catch (Exception exc) { throw new Exception(this.FieldInfo + ": \"" + valueString + "\": " + exc.ToString()); } ExtractStatus r = ExtractStatus.Success; if (null == this.InstanceCreator) { if (this.Value.Equals(SignatureValue)) { this.Target = new T(); r = ExtractStatus.Success; } else { r = ExtractStatus.ValueMismatched; } } else { this.Target = this.InstanceCreator(this, this.Value); } return(r); }
public CbsStatusNotification(Guid extractId, ExtractStatus status, int?stats = null, string statusInfo = "") { ExtractId = extractId; Status = status; Stats = stats; StatusInfo = statusInfo; }
public void DwhUpdateStatus(Guid extractId, ExtractStatus status, int?stats, string statusInfo = "") { var history = new ExtractHistory(status, stats, statusInfo, extractId); Create(history); SaveChanges(); }
public ExtractHistory(ExtractStatus status, int?stats, string statusInfo, Guid extractId) { Status = status; StatusDate = DateTime.Now; Stats = stats; StatusInfo = statusInfo; ExtractId = extractId; }
public void DwhUpdateStatus(Guid extractId, ExtractStatus status, int?stats, string statusInfo = "") { var history = new ExtractHistory(status, stats, statusInfo, extractId); CreateBatch(new List <ExtractHistory> { history }); }
public CTStatusNotification(Guid patientExtractId, Guid extractId, ExtractStatus status, int?stats = null, string statusInfo = "") { PatientExtractId = patientExtractId; ExtractId = extractId; Status = status; Stats = stats; StatusInfo = statusInfo; }
private static int GetStats(List <ExtractHistory> extractHistories, ExtractStatus extractStatus, ExtractStatus extractStatusOther) { var history = extractHistories .Where(x => x.Status == extractStatus || x.Status == extractStatusOther) .OrderByDescending(x => x.StatusDate) .FirstOrDefault(); return(null != history && history.Stats.HasValue ? history.Stats.Value : 0); }
public virtual ExtractStatus Import(ExcelFileReader recordSource) { recordSource.Next(); try { ExtractStatus r = this.Extract(recordSource); if (r == ExtractStatus.ValueMismatched) { recordSource.Previous(); } return(r); } catch (Exception exc) { throw new Exception(string.Format("Line {0} : ", recordSource.LineNo), exc); } }
//public virtual ExtractStatus Extract(ExcelFileReader recordSource) //{ // if (this.SignatureFieldMapper == null) // { // if (this.Value == null) // this.Value = new V(); // } // else // { // this.SignatureFieldMapper.Target = this.Value; // ExtractStatus r = this.SignatureFieldMapper.Extract(recordSource); // if (r != ExtractStatus.Success) // return r; // if (this.Value == null) // this.Value = this.SignatureFieldMapper.Target; // } // return ExtractValues(this.Value, recordSource); //} public virtual ExtractStatus ExtractValues(V v, ExcelFileReader recordSource) { ExtractStatus r = ExtractStatus.Success; if (null != this.FieldMappers) { foreach (var f in this.FieldMappers) { f.Target = v; r = f.Extract(recordSource); if (r != ExtractStatus.Success) { break; } } } return(r); }
public virtual ExtractStatus ExtractValues(V v, TextFileReader reader) { ExtractStatus r = ExtractStatus.Success; if (null != this.FieldMappers) { foreach (FixedLengthFieldMapper <V> f in this.FieldMappers) { f.Target = v; r = f.Extract(reader); if (r != ExtractStatus.Success) { break; } } } return(r); }
public void UpdateStatus(Guid extractId, ExtractStatus status, int?stats, string statusInfo = "", bool express = false) { if (express) { var history = new ExtractHistory(status, stats, statusInfo, extractId); Create(history); SaveChanges(); return; } var started = DbSet.Any(x => x.ExtractId == extractId && x.Status == status); if (!started) { var history = new ExtractHistory(status, stats, statusInfo, extractId); Create(history); SaveChanges(); } }
/// <summary> /// Import records to create an instance of T that would be put in the property Value. /// </summary> /// <param name="reader"></param> /// <returns></returns> public override ExtractStatus Import(TextFileReader reader) { this.HeaderMapper.Value = null; reader.Next(); ExtractStatus r = this.HeaderMapper.Extract(reader); if (r != ExtractStatus.Success) { return(r); } this.Target = this.DetailMapper.Target = this.FooterMapper.Value = this.HeaderMapper.Value; r = this.DetailMapper.Import(reader); if (r == ExtractStatus.Success) { reader.Next(); r = this.FooterMapper.Extract(reader); } return(r); }
public override ExtractStatus Import(String filePath, out T t) { ExcelFileReader reader = null; t = null; ExtractStatus r = ExtractStatus.Success; try { reader = new ExcelFileReader(filePath); if (null != this.OnImportStartHandler) { this.OnImportStartHandler(filePath, t); } r = this.RecordMapping.Import(reader); if (r == ExtractStatus.Success) { t = this.RecordMapping.Target; reader.Close(); if (null != this.OnImportFinishHandler) { this.OnImportFinishHandler(filePath, t); } } } catch (Exception exc) { reader.Close(); if (!(exc is EndOfStreamException)) { throw exc; } } return(r); }
public override ExtractStatus Extract(ExcelFileReader recordSource) { dynamic v = null; try { v = recordSource.Extract(this.ColumnNo); this.Value = (V)v; } catch (Exception exc) { throw new Exception(this.FieldInfo + " value=" + (v == null ? "[null]" : "\"" + v.ToString() + "\""), exc); } ExtractStatus r = ExtractStatus.Success; if (null == this.InstanceCreator) { if (this.Value.Equals(SignatureValue)) { if (this.Target == null) { this.Target = new T(); } } else { return(ExtractStatus.ValueMismatched); } } else { this.Target = this.InstanceCreator(this, this.Value); } return(r); }
public override IList <T> Import(String filePath) { TextFileReader reader = new TextFileReader(filePath); IList <T> instances = new List <T>(); T t = null; ExtractStatus r = ExtractStatus.Success; //while (true) //{ try { r = this.RecordMapping.Import(reader); } catch (Exception exc) { if (!(exc is EndOfStreamException)) { throw exc; } } //} instances.Add(t); return(instances); }
public void UpdateUiNumbers(ExtractStatus status) { //update progress bar DomainEvents.Dispatch(new DwhSendNotification(new SendProgress(nameof(PatientExtract), Common.GetProgress(_count, _total)))); //update Patients if (_patientExtractStatus.Found != null) { if (_patientExtractStatus.Loaded != null) { if (_patientExtractStatus.Rejected != null) { DomainEvents.Dispatch(new ExtractActivityNotification(_patientExtract.Id, new DwhProgress(nameof(PatientExtract), status.ToString(), (int)_patientExtractStatus.Found, (int)_patientExtractStatus.Loaded, (int)_patientExtractStatus.Rejected, (int)_patientExtractStatus.Loaded, _count))); } } } //update Patient ARTs if (_patientArtExtractStatus.Found != null) { if (_patientArtExtractStatus.Loaded != null) { if (_patientArtExtractStatus.Rejected != null) { DomainEvents.Dispatch(new ExtractActivityNotification(_patientArtExtract.Id, new DwhProgress(nameof(PatientExtract), status.ToString(), (int)_patientArtExtractStatus.Found, (int)_patientArtExtractStatus.Loaded, (int)_patientArtExtractStatus.Rejected, (int)_patientArtExtractStatus.Loaded, _artCount))); } } } //update Patient Baselines if (_patientBaselineExtractStatus.Found != null) { if (_patientBaselineExtractStatus.Loaded != null) { if (_patientBaselineExtractStatus.Rejected != null) { DomainEvents.Dispatch(new ExtractActivityNotification(_patientBaselineExtract.Id, new DwhProgress(nameof(PatientExtract), status.ToString(), (int)_patientBaselineExtractStatus.Found, (int)_patientBaselineExtractStatus.Loaded, (int)_patientBaselineExtractStatus.Rejected, (int)_patientBaselineExtractStatus.Loaded, _baselineCount))); } } } //update Patient Labs if (_patientLabExtractStatus.Found != null) { if (_patientLabExtractStatus.Loaded != null) { if (_patientLabExtractStatus.Rejected != null) { DomainEvents.Dispatch(new ExtractActivityNotification(_patientLabExtract.Id, new DwhProgress(nameof(PatientExtract), status.ToString(), (int)_patientLabExtractStatus.Found, (int)_patientLabExtractStatus.Loaded, (int)_patientLabExtractStatus.Rejected, (int)_patientLabExtractStatus.Loaded, _labCount))); } } } //update Patient Pharmacies if (_patientPharmacyExtractStatus.Found != null) { if (_patientPharmacyExtractStatus.Loaded != null) { if (_patientPharmacyExtractStatus.Rejected != null) { DomainEvents.Dispatch(new ExtractActivityNotification(_patientPharmacyExtract.Id, new DwhProgress(nameof(PatientExtract), status.ToString(), (int)_patientPharmacyExtractStatus.Found, (int)_patientPharmacyExtractStatus.Loaded, (int)_patientPharmacyExtractStatus.Rejected, (int)_patientPharmacyExtractStatus.Loaded, _pharmacyCount))); } } } //update Patient Statuses if (_patientStatusExtractStatus.Found != null) { if (_patientStatusExtractStatus.Loaded != null) { if (_patientStatusExtractStatus.Rejected != null) { DomainEvents.Dispatch(new ExtractActivityNotification(_patientStatusExtract.Id, new DwhProgress(nameof(PatientExtract), status.ToString(), (int)_patientStatusExtractStatus.Found, (int)_patientStatusExtractStatus.Loaded, (int)_patientStatusExtractStatus.Rejected, (int)_patientStatusExtractStatus.Loaded, _statusCount))); } } } //update Patient Visits if (_patientVisitExtractStatus.Found != null) { if (_patientVisitExtractStatus.Loaded != null) { if (_patientVisitExtractStatus.Rejected != null) { DomainEvents.Dispatch(new ExtractActivityNotification(_patientVisitExtract.Id, new DwhProgress(nameof(PatientExtract), status.ToString(), (int)_patientVisitExtractStatus.Found, (int)_patientVisitExtractStatus.Loaded, (int)_patientVisitExtractStatus.Rejected, (int)_patientVisitExtractStatus.Loaded, _visitCount))); } } } //update Patient Adverse Events if (_patientAdverseEventExtractStatus.Found != null) { if (_patientAdverseEventExtractStatus.Loaded != null) { if (_patientAdverseEventExtractStatus.Rejected != null) { DomainEvents.Dispatch(new ExtractActivityNotification(_patientAdverseEventExtract.Id, new DwhProgress(nameof(PatientExtract), status.ToString(), (int)_patientAdverseEventExtractStatus.Found, (int)_patientAdverseEventExtractStatus.Loaded, (int)_patientAdverseEventExtractStatus.Rejected, (int)_patientAdverseEventExtractStatus.Loaded, _adverseEventCount))); } } } }
public ExtractHistory(ExtractStatus status, Guid extractId) { Status = status; StatusDate = DateTime.Now; ExtractId = extractId; }
public ExtractHistory HasStarted(Guid extractId, ExtractStatus status, ExtractStatus otherStatus) { var history = _extractHistoryRepository.GetLatest(extractId, status, otherStatus); return(history); }