예제 #1
0
파일: Abort.cs 프로젝트: juanlurie/Tools
 public Command Execute()
 {
     if (simpleJobBuilder.IsStarted)
     {
         simpleJobBuilder.Stop();
         command.Message = "Shutdown Aborted";
         var notification = new Notification();
         notification.SendNotification(command.Message);
     }
     command.Message = "Shutdown Not Scheduled";
     Notify();
     return command;
 }
        public int AddNotificationInDatabase(User senderUser, User receiverUser, NotificationType notificationType)
        {
            var notification = new Notification()
            {
                FromId = senderUser.Id,
                ToId = receiverUser.Id,
                NotificationType = notificationType
            };

            this.Data.Notifications.Add(notification);
            this.Data.SaveChanges();

            return notification.Id;
        }
예제 #3
0
파일: Shutdown.cs 프로젝트: juanlurie/Tools
        public Command Execute()
        {
            if (simpleJobBuilder.TriggerKey != null && (simpleJobBuilder.Schedule.GetTrigger(simpleJobBuilder.TriggerKey) != null || simpleJobBuilder.IsStarted))
            {
                var nextFireTimeUtc = simpleJobBuilder.Schedule.GetTrigger(simpleJobBuilder.TriggerKey).GetNextFireTimeUtc();
                if (nextFireTimeUtc != null)
                {
                    var date = nextFireTimeUtc.Value;
                    if (date.Day > DateTime.Now.Day)
                    {
                        command.Message = "Shutdown Already Scheduled For " + date.ToString("yyyy-MM-dd HH:mm:ss");
                    }
                    command.Message = "Shutdown Already Scheduled For " + date.ToString("HH:mm:ss");
                }
            }
            else
            {
                var firstParameter = command.Parameter;

                DateTime time = DateTime.Parse(firstParameter);

                simpleJobBuilder.AddJob<ProcessJob>("1", time);
                simpleJobBuilder.Start();

                var nextFireTimeUtc = simpleJobBuilder.Schedule.GetTrigger(simpleJobBuilder.TriggerKey).GetNextFireTimeUtc();

                if (nextFireTimeUtc != null)
                {
                    var nextFire = nextFireTimeUtc.Value;
                    command.Message = nextFire.Day > DateTime.Now.Day
                                          ? "Shutdown Scheduled For " + nextFire.ToString("yyyy-MM-dd HH:mm:ss")
                                          : "Shutdown Scheduled For " + nextFire.ToString("HH:mm:ss");
                }

                var notification = new Notification();
                notification.SendNotification(command.Message);
            }

            Response = command.Message;
            Notify();
            return command;
        }