/// <summary> /// 检查WebService服务器状态(激活webservice服务器)。 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void tmrServiceRunStatus_Tick(object sender, EventArgs e) { try { if (this.tcpPassiveEngine == null || this.tcpPassiveEngine.IsConnected == false) { fastPrintNetClient.GetServiceRunStatus(); MainForm_Load(null, null); } else { this.tmrServiceRunStatus.Enabled = false; this.tmrServiceRunStatus.Stop(); } } catch (Exception ex) { NLogHelper.Instance.Error(ex.Message); } }
public MessageMainForm() { //初始化窗口组件 InitializeComponent(); Control.CheckForIllegalCrossThreadCalls = false; //显示登录账号信息 this.notifyIcon.Text = string.Format("登录账号:[{0}]", GlobalStatic.UserId); this.Text = string.Format("{0}—【{1}】", this.Text, GlobalStatic.UserId); RegisterFormEvents(); try { //开启心跳数据包 tmrHeartBeat = new System.Threading.Timer(HeartBeatCallBack, null, mHeartBeatInterval, mHeartBeatInterval); //初始化远程服务对象 fastPrintNetClient = new FastPrintNetService(); fastPrintNetClient.Url = string.Concat(AppContext.AppServiceConfig.RemoteWebServiceURL.TrimEnd(new char[] { '/' }), "/FastPrintNetService.asmx"); fastPrintNetClient.EnableDecompression = true; fastPrintNetClient.GetServiceRunStatus();//检查接口状态 this.WebServiceConneted = true; } catch (WebException wex) { if (wex.Status == WebExceptionStatus.ConnectFailure || wex.Status == WebExceptionStatus.ProtocolError || wex.Status == WebExceptionStatus.NameResolutionFailure) { WriteToolStripMsg("与WebSevice服务器连接失败,请联系技术支持!", Color.Red); this.WebServiceConneted = false; this.tmrServiceRunStatus.Enabled = true; this.tmrServiceRunStatus.Start(); } } catch (Exception ex) { WriteToolStripMsg("系统出错,请联系技术支持!", Color.Red); this.WebServiceConneted = false; this.tmrServiceRunStatus.Enabled = true; this.tmrServiceRunStatus.Start(); } }
/// <summary> /// 初始化加载:该方法暂时未用到 /// </summary> private void InitLoading() { Thread t = new Thread(() => { string lastShowInfo = string.Empty; Stopwatch sw1 = new Stopwatch(); sw1.Start(); bool blFinish = true; try { this.BeginInvoke(new MethodInvoker(() => { this.btnLogin.Enabled = false; })); #region [=>(1)、检查版本更新] WriteToolStripMsg("正在检查版本更新..."); #endregion #region [=>(2)、检查服务连接状态] WriteToolStripMsg("正在检查与服务器连接,请耐心等待..."); //=>WebService服务器 WriteToolStripMsg("正在检查与WebService服务器连接状态..."); string web_Result = string.Empty; web_Result = fastPrintNetClient.GetServiceRunStatus(); if (web_Result == "ok") { ////=>DB数据库服务器 //WriteToolStripMsg("正在检查与数据库服务器连接状态..."); //string db_Result = string.Empty; //db_Result = foundationService.GetDBServiceRunStatus(); ////=>aip服务器 //string api_Result = string.Empty; //WriteToolStripMsg("正在检查与PHP API服务器连接状态..."); //api_Result = loginAPIService.GetAPIRunStatus(); //sw1.Stop(); //if (api_Result == "ok" // && db_Result == "ok") //{ //} } else { WriteToolStripMsg(string.Format("Web服务请求拒绝:{0}", web_Result), Color.Red); blFinish = false; return; } #endregion } catch (Exception ex) { WriteToolStripMsg("系统出错,请联系技术支持!", Color.Red); this.BeginInvoke(new MethodInvoker(() => { this.btnLogin.Enabled = false; })); } finally { if (this.IsHandleCreated) { this.BeginInvoke(new MethodInvoker(() => { if (blFinish) { lastShowInfo = "与服务器连接正常,耗时:" + sw1.ElapsedMilliseconds + "ms"; WriteToolStripMsg(lastShowInfo); } this.BeginInvoke(new MethodInvoker(delegate() { this.btnLogin.Enabled = true; })); })); } } }); t.IsBackground = true; t.Start(); }