Пример #1
0
        void loadEmployees()
        {
            using(OluContext db = new OluContext())
            {

                Employees = db.EhriEmployee.ToList();
                int i = Employees.Count();
                Logger.Log.Record(i + " employees loaded");
            }
        }
Пример #2
0
        void saveTransmissionInfo(int recordCount)
        {
            using(OluContext oluContext = new OluContext())
            {
                transmissionFile.RecordCount = recordCount;
                transmissionFile.SentToOpmdate = DateTime.Now;
                oluContext.EhriTransmissionfile.Add(transmissionFile);
                oluContext.SaveChanges();
            }

        }
Пример #3
0
 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");
 }
Пример #4
0
        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();
            }
        }
Пример #5
0
        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();
            }
        }
Пример #6
0
        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;
                }
            }
        }
Пример #7
0
 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");
 }
Пример #8
0
        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;
        }