예제 #1
0
            public HistoryRow(PolicyAlert alert)
            {
                Alert = alert;
                Cells.Add(_expand);
                Cells.Add(_result);
                Cells.Add(_dateTime);
                Cells.Add(_description);

                RefreshRow();
            }
예제 #2
0
            public HistoryRow(PolicyAlert alert)
            {
                Alert = alert;
                Cells.Add(_expand);
                _expand.Style.Alignment = DataGridViewContentAlignment.MiddleCenter;
                Cells.Add(_result);
                Cells.Add(_dateTime);
                Cells.Add(_description);

                RefreshRow();
            }
예제 #3
0
        private void RefreshHistoryGrid()
        {
            try
            {
                dataGridViewRunHistory.SuspendLayout();
                dataGridViewRunHistory.Rows.Clear();

                var row = SelectedVmssRow;
                if (row == null)
                {
                    return;
                }

                var vmss     = row.Policy;
                var messages = row.AlertMessages;

                int hoursFromNow = RunHistoryTimeSpan;

                DateTime currentTime = DateTime.Now;
                DateTime offset      = currentTime.Add(new TimeSpan(-hoursFromNow, 0, 0));

                if (hoursFromNow == 0)
                {
                    for (int i = 0; i < 10 && i < messages.Count; i++)
                    {
                        var msg   = messages[i];
                        var alert = new PolicyAlert(msg.priority, msg.name, msg.timestamp, msg.body, vmss.Name());
                        dataGridViewRunHistory.Rows.Add(new HistoryRow(alert));
                    }
                }
                else
                {
                    foreach (var msg in messages)
                    {
                        if (msg.timestamp >= offset)
                        {
                            var alert = new PolicyAlert(msg.priority, msg.name, msg.timestamp, msg.body, vmss.Name());
                            dataGridViewRunHistory.Rows.Add(new HistoryRow(alert));
                        }
                        else
                        {
                            break;
                        }
                    }
                }
            }
            finally
            {
                dataGridViewRunHistory.ResumeLayout();
            }
        }
예제 #4
0
            private void RefreshRow()
            {
                PolicyName    = Policy.Name();
                PolicyVmCount = Policy.VMs.FindAll(vm => Policy.Connection.Resolve(vm).is_a_real_vm()).Count;
                PolicyStatus  = Policy.enabled ? Messages.ENABLED : Messages.DISABLED;

                //the policy is in server's local time zone
                if (serverTimeInfo.HasValue)
                {
                    NextRunLocalToServer = Policy.GetNextRunTime(serverTimeInfo.Value.ServerLocalTime);
                }

                if (serverTimeInfo.HasValue && NextRunLocalToServer.HasValue)
                {
                    NextRunLocalToClient = HelpersGUI.RoundToNearestQuarter(NextRunLocalToServer.Value + serverTimeInfo.Value.ServerClientTimeZoneDiff);
                }

                if (AlertMessages.Count > 0)
                {
                    var paType = PolicyAlert.FromPriority(AlertMessages[0].priority);
                    PolicyLastResult      = paType.GetString();
                    PolicyLastResultImage = paType.GetImage();
                }
                else
                {
                    PolicyLastResult      = Messages.NOT_YET_RUN;
                    PolicyLastResultImage = null;
                }

                _name.Value       = PolicyName;
                _numVMs.Value     = PolicyVmCount;
                _status.Value     = PolicyStatus;
                _lastResult.Value = PolicyLastResult;
                _lastResult.Image = PolicyLastResultImage;

                _nextRunClientLocal.Value = NextRunLocalToClient.HasValue
                    ? HelpersGUI.DateTimeToString(NextRunLocalToClient.Value, Messages.DATEFORMAT_DMY_HM, true)
                    : Messages.VMSS_HOST_NOT_LIVE;

                _nextRunServerLocal.Value = NextRunLocalToServer.HasValue
                    ? HelpersGUI.DateTimeToString(NextRunLocalToServer.Value, Messages.DATEFORMAT_DMY_HM, true)
                    : Messages.VMSS_HOST_NOT_LIVE;
            }
예제 #5
0
            public HistoryRow(PolicyAlert alert)
            {
                Alert = alert;
                Cells.Add(_expand);
                _expand.Style.Alignment = DataGridViewContentAlignment.MiddleCenter;
                Cells.Add(_result);
                Cells.Add(_dateTime);
                Cells.Add(_description);

                RefreshRow();
            }
예제 #6
0
 public HistoryRow(PolicyAlert alert)
 {
     Alert = alert;
     Cells.AddRange(_expand, _result, _dateTime, _description);
     RefreshRow();
 }