private void Window_Closed(object sender, EventArgs e) { WinSleepCtr.ResotreSleep(); WinSleepCtr.RestoreScreenSave(); _theadDeal.Stop(); base.Hide(); if (this.videopage != null) { this.videopage.Close(); } }
private void Window_Loaded(object sender, RoutedEventArgs e) { try { WinSleepCtr.PreventScreenSave(); WinSleepCtr.PreventSleep(true); //*******************端口连接部分 T_ReadConfig.ReadConfig(); //读取配置文件 T_ReadConfig.GetPIN(); //获取PIN码 AUTHORIZATION auth = new AUTHORIZATION(); auth.ClientId = M_Configuration.CLIENTID; //终端号 auth.Token = M_Configuration.TOKEN; //ConfigurationManager.AppSettings["Token"].ToString();//授权码 Client = new T_RpcClient(auth, M_Configuration.HOST, M_Configuration.PORT, M_Configuration.TIMEOUT); //StateClient = new T_RpcClient(auth, M_Configuration.HOST, M_Configuration.PORT, M_Configuration.TIMEOUT); // HeartClient = new T_RpcClient(auth, M_Configuration.HOST, M_Configuration.PORT, M_Configuration.TIMEOUT);//心跳 //票种名称 M_Configuration.RunState = 0;//自助售票运行状态 0表示正常 M_Configuration.TicketID_AName = T_SellTicketRecord.GetTicketTypeName(M_Configuration.TicketTypeID_1); M_Configuration.TicketID_BName = T_SellTicketRecord.GetTicketTypeName(M_Configuration.TicketTypeID_2); #region//暂时不用 ////获取票种信息 //try //{ // M_TicketTypeList.listTicketType = Client.TicketTypeSyncRpc(T_Date.ConvertDataTimeToLong(DateTime.Now)); //} //catch (Exception ex) //{ // _log.Error(typeof(MainWindow), ex); //} ////获取售售期信息 //try //{ // M_PeriodList.listPeriod = Client.SalePeriodSyncRpc(T_Date.ConvertDataTimeToLong(DateTime.Now)); //} //catch (Exception ex) //{ // _log.Error(typeof(MainWindow), ex); //} #endregion ////启动数据同步线程 _DataSyncThread = new Thread(new ThreadStart(_theadDeal.DataSyncThread)); _DataSyncThread.Name = "DataSyncThread"; _DataSyncThread.IsBackground = true; _DataSyncThread.Start(); _DataSyncThread.Priority = ThreadPriority.BelowNormal; Thread.Sleep(10); if (_DataSyncThread.IsAlive) { _log.Info("数据同步工作线程启动成功。"); } ////*******************端口连接部分 //强制回收线程 TGCThread = new T_GCThread(); GCThread = new Thread(new ThreadStart(TGCThread.DoWork)); GCThread.IsBackground = true; GCThread.Start(); if (GCThread.IsAlive) { _log.Error("强制回收线程启动成功!"); } string strSAM = M_Configuration.Samreadername; string strRFID = M_Configuration.RfidReadername; string strPIN = M_Configuration.Pin; try { rfidReaderTest = TicketHandlerAdapter.getRfidTicketHandler(Convert.ToInt32(M_Configuration.CLIENTID), strRFID, strSAM, Encoding.ASCII.GetBytes(strPIN)); } catch { // MessageBox.Show("初始化失败,请确认读卡器选择正确!"); } this.totaltimeout = int.Parse(ConfigHelper.GetConfigValue("window", "totaltimeout"));//操作最长时间 this.InitControlSize(); base.WindowState = WindowState.Maximized; base.WindowStyle = WindowStyle.None; base.ResizeMode = ResizeMode.NoResize; base.Left = 0.0; base.Top = 0.0; this.notice = new NoticePage(ConfigHelper.GetConfigValue("window", "notice"), double.Parse(ConfigHelper.GetConfigValue("window", "noticefontsize"))); this.topFrame.Content = this.notice; //this.videopage = new VideoPage(this); //this.topFrame.Content = this.videopage; this.imagepage = new ImageShowPage(this); this.middleFrame.Content = this.imagepage; pageTest = new FirstPage(this); this.operationpage = pageTest;//new FirstPage(this); this.mainFrame.Content = this.operationpage; //bool flag = SystemInfo.GetAllNetInfo() != null; //if (flag) //{ // this.MacStr = SystemInfo.GetAllNetInfo()[0].PhysAddr; //} this.countdowntimer = new DispatcherTimer(); this.countdowntimer.Interval = new TimeSpan(0, 0, 0, 1, 0); this.countdowntimer.Tick += new EventHandler(this.timer_Tick); this.countdowntimer.Start(); } catch (Exception ex) { _log.Error("服务器连接失败!"); _log.Error(typeof(MainWindow), ex); MessageBox.Show("服务器连接失败!", T_SellTicketRecord.str_Apption, MessageBoxButton.OK, MessageBoxImage.Information); base.Close(); } }