Example #1
0
        public static HsResultData parseData(string rtnString)
        {
            if (rtnString == null)
            {
                return(HsResultData.InnerError());
            }
            HsResultData returnData = new HsResultData();

            JObject jo = JObject.Parse(rtnString);
            Dictionary <string, object> rtnResults = jo.ToObject <Dictionary <string, object> >();

            returnData.ErrorId   = Int32.Parse(rtnResults["ErrorId"].ToString());
            returnData.ErrorInfo = rtnResults["ErrorInfo"].ToString();

            if (rtnResults["Result"] == null)
            {
                returnData.ResultString = null;
            }
            else
            {
                returnData.ResultString = rtnResults["Result"];
            }


            return(returnData);
        }
Example #2
0
        private static HsResultData InnerError()
        {
            HsResultData rtnError = new HsResultData();

            rtnError.ErrorId   = 9999;
            rtnError.ErrorInfo = "系统内部错误";

            return(rtnError);
        }
Example #3
0
        internal static HsResultData parseBinData(string srResult)
        {
            HsResultData returnData = new HsResultData();

            returnData.ErrorId   = 200;
            returnData.ErrorInfo = "";


            returnData.ResultString = srResult;

            return(returnData);
        }
Example #4
0
        internal HsResultData dispatcherCommand(HsApply applyData)
        {
            string urlHeader = applyData.UrlHeader;


            string urlTemplate = null;

            if (applyData.CommandString == "LOGIN_SYSTEM" || applyData.CommandString == "FETCH_MENUS")
            {
                urlTemplate =
                    String.Format("/api/{0}/?Command={1}&TimeSnap=mmm&Sig=20151023", "user", applyData.CommandString);
            }
            else
            {
                urlTemplate =
                    String.Format("/api/{0}/?Command={1}&TimeSnap=mmm&Sig=20151023", GlobalConfig.getMenu(applyData.CommandString).PreApi, applyData.CommandString);
            }

            string ecuteUrl = applyData.getAbusoluteUrl(urlHeader, urlTemplate);

            string srResult;

            if (applyData.InvokeType == InvType.GET)
            {
                srResult = HsExcute.HttpGet(ecuteUrl);

                if (applyData.ReturnType != 0)
                {
                    return(HsResultData.parseBinData(srResult));
                }
            }
            else
            {
                string postData = applyData.getPostData();

                srResult = HsExcute.PostMoths(ecuteUrl, postData);
            }


            return(HsResultData.parseData(srResult));
        }