예제 #1
0
 public static void OnStatusUpdate(IUpdateStatus sender, string status, StatusChangeEvent handler)
 {
     if (handler != null)
     {
         handler(status);
     }
 }
예제 #2
0
        private void RemoveTask(bool kill)
        {
            int index = lstTasks.SelectedIndex;

            lstTasks.SelectedIndexChanged -= new EventHandler(lstTasks_SelectedIndexChanged);
            lstTasks.Items.RemoveAt(index);

            AppConfigHelper.DeleteTask(index, kill);
            ClearFields();

            lstTasks.SelectedIndexChanged += new EventHandler(lstTasks_SelectedIndexChanged);
            if (lstTasks.Items.Count > 0)
            {
                if (index == lstTasks.Items.Count)
                {
                    RefreshTaskList(index - 1);
                }
                else
                {
                    RefreshTaskList(index);
                }
                btnDeleteTask.Enabled = true;
            }
            else
            {
                btnDeleteTask.Enabled = false;
            }
            StatusChangeEvent?.Invoke(this, null); // Notify parent we have a potential status change.
        }
        private void SystemEvents_SessionSwitch(object sender, [NotNull] SessionSwitchEventArgs e)
        {
            StatusChangeEventType eventType;

            switch (e.Reason)
            {
            case SessionSwitchReason.SessionLogoff:
                eventType = StatusChangeEventType.Logoff;
                break;

            case SessionSwitchReason.SessionLock:
                eventType = StatusChangeEventType.Lock;
                break;

            case SessionSwitchReason.SessionLogon:
                eventType = StatusChangeEventType.Logon;
                break;

            case SessionSwitchReason.SessionUnlock:
                eventType = StatusChangeEventType.Unlock;
                break;

            default:
                return;
            }

            var entity = new StatusChangeEvent
            {
                StatusChangeEventType = eventType
            };

            _statusChangeEventRepository.Insert(entity);
        }
예제 #4
0
        protected virtual void OnStatusChanged(string status)
        {
            StatusChangeEvent handler = StatusChanged;

            if (handler != null)
            {
                handler(status);
            }
        }
예제 #5
0
 private void MediaOpened(object sender, EventArgs e)             // Event that triggers once a song is loaded
 {
     StatusChangeEvent?.Invoke(this, new PlayerStatusChangedEvent // Trigger the status changed event
     {
         IsPlaying      = IsPlaying,
         CurrentSong    = this.CurrentSong,
         SongHasChanged = true
     });
 }
예제 #6
0
 private void UpdatePlayStatus(bool playing)  // Internal function that updates varaibles and triggers the status changed event
 {
     IsPlaying = playing;
     StatusChangeEvent?.Invoke(this, new PlayerStatusChangedEvent
     {
         IsPlaying      = IsPlaying,
         CurrentSong    = CurrentSong,
         SongHasChanged = false
     });
 }
