Exemplo n.º 1
0
        protected void Page_Load(object sender, EventArgs e)
        {
            EnterpriseService service = new EnterpriseService();
            SmsEnterpriseInfo info    = service.GetEnterpriseInfo(int.Parse(Request.QueryString["id"]));

            name         = info.EnterpriseName;
            introduction = info.Introduction;
            capital      = info.Capital.ToString();
            extendnum    = info.ExtendNum;
            Page.DataBind();
        }
Exemplo n.º 2
0
        void Sendmt(object sender)
        {
            SmsBatchWaitInfo model = sender as SmsBatchWaitInfo;

            if (model != null)
            {
                if (model.Channels.Length == 0)
                {
                    CompleteMt(model, 0, 0);
                    return;
                }
                SmsEnterpriseCfgInfo configmodel = config.GetModelWithKey("smsprice", model.EnterPriseID);
                SmsEnterpriseInfo    info        = config.GetEnterpriseInfo(model.EnterPriseID);
                model.ExtendNum = info.ExtendNum;
                float smsprice  = float.Parse(configmodel.CfgValue);
                int   result    = 3;
                int   sendCount = 0;
                if ((SMSEnum)model.MsgType == SMSEnum.Group)
                {//群发
                    SMSGroupInfo gGroup   = JsonConvert.DeserializeObject <SMSGroupInfo>(model.MsgPack);
                    bool         hasMoney = !(info.Capital * 1000 - smsprice * 10 * gGroup.groupInfos.Count < 0);
                    foreach (string chanelid in model.Channels)
                    {
                        BaseService service = ServicesFactory.Execute(int.Parse(chanelid));
                        int         count   = service.MassCount();
                        for (int i = 0; i < (gGroup.groupInfos.Count / count + (gGroup.groupInfos.Count % count > 0 ? 1 : 0)); i++)
                        {
                            SMSSDKGroupInfo smssdkGroupInfo = new SMSSDKGroupInfo();
                            smssdkGroupInfo.groupInfos = new List <SDKGroupInfo>();

                            if (gGroup.groupInfos.Count - i * count >= count)
                            {
                                List <GroupInfo> groupInfos = gGroup.groupInfos.GetRange(i * count, count);
                                foreach (GroupInfo smsDetial in groupInfos)
                                {
                                    smssdkGroupInfo.groupInfos.Add(new SDKGroupInfo()
                                    {
                                        Phone   = smsDetial.Phone,
                                        Content = smsDetial.Content
                                    });
                                }
                            }
                            else
                            {
                                List <GroupInfo> groupInfos = gGroup.groupInfos.GetRange(i * count, gGroup.groupInfos.Count - i * count);
                                foreach (GroupInfo smsDetial in groupInfos)
                                {
                                    smssdkGroupInfo.groupInfos.Add(new SDKGroupInfo()
                                    {
                                        Phone   = smsDetial.Phone,
                                        Content = smsDetial.Content
                                    });
                                }
                            }

                            if (hasMoney)
                            {
                                result = service.SendSMS(smssdkGroupInfo.groupInfos, model.ExtendNum);
                                if (result == 1)
                                {
                                    sendCount += smssdkGroupInfo.groupInfos.Count;
                                }
                            }
                            WriteBatchDetial(smssdkGroupInfo.groupInfos, (SendResultEnum)Enum.ToObject(typeof(SendResultEnum), result), model, chanelid);
                        }
                    }
                }
                else
                {//组发
                    SMSMassInfo mMass    = JsonConvert.DeserializeObject <SMSMassInfo>(model.MsgPack);
                    bool        hasMoney = !(info.Capital * 1000 - smsprice * 10 * mMass.Phones.Count < 0);
                    foreach (string chanelid in model.Channels)
                    {
                        BaseService service = ServicesFactory.Execute(int.Parse(chanelid));
                        int         count   = service.MassCount();
                        for (int i = 0; i < (mMass.Phones.Count / count + (mMass.Phones.Count % count > 0 ? 1 : 0)); i++)
                        {
                            List <string> readyphones = new List <string>();
                            if (mMass.Phones.Count - i * count >= count)
                            {
                                readyphones = mMass.Phones.GetRange(i * count, count);
                            }
                            else
                            {
                                readyphones = mMass.Phones.GetRange(i * count, mMass.Phones.Count - i * count);
                            }

                            if (hasMoney)
                            {
                                result = service.SendSMS(GetFromDetails(readyphones, mMass.Content), model.ExtendNum);
                                if (result == 1)
                                {
                                    sendCount += readyphones.Count;
                                }
                            }
                            WriteBatchDetial(readyphones, mMass.Content, (SendResultEnum)Enum.ToObject(typeof(SendResultEnum), result), model, chanelid);
                        }
                    }
                }
                CompleteMt(model, smsprice, sendCount);
                lock (lockobj)
                    SendingMtCount--;
            }
        }