void loadEmployees() { using(OluContext db = new OluContext()) { Employees = db.EhriEmployee.ToList(); int i = Employees.Count(); Logger.Log.Record(i + " employees loaded"); } }
void saveTransmissionInfo(int recordCount) { using(OluContext oluContext = new OluContext()) { transmissionFile.RecordCount = recordCount; transmissionFile.SentToOpmdate = DateTime.Now; oluContext.EhriTransmissionfile.Add(transmissionFile); oluContext.SaveChanges(); } }
public void Save(List<EhriTraining> records) { Logger.Log.Record("Saving " + records.Count + " records"); using(OluContext context = new OluContext()) { foreach(EhriTraining record in records) { context.EhriTraining.Add(record); } context.SaveChangesAsync(); } Logger.Log.Record("Saving completed"); }
public void UpdateCount(int processedCount) { using (OluContext db = new OluContext()) { var trainingRecord = (from t in db.EhriTrainingfileinfo where t.TrainingFileInfoId == FileID select t).First(); trainingRecord.SavedRecordCount = processedCount; db.SaveChanges(); } }
private void addFile(string fileName) { FileID = Guid.NewGuid().ToString(); EhriTrainingfileinfo tf = new EhriTrainingfileinfo(); tf.TrainingFileInfoId = FileID; tf.FileName = fileName; tf.Loaded = DateTime.Now; tf.FileRecordCount = getFileRecordCount(fileName); using (OluContext db = new OluContext()) { db.EhriTrainingfileinfo.Add(tf); db.SaveChanges(); } }
void checkIfFileExists(string fileName) { using (OluContext db = new OluContext()) { var trainingRecord = db.EhriTrainingfileinfo.FirstOrDefault(t => t.FileName == fileName); if (trainingRecord == null) { fileExists = false; } else { FileID = trainingRecord.TrainingFileInfoId; fileExists = true; } } }
public void Write() { Logger.Log.Record("Preparing records for EHRI Transmission"); int recordsToSendCount = 0; using(OluContext oluContext = new OluContext()) { List<EhriTraining> records = (from t in oluContext.EhriTraining where t.ProcessStatus == "R" select t).ToList(); recordsToSendCount = records.Count; xmlWriter.WriteEhriFile(records,fileName); foreach(EhriTraining record in records) { record.TransmissionFileId = transmissionFile.TransmissionFileId; record.LastUpdatedDate = DateTime.Now; record.ProcessStatus = "S"; oluContext.EhriTraining.Update(record); } oluContext.SaveChanges(); } saveTransmissionInfo(recordsToSendCount); Logger.Log.Record("EHRI Transmission records updated"); }
public List<EhriTraining> RemoveDuplicateRecords(List<EhriTraining> records) { List<EhriTraining> returnRecords = new List<EhriTraining>(); int loopCount = 0; int errorCount = 0; using(OluContext db = new OluContext()) { foreach(EhriTraining record in records) { var count = (from t in db.EhriTraining where t.Ssn == record.Ssn && t.CourseId == record.CourseId && t.CourseCompletionDate == record.CourseCompletionDate select t).Count(); if(count > 0) { errorCount++; } else { returnRecords.Add(record); } loopCount++; if(loopCount % 100 == 0) { Console.WriteLine("Verified " + loopCount + " records"); } } } Logger.Log.Record("Completed removing duplicate records " + errorCount + " duplicates found"); return returnRecords; }