/// <summary> /// 手动发送计量任务(测试使用) /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void Button_Click(object sender, RoutedEventArgs e) { CarMeasureClientViewModel viewModel = this.DataContext as CarMeasureClientViewModel; System.Threading.Tasks.Task.Factory.StartNew(() => { Thread.Sleep(10000); viewModel.Weight = 0; }); InputBusinessInfos bInfosView = new InputBusinessInfos(); bInfosView.Owner = this; bInfosView.ShowDialog(); if (!string.IsNullOrEmpty(bInfosView.BusinessInfoJson)) { viewModel.ReceiveIcNo(bInfosView.BusinessInfoJson); } //MeasureServiceModel msm = InfoExchange.DeConvert(typeof(MeasureServiceModel), bInfosView.BusinessInfoJson) as MeasureServiceModel; //TaskModel carTaskModel = new TaskModel //{ // CreateTime = DateTime.Now, // ClientId = ClientInfo.ClientId, // ClientName = ClientInfo.Name, // IsBusinessInfoQuery = false, // CarNumber = "鲁A00001", // MeasureType = "现场自助", // ErrorMsg = "业务不完整", // Weight = 120.38M, // ServiceModel = msm //}; //string paraJsonStr = JsonConvert.SerializeObject(carTaskModel);// Talent.CommonMethod.InfoExchange.ToJson(carTaskModel); //SocketCls.Emit(ClientSendCmdEnum.measureData, paraJsonStr); }
/// <summary> /// 车号显示值改变事件(临时不可见的textBox,用以清楚窗体中的"重量"信息) /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void CarNoTempTextBox_TextChanged(object sender, TextChangedEventArgs e) { if (string.IsNullOrEmpty(this.CarNoTempTextBox.Text.Trim())) { CarMeasureClientViewModel tvm = (CarMeasureClientViewModel)this.DataContext; tvm.CarTaskModel = null; } }
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> /// <param name="sender"></param> /// <param name="e"></param> private void fullScreenTb_IsEnabledChanged(object sender, DependencyPropertyChangedEventArgs e) { if ((bool)e.NewValue == true) { try { CarMeasureClientViewModel cmcvm = this.DataContext as CarMeasureClientViewModel; if (cmcvm.inputPlanCodeView != null) { cmcvm.inputPlanCodeView.Activate(); cmcvm.inputPlanCodeView.businessNoTextBlock.Focus(); } else { this.Topmost = true; this.WindowState = WindowState.Maximized; this.Focus(); this.Activate(); this.Topmost = false; } this.fullScreenTb.IsEnabled = false; } catch (Exception ex) { #region log LogModel log = new LogModel() { Origin = "汽车衡_" + ClientInfo.Name, FunctionName = "称点主窗体_接收全屏命令后触发的事件", Level = LogConstParam.LogLevel_Error, CreateTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"), Direction = LogConstParam.Directions_Out, Msg = "接收全屏命令后触发的事件异常:" + ex.Message }; Talent.ClinetLog.SysLog.Log(JsonConvert.SerializeObject(log)); #endregion } } }
private void Button_Click1(object sender, RoutedEventArgs e) { CarMeasureClientViewModel viewModel = this.DataContext as CarMeasureClientViewModel; viewModel.TestOpenInputPlanCodeView(); //// System.Windows.Forms.Application.Restart(); //// //CarMeasureClientViewModel viewModel = this.DataContext as CarMeasureClientViewModel; ////this.userNotic.Content = viewModel.TestCardNo;//测试滚动显示文字 ////this.userNotic.DataContext = viewModel.TestCardNo; //viewModel.iic_OnReadCardNo("COM1", viewModel.TestCardNo); ////viewModel.getBllRulesServiceInfo("鲁GM8925", "", "", 0, "", ClientInfo.ClientId, 1); ////viewModel.iic_OnReadCardNo("COM1", ""); ////viewModel.iwc.IsFinish = true; ////viewModel.BullState = eBullTag.end; ////List<ReaderInfo> rlist = new List<ReaderInfo>(); ////for (int i = 0; i < 10; i++) ////{ //// ReaderInfo info0 = new ReaderInfo(); //// info0.no = i; //// info0.bindStr = "carno"; //// info0.lblText = "车 号"; //// rlist.Add(info0); ////} ////rendergv.Children.Clear(); ////for (int i = rendergv.RowDefinitions.Count - 1; i > -1; i--) ////{ //// rendergv.RowDefinitions.RemoveAt(i); ////} ////RenderMainUI ui = new RenderMainUI(500, rendergv, viewModel.CarTaskModel.BullInfo, rlist); ////ui.SetRenderMainUI(); }
/// <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"); }
/// <summary> /// 窗体按键事件 /// </summary> private void Window_KeyDown(object sender, KeyEventArgs e) { if (e.IsDown) { this.WindowState = WindowState.Maximized; CarMeasureClientViewModel viewModel = this.DataContext as CarMeasureClientViewModel; if (viewModel.MeasureTypeInfo == eMeasureType.远程计量.ToString())//如果是远程计量, 键盘按键 不起作用……2016-3-31 15:38:26…… { return; } int keyData = Convert.ToInt32(Enum.Parse(typeof(Key), e.Key.ToString())); if (viewModel.ikb != null) { var keyCode = viewModel.ikb.GetKeyCommand(keyData); if (keyCode == Keyboard.Interface.KeyCommand.OK) { #region 写日志 LogModel log = new LogModel() { CreateTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"), Msg = "获取当前系统的BullState:" + viewModel.BullState + "是否摁过:" + viewModel.isEnterOK + "是否允许恩下:" + viewModel.isAllowEnterOk, FunctionName = "称点主窗体_Window_KeyDown", Origin = "汽车衡_" + ClientInfo.Name, Level = LogConstParam.LogLevel_Info }; Talent.ClinetLog.SysLog.Log(JsonConvert.SerializeObject(log)); #endregion if (viewModel.BullState == eBullTag.metering || viewModel.BullState == eBullTag.specification) { if (!viewModel.isAllowEnterOk)//当系统提示允许恩确认键时 { return; } if (viewModel.isEnterOK)//恩过 确认键之后 { return; } if (viewModel.isEnterOnly)//摁过求助键 不允许再摁回撤键 { return; } viewModel.isEnterOnly = true; #region 写日志 LogModel kLog = new LogModel() { CreateTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"), Msg = "车号:" + viewModel.CarNumber + "按下确认键准备保存重量", FunctionName = "称点主窗体_Window_KeyDown", Origin = "汽车衡_" + ClientInfo.Name, Level = LogConstParam.LogLevel_Info }; Talent.ClinetLog.SysLog.Log(JsonConvert.SerializeObject(kLog)); #endregion Thread t1 = new Thread(new ThreadStart(viewModel.saveWeightServiceInfo)); t1.Start(); } } else if (keyCode == Keyboard.Interface.KeyCommand.CANCEL) { if (viewModel.isEnterCancel) { return; } //if (!string.IsNullOrEmpty(viewModel.measureServiceResult) && viewModel.measureServiceResult != null && !string.IsNullOrEmpty(viewModel.CarNumber)) //{ // std.Stop(); // Thread t1 = new Thread(new ThreadStart(viewModel.tipMsg)); // t1.Start(); //} } else if (keyCode == Keyboard.Interface.KeyCommand.HELP)//远程求助……2016-2-29 13:03:53…… { if (viewModel.isEnterHelp) { return; } if (!string.IsNullOrEmpty(viewModel.measureServiceResult) && viewModel.measureServiceResult != null && !string.IsNullOrEmpty(viewModel.CarNumber)) { if (viewModel.isEnterOnly)//摁过回车键 不允许再摁求助键 { return; } viewModel.isEnterOnly = true; #region 写日志 LogModel log = new LogModel() { CreateTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"), Msg = "车号:" + viewModel.CarNumber + "按下求助键远程求助", FunctionName = "称点主窗体_Window_KeyDown", Origin = "汽车衡_" + ClientInfo.Name, Level = LogConstParam.LogLevel_Info }; Talent.ClinetLog.SysLog.Log(JsonConvert.SerializeObject(log)); #endregion viewModel.SendTaskToServer("司机按键远程求助", viewModel.measureServiceResult, true, true); } } } } }
void MainWindow_Loaded(object sender, RoutedEventArgs e) { ShowInTaskbar = false; #region 日志 LogModel log1 = new LogModel() { Origin = "汽车衡_" + ClientInfo.Name, FunctionName = "称点主窗体_MainWindow_Loaded", 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(log1)); #endregion //SoundReading sr = new SoundReading("测试12121212"); //sr.Voice(); //检查更新…… CheckUpdate(); #region 是否显示测试内容 isTest = ConfigurationManager.AppSettings["IsTest"].ToString().Trim() == "1" ? true : false; if (isTest) { canvas1.Visibility = System.Windows.Visibility.Visible; testCardNoBtn.Visibility = System.Windows.Visibility.Visible; testCardNoTxt.Visibility = System.Windows.Visibility.Visible; TestSendTaskBtn.Visibility = System.Windows.Visibility.Visible; } else { canvas1.Visibility = System.Windows.Visibility.Hidden; testCardNoBtn.Visibility = System.Windows.Visibility.Hidden; testCardNoTxt.Visibility = System.Windows.Visibility.Hidden; TestSendTaskBtn.Visibility = System.Windows.Visibility.Hidden; } #endregion //版本 txtVer.Text = System.Reflection.Assembly.GetExecutingAssembly().GetName().Version.ToString().Substring(0, 3); //展示系统当前时间 firstStartTime = DateTime.Now; timer = new DispatcherTimer(); timer.Interval = TimeSpan.FromSeconds(1); timer.Tick += timer_Tick; timer.Start(); // ErrorAutoStart(); CarMeasureClientViewModel viewModel = this.DataContext as CarMeasureClientViewModel; viewModel.std = std; viewModel.gridReader = rendergv; viewModel.gridSupplier = gridSupplier; viewModel.gridMeasure = gridMeasure; viewModel.gridMeasureWeight = gridMeasureWeight; viewModel.isTest = isTest;//是否测试模式 viewModel.window = this; TestWeightviewModel = viewModel; this.KeyDown += Window_KeyDown; //启动文件同步程序 if (_enableFileSync == true) { string processName = "Talent.FIleSync"; Process[] procList = Process.GetProcessesByName(processName); if (procList != null && procList.Length > 0) { proSync = procList[0]; } else { proSync = new Process(); string syncExePath = System.IO.Path.Combine(System.AppDomain.CurrentDomain.BaseDirectory, processName + ".exe"); proSync.StartInfo.FileName = syncExePath; proSync.StartInfo.WindowStyle = ProcessWindowStyle.Minimized; try { proSync.Start(); LogModel log = new LogModel() { Origin = "汽车衡_" + ClientInfo.Name, FunctionName = "称点主窗体_MainWindow_Loaded", 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)); } catch (Win32Exception err) { #region log LogModel log = new LogModel() { Origin = "汽车衡_" + ClientInfo.Name, FunctionName = "称点主窗体_MainWindow_Loaded", Level = LogConstParam.LogLevel_Error, CreateTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"), Direction = LogConstParam.Directions_Out, Msg = "启动文件同步程序失败。原因:" + err.Message }; Talent.ClinetLog.SysLog.Log(JsonConvert.SerializeObject(log)); #endregion } } } FileHelpClass fHClass = new FileHelpClass(); fHClass.FileLogDelete(15, false); this.WindowState = System.Windows.WindowState.Normal; this.WindowStyle = System.Windows.WindowStyle.None; this.ResizeMode = System.Windows.ResizeMode.NoResize; //this.Topmost = true; this.Activate(); this.Left = 0.0; this.Top = 0.0; this.Width = System.Windows.SystemParameters.PrimaryScreenWidth; this.Height = System.Windows.SystemParameters.PrimaryScreenHeight; #region log LogModel log11 = 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 = "程序运行超过设定时间" + viewModel.AutoRunTime.ToString() }; Talent.ClinetLog.SysLog.Log(JsonConvert.SerializeObject(log11)); #endregion }
private void MyMethod() { CarMeasureClientViewModel viewModel = this.DataContext as CarMeasureClientViewModel; viewModel.AfterAnimation(); }