/// <summary> /// 向服务发送异步请求 /// 客户端建议不要用多线程,都采用异步请求方式 /// </summary> /// <param name="controller">控制器名称</param> /// <param name="method">方法名称</param> /// <param name="jsondata">数据</param> /// <returns>返回Json数据</returns> public static IAsyncResult RequestAsync(string controller, string method, string jsondata, Action <string> action) { try { if (WcfClientManage.IsCompressJson) //开启压缩 { jsondata = ZipComporessor.Compress(jsondata); //压缩传入参数 //jsondata = JsonComporessor.Compress(jsondata);//压缩传入参数 } IWCFHandlerService _wcfService = AppGlobal.cache.GetData("WCFService") as IWCFHandlerService; //string retJson; IAsyncResult result = null; using (var scope = new OperationContextScope(_wcfService as IContextChannel)) { var router = System.ServiceModel.Channels.MessageHeader.CreateHeader("routerID", myNamespace, AppGlobal.cache.GetData("routerID").ToString()); OperationContext.Current.OutgoingMessageHeaders.Add(router); AsyncCallback callback = delegate(IAsyncResult r) { string retJson = _wcfService.EndProcessRequest(r); if (WcfClientManage.IsCompressJson) { retJson = ZipComporessor.Decompress(retJson); //retJson = JsonComporessor.Decompress(retJson); } action(retJson); }; result = _wcfService.BeginProcessRequest(AppGlobal.cache.GetData("WCFClientID").ToString(), controller, method, jsondata, callback, null); } if (WcfClientManage.IsHeartbeat == false)//如果没有启动心跳,则请求发送心跳 { WcfClientManage.ServerConfigRequestState = false; Heartbeat(); } //return retJson; return(result); } catch (Exception e) { WcfClientManage.ServerConfigRequestState = false; ReConnection(true);//连接服务主机失败,重连 throw new Exception(e.Message + "\n连接服务主机失败,请联系管理员!"); } }
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()))); } }
/// <summary> /// 向服务发送异步请求 /// 客户端建议不要用多线程,都采用异步请求方式 /// </summary> /// <param name="controller">插件名@控制器名称</param> /// <param name="method">方法名称</param> /// <param name="jsondata">数据</param> /// <returns>返回Json数据</returns> public IAsyncResult RequestAsync(string controller, string method, Action <ClientRequestData> requestAction, Action <ServiceResponseData> action) { if (clientObj == null) { throw new Exception("还没有创建连接!"); } try { ClientRequestData requestData = new ClientRequestData(IsCompressJson, IsEncryptionJson, serializeType); if (requestAction != null) { requestAction(requestData); } string jsondata = requestData.GetJsonData(); //获取序列化的请求数据 if (requestData.Iscompressjson) //开启压缩 { jsondata = ZipComporessor.Compress(jsondata); //压缩传入参数 } if (requestData.Isencryptionjson) //开启加密 { DESEncryptor des = new DESEncryptor(); des.InputString = jsondata; des.DesEncrypt(); jsondata = des.OutString; } DuplexBaseServiceClient _wcfService = clientObj.WcfService; IAsyncResult result = null; AddMessageHeader(_wcfService.InnerDuplexChannel as IContextChannel, "", requestData.Iscompressjson, requestData.Isencryptionjson, requestData.Serializetype, requestData.LoginRight, (() => { AsyncCallback callback = delegate(IAsyncResult r) { string retJson = _wcfService.EndProcessRequest(r); if (requestData.Isencryptionjson)//解密结果 { DESEncryptor des = new DESEncryptor(); des.InputString = retJson; des.DesDecrypt(); retJson = des.OutString; } if (requestData.Iscompressjson)//解压结果 { retJson = ZipComporessor.Decompress(retJson); } string retData = ""; object Result = JsonConvert.DeserializeObject(retJson); int ret = Convert.ToInt32((((Newtonsoft.Json.Linq.JObject)Result)["flag"]).ToString()); string msg = (((Newtonsoft.Json.Linq.JObject)Result)["msg"]).ToString(); if (ret == 1) { throw new Exception(msg); } else { retData = ((Newtonsoft.Json.Linq.JObject)(Result))["data"].ToString(); } ServiceResponseData responsedata = new ServiceResponseData(); responsedata.Iscompressjson = requestData.Iscompressjson; responsedata.Isencryptionjson = requestData.Isencryptionjson; responsedata.Serializetype = requestData.Serializetype; responsedata.SetJsonData(retData); action(responsedata); }; result = _wcfService.BeginProcessRequest(clientObj.ClientID, clientObj.PluginName, controller, method, jsondata, callback, null); })); new Action(delegate() { if (IsHeartbeat == false)//如果没有启动心跳,则请求发送心跳 { ServerConfigRequestState = false; Heartbeat(); } }).BeginInvoke(null, null);//异步执行 return(result); } catch (Exception e) { ServerConfigRequestState = false; ReConnection(true);//连接服务主机失败,重连 throw new Exception(e.Message + "\n连接服务主机失败,请联系管理员!"); } }
/// <summary> /// 向服务发送请求 /// </summary> /// <param name="controller">控制器名称</param> /// <param name="method">方法名称</param> /// <param name="requestAction">数据</param> /// <returns>返回Json数据</returns> public ServiceResponseData Request(string controller, string method, Action <ClientRequestData> requestAction) { if (clientObj == null) { throw new Exception("还没有创建连接!"); } while (baseServiceClient.State == CommunicationState.Opening || clientObj.ClientID == null)//解决并发问题 { Thread.Sleep(400); } if (baseServiceClient.State == CommunicationState.Closed || baseServiceClient.State == CommunicationState.Faulted) { ReConnection(true);//连接服务主机失败,重连 } try { ClientRequestData requestData = new ClientRequestData(serverConfig.IsCompressJson, serverConfig.IsEncryptionJson, (SerializeType)serverConfig.SerializeType); if (requestAction != null) { requestAction(requestData); } string jsondata = requestData.GetJsonData(); //获取序列化的请求数据 if (requestData.Iscompressjson) //开启压缩 { jsondata = ZipComporessor.Compress(jsondata); //压缩传入参数 } if (requestData.Isencryptionjson) //开启加密 { DESEncryptor des = new DESEncryptor(); des.InputString = jsondata; des.DesEncrypt(); jsondata = des.OutString; } string retJson = ""; #if ClientProxy BaseServiceClient _wcfService = clientObj.WcfService; AddMessageHeader(_wcfService.InnerChannel as IContextChannel, "", requestData.Iscompressjson, requestData.Isencryptionjson, requestData.Serializetype, requestData.LoginRight, (() => { retJson = _wcfService.ProcessRequest(clientObj.ClientID, clientObj.PluginName, controller, method, jsondata); })); #else DuplexBaseServiceClient _wcfService = clientObj.WcfService; AddMessageHeader(_wcfService.InnerDuplexChannel as IContextChannel, "", requestData.Iscompressjson, requestData.Isencryptionjson, requestData.Serializetype, requestData.LoginRight, (() => { retJson = _wcfService.ProcessRequest(clientObj.ClientID, clientObj.PluginName, controller, method, jsondata); })); #endif if (requestData.Isencryptionjson)//解密结果 { DESEncryptor des = new DESEncryptor(); des.InputString = retJson; des.DesDecrypt(); retJson = des.OutString; } if (requestData.Iscompressjson)//解压结果 { retJson = ZipComporessor.Decompress(retJson); } new Action(delegate() { if (serverConfig.IsHeartbeat == false)//如果没有启动心跳,则请求发送心跳 { ServerConfigRequestState = false; Heartbeat(); } }).BeginInvoke(null, null);//异步执行 string retData = ""; object Result = JsonConvert.DeserializeObject(retJson); int ret = Convert.ToInt32((((Newtonsoft.Json.Linq.JObject)Result)["flag"]).ToString()); string msg = (((Newtonsoft.Json.Linq.JObject)Result)["msg"]).ToString(); if (ret == 1) { throw new Exception(msg); } else { retData = ((Newtonsoft.Json.Linq.JObject)(Result))["data"].ToString(); } ServiceResponseData responsedata = new ServiceResponseData(); responsedata.Iscompressjson = requestData.Iscompressjson; responsedata.Isencryptionjson = requestData.Isencryptionjson; responsedata.Serializetype = requestData.Serializetype; responsedata.SetJsonData(retData); return(responsedata); } catch (Exception e) { ServerConfigRequestState = false; //ReConnection(true);//连接服务主机失败,重连 //throw new Exception(e.Message + "\n连接服务主机失败,请联系管理员!"); throw new Exception(e.Message); } }
public static string ProcessRequest(string clientId, string plugin, string controller, string method, string jsondata, HeaderParameter para) { string retJson = null; try { if (plugin == null || controller == null) { throw new Exception("插件名称或控制器名称不能为空!"); } if (ClientManage.ClientDic.ContainsKey(clientId) == false) { throw new Exception("客户端不存在,正在创建新的连接!"); } if (ClientManage.IsToken == true)//非调试模式下才验证 { //验证身份,创建连接的时候验证,请求不验证 IsAuth(plugin, controller, method, para.token); } //显示调试信息 if (WcfGlobal.IsDebug == true) { ShowHostMsg(Color.Black, DateTime.Now, "客户端[" + clientId + "]正在执行:" + controller + "." + method + "(" + jsondata + ")"); } begintime(); #region 执行插件控制器的核心算法 object[] paramValue = null;//jsondata? ServiceResponseData retObj = null; LocalPlugin localPlugin = RemotePluginManage.GetLocalPlugin(); if (string.IsNullOrEmpty(para.replyidentify) || localPlugin.ServerIdentify == para.replyidentify) { if (localPlugin.PluginDic.ContainsKey(plugin) == true) { //先解密再解压 string _jsondata = jsondata; //解密参数 if (para.isencryptionjson) { DESEncryptor des = new DESEncryptor(); des.InputString = _jsondata; des.DesDecrypt(); _jsondata = des.OutString; } //解压参数 if (para.iscompressjson) { _jsondata = ZipComporessor.Decompress(_jsondata); } ClientRequestData requestData = new ClientRequestData(para.iscompressjson, para.isencryptionjson, para.serializetype); requestData.SetJsonData(_jsondata); requestData.LoginRight = para.LoginRight; EFWCoreLib.CoreFrame.Plugin.ModulePlugin moduleplugin = localPlugin.PluginDic[plugin]; retObj = (ServiceResponseData)moduleplugin.WcfServerExecuteMethod(controller, method, paramValue, requestData); if (retObj != null) { retJson = retObj.GetJsonData(); } else { retObj = new ServiceResponseData(); retObj.Iscompressjson = para.iscompressjson; retObj.Isencryptionjson = para.isencryptionjson; retObj.Serializetype = para.serializetype; retJson = retObj.GetJsonData(); } retJson = "{\"flag\":0,\"msg\":" + "\"\"" + ",\"data\":" + retJson + "}"; //先压缩再加密 //压缩结果 if (para.iscompressjson) { retJson = ZipComporessor.Compress(retJson); } //加密结果 if (para.isencryptionjson) { DESEncryptor des = new DESEncryptor(); des.InputString = retJson; des.DesEncrypt(); retJson = des.OutString; } } else { throw new Exception("本地插件找不到指定的插件"); } } else//本地插件找不到,就执行远程插件 { if (RemotePluginManage.GetRemotePlugin().FindIndex(x => x.ServerIdentify == para.replyidentify) > -1) { RemotePlugin rp = RemotePluginManage.GetRemotePlugin().Find(x => x.ServerIdentify == para.replyidentify); string[] ps = rp.plugin; if (ps.ToList().FindIndex(x => x == plugin) > -1) { retJson = rp.callback.ReplyProcessRequest(para, plugin, controller, method, jsondata); } else { throw new Exception("远程插件找不到指定的插件"); } } else { throw new Exception("远程插件找不到指定的回调中间件"); } } #endregion double outtime = endtime(); //记录超时的方法 if (ClientManage.IsOverTime == true) { if (outtime > Convert.ToDouble(ClientManage.OverTime * 1000)) { WriterOverTimeLog(outtime, controller + "." + method + "(" + jsondata + ")"); } } //显示调试信息 if (WcfGlobal.IsDebug == true) { ShowHostMsg(Color.Green, DateTime.Now, "客户端[" + clientId + "]收到结果(耗时[" + outtime + "]):" + retJson); } //更新客户端信息 ClientManage.UpdateRequestClient(clientId, jsondata == null ? 0 : jsondata.Length, retJson == null ? 0 : retJson.Length); if (retJson == null) { throw new Exception("插件执行未返回有效数据"); } return(retJson); } catch (Exception err) { //记录错误日志 if (err.InnerException == null) { retJson = "{\"flag\":1,\"msg\":" + "\"" + err.Message + "\"" + "}"; if (para.iscompressjson) { retJson = ZipComporessor.Compress(retJson); } ShowHostMsg(Color.Red, DateTime.Now, "客户端[" + clientId + "]执行失败:" + err.Message); return(retJson); } else { retJson = "{\"flag\":1,\"msg\":" + "\"" + err.InnerException.Message + "\"" + "}"; if (para.iscompressjson) { retJson = ZipComporessor.Compress(retJson); } ShowHostMsg(Color.Red, DateTime.Now, "客户端[" + clientId + "]执行失败:" + err.InnerException.Message); return(retJson); } } }
public static string ReplyProcessRequest(string plugin, string controller, string method, string jsondata, HeaderParameter para) { string retJson = null; try { //显示调试信息 if (WcfGlobal.IsDebug == true) { ShowHostMsg(Color.Black, DateTime.Now, "客户端[本地回调]正在执行:" + controller + "." + method + "(" + jsondata + ")"); } begintime(); #region 执行插件控制器的核心算法 object[] paramValue = null;//jsondata? ServiceResponseData retObj = null; LocalPlugin localPlugin = RemotePluginManage.GetLocalPlugin(); if (string.IsNullOrEmpty(para.replyidentify) || localPlugin.ServerIdentify == para.replyidentify) { if (localPlugin.PluginDic.ContainsKey(plugin) == true) { //先解密再解压 string _jsondata = jsondata; //解密参数 if (para.isencryptionjson) { DESEncryptor des = new DESEncryptor(); des.InputString = _jsondata; des.DesDecrypt(); _jsondata = des.OutString; } //解压参数 if (para.iscompressjson) { _jsondata = ZipComporessor.Decompress(_jsondata); } ClientRequestData requestData = new ClientRequestData(para.iscompressjson, para.isencryptionjson, para.serializetype); requestData.SetJsonData(_jsondata); requestData.LoginRight = para.LoginRight; EFWCoreLib.CoreFrame.Plugin.ModulePlugin moduleplugin = localPlugin.PluginDic[plugin]; retObj = (ServiceResponseData)moduleplugin.WcfServerExecuteMethod(controller, method, paramValue, requestData); if (retObj != null) { retJson = retObj.GetJsonData(); } else { retObj = new ServiceResponseData(); retObj.Iscompressjson = para.iscompressjson; retObj.Isencryptionjson = para.isencryptionjson; retObj.Serializetype = para.serializetype; retJson = retObj.GetJsonData(); } retJson = "{\"flag\":0,\"msg\":" + "\"\"" + ",\"data\":" + retJson + "}"; //先压缩再加密 //压缩结果 if (para.iscompressjson) { retJson = ZipComporessor.Compress(retJson); } //加密结果 if (para.isencryptionjson) { DESEncryptor des = new DESEncryptor(); des.InputString = retJson; des.DesEncrypt(); retJson = des.OutString; } } else { throw new Exception("本地插件找不到指定的插件"); } } else//本地插件找不到,就执行远程插件 { if (RemotePluginManage.GetRemotePlugin().FindIndex(x => x.ServerIdentify == para.replyidentify) > -1) { RemotePlugin rp = RemotePluginManage.GetRemotePlugin().Find(x => x.ServerIdentify == para.replyidentify); string[] ps = rp.plugin; if (ps.ToList().FindIndex(x => x == plugin) > -1) { retJson = rp.callback.ReplyProcessRequest(para, plugin, controller, method, jsondata); } else { throw new Exception("远程插件找不到指定的插件"); } } else { throw new Exception("远程插件找不到指定的回调中间件"); } } #endregion //System.Threading.Thread.Sleep(20000);//测试并发问题,此处也没有问题 double outtime = endtime(); //记录超时的方法 if (ClientManage.IsOverTime == true) { if (outtime > Convert.ToDouble(ClientManage.OverTime * 1000)) { WriterOverTimeLog(outtime, controller + "." + method + "(" + jsondata + ")"); } } //显示调试信息 if (WcfGlobal.IsDebug == true) { ShowHostMsg(Color.Green, DateTime.Now, "客户端[本地回调]收到结果(耗时[" + outtime + "]):" + retJson); } if (retJson == null) { throw new Exception("请求的插件未获取到有效数据"); } return(retJson); } catch (Exception err) { //记录错误日志 //EFWCoreLib.CoreFrame.EntLib.ZhyContainer.CreateException().HandleException(err, "HISPolicy"); if (err.InnerException == null) { retJson = "{\"flag\":1,\"msg\":" + "\"" + err.Message + "\"" + "}"; if (para.iscompressjson) { retJson = ZipComporessor.Compress(retJson); } ShowHostMsg(Color.Red, DateTime.Now, "客户端[本地回调]执行失败:" + err.Message); return(retJson); } else { retJson = "{\"flag\":1,\"msg\":" + "\"" + err.InnerException.Message + "\"" + "}"; if (para.iscompressjson) { retJson = ZipComporessor.Compress(retJson); } ShowHostMsg(Color.Red, DateTime.Now, "客户端[本地回调]执行失败:" + err.InnerException.Message); return(retJson); } } }
//执行服务核心方法 private static string ExecuteService(string plugin, string controller, string method, string jsondata, HeaderParameter para) { string retJson = null; try { #region 执行插件控制器的核心算法 object[] paramValue = null;//jsondata? ServiceResponseData retObj = null; //先解密再解压 string _jsondata = jsondata; //解密参数 if (para.isencryptionjson) { DESEncryptor des = new DESEncryptor(); des.InputString = _jsondata; des.DesDecrypt(); _jsondata = des.OutString; } //解压参数 if (para.iscompressjson) { _jsondata = ZipComporessor.Decompress(_jsondata); } ClientRequestData requestData = new ClientRequestData(para.iscompressjson, para.isencryptionjson, para.serializetype); requestData.SetJsonData(_jsondata); requestData.LoginRight = para.LoginRight; //获取插件服务 EFWCoreLib.CoreFrame.Plugin.ModulePlugin moduleplugin = CoreFrame.Init.AppPluginManage.PluginDic[plugin]; retObj = (ServiceResponseData)moduleplugin.WcfServerExecuteMethod(controller, method, paramValue, requestData); if (retObj != null) { retJson = retObj.GetJsonData(); } else { retObj = new ServiceResponseData(); retObj.Iscompressjson = para.iscompressjson; retObj.Isencryptionjson = para.isencryptionjson; retObj.Serializetype = para.serializetype; retJson = retObj.GetJsonData(); } retJson = "{\"flag\":0,\"msg\":" + "\"\"" + ",\"data\":" + retJson + "}"; //先压缩再加密 //压缩结果 if (para.iscompressjson) { retJson = ZipComporessor.Compress(retJson); } //加密结果 if (para.isencryptionjson) { DESEncryptor des = new DESEncryptor(); des.InputString = retJson; des.DesEncrypt(); retJson = des.OutString; } #endregion return(retJson); } catch (Exception err) { throw err; } }
/// <summary> /// 向服务发送请求 /// </summary> /// <param name="controller">控制器名称</param> /// <param name="method">方法名称</param> /// <param name="requestAction">数据</param> /// <returns>返回Json数据</returns> public ServiceResponseData Request(string controller, string method, Action <ClientRequestData> requestAction) { if (mConn == null) { throw new Exception("还没有创建连接!"); } try { ClientRequestData requestData = new ClientRequestData(IsCompressJson, IsEncryptionJson, serializeType); if (requestAction != null) { requestAction(requestData); } string jsondata = requestData.GetJsonData(); //获取序列化的请求数据 if (requestData.Iscompressjson) //开启压缩 { jsondata = ZipComporessor.Compress(jsondata); //压缩传入参数 } IWCFHandlerService _wcfService = mConn.WcfService; string retJson = ""; AddMessageHeader(_wcfService as IContextChannel, "", requestData.Iscompressjson, requestData.Isencryptionjson, requestData.Serializetype, (() => { retJson = _wcfService.ProcessRequest(mConn.ClientID, mConn.PluginName + "@" + controller, method, jsondata); })); if (requestData.Iscompressjson) { retJson = ZipComporessor.Decompress(retJson); //retJson = JsonComporessor.Decompress(retJson); } new Action(delegate() { if (IsHeartbeat == false)//如果没有启动心跳,则请求发送心跳 { ServerConfigRequestState = false; Heartbeat(); } }).BeginInvoke(null, null);//异步执行 string retData = ""; object Result = JsonConvert.DeserializeObject(retJson); int ret = Convert.ToInt32((((Newtonsoft.Json.Linq.JObject)Result)["flag"]).ToString()); string msg = (((Newtonsoft.Json.Linq.JObject)Result)["msg"]).ToString(); if (ret == 1) { throw new Exception(msg); } else { retData = ((Newtonsoft.Json.Linq.JObject)(Result))["data"].ToString(); } ServiceResponseData responsedata = new ServiceResponseData(); responsedata.Iscompressjson = requestData.Iscompressjson; responsedata.Isencryptionjson = requestData.Isencryptionjson; responsedata.Serializetype = requestData.Serializetype; responsedata.SetJsonData(retData); return(responsedata); } catch (Exception e) { ServerConfigRequestState = false; ReConnection(true);//连接服务主机失败,重连 throw new Exception(e.Message + "\n连接服务主机失败,请联系管理员!"); } }
public static string ProcessRequest(string clientId, string controller, string method, string jsondata) { string retJson = null; WCFClientInfo ClientInfo = null; try { lock (wcfClientDic) { if (wcfClientDic.ContainsKey(clientId) == false) { throw new Exception("客户端不存在,正在创建新的连接!"); } ClientInfo = wcfClientDic[clientId].Clone() as WCFClientInfo; } //显示调试信息 if (WcfServerManage.IsDebug == true) { ShowHostMsg(Color.Black, DateTime.Now, "客户端[" + clientId + "]正在执行:" + controller + "." + method + "(" + jsondata + ")"); } begintime(); object[] paramValue = null;//jsondata? //解压参数 string _jsondata = jsondata; if (WcfServerManage.IsCompressJson) { _jsondata = ZipComporessor.Decompress(jsondata); //_jsondata = JsonComporessor.Decompress(jsondata); } string[] names = controller.Split(new char[] { '@' }); if (names.Length != 2) { throw new Exception("控制器名称错误!"); } string pluginname = names[0]; string cname = names[1]; Object retObj = null; if (AppPluginManage.PluginDic.ContainsKey(pluginname) == true) { EFWCoreLib.CoreFrame.Plugin.ModulePlugin plugin = AppPluginManage.PluginDic[pluginname]; retObj = plugin.WcfServerExecuteMethod(cname, method, paramValue, _jsondata, ClientInfo); } else { throw new Exception("请求的插件未找到"); } if (retObj != null) { retJson = retObj.ToString(); } retJson = "{\"flag\":0,\"msg\":" + "\"\"" + ",\"data\":" + retJson + "}"; //压缩结果 if (WcfServerManage.IsCompressJson) { retJson = ZipComporessor.Compress(retJson); //retJson = JsonComporessor.Compress(retJson); } //System.Threading.Thread.Sleep(20000);//测试并发问题,此处也没有问题 double outtime = endtime(); //记录超时的方法 if (WcfServerManage.IsOverTime == true) { if (outtime > Convert.ToDouble(WcfServerManage.OverTime * 1000)) { WriterOverTimeLog(outtime, controller + "." + method + "(" + _jsondata + ")"); } } //显示调试信息 if (WcfServerManage.IsDebug == true) { ShowHostMsg(Color.Green, DateTime.Now, "客户端[" + clientId + "]收到结果(耗时[" + outtime + "]):" + retJson); } //更新客户端信息 UpdateRequestClient(clientId, jsondata == null ? 0 : jsondata.Length, retJson == null ? 0 : retJson.Length); return(retJson); } catch (Exception err) { //记录错误日志 //EFWCoreLib.CoreFrame.EntLib.ZhyContainer.CreateException().HandleException(err, "HISPolicy"); if (err.InnerException == null) { retJson = "{\"flag\":1,\"msg\":" + "\"" + err.Message + "\"" + "}"; if (WcfServerManage.IsCompressJson) { retJson = ZipComporessor.Compress(retJson); //retJson = JsonComporessor.Compress(retJson); } ShowHostMsg(Color.Red, DateTime.Now, "客户端[" + clientId + "]执行失败:" + err.Message); return(retJson); } else { retJson = "{\"flag\":1,\"msg\":" + "\"" + err.InnerException.Message + "\"" + "}"; if (WcfServerManage.IsCompressJson) { retJson = ZipComporessor.Compress(retJson); //retJson = JsonComporessor.Compress(retJson); } ShowHostMsg(Color.Red, DateTime.Now, "客户端[" + clientId + "]执行失败:" + err.InnerException.Message); return(retJson); } } }