コード例 #1
0
ファイル: DCRequest.cs プロジェクト: P79N6A/projects
        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);
            }
        }
コード例 #2
0
ファイル: DCRequest.cs プロジェクト: P79N6A/projects
        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);
            }
        }