Ejemplo n.º 1
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;
            }
        }
Ejemplo n.º 2
0
        public static getBalanceResponse getBalance(Environment env, getBalance request)
        {
            DomesticRemittanceByPartnerServiceClient client = createClient(env);

            request.version = VERSION;

            using (new System.ServiceModel.OperationContextScope((System.ServiceModel.IClientChannel)client.InnerChannel))
            {
                System.Net.ServicePointManager.SecurityProtocol = env.getSecurityProtocol();

                System.ServiceModel.Web.WebOperationContext.Current.OutgoingRequest.UserAgent = "APIBanking.NET";


                IDictionaryEnumerator headers = env.getHeaders().GetEnumerator();
                while (headers.MoveNext())
                {
                    System.ServiceModel.Web.WebOperationContext.Current.OutgoingRequest.Headers.Add(headers.Key.ToString(), headers.Value.ToString());
                }

                getBalanceResponse response = client.getBalance(request);

                return(response);
            }
        }