예제 #1
0
 private void Save()
 {
     try
     {
         MOE.Common.Models.SPM db = new MOE.Common.Models.SPM();
         {
             MOE.Common.Models.Speed_Events se = new MOE.Common.Models.Speed_Events();
             se.DetectorID = this.sensorId;
             se.timestamp  = this.date;
             se.MPH        = this.mph;
             se.KPH        = this.kph;
             Regex r = new Regex("^[a-zA-Z0-9]*$");
             if (r.IsMatch(se.DetectorID))
             {
                 db.Speed_Events.Add(se);
                 db.SaveChanges();
             }
         }
     }
     catch (DbUpdateException ex)
     {
         SqlException innerException = ex.InnerException.InnerException as SqlException;
         if (innerException != null && (innerException.Number == 2627 || innerException.Number == 2601))
         {
         }
         else
         {
             MOE.Common.Models.Repositories.IApplicationEventRepository eventRepository =
                 MOE.Common.Models.Repositories.ApplicationEventRepositoryFactory.Create();
             eventRepository.QuickAdd("SpeedListener", this.GetType().ToString(), "Save",
                                      MOE.Common.Models.ApplicationEvent.SeverityLevels.High, ex.HResult.ToString() + ex.Message + ex.InnerException);
         }
     }
     catch (Exception ex)
     {
         MOE.Common.Models.Repositories.IApplicationEventRepository eventRepository =
             MOE.Common.Models.Repositories.ApplicationEventRepositoryFactory.Create();
         eventRepository.QuickAdd("SpeedListener", this.GetType().ToString(), "Save",
                                  MOE.Common.Models.ApplicationEvent.SeverityLevels.High, ex.HResult.ToString() + ex.Message + ex.InnerException);
     }
 }
예제 #2
0
파일: Packet.cs 프로젝트: gmonk/ATSPM
 private void Save()
 {
     try
     {
         MOE.Common.Models.SPM db = new MOE.Common.Models.SPM();
         {
             MOE.Common.Models.Speed_Events se = new MOE.Common.Models.Speed_Events();
             se.DetectorID = this.sensorId;
             se.timestamp  = this.date;
             se.MPH        = this.mph;
             se.KPH        = this.kph;
             Regex r = new Regex("^[a-zA-Z0-9]*$");
             if (r.IsMatch(se.DetectorID))
             {
                 db.Speed_Events.Add(se);
                 db.SaveChanges();
             }
         }
     }
     catch (DbUpdateException ex)
     {
         //NOTE: I think trying to write to the applicaiton log when the DB is unavailbe is making the serivce crash more than it needs too.
         SqlException innerException = ex.InnerException.InnerException as SqlException;
         if (innerException != null && (innerException.Number == 2627 || innerException.Number == 2601))
         {
         }
         else
         {
             //applicationEventRepository.QuickAdd("SpeedListener", this.GetType().ToString(), "Save",
             //    MOE.Common.Models.ApplicationEvent.SeverityLevels.High, ex.HResult.ToString() + ex.Message + ex.InnerException);
         }
     }
     catch (Exception ex)
     {
         //applicationEventRepository.QuickAdd("SpeedListener", this.GetType().ToString(), "Save",
         //    MOE.Common.Models.ApplicationEvent.SeverityLevels.High, ex.HResult.ToString() + ex.Message + ex.InnerException);
     }
 }