Exemplo n.º 1
0
        public static int GetBatchId(string Batch)
        {
            using (var db = new RIT_QAEntities())
            {
                Batch ExistBatch = null;
                var   b          = Batch;
                try
                {
                    ExistBatch = db.Batches.FirstOrDefault(x => x.BatchNumber == b);
                }
                catch (Exception ex)
                {
                    Logger.Error("This should happend only when the Batch table is empty", ex);
                }

                int BatchId = 0;
                // and create if it is new
                if (ExistBatch == null)
                {
                    Batch _currentBatch = db.Batches.Create();
                    _currentBatch.BatchNumber = Batch;
                    _currentBatch.Date        = DateTime.Now;
                    db.Batches.Add(_currentBatch);
                    db.SaveChanges();
                    BatchId = _currentBatch.Id;
                    Logger.Debug("New batch created. Batch Number = " + _currentBatch.BatchNumber);
                }
                else
                {
                    BatchId = ExistBatch.Id;
                }

                return(BatchId);
            }
        }
 public void Save()
 {
     using (var db = new RIT_QAEntities())
     {
         try
         {
             db.Calibrations.Add(DpsDetails);
             foreach (CalibrationData record in DataRecords)
             {
                 db.CalibrationDatas.Add(record);
             }
             db.SaveChanges();
             Logger.Debug("Calibrations saved");
         }
         catch (Exception ex)
         {
             Logger.Info("Save DPS calibration result failed.");
             Logger.Error("", ex);
         }
     }
 }
Exemplo n.º 3
0
        public void Save()
        {
            using (var db = new RIT_QAEntities())
            {
                try
                {
                    if (this.EndDate == null)
                    {
                        this.EndDate = DateTime.Now;
                    }

                    db.ElectricalTests.Add(GetBase());
                    db.SaveChanges();
                    Logger.Debug("Test saved");
                }
                catch (Exception ex)
                {
                    Logger.Info("Save DPS test result failed. Please that SErialNo, MAC and Result are field", ex);
                    Logger.Error("", ex);
                }
            }
        }