示例#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
        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;
        }