Ejemplo n.º 1
0
        public static void ProcessLabelCheck(LabelChecksDbContext labelChecksDbContext, string connStr, LabelCheck labelCheck, DateTime fromTime, DateTime toTime)
        {
            PspMeasurement meas = labelChecksDbContext.PspDbMeasurements.Where(m => m.MeasId == labelCheck.PspMeasurementId).FirstOrDefault();

            labelCheck.PspMeasurement = meas;
            List <LabelCheckResult> labelCheckResults = GetLabelCheckResults(connStr, labelCheck, fromTime, toTime);

            //iterate through each result, find if record already exists and update the database
            for (int resIter = 0; resIter < labelCheckResults.Count; resIter++)
            {
                LabelCheckResult targetRes = labelCheckResults[resIter];
                LabelCheckResult foundRes  = labelChecksDbContext.LabelCheckResults.Where(res => res.LabelCheckId == targetRes.LabelCheckId &&
                                                                                          res.CheckProcessEndTime.Date == targetRes.CheckProcessEndTime.Date &&
                                                                                          res.CheckProcessStartTime.Date == targetRes.CheckProcessStartTime.Date).FirstOrDefault();
                if (foundRes == null)
                {
                    // the record doesnot exist, so insert into the db
                    labelChecksDbContext.LabelCheckResults.Add(targetRes);
                }
                else
                {
                    //targetRes.Id = foundRes.Id;
                    // make found result as target result and update
                    foundRes.IsSuccessful          = targetRes.IsSuccessful;
                    foundRes.Remarks               = targetRes.Remarks;
                    foundRes.CheckProcessEndTime   = targetRes.CheckProcessEndTime;
                    foundRes.CheckProcessStartTime = targetRes.CheckProcessStartTime;
                    labelChecksDbContext.LabelCheckResults.Update(foundRes);
                }
            }
            labelChecksDbContext.SaveChanges();
        }
Ejemplo n.º 2
0
 public static void ProcessAllLabelChecks(LabelChecksDbContext labelChecksDbContext, string connStr, DateTime fromTime, DateTime toTime)
 {
     foreach (LabelCheck labelCheck in labelChecksDbContext.LabelChecks.ToList())
     {
         ProcessLabelCheck(labelChecksDbContext, connStr, labelCheck, fromTime, toTime);
     }
 }
Ejemplo n.º 3
0
        public static void ProcessLabelCheck(string labelsConnStr, string connStr, LabelCheck labelCheck, DateTime fromTime, DateTime toTime)
        {
            DbContextOptionsBuilder <LabelChecksDbContext> builder = new DbContextOptionsBuilder <LabelChecksDbContext>().UseSqlServer(labelsConnStr);
            LabelChecksDbContext labelChecksDbContext = new LabelChecksDbContext(builder.Options);

            ProcessLabelCheck(labelChecksDbContext, connStr, labelCheck, fromTime, toTime);
        }
Ejemplo n.º 4
0
        public static void ProcessAllLabelChecks(string labelsConnStr, string connStr, DateTime fromTime, DateTime toTime)
        {
            Console.WriteLine("Processing all label checks via hangfire");

            DbContextOptionsBuilder <LabelChecksDbContext> builder = new DbContextOptionsBuilder <LabelChecksDbContext>().UseSqlServer(labelsConnStr);
            LabelChecksDbContext labelChecksDbContext = new LabelChecksDbContext(builder.Options);

            foreach (LabelCheck labelCheck in labelChecksDbContext.LabelChecks.ToList())
            {
                ProcessLabelCheck(labelsConnStr, connStr, labelCheck, fromTime, toTime);
            }
        }