private void BindErrorTypes() { if (DropDownListCategory.SelectedValue != "") { DropDownListErrorType.DataSource = ErrorTypeController.GetErrorTypes(DropDownListOpco.SelectedValue, DropDownListCategory.SelectedItem.Text, ""); DropDownListErrorType.Items.Clear(); DropDownListErrorType.Items.Add(new ListItem("-", "")); DropDownListErrorType.DataBind(); } }
public Exception HandleException(Exception exception, Guid handlingInstanceId) { if (exception != null && exception is DiscoveryException) { //only attempt to send an email if we are handling a DiscoveryException, otherwise we will be //unable to find the email address DiscoveryException discoveryException = (DiscoveryException)exception; //this email handler has been related to the exception so we will email someone if we //can find the email address from the DB using the exception type, the policy name and the opcocode //check the properties collection of the DiscoveryException object string opCoCode = discoveryException.Properties["OpCoCode"].ToString(); string operatorEmail = discoveryException.Properties["OperatorEmail"].ToString(); string exceptionType = exception.GetType().ToString(); //use OpCoId + exceptionType + CategoryName (name) to look in the database and see if //there is an email address to send the exception message to ErrorType errorType = ErrorTypeController.GetErrorType(exceptionType, opCoCode, Policy); if (errorType != null) { //get from object bool emailOperator = errorType.EmailOperator; string toAddress = errorType.EmailRecipients; if (emailOperator & !string.IsNullOrEmpty(operatorEmail)) { if (!string.IsNullOrEmpty(toAddress)) { //add the operator email to the recipient list if there is a list and //there is a operatorEmail toAddress = string.Concat(toAddress, ",", operatorEmail); } else { //set the toaddress to be the operatorEmail if there isn't a list retrived from the DB and //there is a operatorEmail toAddress = operatorEmail; } } if (!string.IsNullOrEmpty(toAddress)) { string emailServerName = ConfigurationManager.AppSettings["EmailServerName"]; string fromAddress = ConfigurationManager.AppSettings["FromAddress"]; int smtpPort = Convert.ToInt32(ConfigurationManager.AppSettings["SMTPPort"]); //get from exception string emailBody = exception.Message; SmtpClient mailClient = new SmtpClient(emailServerName, smtpPort); MailMessage message = new MailMessage(fromAddress.Replace(";", ","), toAddress.Replace(";", ","), errorType.EmailSubject, emailBody); mailClient.Send(message); } } } return(exception); }
public Exception HandleException(Exception exception, Guid handlingInstanceId) { if (exception is DiscoveryException && exception != null) { //only attempt to send an email if we are handling a DiscoveryException, otherwise we will be //unable to find the email address DiscoveryException discoveryException = (DiscoveryException)exception; //this email handler has been related to the exception so we will email someone if we //can find the email address from the DB using the exception type, the policy name and the opcocode //check the properties collection of the DiscoveryException object try { int opCoId = Convert.ToInt32(discoveryException.Properties["OpCoId"]); string operatorEmail = discoveryException.Properties["OperatorEmail"].ToString(); string exceptionType = exception.GetType().ToString(); //use OpCoId + exceptionType + Policy (name) to look in the database and see if //there is an email address to send the exception message to ErrorType errorType = ErrorTypeController.GetErrorType(exceptionType, opCoId, Policy); if (errorType != null) { //get from object bool emailOperator = errorType.EmailOperator; string toAddress = errorType.EmailRecipients; if (emailOperator & !string.IsNullOrEmpty(operatorEmail)) { if (!string.IsNullOrEmpty(toAddress)) { //add the operator email to the recipient list if there is a list and //there is a operatorEmail toAddress = string.Concat(toAddress, ";", operatorEmail); } else { //set the toaddress to be the operatorEmail if there isn't a list retrived from the DB and //there is a operatorEmail toAddress = operatorEmail; } } if (!string.IsNullOrEmpty(toAddress)) { //get from config file? string emailServerName = "tigger"; string fromAddress = "*****@*****.**"; int smtpPort = 25; string emailSubject = "Test Subject"; //get from exception string emailBody = exception.Message; SmtpClient mailClient = new SmtpClient(emailServerName, smtpPort); MailMessage message = new MailMessage(toAddress, fromAddress, emailSubject, emailBody); mailClient.Send(message); } } } catch (Exception e) { } } return(exception); }