Exemple #1
0
        /// <summary>
        /// 发送短信接口
        /// </summary>
        /// <param name="content"></param>
        /// <param name="numbers"></param>
        /// <param name="priority"></param>
        /// <returns></returns>
        public static bool SendSMS(string content, string[] numbers, int priority = 5)
        {
            //获取短信接口的序列号,和自定义Key
            string SerialNo = BLL.SysManage.ConfigSystem.GetValueByCache("Emay_SMS_SerialNo");
            string Key      = BLL.SysManage.ConfigSystem.GetValueByCache("Emay_SMS_Key");

            if (String.IsNullOrWhiteSpace(SerialNo) || String.IsNullOrWhiteSpace(Key))
            {
                LogHelp.AddErrorLog("亿美短信接口缺少企业序列号或者自定义关键字Key", "亿美短信接口调用失败", HttpContext.Current.Request);
                return(false);
            }
            SMSService.SDKClient sdkClient  = new SDKClientClient();
            sendSMSRequest       smsRequest = new sendSMSRequest();

            smsRequest.arg0 = SerialNo;
            smsRequest.arg1 = Key;
            smsRequest.arg3 = numbers;
            smsRequest.arg4 = YSWL.Common.Globals.HtmlEncode(content);
            smsRequest.arg7 = priority;
            sendSMSResponse smsResponse = sdkClient.sendSMS(smsRequest);

            if (smsResponse.@return == 0)
            {
                return(true);
            }
            string msg = SendSMSException(smsResponse.@return);

            LogHelp.AddErrorLog("亿美短信接口发送短信出现异常,【" + msg + "】,错误码【" + smsResponse.@return + "】", "亿美短信接口调用失败", HttpContext.Current.Request);
            return(false);
        }
Exemple #2
0
 public static bool Logout()
 {
     string valueByCache = ConfigSystem.GetValueByCache("Emay_SMS_SerialNo");
     string str2 = ConfigSystem.GetValueByCache("Emay_SMS_Key");
     ConfigSystem.GetValueByCache("Emay_SMS_Pwd");
     if (string.IsNullOrWhiteSpace(valueByCache) || string.IsNullOrWhiteSpace(str2))
     {
         LogHelp.AddErrorLog("亿美短信接口缺少企业序列号或者自定义关键字Key", "亿美短信接口调用失败", HttpContext.Current.Request);
         return false;
     }
     SDKClient client = new SDKClientClient();
     logoutRequest request = new logoutRequest(valueByCache, str2);
     logoutResponse response = client.logout(request);
     if (response.@return == 0)
     {
         return true;
     }
     LogHelp.AddErrorLog("亿美短信注销序列号出现异常,【" + LogoutException(response.@return) + "】", "亿美短信接口调用失败", HttpContext.Current.Request);
     return false;
 }
Exemple #3
0
        /// <summary>
        /// 查询余额
        /// </summary>
        public static double GetBalance()
        {
            string SerialNo = BLL.SysManage.ConfigSystem.GetValueByCache("Emay_SMS_SerialNo");
            string Key      = BLL.SysManage.ConfigSystem.GetValueByCache("Emay_SMS_Key");

            if (String.IsNullOrWhiteSpace(SerialNo) || String.IsNullOrWhiteSpace(Key))
            {
                LogHelp.AddErrorLog("亿美短信接口缺少企业序列号或者自定义关键字Key", "亿美短信接口调用失败", HttpContext.Current.Request);
                return(0);
            }
            try
            {
                SMSService.SDKClient sdkClient = new SDKClientClient();
                getBalanceRequest    request   = new getBalanceRequest(SerialNo, Key);
                getBalanceResponse   response  = sdkClient.getBalance(request);
                return(response.@return);
            }
            catch (Exception ex)
            {
                LogHelp.AddErrorLog("查询短信余额异常:" + ex.Message, ex.StackTrace, HttpContext.Current.Request);
                throw;
            }
        }
