Esempio n. 1
0
        /// <summary>
        /// 发送
        /// </summary>
        /// <param name="identityType"><seealso cref="IdentityType"/></param>
        /// <param name="senderId">发送者ID</param>
        /// <param name="mobiles">发送的目标手机号</param>
        /// <param name="uid">业务ID</param>
        /// <returns></returns>
        internal async Task <SmsSendResult> SendSms(IdentityType identityType, long senderId, IEnumerable <string> mobiles, object uid)
        {
            try
            {
                string strId = (uid ?? string.Empty).ToString();

                var result = await MiddlewareConfig.Options.SendProvider.SendSmsAsync(mobiles, Content, strId);

                //添加发送记录
                List <SmsSendRecords> records = new List <SmsSendRecords>();

                foreach (var m in realSendMobiles)
                {
                    SmsSendRecords record = new SmsSendRecords
                    {
                        IsSuccess  = result.IsSuccess,
                        Message    = Content,
                        Mobile     = m,
                        Remark     = result.Remark,
                        SenderId   = senderId,
                        SenderType = (int)identityType,
                        SmsType    = (int)Option,
                        SendID     = IDProvider.NewId(),
                        SendTime   = DateTime.Now
                    };

                    records.Add(record);
                }

                new SmsSendRecordsService().AddRecord(records);

                return(result);
            }
            catch
            {
                return(null);
            }
        }
Esempio n. 2
0
 /// <summary>
 /// 添加短信发送记录
 /// </summary>
 /// <param name="record"></param>
 /// <returns></returns>
 public bool AddRecord(SmsSendRecords record)
 {
     return(AddRecord(new[] { record }));
 }