/// <summary> /// 通知WCF信息反馈 /// </summary> /// <param name="tfr"></param> public void OnTFReponseHandlerEvent(tfReponse tfr) { var handler = TFReponseHandlerEvent; if (handler != null) { handler(tfr); } }
public string TFRequset(string request) { tfr = new tfReponse() { Result = false }; _mre = new ManualResetEvent(false); try { tfRequest tf = new tfRequest(); tf = (tfRequest)JSON.JsonToObject(request, tf); if (tf == null || string.IsNullOrEmpty(tf.Zjhm)) { tfr.Result = false; tfr.ErrMsg = "消息格式错误无法序列化或者主叫号码为空"; } else { string ZJHM = tf.Zjhm; LogUtility.DataLog.WriteLog(LogUtility.LogLevel.Info, "WCF_TFReuset收到请求,主叫号码:" + ZJHM, new LogUtility.RunningPlace("ThreeFieldWCF", "TFReuset"), "软件业务处理"); if (control.ts != null && control.ts.OnlineClents.Count > 0) { control.TFReponseHandlerEvent += Control_TFReponseHandlerEvent; control.ts.BroadCastMessage(BuildTFRequestFromModel(ZJHM), ClientType.TF); bool blntimeout = _mre.WaitOne(new TimeSpan(0, 0, SysParameters.WCFTimeout)); if (blntimeout) { LogUtility.DataLog.WriteLog(LogUtility.LogLevel.Info, "WCF_TFReuset正常反馈请求,主叫号码:" + ZJHM + ",Reponse:" + JSON.ObjectToJson(tfr), new LogUtility.RunningPlace("ThreeFieldWCF", "TFReuset"), "软件业务处理"); } else { tfr.Result = false; tfr.ErrMsg = "WCF_TFReuset反馈请求超时"; LogUtility.DataLog.WriteLog(LogUtility.LogLevel.Info, "WCF_TFReuset超时反馈请求,主叫号码:" + ZJHM + ",Reponse:" + JSON.ObjectToJson(tfr), new LogUtility.RunningPlace("ThreeFieldWCF", "TFReuset"), "软件业务处理"); } //初始化变量 control.TFReponseHandlerEvent -= Control_TFReponseHandlerEvent; } else { tfr.ErrMsg = "WCF尚未与三字段服务器正常连接,请检查与三字段服务器之间的TCP连接"; LogUtility.DataLog.WriteLog(LogUtility.LogLevel.Info, "WCF_TFReuset三字段服务器没有连接上,主叫号码:" + ZJHM, new LogUtility.RunningPlace("ThreeFieldWCF", "TFReuset"), "软件业务处理"); } } } catch (Exception ex) { tfr.Result = false; tfr.ErrMsg = ex.Message; LogUtility.DataLog.WriteLog(LogUtility.LogLevel.Error, ex.Message.ToString(), new LogUtility.RunningPlace("TFRequset", "ThreeFieldWCF"), "WCF错误"); } string reponse = JSON.ObjectToJson(tfr); return(reponse); }
private void Handle2051Message(string msg) { try { tfReponse tfr = new tfReponse(); tfr.Tfinfo.Zjhm = GetValueByKey(msg, "ZJHM"); tfr.Tfinfo.Dz = GetValueByKey(msg, "DZ"); tfr.Tfinfo.Hz = GetValueByKey(msg, "HZ"); LogUtility.DataLog.WriteLog(LogUtility.LogLevel.Info, "三字段服务器登陆", new LogUtility.RunningPlace("ThreeFieldMsgHandler", "Handle8000Message"), "软件业务处理"); CoreService.GetInstance().OnTFReponseHandlerEvent(tfr); } catch (Exception ex) { } }
private void Control_TFReponseHandlerEvent(tfReponse t) { try { LogUtility.DataLog.WriteLog(LogUtility.LogLevel.Info, "WCF_TFReuset结束TCP反馈,主叫号码:" + t.Tfinfo.Zjhm, new LogUtility.RunningPlace("Control_TFReponseHandlerEvent", "TFReuset"), "软件业务处理"); lock (tfr) { tfr.Result = true; tfr.Tfinfo = t.Tfinfo; _mre.Set(); } } catch (Exception ex) { lock (tfr) { tfr.Result = false; tfr.ErrMsg = ex.Message; LogUtility.DataLog.WriteLog(LogUtility.LogLevel.Error, ex.Message.ToString(), new LogUtility.RunningPlace("TFRequset", "Control_TFReponseHandlerEvent"), "WCF错误"); } } }