Exemple #4
0
        /// <summary>
        ///     注册序列号
        /// </summary>
        /// <returns></returns>
        public static bool Logout()
        {
            string SerialNo = BLL.SysManage.ConfigSystem.GetValueByCache("Emay_SMS_SerialNo");
            string Key      = BLL.SysManage.ConfigSystem.GetValueByCache("Emay_SMS_Key");
            string Pwd      = BLL.SysManage.ConfigSystem.GetValueByCache("Emay_SMS_Pwd");

            if (String.IsNullOrWhiteSpace(SerialNo) || String.IsNullOrWhiteSpace(Key))
            {
                LogHelp.AddErrorLog("亿美短信接口缺少企业序列号或者自定义关键字Key", "亿美短信接口调用失败", HttpContext.Current.Request);
                return(false);
            }
            SMSService.SDKClient sdkClient = new SDKClientClient();
            logoutRequest        request   = new logoutRequest(SerialNo, Key);
            logoutResponse       response  = sdkClient.logout(request);

            if (response.@return == 0)
            {
                return(true);
            }
            string msg = LogoutException(response.@return);

            LogHelp.AddErrorLog("亿美短信注销序列号出现异常,【" + msg + "】", "亿美短信接口调用失败", HttpContext.Current.Request);
            return(false);
        }
Exemple #5
0
 public static bool SendSMS(string content, string[] numbers, int priority = 5)
 {
     string valueByCache = ConfigSystem.GetValueByCache("Emay_SMS_SerialNo");
     string str2 = ConfigSystem.GetValueByCache("Emay_SMS_Key");
     if (string.IsNullOrWhiteSpace(valueByCache) || string.IsNullOrWhiteSpace(str2))
     {
         LogHelp.AddErrorLog("亿美短信接口缺少企业序列号或者自定义关键字Key", "亿美短信接口调用失败", HttpContext.Current.Request);
         return false;
     }
     SDKClient client = new SDKClientClient();
     sendSMSRequest request = new sendSMSRequest {
         arg0 = valueByCache,
         arg1 = str2,
         arg3 = numbers,
         arg4 = Globals.HtmlEncode(content),
         arg7 = priority
     };
     sendSMSResponse response = client.sendSMS(request);
     if (response.@return == 0)
     {
         return true;
     }
     LogHelp.AddErrorLog("亿美短信接口发送短信出现异常,【" + SendSMSException(response.@return) + "】", "亿美短信接口调用失败", HttpContext.Current.Request);
     return false;
 }
Exemple #6
0
        /// <summary>
        /// 作者:Ark
        /// 时间:2014.08.05
        /// 描述:短信发送
        /// </summary>
        /// <param name="smsList">短信列表信息</param>
        /// <returns></returns>
        public SmsResult Send(List<SmsModel> smsList)
        {
            SmsResult smsRet = new SmsResult();
            // 转为json字符串
            string jsonSms = JsonHelper.ToJson(smsList);
            //try
            //{
            //    // 实例化服务
            //    APIServiceClient client = new APIServiceClient();
            //    // 调用发送短信,返回结果为json字符串
            //    string ret = client.(jsonSms);
            //    smsRet = JsonHelper.FromJson<SmsResult>(ret);
            //    // 关闭
            //    client.Close();
            //}
            //catch (Exception ex)
            //{
            //    smsRet.Code = 101;
            //    smsRet.Msg = "调用SmsForEme服务异常,请联系管理员!";
            //}

            //2015-1-15号换成直接调用供应商(亿美)接口进行短信发送
            SmsToEme.SDKClientClient client = new SDKClientClient();

            foreach (var item in smsList)
            {
                try
                {

                    var content = item.Message;
                    List<string> mobiles = new List<string>() { item.Mobile };
                    var serial = item.Serial;
                    var smsId = item.SmsId;
                    //var mresult = new MobileResult();
                    int result = client.sendSMS(SerialNo, SoftwareKey, "", mobiles.ToArray(), content, serial, "GBK", 5, smsId);
                    //记录日志
                    //Common.Log4Helper.WriteLog("mobile:"+mobiles.ToString()+",content:"+content+",senttime:"+DateTime.Now+",resutl:"+result);
                    if (result == 0)
                    {
                        smsRet.Count += 1;
                        smsRet.Code = result;
                        smsRet.Msg = GetErrMsgByCode(result);
                    }
                }
                catch (Exception ex)
                {
                    smsRet.Code = 101;
                    smsRet.Msg = "调用SmsToEme服务异常,请联系管理员!";
                }
            }
            client.Close();
            return smsRet;
        }
Exemple #7
0
 /// 通道开通注册
 /// </summary>
 /// <param name="serialpass"></param>
 /// <returns></returns>
 public int registEx(string serialpass)
 {
     SmsToEme.SDKClientClient client = new SDKClientClient();
     var result= client.registEx(SerialNo, SoftwareKey, serialpass);
     return result;
 }