//------------------------------------------------------------------------------------------------- /// <summary> /// Sends the mail. /// </summary> private void SendMail() { configManager.Logger.Debug(EnumMethod.START); SMTPTransport smtp = new SMTPTransport(); try { PMAMailController mailer = new PMAMailController(configManager.GetConsolidatedError("System Alert"), AlertType.GENERAL_ALERT, null); mailer.SendMail(); } catch (Exception ex) { configManager.FlagInfo.FlagedDiscAlert = false; configManager.FlagInfo.FlagedPhysicalMemoryAlert = false; configManager.FlagInfo.FlagedServiceAlert = false; configManager.FlagInfo.FlagedASPStateSizeAlert = false; configManager.FlagInfo.FlagedTempDBMemoryAlert = false; configManager.Logger.Error(ex); } configManager.Logger.Debug(EnumMethod.END); }
private void label_Home_Click(object sender, EventArgs e) { if (CauseValidation()) { UpdateConfig(PANEL); ShowPanel(ENUMPanel.PANEL_HOME); } else { MessageBox.Show(this, configManager.GetConsolidatedError("Error")); } }
//------------------------------------------------------------------------------------------------- /// <summary> /// Generates the message body. /// </summary> /// <returns></returns> public string GenerateMessageBody() { configManager.Logger.Debug(EnumMethod.START); StringBuilder builder = new StringBuilder(); string lineSeprator = string.Empty; bool isHTMLMessage = false; if (!_isGeneratingLog) { if (configManager.SmtpInfo.IsBodyHtml) { isHTMLMessage = true; lineSeprator = "<br/>"; } else { lineSeprator = "\r\n"; } } else { isHTMLMessage = false; lineSeprator = "\r\n"; } if (!_isGeneratingLog) { builder.Append("Hi,"); builder.Append(lineSeprator); builder.Append(lineSeprator); builder.Append(lineSeprator); } if (alertType == AlertType.EVENT_ALERT) { if (isHTMLMessage) { builder.Append("<div style=\"COLOR:RED\">"); } builder.Append("Event Alert Generated For machine :" + Environment.MachineName + " : " + configManager.SystemAnalyzerInfo.ClientInstanceName); builder.Append(lineSeprator + " Total RAM :" + PMAServiceProcessController.TotalPhysicalMemoryInKB); builder.Append(lineSeprator + " Available RAM :" + PMAServiceProcessController.TotalFreePhysicalMemoryInKB); builder.Append(lineSeprator + " CPU Usage : " + PMAServiceProcessController.CPUPercentageUsageAtMoment + "%"); builder.Append(lineSeprator); builder.Append(_message); } else if (alertType == AlertType.GENERAL_ALERT) { if (isHTMLMessage) { builder.Append("<div style=\"COLOR:RED\">"); } builder.Append("Alert Generated For machine :" + Environment.MachineName + " : " + configManager.SystemAnalyzerInfo.ClientInstanceName); builder.Append(lineSeprator); if (isHTMLMessage) { builder.Append(configManager.GetConsolidatedError("System Alert").Replace("\r\n", "<br/>")); } else { builder.Append(configManager.GetConsolidatedError("System Alert")); } } else if (alertType == AlertType.SQL_ALERT) { if (isHTMLMessage) { builder.Append("<div style=\"COLOR:GREEN\">"); } builder.Append("SQL Action On :" + configManager.PMAServerManagerInfo.DatabaseServer); builder.Append(lineSeprator); builder.Append("Query : " + _message); } else if (alertType == AlertType.SERVICE_ALERT) { if (isHTMLMessage) { builder.Append("<div style=\"COLOR:GREEN\">"); } builder.Append("Service Action On :" + configManager.PMAServerManagerInfo.DatabaseServer); builder.Append(lineSeprator); builder.Append("Services Effected "); builder.Append(lineSeprator); builder.Append(_message); } else if (alertType == AlertType.ACTION_ALERT) { if (isHTMLMessage) { builder.Append("<div style=\"COLOR:GREEN\">"); } builder.Append("Command Action On : " + Environment.MachineName + ":" + configManager.SystemAnalyzerInfo.ClientInstanceName); builder.Append(lineSeprator); builder.Append("Actions Performed Are :"); builder.Append(lineSeprator); builder.Append(_message); } else if (alertType == AlertType.USER_ALERT) { if (isHTMLMessage) { builder.Append("<div style=\"COLOR:GREEN\">"); } builder.Append("User :"******" login on : " + Environment.MachineName + ":" + configManager.SystemAnalyzerInfo.ClientInstanceName); } if (isHTMLMessage) { builder.Append("</div>"); } if (!_isGeneratingLog) { builder.Append(lineSeprator); builder.Append(lineSeprator); builder.Append(lineSeprator); builder.Append(lineSeprator); if (isHTMLMessage) { builder.Append("<h4>"); } builder.Append("Thanks,"); builder.Append(lineSeprator); builder.Append("Cosmos Team."); if (isHTMLMessage) { builder.Append("</h4>"); } } configManager.Logger.Debug(EnumMethod.END); return(builder.ToString()); }