Ejemplo n.º 1
0
        /// <summary>
        /// 给分类查询出的用户发送短信
        /// </summary>
        /// <param name="entity">短信内容</param>
        public void SendSMS(CategoryCustomersSendSMS entity)
        {
            if (string.IsNullOrWhiteSpace(entity.SMSBody))
            {
                throw new BusinessException("请输入短信内容!");
            }

            QueryCategoryCustomersFilter filter = new QueryCategoryCustomersFilter()
            {
                PageIndex = 1,
                PageSize  = 100000000,
                Category  = entity.Category
            };
            StatementResult <ArrayList> queryUsers = QueryCategoryCustomers(filter);

            if (queryUsers != null && queryUsers.Result != null && queryUsers.Result.Count > 0)
            {
                Soho.EmailAndSMS.Service.Entity.SMSEntity smsEntity = new Soho.EmailAndSMS.Service.Entity.SMSEntity();
                smsEntity.Status  = Soho.EmailAndSMS.Service.Entity.SMSStatus.AuditPassed;
                smsEntity.InDate  = DateTime.Now.ToString();
                smsEntity.SMSBody = entity.SMSBody;
                List <Soho.EmailAndSMS.Service.Entity.SMSEntity> sendSMSList = new List <Soho.EmailAndSMS.Service.Entity.SMSEntity>();

                ArrayList users = queryUsers.Result;
                for (int i = 0; i < users.Count; i++)
                {
                    Dictionary <string, object> item = users[i] as Dictionary <string, object>;
                    foreach (var obj in item)
                    {
                        if (obj.Key.Equals("CustomerID"))
                        {
                            smsEntity.UserSysNo = int.Parse(obj.Value.ToString());
                        }
                        if (obj.Key.Equals("TrueName"))
                        {
                            smsEntity.ReceiveName = obj.Value.ToString();
                        }
                        if (obj.Key.Equals("ComMobile"))
                        {
                            smsEntity.ReceivePhoneNumber = obj.Value.ToString();
                        }
                    }
                    if (!string.IsNullOrEmpty(smsEntity.ReceivePhoneNumber))
                    {
                        sendSMSList.Add(smsEntity);
                    }
                }
                EmailAndSMSService.Instance.BatchInsertSMS(sendSMSList);
            }
        }
Ejemplo n.º 2
0
        /// <summary>
        /// 发送短信给批量用户
        /// </summary>
        /// <param name="entity">短信内容</param>
        public void SendSMSToBatchCustomers(BatchCustomersSendSMS entity)
        {
            if (string.IsNullOrWhiteSpace(entity.SMSBody))
            {
                throw new BusinessException("请输入短信内容!");
            }

            if (entity.CustomerIDList != null && entity.CustomerIDList.Count > 0)
            {
                Soho.EmailAndSMS.Service.Entity.SMSEntity smsEntity = new Soho.EmailAndSMS.Service.Entity.SMSEntity();
                smsEntity.Status  = Soho.EmailAndSMS.Service.Entity.SMSStatus.AuditPassed;
                smsEntity.InDate  = DateTime.Now.ToString();
                smsEntity.SMSBody = entity.SMSBody;
                List <Soho.EmailAndSMS.Service.Entity.SMSEntity> sendSMSList = new List <Soho.EmailAndSMS.Service.Entity.SMSEntity>();

                entity.CustomerIDList.ForEach(m =>
                {
                    ArrayList users = QueryCategoryCustomersDA.GetCustomerByCustomerID(m);
                    if (users != null && users.Count > 0)
                    {
                        Dictionary <string, object> item = users[0] as Dictionary <string, object>;
                        foreach (var obj in item)
                        {
                            if (obj.Key.Equals("CustomerID"))
                            {
                                smsEntity.UserSysNo = int.Parse(obj.Value.ToString());
                            }
                            if (obj.Key.Equals("TrueName"))
                            {
                                smsEntity.ReceiveName = obj.Value.ToString();
                            }
                            if (obj.Key.Equals("ComMobile"))
                            {
                                smsEntity.ReceivePhoneNumber = obj.Value.ToString();
                            }
                        }
                        if (!string.IsNullOrEmpty(smsEntity.ReceivePhoneNumber))
                        {
                            sendSMSList.Add(smsEntity);
                        }
                        EmailAndSMSService.Instance.BatchInsertSMS(sendSMSList);
                    }
                });
            }
        }