Exemplo n.º 1
0
 public bool SendMessage(List<CCSMSEntityMessage> ls)
 {
     try
     {
         if (ls != null && ls.Count > 0)
         {
             SMSService smsService = new SMSService();
             List<string> lsTenantCode = ls.Select(o => o.SearchLocation.TenantCode).ToList();
             Dictionary<string, string> dicUser = GetUserCode(lsTenantCode);
             foreach (CCSMSEntityMessage m in ls)
             {
                 Logger.Info(string.Format("开始发送信息:上行:{0}; 手机号码:{1}; 下发内容:{2}", m.SearchLocation.UpSMSContent, m.SearchLocation.telephone_number, m.SearchLocation.DownSMSContent));
                 if (!m.SearchLocation.IsProfessional)
                 {
                     smsService.SendSMS(m.SearchLocation.TenantCode, m.SearchLocation.DownSMSContent, m.SearchLocation.telephone_number, SMS.Enum.ConsumeType.SMSQuery);
                 }
                 Logger.Info(string.Format("结束发送信息:上行:{0}; 手机号码:{1}; 下发内容:{2}", m.SearchLocation.UpSMSContent, m.SearchLocation.telephone_number, m.SearchLocation.DownSMSContent));
                 if (m.isHistory)
                 {
                     InsertLocation(m.SearchLocation);
                 }
             }
         }
         return true;
     }
     catch (Exception ex)
     {
         Logger.Error(ex.Message);
         return false;
     }
 }
Exemplo n.º 2
0
        public DBProcessResult Get_MobileSMSSendOut(string mobile, string userCode, string sendMsg)
        {
            DBProcessResult result = new DBProcessResult() { IsSuccess = true, Message = "短信已发送,请注意查收!" };
            try
            {
                SMSService smsService = new SMSService();
                DateTime today = DateTime.Today;
                MobileSMSSendOutHelper.RemoveMobileSMSSendOutInfo(today.AddDays(-1).ToString("yyyyMMdd"));
                IDictionary<string, int> dictionary = MobileSMSSendOutHelper.GetMobileDictionary(today.ToString("yyyyMMdd"));
                if (dictionary != null && dictionary.Count > 0)
                {
                    if (dictionary.ContainsKey(mobile))
                    {
                        int num = dictionary[mobile];
                        if (num > 10)
                        {
                            result.IsSuccess = false;
                            result.Message = "对不起,同一个手机号码每天最多只能发送10次!";
                        }
                        else
                        {
                            //MovoSMSProxy.SendMoveSMS(mobile, MobileSMSSendOutHelper.SMSString, -1, "20010030300002", userCode);
                            smsService.SendSMS(sendMsg, mobile);

                            //smsService.SendSMS(MobileSMSSendOutHelper.SMSString, mobile);
                            num++;
                            dictionary[mobile] = num;
                        }
                    }
                    else
                    {
                        //MovoSMSProxy.SendMoveSMS(mobile, MobileSMSSendOutHelper.SMSString, -1, "20010030300002", userCode);
                        smsService.SendSMS(sendMsg, mobile);
                        dictionary.Add(mobile, 1);
                    }
                }
                else
                {
                    //MovoSMSProxy.SendMoveSMS(mobile, MobileSMSSendOutHelper.SMSString, -1, "20010030300002", userCode);
                    smsService.SendSMS(sendMsg, mobile);
                    dictionary.Add(mobile, 1);
                }
                MobileSMSSendOutHelper.SetMobileSMSSendOutInfo(today.ToString("yyyyMMdd"), dictionary);
            }
            catch (Exception exception)
            {
                Logger.Error("Get_MobileSMSSendOut:手机号码(" + mobile + ")" + exception.Message);
            }
            return result;
        }