private void timer_Tick(object sender, EventArgs e) { txtCurrentTime.Text = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"); string[] weekdays = { "星期日", "星期一", "星期二", "星期三", "星期四", "星期五", "星期六" }; string week = weekdays[Convert.ToInt32(DateTime.Now.DayOfWeek)]; txtCurrentTime.Text += " " + week; //bool isPing=cpH.CheckPingIsSuccess("10.1.196.86"); //if(!isPing) //{ // FileHelpClass.WriteSysLog("ping 10.1.196.86 返回:" + isPing); //} CarMeasureClientViewModel viewModel = this.DataContext as CarMeasureClientViewModel; runTimeCount += 1; if ((viewModel.BullState == eBullTag.free || viewModel.BullState == eBullTag.init) && runTimeCount > 60 * viewModel.AutoRunTime) { int setTimerCount = 60 * viewModel.AutoRunTime; #region log LogModel log = new LogModel() { Origin = "汽车衡_" + ClientInfo.Name, FunctionName = "称点主窗体_MainWindow", Level = LogConstParam.LogLevel_Info, CreateTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"), Direction = LogConstParam.Directions_Out, Msg = "程序运行超过设定时间" + setTimerCount.ToString() + ",自动重启." }; Talent.ClinetLog.SysLog.Log(JsonConvert.SerializeObject(log)); #endregion //CloseInfos(); viewModel.ClosedHardWare(); System.Windows.Forms.Application.Restart(); //程序运行超过设定时间,自动重启 Application.Current.Shutdown(0); } #region 写日志 Talent.ClinetLog.TimeLog.Log(txtCurrentTime.Text + " BullState:" + viewModel.BullState); #endregion FileHelpClass.WriteTalent(DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")); //CheckIsGetWeight(); }
/// <summary> /// 关闭之前必须要关闭的活 /// </summary> private void CloseInfos() { try { if (_enableFileSync == true) { if (proSync != null && proSync.Id != 0 && proSync.HasExited == false) { uint msg = Win.RegisterWindowMessage(Win.msgstr); if (msg != 0) { Win.PostMessage(Win.HWND_BROADCAST, msg, IntPtr.Zero, IntPtr.Zero); // MessageBox.Show(Marshal.GetLastWin32Error().ToString()); } //proSync.CloseMainWindow(); //proSync.Close(); //proSync.Dispose(); #region log LogModel log = new LogModel() { Origin = "汽车衡_" + ClientInfo.Name, FunctionName = "称点主窗体_关闭文件上传的程序", Level = LogConstParam.LogLevel_Info, CreateTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"), Direction = LogConstParam.Directions_Out, Msg = "停止文件同步程序成功。" }; Talent.ClinetLog.SysLog.Log(JsonConvert.SerializeObject(log)); #endregion } } } catch { } CarMeasureClientViewModel viewModel = this.DataContext as CarMeasureClientViewModel; viewModel.CloseCheat(); if (!viewModel.IsSeatRestart) { try { if (viewModel != null) { //viewModel.SendBackTaskInfo(); } } catch { } viewModel.ClosedHardWare(); } //try //{ // if (_enableFileSync == true) // { // ClearPross("Talent.FIleSync"); // } // ClearPross("Talent.CarMeasureConfig"); //} //catch //{ //} ClearPross("Talent.FIleSync"); }