/// <summary> /// 登录方法 /// </summary> /// <param name="uCode"></param> public void Login(object uCode) { string barCode = uCode.ToString(); if (string.IsNullOrEmpty(barCode)) { LoginMsg = @"请扫用户条码!"; return; } else { try { var loginResult = new BLL.ExtraBLL.WorkGroupInfoBLL().GetWorkGroupInfo(barCode); LoginMsg = loginResult.Msg; if (loginResult.Result) { WindowHelper.ShowPageProducePlan(); Thread thread = new Thread(new ThreadStart(delegate { ResultModel loginStatus = new ResultModel(); while (true) { loginStatus = BLL.Helpers.ClientHelper.GetUsetLoginStatus(); if (!loginStatus.Result) { MessageBox.Show(loginStatus.Msg, "警告", MessageBoxButton.OK, MessageBoxImage.Warning); System.Diagnostics.Process.Start(System.Reflection.Assembly.GetExecutingAssembly().Location); Environment.Exit(0); } } })); thread.IsBackground = true; thread.Start(); } else { } } catch (Exception ex) { LoginMsg = ex.Message; } } }
private void TxtUserCode_PreviewKeyUp(object sender, KeyEventArgs e) { int key = (int)e.Key; string userCode = txtUserCode.Text.Trim(); //Enter-回车 if (key.Equals(6)) { if (string.IsNullOrEmpty(userCode)) { return; } //模拟登陆 var GetWorkGroupInfoModel = new BLL.ExtraBLL.WorkGroupInfoBLL().GetWorkGroupInfo(userCode); if (GetWorkGroupInfoModel.Result) { string targetUri = string.Empty; //查班组负责所有设备的保养计划 var obj = new BLL.ExtraBLL.EquipmentInfoBLL().GetEquipmentInfo(); //如若当天有保养计划,则进入保养计划页面 if (obj.Data.Count > 0) { targetUri = @"EQPMaintainPlanPage.xaml"; } //否则进入计划页面 else { targetUri = @"ProductPlanPage.xaml"; } lblMsg.Foreground = new SolidColorBrush(Color.FromRgb(93, 229, 32)); lblMsg.Content = @"登录成功!"; NavigationService.GetNavigationService(this).Navigate(new Uri(targetUri, UriKind.Relative)); } else { //MessageBox.Show(GetWorkGroupInfoModel.Msg, "提示", MessageBoxButton.OK, MessageBoxImage.Warning); lblMsg.Foreground = new SolidColorBrush(Color.FromRgb(247, 125, 44)); lblMsg.Content = GetWorkGroupInfoModel.Msg; return; } } }
private void TxtUserCode_PreviewKeyDown(object sender, KeyEventArgs e) { string userCode = txtUserCode.Text.Trim(); if (e.Key.Equals(Key.Enter)) { if (string.IsNullOrEmpty(userCode)) { return; } try { var loginResult = new BLL.ExtraBLL.WorkGroupInfoBLL().GetWorkGroupInfo(userCode); if (loginResult.Result) { string targetUri = string.Empty; //查班组负责所有设备的保养计划 var obj = new BLL.ExtraBLL.EquipmentInfoBLL().GetEquipmentInfo(); //如若当天有保养计划,则进入保养计划页面 if (obj.Data.Count > 0) { targetUri = @"View/MaintainPlanPage.xaml"; } //否则进入计划页面 else { targetUri = @"View/ProducePlanPage.xaml"; } var temp = BLL.Helpers.ClientHelper.RecordOperateLog(string.Format(@"用户【{0}】成功登录客户端!", Model.StoreInfoModel.UserName)); Thread thread = new Thread(new ThreadStart(delegate { //CheckForIllegalCrossThreadCalls = false; Model.ResultModel loginStatus = new Model.ResultModel(); while (true) { loginStatus = BLL.Helpers.ClientHelper.GetUsetLoginStatus(); if (!loginStatus.Result) { MessageBox.Show(loginStatus.Msg, "警告", MessageBoxButton.OK, MessageBoxImage.Warning); System.Diagnostics.Process.Start(System.Reflection.Assembly.GetExecutingAssembly().Location); Environment.Exit(0); } } })); thread.IsBackground = true; thread.Start(); lblMsg.Text = @"登录成功!"; NavigationService.GetNavigationService(this).Navigate(new Uri(targetUri, UriKind.Relative)); } else { lblMsg.Text = loginResult.Msg; lblMsg.Foreground = Brushes.Red; var temp = BLL.Helpers.ClientHelper.RecordOperateLog(new List <Model.Models.ClientOperateLog>() { new Model.Models.ClientOperateLog() { Content = string.Format(@"用户【{0}】登录客户端失败!", userCode), CreatePersonCode = userCode, CreatePersonName = userCode } }); } } catch (Exception ex) { lblMsg.Text = ex.Message; MessageBox.Show(ex.Message, "警告", MessageBoxButton.OK, MessageBoxImage.Warning); } } }