예제 #1
0
        public string GetSMSAmount()
        {
            var    config   = SMSCore.GetConfig();
            string postdata = "method=getAmount&appkey=" + config.AppKey;

            return(SMSAPiHelper.PostData("http://sms.kuaidiantong.cn/GetAmount.aspx", postdata));
        }
예제 #2
0
        public Core.Plugins.FormData GetFormData()
        {
            var config = SMSCore.GetConfig();

            var formData = new Core.Plugins.FormData()
            {
                Items = new Core.Plugins.FormData.FormItem[] {
                    //AppKey
                    new  Core.Plugins.FormData.FormItem()
                    {
                        DisplayName = "AppKey",
                        Name        = "AppKey",
                        IsRequired  = true,
                        Type        = Core.Plugins.FormData.FormItemType.text,
                        Value       = config.AppKey
                    },
                    new  Core.Plugins.FormData.FormItem()
                    {
                        DisplayName = "AppSecret",
                        Name        = "AppSecret",
                        IsRequired  = true,
                        Type        = Core.Plugins.FormData.FormItemType.text,
                        Value       = config.AppSecret
                    }
                }
            };

            return(formData);
        }
예제 #3
0
        public void CheckCanEnable()
        {
            MessageSMSConfig config = SMSCore.GetConfig();

            if (string.IsNullOrWhiteSpace(config.AppKey))
            {
                throw new Mall.Core.PluginConfigException("未设置AppKey");
            }

            if (string.IsNullOrWhiteSpace(config.AppSecret))
            {
                throw new Mall.Core.PluginConfigException("未设置AppSecret");
            }
        }
예제 #4
0
 private void BatchSendMessage(string[] destination, string text)
 {
     if (destination.Length > 0)
     {
         var config = SMSCore.GetConfig();
         SortedDictionary <string, string> tmpParas = new SortedDictionary <string, string>();
         tmpParas.Add("mobiles", string.Join(",", destination));
         tmpParas.Add("text", text);
         tmpParas.Add("appkey", config.AppKey);
         tmpParas.Add("sendtime", DateTime.Now.ToString());
         tmpParas.Add("speed", "1");
         Dictionary <string, string> paras = SMSAPiHelper.Parameterfilter(tmpParas);
         string sign = SMSAPiHelper.BuildSign(paras, config.AppSecret, "MD5", "utf-8");
         paras.Add("sign", sign);
         paras.Add("sign_type", "MD5");
         string postdata = SMSAPiHelper.CreateLinkstring(paras);
         SMSAPiHelper.PostData("http://sms.kuaidiantong.cn/SendMsg.aspx", postdata);
     }
 }
예제 #5
0
 private string SendMessage(string destination, string text, string speed = "0")
 {
     if (!string.IsNullOrWhiteSpace(destination))
     {
         var config = SMSCore.GetConfig();
         SortedDictionary <string, string> tmpParas = new SortedDictionary <string, string>();
         tmpParas.Add("mobiles", destination);
         tmpParas.Add("text", text);
         tmpParas.Add("appkey", config.AppKey);
         tmpParas.Add("sendtime", DateTime.Now.ToString());
         tmpParas.Add("speed", speed);
         Dictionary <string, string> paras = SMSAPiHelper.Parameterfilter(tmpParas);
         string sign = SMSAPiHelper.BuildSign(paras, config.AppSecret, "MD5", "utf-8");
         paras.Add("sign", sign);
         paras.Add("sign_type", "MD5");
         string postdata = SMSAPiHelper.CreateLinkstring(paras);
         return(SMSAPiHelper.PostData("http://sms.kuaidiantong.cn/SendMsg.aspx", postdata));
     }
     return("发送目标不能为空!");
 }
예제 #6
0
        public void SetFormValues(IEnumerable <KeyValuePair <string, string> > values)
        {
            var appKeyItem = values.FirstOrDefault(item => item.Key == "AppKey");

            if (string.IsNullOrWhiteSpace(appKeyItem.Value))
            {
                throw new Mall.Core.PluginConfigException("AppKey不能为空");
            }
            var appSecretItem = values.FirstOrDefault(item => item.Key == "AppSecret");

            if (string.IsNullOrWhiteSpace(appSecretItem.Value))
            {
                throw new Mall.Core.PluginConfigException("AppSecret不能为空");
            }
            MessageSMSConfig oldConfig = SMSCore.GetConfig();

            oldConfig.AppKey    = appKeyItem.Value;
            oldConfig.AppSecret = appSecretItem.Value;
            SMSCore.SaveConfig(oldConfig);
        }