예제 #7
0
        private void RefreshTaskList(int index)
        {
            lstTasks.Items.Clear();
            btnDeleteTask.Enabled = false;

            if (AppConfigHelper.TaskList.Count == 0)
            {
                return;
            }

            Cursor.Current = Cursors.WaitCursor;
            foreach (BioSeqTask task in AppConfigHelper.TaskList.Values)
            {
                if (string.IsNullOrEmpty(TaskFilter) || TaskFilter == "All" || TaskFilter == task.TaskStatus)
                {
                    if (IsServiceClass.IsService)
                    {
                        // If the task has completed, this brings back the task details and deletes the task file on the server.
                        string taskCompleted = BioSeqDBModel.Instance.TaskComplete(AppConfigHelper.LoggedOnUser, task.TaskID);
                        if (!string.IsNullOrEmpty(taskCompleted))
                        {
                            BioSeqTask taskFromService = JsonSerializer.Deserialize <BioSeqTask>(taskCompleted);
                            task.LastError      = taskFromService.LastError;
                            task.LastExitCode   = taskFromService.LastExitCode;
                            task.StandardOutput = taskFromService.StandardOutput;
                            task.TaskComplete   = taskFromService.TaskComplete;
                            task.TaskCommand    = taskFromService.TaskCommand;
                            AppConfigHelper.BackgroundTaskComplete(task); // Mark task Ready and save config.
                        }
                    }
                    task.TaskIndexInList = lstTasks.Items.Add(task.TaskType + ": " + task.TaskStatus + " " + task.TaskDB + " " + task.TaskUser);
                }
            }
            if (index < 0)
            {
                index = 0;
            }
            if (index >= lstTasks.Items.Count)
            {
                index = lstTasks.Items.Count - 1;
            }
            lstTasks.SelectedIndex = index;
            btnDeleteTask.Enabled  = lstTasks.Items.Count > 0;

            StatusChangeEvent?.Invoke(this, null); // Notify parent we have a potential status change.
            Cursor.Current = Cursors.Default;
        }
        public ActivityReport GenerateReport(DateTime date)
        {
            var start                 = date.Date;
            var end                   = date.Date.AddDays(1);
            var todaysActivity        = _statusChangeEventRepository.GetCreatedBetween(start, end).OrderBy(x => x.CreatedDate).Cast <StatusChangeEvent>().ToArray();
            var lastStartWorkingEvent = new StatusChangeEvent
            {
                CreatedDate = start.AddHours(8)
            }; // assume that if first event of the Day is Lock/Logoff then the day was started at 8AM

            StatusChangeEvent lastStartLeisureEvent = null;
            var addLast     = true;
            var reportItems = new List <ActivityReportItem>();

            foreach (var activityItem in todaysActivity)
            {
                if (activityItem.StatusChangeEventType == StatusChangeEventType.Logon || activityItem.StatusChangeEventType == StatusChangeEventType.Unlock)
                {
                    addLast = true;
                    lastStartWorkingEvent = activityItem;
                    if (lastStartLeisureEvent == null)
                    {
                        continue;
                    }

                    var reportItem = new ActivityReportItem(PeriodType.Leisure, lastStartLeisureEvent, activityItem);
                    reportItems.Add(reportItem);
                }
                else
                {
                    addLast = false;
                    var reportItem = new ActivityReportItem(PeriodType.Working, lastStartWorkingEvent, activityItem);
                    reportItems.Add(reportItem);
                    lastStartLeisureEvent = activityItem;
                }
            }

            if (addLast)
            {
                reportItems.Add(new ActivityReportItem(PeriodType.Working, lastStartWorkingEvent, null));
            }

            return(new ActivityReport(reportItems, date));
        }
예제 #9
0
        private void UpdateStatus(GameSrvStatus newStatus)
        {
            // Record the new status
            _Status = newStatus;

            StatusChangeEvent?.Invoke(this, new StatusEventArgs(newStatus));

            switch (newStatus)
            {
            case GameSrvStatus.Paused:
                RMLog.Info("Server(s) are paused");
                break;

            case GameSrvStatus.Pausing:
                RMLog.Info("Server(s) are pausing...");
                break;

            case GameSrvStatus.Resuming:
                RMLog.Info("Server(s) are resuming...");
                break;

            case GameSrvStatus.Started:
                RMLog.Info("Server(s) have started");
                break;

            case GameSrvStatus.Starting:
                RMLog.Info("Server(s) are starting...");
                break;

            case GameSrvStatus.Stopped:
                RMLog.Info("Server(s) have stopped");
                break;

            case GameSrvStatus.Stopping:
                RMLog.Info("Server(s) are stopping...");
                break;
            }
        }
예제 #10
0
 public void UnbindStatusChangeEvent()
 {
     this.statusChange = null;
 }
예제 #11
0
 public void BindStatusChangeEvent(StatusChangeEvent statusChange)
 {
     this.statusChange = statusChange;
 }
예제 #12
0
 private void Client_OpcStatusChange(object sender, OpcUaStatusEventArgs e)
 {
     StatusChangeEvent?.Invoke(IsConnected);
 }
예제 #13
0
 public void UnbindStatusChangeEvent(StatusChangeEvent statusChange)
 {
     this.statusChanges.Remove(statusChange);
 }
