Пример #1
0
 public void SendEmail(List<string> userNames, string Message)
 {
     ThreadPool.QueueUserWorkItem(state =>
     {
         try
         {
             {
                 foreach (var username in userNames)
                 {
                     var admin = mongodbQueryService.GetAdminConfigurationInternal(username);
                     if (admin != null)
                     {
                         var mail = new MailItem
                         {
                             MailTitle = Message,
                             MailBody = Message,
                             MailAddress = admin.MailAddress,
                         };
                         mailService.Send(new List<MailItem> { mail });
                     }
                 }
             }
         }
         catch (Exception ex)
         {
             ex.Handle("SendMessage");
             throw;
         }
     });
 }
Пример #2
0
        private void SendMessage(string configName, string mobileMessage, string mailMessage)
        {
            ThreadPool.QueueUserWorkItem(state =>
            {
                try
                {
                    var configitem = AlarmConfigurationBase.GetConfig().AlarmConfigurationByStatistics.Values.FirstOrDefault(c => c.ConfigName == configName);
                    if (configitem != null)
                    {
                        foreach (var groupName in configitem.AlarmReceiverGroupNames.Values)
                        {
                            var group = AlarmConfigurationBase.GetConfig().AlarmReceiverGroups.Values.FirstOrDefault(g => g.GroupName == groupName);
                            foreach (var r in group.AlarmReceivers)
                            {
                                var admin = mongodbQueryService.GetAdminConfigurationInternal(r.Value.Name);
                                if (admin != null)
                                {
                                    if (group.EnableMobileMessage)
                                    {
                                        var mobile = new MobileItem
                                        {
                                            MobileNumber = admin.MobileNumber,
                                            MobileMessage = mobileMessage,
                                        };
                                        mobileService.Send(new List<MobileItem> { mobile });

                                    }

                                    if (group.EnableMailMessage)
                                    {
                                        var mail = new MailItem
                                        {
                                            MailTitle = mailMessage,
                                            MailBody = mailMessage,
                                            MailAddress = admin.MailAddress,
                                        };
                                        mailService.Send(new List<MailItem> { mail });
                                    }
                                }
                            }
                        }
                    }
                }
                catch (Exception ex)
                {
                    ex.Handle("SendMessage");
                    throw;
                }
            });
        }