void TmCheckForACKTick(object sender, System.EventArgs e) { OpsMMEventLog opsEventLog = new OpsMMEventLog(); if (opsEventLog.gotAckEvent()) { setStatusMessage("Server is in maintenance mode!\nYou may close this window.", STATUS_OK); updateProgressBar(MM_TIMEOUT, MM_TIMEOUT, Color.Green); btnCancel.Text = "&Close"; btnCancel.Focus(); tmCheckForACK.Stop(); btStartMaintenance.Enabled = true; btStopMaintenance.Enabled = true; } else { setMMTimeout = setMMTimeout - tmCheckForACK.Interval; if (setMMTimeout > 60000) { updateProgressBar(MM_TIMEOUT - setMMTimeout, MM_TIMEOUT, ATEA_GREEN); } else if (setMMTimeout > 0) { updateProgressBar(MM_TIMEOUT - setMMTimeout, MM_TIMEOUT, Color.Gold); } else { setStatusMessage("Timed out waiting for maintenance mode.\nPlease contact monitoring support for assistance.", STATUS_ERROR); updateProgressBar(MM_TIMEOUT - setMMTimeout, MM_TIMEOUT, Color.Red); tmCheckForACK.Stop(); setMMTimeout = MM_TIMEOUT; } } }
void BtStartMaintenanceClick(object sender, System.EventArgs e) { bool allPropertiesSet = false; if (cbDuration.SelectedIndex >= 0) { allPropertiesSet = true; } else { epDuration.SetError(cbDuration, "Must select duration!"); allPropertiesSet = false; } if (cbReason.SelectedIndex >= 0) { allPropertiesSet = true; } else { epReason.SetError(cbReason, "Must select reason!"); allPropertiesSet = false; } if (epIllegalComment.GetError(tbComment) != "" || epReason.GetError(cbReason) != "" || epDuration.GetError(cbDuration) != "") { allPropertiesSet = false; } // All inputs looks OK, write start command to event log. if (allPropertiesSet) { OpsMMEventLog opsEventlog = new OpsMMEventLog(); KeyValuePair kvpDuration = (KeyValuePair)cbDuration.SelectedItem; KeyValuePair kvpReason = (KeyValuePair)cbReason.SelectedItem; string comment = tbComment.Text; string userName = tbCurrentUser.Text; if (opsEventlog.writeStartEvent(kvpDuration.m_objectKey.ToString(), kvpReason.m_objectKey.ToString(), "", "", comment, userName)) { setStatusMessage("", STATUS_INFO); updateProgressBar(0, MM_TIMEOUT, Color.Green); tmCheckForACK.Start(); btStartMaintenance.Enabled = false; btStopMaintenance.Enabled = false; btnCancel.Text = "&Close"; } else { setStatusMessage("Failed to write event! Are you running as administrator?", STATUS_ERROR); } } }
void BtStopMaintenanceClick(object sender, System.EventArgs e) { OpsMMEventLog opsEventlog = new OpsMMEventLog(); string comment = tbComment.Text; string userName = tbCurrentUser.Text; if (epIllegalComment.GetError(tbComment) == "") { if (opsEventlog.writeStopEvent("", "", comment, userName)) { setStatusMessage("Stopping Maintenance Mode\n", STATUS_INFO); tmCheckForACK.Start(); btStartMaintenance.Enabled = false; btStopMaintenance.Enabled = false; btnCancel.Text = "&Close"; } else { setStatusMessage("Failed to write event! Are you running as administrator?", STATUS_ERROR); } } }