예제 #14
0
        private void TaskCompletion(BioSeqTask task, string taskName, string successMsg)
        {
            // Called by the user from the Push button when task status is Ready.
            Cursor.Current = Cursors.WaitCursor;

            TimeSpan duration = task.TaskComplete - task.TaskTime;

            string db      = string.IsNullOrEmpty(task.TaskDB) ? string.Empty : "Sequence database: " + task.TaskDB;
            string memo    = string.IsNullOrEmpty(task.TaskMemo) ? string.Empty : "Memo: " + task.TaskMemo;
            string subject = "Task completed: " + taskName + " at " + task.TaskComplete.ToString("MMM d, yyyy HH:mm") + " after " +
                             duration.TotalMinutes.ToString("#.0") + " minutes." + Environment.NewLine + (db + " " + Environment.NewLine + memo).Trim();
            string message = subject + Environment.NewLine + AppConfigHelper.LastCommand + Environment.NewLine;

            subject = subject.Replace(Environment.NewLine, "  ");
            List <string> attachments = new List <string>();
            string        output      = task.StandardOutput + Environment.NewLine + task.LastError;

            message += "Standard output: " + output + Environment.NewLine;

            // Read and delete the output file from the command.
            string linuxCapture = string.Empty;
            string filename     = AppConfigHelper.NormalizePathToWindows(AppConfigHelper.LinuxHomeDirectory + "/output" + task.TaskID);

            if (DirectoryHelper.FileExists("[S]" + filename))
            {
                linuxCapture = BioSeqDBModel.Instance.ReadAllText(filename, AppConfigHelper.LoggedOnUser, AppConfigHelper.JsonConfig()); // We know it is on the server.
                int residual = 6000;
                if (linuxCapture.Length > residual)
                {
                    // Write the whole thing to a log file that can be opened separately.
                    string tasklog = "C:\\Temp\\TaskLog.txt";
                    File.WriteAllText(tasklog, linuxCapture);
                    linuxCapture = "[Full text truncated; see saved log file " + tasklog + "]" + Environment.NewLine + Environment.NewLine +
                                   linuxCapture.Substring(linuxCapture.Length - residual);         // Display the last residual chars.
                    Process.Start(tasklog);
                    attachments.Add(tasklog);
                }
            }

            SuccessDialog.MainInstruction = successMsg;
            SuccessDialog.Content         = output;
            if (linuxCapture.Length > 0 && output.IndexOf(linuxCapture) == -1)
            {
                SuccessDialog.Content += (output.Length > 0 ? Environment.NewLine : string.Empty) + linuxCapture;
            }

            if (task.LastExitCode != 0 && task.LastExitCode != -999) // We handle -999 elsewhere (lost task status after completion, likely because BioSeqDB was restarted).
            {
                SuccessDialog.WindowTitle     = "ERROR";
                SuccessDialog.MainInstruction = taskName + " completed with error code " + task.LastExitCode.ToString() + ".";
                message += SuccessDialog.MainInstruction + Environment.NewLine;
            }
            SuccessDialog.ShowDialog(this);

            RemoveTask(false);                     // Do this as soon as possible to reflect the user's closing of the dialog.
            StatusChangeEvent?.Invoke(this, null); // Notify parent we have a potential status change.

            message += linuxCapture;
            User user = AppConfigHelper.seqdbConfigGlobal.Users[AppConfigHelper.LoggedOnUser];

            if (user.EmailNotifications)
            {
                string s1 = Emailer.SendEmail(AppConfigHelper.LoggedOnUser + "@mail.usask.ca", "BioSeqDB User: "******" " + subject, message, attachments, null);
                if (!string.IsNullOrEmpty(s1))
                {
                    Logger.Log.Debug("Email error: " + s1);
                    //MessageBox.Show(s1, "ERROR", MessageBoxButtons.OK);
                }
            }

            if (File.Exists(filename)) // Must do after email since it might be attached.
            {
                File.Delete(filename);
            }
            Cursor.Current = Cursors.Default;
        }
    void OnStatusChanged(StatusChangeEvent arg)
    {
        var str = _battleSystem.Helper.GetStatusAddedMessage(arg.Character, arg.Status);

        _battleSystem.Log(str);
    }
 private void SetStatus(Status status)
 {
     this.CurrentStatus = status;
     StatusChangeEvent?.Invoke(CurrentStatus);
 }
 private void StatusUpdate(Status status)
 {
     StatusChangeEvent?.Invoke(this, new StatusEventArgs(status));
 }
예제 #18
0
 public void BindStatusChangeEvent(StatusChangeEvent statusChange)
 {
     this.statusChanges.Add(statusChange);
 }