private void btnStart_Click(object sender, EventArgs e) { timermsg.Start(); MiddlewareLogHelper.hostwcfMsg = new MiddlewareMsgHandler(AddMsg); MiddlewareLogHelper.StartWriteFileLog();//开放中间件日志 int res = TimeCDKEY.InitRegedit(out expireDate, out identify); if (res == 0) { MiddlewareLogHelper.WriterLog(LogType.MidLog, true, Color.Green, "软件已注册,到期时间【" + expireDate + "】"); StartAllHost(); } else if (res == 1) { MiddlewareLogHelper.WriterLog(LogType.MidLog, true, Color.Red, "软件尚未注册,请注册软件"); } else if (res == 2) { MiddlewareLogHelper.WriterLog(LogType.MidLog, true, Color.Red, "注册机器与本机不一致,请联系管理员"); } else if (res == 3) { MiddlewareLogHelper.WriterLog(LogType.MidLog, true, Color.Red, "软件试用已到期"); } else { MiddlewareLogHelper.WriterLog(LogType.MidLog, true, Color.Red, "软件运行出错,请重新启动"); } }
public string ProcessHttpRequest(RequestArgs requestArgs) { MiddlewareLogHelper.WriterLog(LogType.MidLog, true, Color.Blue, "接受Http请求:" + requestArgs.ToString()); //获取的池子索引 int? index = null; ClientLink clientlink = null; ClientLinkPool pool = fromPoolGetClientLink(requestArgs.plugin, out clientlink, out index); ServiceResponseData retData = new ServiceResponseData(); try { //绑定LoginRight Action <ClientRequestData> _requestAction = ((ClientRequestData request) => { request.LoginRight = requestArgs.sysright; request.SetJsonData(requestArgs.jsondata); }); retData = clientlink.Request(requestArgs.controller, requestArgs.method, _requestAction); } catch (Exception ex) { throw ex; } finally { if (index != null) { pool.ReturnPool(requestArgs.plugin, (int)index); } } return(retData.GetJsonData()); }
/// <summary> /// 重新连接wcf服务,服务端存在ClientID /// </summary> /// <param name="isRequest">是否请求调用</param> private void ReConnection(bool isRequest) { try { if (baseServiceClient.State == CommunicationState.Closed || baseServiceClient.State == CommunicationState.Faulted) { CreateConnection(); } //else { // baseServiceClient.Open(); // clientObj.WcfService = baseServiceClient; // if (createconnAction != null) // { // createconnAction(); // } //} if (isRequest == true) //避免死循环 { Heartbeat(); //重连之后必须再次调用心跳 } MiddlewareLogHelper.WriterLog(LogType.MidLog, true, Color.Red, "重新连接上级中间件成功!"); } catch { //throw new Exception(err.Message); } }
public static void Main() { webapiHost = new WebApiSelfHosting(System.Configuration.ConfigurationSettings.AppSettings["WebApiUri"]); webapiHost.StartHost(); MiddlewareLogHelper.WriterLog(LogType.MidLog, true, Color.Blue, "WebAPI服务启动完成"); }
private static List <PublishServiceObject> LoadXML() { List <PublishServiceObject> _serviceList = new List <PublishServiceObject>(); try { XmlDocument xmlDoc = new System.Xml.XmlDocument(); xmlDoc.Load(publishSubscibefile); XmlNodeList pubservicelist = xmlDoc.DocumentElement.SelectNodes("Publish/service"); foreach (XmlNode xe in pubservicelist) { PublishServiceObject serviceObj = new PublishServiceObject(); serviceObj.whether = xe.Attributes["switch"].Value == "1" ? true : false; serviceObj.publishServiceName = xe.Attributes["servicename"].Value; serviceObj.explain = xe.Attributes["explain"].Value; serviceObj.pluginname = xe.Attributes["pluginname"].Value; serviceObj.controller = xe.Attributes["controller"].Value; serviceObj.method = xe.Attributes["method"].Value; serviceObj.argument = xe.Attributes["argument"].Value; _serviceList.Add(serviceObj); } } catch (Exception e) { MiddlewareLogHelper.WriterLog(LogType.TimingTaskLog, true, System.Drawing.Color.Red, "加载定时任务配置文件错误!"); MiddlewareLogHelper.WriterLog(LogType.TimingTaskLog, true, System.Drawing.Color.Red, e.Message); } return(_serviceList); }
//[AOP(typeof(AopTransaction))] public ServiceResponseData AutoDepositFeeRunninAccount() { try { int[] iWorkIDList = requestData.GetData <int[]>(0); foreach (int iWorkId in iWorkIDList) { SetWorkId(iWorkId); MiddlewareLogHelper.WriterLog(LogType.TimingTaskLog, true, System.Drawing.Color.Red, "------------------------------------------------------------------------------------"); bool b = NewDao <IIPManageDao>().InsertIPAccountBookData(1); MiddlewareLogHelper.WriterLog(LogType.TimingTaskLog, true, (b?System.Drawing.Color.Blue: System.Drawing.Color.Red), DateTime.Now.ToString("yyyy-MM-dd") + (b ? " 住院每日预交金流水发送成功!" : " 住院每日预交金流水发送失败!")); MiddlewareLogHelper.WriterLog(LogType.TimingTaskLog, true, System.Drawing.Color.Red, "------------------------------------------------------------------------------------"); } return(responseData); } catch (Exception e) { MiddlewareLogHelper.WriterLog(LogType.TimingTaskLog, true, System.Drawing.Color.Red, "------------------------------------------------------------------------------------"); MiddlewareLogHelper.WriterLog(LogType.TimingTaskLog, true, System.Drawing.Color.Red, DateTime.Now.ToString("yyyy-MM-dd") + " 住院每日预交金流水发送异常!"); MiddlewareLogHelper.WriterLog(LogType.TimingTaskLog, true, System.Drawing.Color.Red, "住院每日预交金流水自动发送错误信息:"); MiddlewareLogHelper.WriterLog(LogType.TimingTaskLog, true, System.Drawing.Color.Red, " " + e.Message); MiddlewareLogHelper.WriterLog(LogType.TimingTaskLog, true, System.Drawing.Color.Red, "------------------------------------------------------------------------------------"); return(null); } }
private void StopAllHost() { MiddlewareLogHelper.WriterLog(LogType.MidLog, true, Color.Red, "正在准备关闭中间件服务,请等待..."); WcfGlobal.Exit(); WebApiGlobal.Exit(); RunState = HostState.NoOpen; }
/// <summary> /// 客户端执行订阅服务 /// </summary> /// <param name="_clientLink"></param> public static void ProcessPublishService(string publishServiceName, ClientLink _clientLink) { switch (publishServiceName) { case "DistributedCache": //分布式缓存服务 List <CacheIdentify> ciList = DistributedCacheClient.GetCacheIdentifyList(); List <CacheObject> coList = _clientLink.GetDistributedCacheData(ciList); if (coList.Count > 0) { DistributedCacheClient.SetCacheObjectList(coList); } break; case "RemotePlugin": //远程插件服务 LocalPlugin localPlugin = RemotePluginClient.GetLocalPlugin(); if (localPlugin.PluginDic.Count > 0) { _clientLink.RegisterRemotePlugin(WcfGlobal.Identify, localPlugin.PluginDic.Keys.ToArray()); } break; case "UpgradeClient": //客户端升级 ClientUpgradeManager.DownLoadUpgrade(); break; case "UpgradeServer": //中间件升级 break; case "MongodbSync": //同步Mongodb数据 break; case "MiddlewareMonitor": //中间件集群监控服务 break; case "MiddlewareCmd": //中间件命令服务 break; default: PublishServiceObject pso = psoList.Find(x => x.publishServiceName == publishServiceName); MiddlewareLogHelper.WriterLog(LogType.MidLog, true, System.Drawing.Color.Blue, string.Format("正在执行服务{0}/{1}/{2}/{3}", pso.pluginname, pso.controller, pso.method, pso.argument)); ServiceResponseData retjson = InvokeWcfService( pso.pluginname , pso.controller , pso.method , (ClientRequestData request) => { request.SetJsonData(pso.argument); }); string txtResult = retjson.GetJsonData(); MiddlewareLogHelper.WriterLog(LogType.MidLog, true, System.Drawing.Color.Blue, string.Format("服务执行完成,返回结果:{0}", txtResult)); break; } ShowHostMsg(Color.Blue, DateTime.Now, "执行“" + publishServiceName + "”订阅服务成功!"); }
public ServiceResponseData MZ_Register() { InputClass inputClass = requestData.GetData <InputClass>(0); MiddlewareLogHelper.WriterLog(LogType.MILog, true, Color.Blue, "确认登记开始,病人门诊号:"); ResultClass resultClass = NewObject <ActionObjectFactory>().MZ_Register(inputClass); MiddlewareLogHelper.WriterLog(LogType.MILog, true, Color.Blue, "确认登记结束,结果:" + resultClass.bSucess); responseData.AddData(resultClass.bSucess); responseData.AddData(resultClass.sRemarks); responseData.AddData(resultClass.oResult); return(responseData); }
public ServiceResponseData M_UpdateMIlog() { int ybId = requestData.GetData <int>(0); int workId = requestData.GetData <int>(1); int logType = requestData.GetData <int>(2); MiddlewareLogHelper.WriterLog(LogType.MILog, true, Color.Blue, "接口测试,医保ID:" + ybId); bool b = NewObject <ActionObjectFactory>().M_UpdateMIlog(ybId, workId, logType); responseData.AddData(b); MiddlewareLogHelper.WriterLog(LogType.MILog, false, Color.Blue, "接口测试:" + ybId); return(responseData); }
private static void CreateSuperClient() { //就算上级中间件重启了,下级中间件创建链接的时候会重新注册本地插件 superClientLink = new ClientLink(WcfGlobal.HostName, "SuperPlugin", null, WcfGlobal.Identify, null); try { superClientLink.CreateConnection(); } catch (Exception e) { MiddlewareLogHelper.WriterLog(LogType.MidLog, true, Color.Red, "连接上级中间件失败!" + e.Message); } }
public ServiceResponseData Mz_GetPersonInfo() { InputClass inputClass = requestData.GetData <InputClass>(0); MiddlewareLogHelper.WriterLog(LogType.MILog, true, Color.Blue, "读卡,获取病人信息开始,卡号:"); ResultClass resultClass = NewObject <ActionObjectFactory>().MZ_GetPersonInfo(inputClass); MiddlewareLogHelper.WriterLog(LogType.MILog, true, Color.Blue, "读卡,获取病人信息结束,结果:" + resultClass.bSucess); responseData.AddData(resultClass.bSucess); responseData.AddData(resultClass.sRemarks); responseData.AddData(resultClass.oResult); return(responseData); }
private void btnrestart_Click(object sender, EventArgs e) { if (MessageBox.Show("您确定要重启中间件服务器吗?", "询问窗", MessageBoxButtons.YesNo, MessageBoxIcon.Question, MessageBoxDefaultButton.Button2) == DialogResult.Yes) { try { MiddlewareLogHelper.WriterLog(LogType.MidLog, true, Color.Red, "正在准备重启中间件服务,请等待..."); StopAllHost(); Application.Restart(); } catch { } this.Dispose(true); } }
public ServiceResponseData GetBooks() { try { int[] vals = requestData.GetData <int[]>(0); MiddlewareLogHelper.WriterLog(LogType.MILog, true, Color.Red, "医保接口日志记录"); DataTable dt = NewDao <IBookDao>().GetBooks("", 0); responseData.AddData(vals); responseData.AddData(dt); return(responseData); } catch (Exception e) { throw new Exception("hhyhwhs"); } }
public ServiceResponseData CallAPI() { string servicecode = requestData.GetData <String>(0); string jsonpara = requestData.GetData <String>(1); string scriptText; MiddlewareLogHelper.WriterLog(LogType.PythonLog, "开始执行Python脚本,业务代码:" + servicecode); bool result = EFWCoreLib.WcfFrame.Utility.AdapterScriptHelper.GetAdapterScript(GetPluginName(), out scriptText); if (result) { ScriptEngine engine = IronPython.Hosting.Python.CreateEngine(); engine.SetSearchPaths(new string[] { EFWCoreLib.CoreFrame.Init.AppGlobal.AppRootPath + "PythonLib" }); ScriptScope scope = engine.CreateScope(); //ScriptSource script = engine.CreateScriptSourceFromFile(@"test01.py", Encoding.UTF8); //"print 'hello kakake'" //ScriptSource script = engine.CreateScriptSourceFromString(@" //__author__ = 'kakake' //import sys //def main(args): // try: // print 'Succeed!!!' // return 'hello %s' %args // except Exception,ex: // print 'Error!!!',Exception,':',ex; // return -1; //#main('') //"); scope.SetVariable("adapter", this); ScriptSource script = engine.CreateScriptSourceFromString(scriptText); script.Execute(scope); var fun_main = scope.GetVariable <Func <object, object, object> >("main"); object funResult = fun_main(servicecode, jsonpara); if (funResult == null || funResult.ToString() == "-1") { throw new Exception("Python脚本执行错误"); } responseData.AddData(funResult.ToString()); } MiddlewareLogHelper.WriterLog(LogType.PythonLog, "Python脚本执行完成,业务代码:" + servicecode); return(responseData); }
public static void ExitBase() { if (IsStartBase == false) { return; } IsStartBase = false;//设置为开启 MiddlewareLogHelper.WriterLog(LogType.MidLog, true, Color.Red, "正在准备关闭中间件服务,请等待..."); ClientLinkManage.UnAllConnection();//关闭所有连接 WcfGlobal.Quit(StartType.MiddlewareTask); WcfGlobal.Quit(StartType.SuperClient); WcfGlobal.Quit(StartType.BaseService); WcfGlobal.Quit(StartType.FileService); WcfGlobal.Quit(StartType.HttpService); }
public ServiceResponseData Zy_UploadzyPatFee() { int iPatientId = requestData.GetData <int>(0); int iFlag = requestData.GetData <int>(1); MiddlewareLogHelper.WriterLog(LogType.MILog, true, Color.Blue, "上传病人费用,病人ID:" + iPatientId + " 开始"); bool b = NewObject <ActionObjectFactory>().Zy_UploadzyPatFee(iPatientId, iFlag); string s = ""; SiInterface.Open(out s); MiddlewareLogHelper.WriterLog(LogType.MILog, true, Color.Blue, "上传病人费用,病人ID:" + iPatientId + " 结束,结果:" + b); MiddlewareLogHelper.WriterLog(LogType.MILog, true, Color.Red, s); responseData.AddData(b); return(responseData); }
public ServiceResponseData AutoSendAccountCheckList() { try { int[] iWorkIDList = requestData.GetData <int[]>(0); foreach (int iWorkId in iWorkIDList) { SetWorkId(iWorkId); DateTime endTime = DateTime.Now; int iPatientID = -1; int empID = 0; #region 1.账单记账 DataTable dtFeeAccountID = NewDao <IOrderCheckDao>().GetFeeAccount(iPatientID, endTime); if (dtFeeAccountID != null && dtFeeAccountID.Rows.Count > 0) { List <int> feeAccountIDList = new List <int>(); foreach (DataRow dr in dtFeeAccountID.Rows) { feeAccountIDList.Add(Convert.ToInt32(dr["GenerateID"])); } bool b = NewObject <DocOrderExpenseCheck>().FeeItemAccounting(feeAccountIDList, endTime, empID); MiddlewareLogHelper.WriterLog(LogType.TimingTaskLog, true, System.Drawing.Color.Red, "------------------------------------------------------------------------------------"); MiddlewareLogHelper.WriterLog(LogType.TimingTaskLog, true, System.Drawing.Color.Blue, DateTime.Now.ToString("yyyy-MM-dd") + (b ? " 账单自动发送成功!" : " 账单自动发送失败!")); MiddlewareLogHelper.WriterLog(LogType.TimingTaskLog, true, System.Drawing.Color.Red, "------------------------------------------------------------------------------------"); } #endregion } return(responseData); } catch (Exception e) { MiddlewareLogHelper.WriterLog(LogType.TimingTaskLog, true, System.Drawing.Color.Red, "------------------------------------------------------------------------------------"); MiddlewareLogHelper.WriterLog(LogType.TimingTaskLog, true, System.Drawing.Color.Red, DateTime.Now.ToString("yyyy-MM-dd") + " 账单自动发送异常!"); MiddlewareLogHelper.WriterLog(LogType.TimingTaskLog, true, System.Drawing.Color.Red, "账单自动发送错误信息:"); MiddlewareLogHelper.WriterLog(LogType.TimingTaskLog, true, System.Drawing.Color.Red, " " + e.Message); MiddlewareLogHelper.WriterLog(LogType.TimingTaskLog, true, System.Drawing.Color.Red, "------------------------------------------------------------------------------------"); return(null); } }
public static ClientLink superclient;//连接上级中间件超级客户端 public static void CreateSuperClient() { //就算上级中间件重启了,下级中间件创建链接的时候会重新注册本地插件 superclient = new ClientLink(WcfGlobal.HostName, null); try { superclient.CreateConnection((() => { //以后可以做成配置方式 //foreach (var item in PublishServiceManage.serviceDic.Keys) //{ // superclient.Subscribe(item);//订阅服务? //} }), null); } catch (Exception e) { MiddlewareLogHelper.WriterLog(LogType.MidLog, true, Color.Red, "连接上级中间件失败!" + e.Message); } }
private static void downloadRemoteFile() { DownFile df = new DownFile(); df.clientId = SuperClient.superclient.clientObj.ClientID; df.DownKey = Guid.NewGuid().ToString(); df.FileName = "update.xml"; df.FileType = 1; SuperClient.superclient.DownLoadFile(df, updatexml, null); df = new DownFile(); df.clientId = SuperClient.superclient.clientObj.ClientID; df.DownKey = Guid.NewGuid().ToString(); df.FileName = "update.zip"; df.FileType = 1; SuperClient.superclient.DownLoadFile(df, updatezip, (delegate(int _num) { MiddlewareLogHelper.WriterLog(LogType.MidLog, true, System.Drawing.Color.Black, "客户端升级包下载进度:%" + _num); })); }
static void Main() { try { MiddlewareLogHelper.hostwcfMsg = new MiddlewareMsgHandler(ShowMsg); MiddlewareLogHelper.StartWriteFileLog();//开放中间件日志 WcfGlobal.MainRoute(); } catch (Exception e) { Console.WriteLine(e.Message); } while (true) { System.Threading.Thread.Sleep(30 * 1000); } }
//从根节点下载 private static void downloadRemotePlugin(string pluginzip, ClientLink _clientLink) { DownFile df = new DownFile(); df.clientId = Guid.NewGuid().ToString(); df.DownKey = Guid.NewGuid().ToString(); df.FileName = pluginzip; df.FileType = 0; FileStream fs = new FileStream(rootpath + pluginzip, FileMode.Create, FileAccess.Write); try { _clientLink.RootDownLoadFile(df, fs, (delegate(int _num) //从根节点下载 { MiddlewareLogHelper.WriterLog(LogType.MidLog, true, System.Drawing.Color.Black, "插件包下载进度:%" + _num); })); } catch (Exception err) { CoreFrame.Common.MiddlewareLogHelper.WriterLog(err.Message + err.StackTrace); } }
public ServiceResponseData AutoSendBedCheckList() { try { int[] iWorkIDList = requestData.GetData <int[]>(0); foreach (int iWorkId in iWorkIDList) { SetWorkId(iWorkId); DateTime endTime = DateTime.Now; int iPatientID = -1; int empID = 0; #region 1.床位费记账 DataTable bedPatientIDList = NewDao <IOrderCheckDao>().GetBedPatientIdList(iPatientID); if (bedPatientIDList != null) { MiddlewareLogHelper.WriterLog(LogType.TimingTaskLog, true, System.Drawing.Color.Red, "------------------------------------------------------------------------------------"); foreach (DataRow dr in bedPatientIDList.Rows) { bool b = NewObject <DocOrderExpenseCheck>().BedFeeAccounting(Convert.ToInt32(dr["PatListID"]), endTime, empID); MiddlewareLogHelper.WriterLog(LogType.TimingTaskLog, true, (b ? System.Drawing.Color.Blue : System.Drawing.Color.Red), dr["DeptName"] + "-" + dr["PatName"] + "-" + DateTime.Now.ToString("yyyy-MM-dd") + (b ? " 床位费自动发送成功!" : " 床位费自动发送失败!")); } MiddlewareLogHelper.WriterLog(LogType.TimingTaskLog, true, System.Drawing.Color.Red, "------------------------------------------------------------------------------------"); } #endregion } return(responseData); } catch (Exception e) { MiddlewareLogHelper.WriterLog(LogType.TimingTaskLog, true, System.Drawing.Color.Red, "------------------------------------------------------------------------------------"); MiddlewareLogHelper.WriterLog(LogType.TimingTaskLog, true, System.Drawing.Color.Red, DateTime.Now.ToString("yyyy-MM-dd") + " 账单自动发送异常!"); MiddlewareLogHelper.WriterLog(LogType.TimingTaskLog, true, System.Drawing.Color.Red, "账单自动发送错误信息:"); MiddlewareLogHelper.WriterLog(LogType.TimingTaskLog, true, System.Drawing.Color.Red, " " + e.Message); MiddlewareLogHelper.WriterLog(LogType.TimingTaskLog, true, System.Drawing.Color.Red, "------------------------------------------------------------------------------------"); return(null); } }
public Message ProcessMessage(Message requestMessage) { try { //Binding binding = null; EndpointAddress endpointAddress = null; Uri touri = null; RouterManage.GetServiceEndpointFile(requestMessage, out endpointAddress, out touri); requestMessage.Headers.To = touri; NetTcpBinding tbinding = new NetTcpBinding("NetTcpBinding_FileService"); using (ChannelFactory <IRouterFileHandler> factory = new ChannelFactory <IRouterFileHandler>(tbinding, endpointAddress)) { factory.Endpoint.Behaviors.Add(new MustUnderstandBehavior(false)); IRouterFileHandler proxy = factory.CreateChannel(); using (proxy as IDisposable) { // 请求消息记录 IClientChannel clientChannel = proxy as IClientChannel; if (WcfGlobal.IsDebug) { MiddlewareLogHelper.WriterLog(LogType.MidLog, true, Color.Black, String.Format("路由请求消息发送: {0}", clientChannel.RemoteAddress.Uri.AbsoluteUri)); } // 调用绑定的终结点的服务方法 Message responseMessage = proxy.ProcessMessage(requestMessage); return(responseMessage); } } } catch (Exception e) { return(Message.CreateMessage(requestMessage.Version, FaultCode.CreateReceiverFaultCode("error", WcfGlobal.ns), e.Message, requestMessage.Headers.Action)); } }
private static void downloadRemoteFile(string updatexml, string updatezip, ClientLink _clientLink) { DownFile df = new DownFile(); df.clientId = Guid.NewGuid().ToString(); df.DownKey = Guid.NewGuid().ToString(); df.FileName = updatexml; df.FileType = 0; FileStream fs = new FileStream(rootpath + updatexml, FileMode.Create, FileAccess.Write); _clientLink.RootDownLoadFile(df, fs, null); df = new DownFile(); df.clientId = Guid.NewGuid().ToString(); df.DownKey = Guid.NewGuid().ToString(); df.FileName = updatezip; df.FileType = 0; fs = new FileStream(rootpath + updatezip, FileMode.Create, FileAccess.Write); _clientLink.RootDownLoadFile(df, fs, (delegate(int _num) { MiddlewareLogHelper.WriterLog(LogType.MidLog, true, System.Drawing.Color.Black, "升级包下载进度:%" + _num); })); }
private static Dictionary <string, bool> LoadXML() { Dictionary <string, bool> _subDic = new Dictionary <string, bool>(); try { XmlDocument xmlDoc = new System.Xml.XmlDocument(); xmlDoc.Load(publishSubscibefile); XmlNodeList subservicelist = xmlDoc.DocumentElement.SelectNodes("Subscibe/service"); foreach (XmlNode xe in subservicelist) { _subDic.Add(xe.Attributes["servicename"].Value, xe.Attributes["switch"].Value == "1" ? true : false); } } catch (Exception e) { MiddlewareLogHelper.WriterLog(LogType.TimingTaskLog, true, System.Drawing.Color.Red, "加载定时任务配置文件错误!"); MiddlewareLogHelper.WriterLog(LogType.TimingTaskLog, true, System.Drawing.Color.Red, e.Message); } return(_subDic); }
static void btnStart() { string identify; string expireDate; MiddlewareLogHelper.hostwcfMsg = new MiddlewareMsgHandler(ShowMsg); MiddlewareLogHelper.StartWriteFileLog();//开放中间件日志 int res = TimeCDKEY.InitRegedit(out expireDate, out identify); if (res == 0) { MiddlewareLogHelper.WriterLog("软件已注册,到期时间【" + expireDate + "】"); //WcfGlobal.Identify = identify; //EFWCoreLib.WcfFrame.ServerManage.ClientManage.clientinfoList = new ClientInfoListHandler(BindGridClient); //EFWCoreLib.WcfFrame.ServerManage.RouterManage.hostwcfRouter = new HostWCFRouterListHandler(BindGridRouter); WcfGlobal.MainBase(identify); RunState = HostState.Opened; } else if (res == 1) { MiddlewareLogHelper.WriterLog("软件尚未注册,请注册软件"); } else if (res == 2) { MiddlewareLogHelper.WriterLog("注册机器与本机不一致,请联系管理员"); } else if (res == 3) { MiddlewareLogHelper.WriterLog("软件试用已到期"); } else { MiddlewareLogHelper.WriterLog("软件运行出错,请重新启动"); } }
public Message ProcessMessage(Message requestMessage) { try { begintime(); IRouterBaseHandler proxy = null; HeaderParameter para = HeaderOperater.GetHeaderValue(requestMessage); if (RouterManage.routerDic.ContainsKey(para.routerid)) { proxy = RouterManage.routerDic[para.routerid]; para.replyidentify = RouterManage.headParaDic[para.routerid].replyidentify; } else { //Binding binding = null; EndpointAddress endpointAddress = null; Uri touri = null; para = RouterManage.AddClient(requestMessage, para, out endpointAddress, out touri); requestMessage.Headers.To = touri; IRouterBaseReply callback = OperationContext.Current.GetCallbackChannel <IRouterBaseReply>(); NetTcpBinding tbinding = new NetTcpBinding("NetTcpBinding_BaseService"); DuplexChannelFactory <IRouterBaseHandler> factory = new DuplexChannelFactory <IRouterBaseHandler>(new InstanceContext(new ReplyRouterBaseCallback(callback)), tbinding, endpointAddress); proxy = factory.CreateChannel(); //缓存会话 RouterManage.routerDic.Add(para.routerid, proxy); RouterManage.headParaDic.Add(para.routerid, para); } Message responseMessage = null; try { HeaderOperater.AddMessageHeader(requestMessage, para);//增加自定义消息头 responseMessage = proxy.ProcessMessage(requestMessage); } catch (CommunicationException e) { RouterManage.RemoveClient(para); throw e; } if (para.cmd == "Quit") { //关闭连接释放缓存会话 RouterManage.RemoveClient(para); } double outtime = endtime(); // 请求消息记录 if (WcfGlobal.IsDebug) { MiddlewareLogHelper.WriterLog(LogType.MidLog, true, Color.Black, String.Format("路由请求消息发送(耗时[" + outtime + "]): {0}", requestMessage.Headers.Action)); } return(responseMessage); } catch (Exception e) { return(Message.CreateMessage(requestMessage.Version, FaultCode.CreateReceiverFaultCode("error", RouterManage.ns), e.Message, requestMessage.Headers.Action)); } }
private void AddLog(string s) { MiddlewareLogHelper.WriterLog(LogType.MILog, true, Color.Blue, s); }
public void ExcuteOnTime(DateTime dt) { MiddlewareLogHelper.WriterLog(LogType.TimingTaskLog, true, System.Drawing.Color.Blue, string.Format("任务【下载客户端升级包】准备开始执行...")); ClientUpgradeManager.DownLoadUpgrade(); }