示例#1
0
        public virtual Object InvokeWCFService(string controller, string method, string jsondata)
        {
            if (string.IsNullOrEmpty(jsondata))
            {
                jsondata = "[]";
            }
            string retJson = WcfClientManage.Request(_pluginName + "@" + controller, method, jsondata);

            object Result = JsonConvert.DeserializeObject(retJson);
            int    ret    = Convert.ToInt32(((Newtonsoft.Json.Linq.JObject)(Result))["flag"]);
            string msg    = ((Newtonsoft.Json.Linq.JObject)(Result))["msg"].ToString();

            if (ret == 1)
            {
                throw new Exception(msg);
            }
            else
            {
                return(((Newtonsoft.Json.Linq.JObject)(Result))["data"]);
            }
        }
示例#2
0
        /*
         * //客户端手动调用此方法进行Json字符串压缩,服务端的方法也要对应压缩,还要实现自动压缩
         * public virtual Object InvokeWCFServiceCompress(string controller, string method, string jsondata)
         * {
         *  if (string.IsNullOrEmpty(jsondata)) jsondata = "[]";
         *  jsondata = ZipComporessor.Compress(jsondata);//压缩传入参数
         *  string retJson= WcfClientManage.Request(_pluginName+"@"+controller, method, jsondata);
         *
         *  object Result = JsonConvert.DeserializeObject(retJson);
         *  int ret = Convert.ToInt32(((Newtonsoft.Json.Linq.JObject)(Result))["flag"]);
         *  string msg = ((Newtonsoft.Json.Linq.JObject)(Result))["msg"].ToString();
         *  if (ret == 1)
         *  {
         *      throw new Exception(msg);
         *  }
         *  else
         *  {
         *      //解压输出结果
         *      return JsonConvert.DeserializeObject(ZipComporessor.Decompress(((Newtonsoft.Json.JArray)((Newtonsoft.Json.Linq.JObject)(Result))["data"])[0].ToString()));
         *  }
         * }*/

        public virtual IAsyncResult InvokeWCFServiceAsync(string controller, string method, string jsondata, Action <Object> action)
        {
            if (string.IsNullOrEmpty(jsondata))
            {
                jsondata = "[]";
            }
            Action <string> retAction = delegate(string retJson)
            {
                object Result = JsonConvert.DeserializeObject(retJson);
                int    ret    = Convert.ToInt32(((Newtonsoft.Json.Linq.JObject)(Result))["flag"]);
                string msg    = ((Newtonsoft.Json.Linq.JObject)(Result))["msg"].ToString();
                if (ret == 1)
                {
                    throw new Exception(msg);
                }
                else
                {
                    action(((Newtonsoft.Json.Linq.JObject)(Result))["data"]);
                }
            };

            return(WcfClientManage.RequestAsync(_pluginName + "@" + controller, method, jsondata, retAction));
        }
示例#3
0
        public virtual Object InvokeWCFServiceCompress(string controller, string method, string jsondata)
        {
            if (string.IsNullOrEmpty(jsondata))
            {
                jsondata = "[]";
            }
            jsondata = ZipComporessor.Compress(jsondata);//压缩传入参数
            string retJson = WcfClientManage.Request(_pluginName + "@" + controller, method, jsondata);

            object Result = JavaScriptConvert.DeserializeObject(retJson);
            int    ret    = Convert.ToInt32(((Newtonsoft.Json.JavaScriptObject)(Result))["flag"]);
            string msg    = ((Newtonsoft.Json.JavaScriptObject)(Result))["msg"].ToString();

            if (ret == 1)
            {
                throw new Exception(msg);
            }
            else
            {
                //解压输出结果
                return(JavaScriptConvert.DeserializeObject(ZipComporessor.Decompress(((Newtonsoft.Json.JavaScriptArray)((Newtonsoft.Json.JavaScriptObject)(Result))["data"])[0].ToString())));
            }
        }