Esempio n. 1
0
        public ReturnMsgDC ExecRequest(string targetFile, Hashtable htbParams)
        {
            string baseUrl = DCConf.GetDCUrl(this.ProdType, this.MethodType);
            string url     = $"{ baseUrl.TrimEnd('/')}/{targetFile}";

            if (htbParams != null && htbParams.Count > 0)
            {
                List <string> lstValues = new List <string>();
                foreach (string key in htbParams.Keys)
                {
                    lstValues.Add($"{key}={htbParams[key]}");
                }
                url = $"{url}?{ string.Join("&", lstValues.ToArray())}";
            }
            HttpComm comm = new HttpComm();
            Dictionary <string, string> dicRequestParams = new Dictionary <string, string>();

            dicRequestParams.Add("url", url);
            HttpResult result = comm.ExecWebRequest(dicRequestParams);

            if (result.IsSucceed)
            {
                return(this.ResolveD2(result.Content));
            }
            else
            {
                throw new Exception("请求DC发生异常", result.HttpException);
            }
        }
Esempio n. 2
0
        public ReturnMsgListDC ExecRequestList(string targetFile, Hashtable htbParams)
        {
            string baseUrl = DCConf.GetDCUrl(this.ProdType, this.MethodType);
            string url     = $"{ baseUrl.TrimEnd('/')}/{targetFile}";

            if (htbParams != null && htbParams.Count > 0)
            {
                List <string> lstValues = new List <string>();
                foreach (string key in htbParams.Keys)
                {
                    lstValues.Add($"{key}={htbParams[key]}");
                }
                url = $"{url}?{ string.Join("&", lstValues.ToArray())}";
            }
            HttpComm comm = new HttpComm();
            Dictionary <string, string> dicRequestParams = new Dictionary <string, string>();

            dicRequestParams.Add("url", url);
            HttpResult result = comm.ExecWebRequest(dicRequestParams);

            if (result.IsSucceed)
            {
                string[]           strArray = result.Content.Split("\n".ToCharArray());
                int                code     = -1;
                List <CLSObject[]> data     = new List <CLSObject[]>();
                for (int i = 0; i < strArray.Length; i++)
                {
                    string[] strArray2 = strArray[i].Split(",".ToCharArray());
                    if ((i == 0) && (strArray2.Length >= 1))
                    {
                        code = int.Parse(strArray2[0]);
                    }
                    CLSObject[] item = new CLSObject[strArray2.Length];
                    for (int j = 0; j < strArray2.Length; j++)
                    {
                        item[j] = strArray2[j];
                    }
                    data.Add(item);
                }
                return(new DC.ReturnMsgListDC(true, result.Content, code, data));
            }
            else
            {
                throw new Exception("请求DC发生异常", result.HttpException);
            }
        }
Esempio n. 3
0
        // 检查普通验证码是否正常
        public static ReturnMsg Func_CheckSmsCode(int number, string telnum, string smscode)
        {
            string     baseUrl    = DC2Conf.MPFUrlHeader;
            string     isProg     = DC2Conf.IsProg.ToString();
            string     url        = $"{baseUrl}&&isprog={isProg}&action=checkcode&number={number}&telnum={telnum}&code={smscode}";
            HttpComm   comm       = new HttpComm();
            HttpResult httpResult = comm.ExecWebRequest(url);

            //string urltext = CLSTemplate.Transform2(urlformat, cht_data);
            //CLSInterfaceReturn cir = new CLSInterfaceReturn().initWithContentsOfURL(urltext);
            //return Operator.RetFor(cir.Succeed, cir.Message, cir.Code);

            if (httpResult.IsSucceed)
            {
                return(new ReturnMsg2980(httpResult.Content));
            }
            else
            {
                throw httpResult.HttpException;
            }
        }