Example #1
0
 public void ManageNotifications(List <GroupMessages> messages, String moduleCode, Int32 idSenderUser, String ipAddress, String proxyIpAddress)
 {
     foreach (NotificationChannel channel in messages.Select(i => i.Channel).Distinct())
     {
         switch (channel)
         {
         case NotificationChannel.Mail:
             SrvMailSender.iServiceMailSender service = GetMailServiceSender(GetMailQueueConfiguration(moduleCode));
             if (service != null)
             {
                 System.ServiceModel.ClientBase <SrvMailSender.iServiceMailSender> srv = null;
                 try
                 {
                     foreach (GroupMessages message in messages)
                     {
                         service.SendMailFromGroupNotification(IstanceConfig.UniqueIdentifier, idSenderUser, moduleCode, message);
                     }
                 }
                 catch (Exception ex)
                 {
                     logger.Log(LogLevel.Error, "Error on GetMailServiceSender", ex);
                     if (service != null)
                     {
                         srv = (System.ServiceModel.ClientBase <SrvMailSender.iServiceMailSender>)service;
                         srv.Abort();
                         srv = null;
                     }
                     service = null;
                     throw new lm.Comol.Core.Msmq.Services.Notifications.Service.Exceptions.NotificationException(ex, Exceptions.ExceptionType.RemoteQueueUnavailable);
                 }
                 finally{
                     if (service != null)
                     {
                         srv = (System.ServiceModel.ClientBase <SrvMailSender.iServiceMailSender>)service;
                         srv.Close();
                         srv = null;
                     }
                 }
             }
             break;
         }
     }
 }
Example #2
0
 public SrvMailSender.iServiceMailSender GetMailServiceSender(MailConfig config)
 {
     SrvMailSender.iServiceMailSender remoteService = null;
     System.ServiceModel.ClientBase <SrvMailSender.iServiceMailSender> srv = null;
     try
     {
         remoteService = new SrvMailSender.iServiceMailSenderClient(GetBinding(config.Binding), new System.ServiceModel.EndpointAddress(config.Address));
     }
     catch (Exception ex)
     {
         logger.Log(LogLevel.Error, "Error on GetMailServiceSender", ex);
         if (remoteService != null)
         {
             srv = (System.ServiceModel.ClientBase <SrvMailSender.iServiceMailSender>)remoteService;
             srv.Abort();
             srv = null;
         }
         remoteService = null;
         throw new lm.Comol.Core.Msmq.Services.Notifications.Service.Exceptions.NotificationException(ex, Exceptions.ExceptionType.RemoteQueueUnavailable);
     }
     return(remoteService);
 }