public static void addMessageToPoisonQueue(Exception error, Notification.Domain.dtoModuleNotificationMessage message, String poisonQueue = "") { if (String.IsNullOrEmpty(poisonQueue)) { poisonQueue = System.Configuration.ConfigurationManager.AppSettings["PoisonErrorsQueueName"]; } if (null != error && !String.IsNullOrEmpty(poisonQueue)) { MessageQueue poisonMessageQueue = new MessageQueue(poisonQueue); if (poisonMessageQueue != null) { using (TransactionScope txScope = new TransactionScope(TransactionScopeOption.RequiresNew)) { ErrorNotificationMessage obj = new ErrorNotificationMessage() { Message = message }; obj.Error.HelpLink = error.HelpLink; obj.Error.StackTrace = error.StackTrace; obj.Error.Source = error.Source; obj.Error.Message = error.Message; obj.Error.InnerException = (error.InnerException == null) ? "" : error.InnerException.Message; poisonMessageQueue.Send(obj, MessageQueueTransactionType.Single); txScope.Complete(); } } } }
/// <summary> /// /// </summary> /// <param name="message">message </param> /// <param name="poisonQueue">queue name</param> public static void addMessageToPoisonQueue(Notification.Domain.dtoModuleNotificationMessage message, String poisonQueue = "") { if (String.IsNullOrEmpty(poisonQueue)) { poisonQueue = System.Configuration.ConfigurationManager.AppSettings["PoisonErrorsQueueName"]; } if (null != message && !String.IsNullOrEmpty(poisonQueue)) { MessageQueue poisonMessageQueue = new MessageQueue(poisonQueue); if (poisonMessageQueue != null) { using (TransactionScope txScope = new TransactionScope(TransactionScopeOption.RequiresNew)) { ErrorNotificationMessage obj = new ErrorNotificationMessage() { Message = message }; poisonMessageQueue.Send(obj, MessageQueueTransactionType.Single); txScope.Complete(); } } } }
public void SendMailFromModuleNotification(string istanceIdentifier, int idUser, string moduleCode, Notification.Domain.dtoModuleNotificationMessage message) { IstanceConfig istance = Config.GetIstanceConfiguration(istanceIdentifier); SmtpServiceConfig cfg = GetSmtpSettings(istanceIdentifier); if (cfg != null && istance != null) { using (ISession session = lm.Comol.Core.Data.SessionDispatcher.NewSession(istance.ConnectionString)) { if (session != null) { using (InternalMailService service = new InternalMailService(cfg, istance, session)) { Boolean result = false; String messagePath = service.GetAttachmentsFullPath(istance.AttachmentUploadPath, message.AttachmentPath); try { result = service.SendMail(idUser, moduleCode, message, (message.MailSettings.IsBodyHtml), messagePath, message.AttachmentSavedPath); } catch (Exception ex) { ErrorHandler.addMessageToPoisonQueue(ex, message); } } } else { ErrorHandler.addMessageToPoisonQueue(message); } } } }