public static SQLAdmin.TimerContract.Schedule ToEntity(this SQLAdmin.Domain.Schedule schedule)
 {
     SQLAdmin.TimerContract.Schedule outSchedule = new TimerContract.Schedule();
     if (schedule != null)
     {
         outSchedule.Id           = schedule.Id;
         outSchedule.DisplayName  = schedule.DisplayName;
         outSchedule.StartTime    = new System.DateTime(DateTimeHelper.ConvertToUtc(schedule.StartTime));
         outSchedule.NextTime     = new System.DateTime(DateTimeHelper.ConvertToUtc(schedule.StartTime));
         outSchedule.EndTime      = new System.DateTime(DateTimeHelper.ConvertToUtc(schedule.EndTime));
         outSchedule.Interval     = schedule.Interval;
         outSchedule.IntervalType = (SQLAdmin.TimerContract.IntervalType)schedule.IntervalType;
     }
     return(outSchedule);
 }
Exemple #2
0
 public bool AddSchedule(SQLAdmin.Domain.Schedule schedule)
 {
     using (ChannelFactory <IScheduleService> channelFactory = new ChannelFactory <IScheduleService>("SQLAdmin.Timer"))
     {
         try
         {
             IScheduleService proxy = channelFactory.CreateChannel();
             SQLAdmin.TimerContract.Schedule entitySchedule = schedule.ToEntity();
             Monitor monitor = MonitorTypeHelper.GetMonitorByType(schedule.MonitorType);
             entitySchedule.Type     = monitor.Type;
             entitySchedule.Method   = monitor.Method;
             entitySchedule.Assembly = monitor.Assembly;
             monitor.Threshold       = schedule.Threshold;
             monitor.ToEmail         = schedule.ToEmail;
             monitor.DBConnect       = this.mDBConnect;
             entitySchedule.Context  = SerializerHelper.SerializerObjectByJsonConvert(monitor);
             return(proxy.AddSchedule(entitySchedule));
         }
         catch (Exception e)
         {
             throw;
         }
     }
 }