private void Button_Click(object sender, RoutedEventArgs e) { try { if ((BitmapImage)NewProfileImage.Source == null) { Tip.Alert("尚未选中新头像"); return; } var newProfilePicture = ((BitmapImage)NewProfileImage.Source).UriSource.ToString(); if (Current.App.UserProfilePicture == newProfilePicture) { Tip.Alert("请选择不同的头像"); return; } Current.App.UserProfilePicture = ((BitmapImage)NewProfileImage.Source).UriSource.ToString(); TengDa.Wpf.Context.UserContext.SaveChanges(); OperationHelper.ShowTips("更换头像成功!", true); } catch (Exception ex) { Error.Alert(ex); } }
private void TsmiStop_Click(object sender, EventArgs e) { if (Current.RGV.Stop(out string msg)) { Tip.Alert("成功发送急停指令给RGV"); } }
private void TsmiTransAutoManu_Click(object sender, EventArgs e) { if (Current.RGV.TransAutoManu(out string msg)) { Tip.Alert("成功发送"); } }
private void TsmiPause_Click(object sender, EventArgs e) { if (Current.RGV.Pause(out string msg)) { Tip.Alert("成功发送停止指令给RGV"); } }
private void TsmiReset_Click(object sender, EventArgs e) { if (Current.RGV.Reset(out string msg)) { Tip.Alert("成功发送复位指令给RGV"); } }
/// <summary> /// 关门 /// </summary> /// <param name="j">炉腔序号</param> /// <returns></returns> public void CloseDoor(int j) { if (!this.Plc.IsPingSuccess) { this.Plc.IsAlive = false; LogHelper.WriteError("无法连接到 " + this.Plc.IP); return; } if (!this.Floors[j].IsNetControlOpen) { Tip.Alert(this.Floors[j].Name + "网控未开启,无法远程关门 "); return; } //Floor floor = this.Floors.FirstOrDefault(f => f.Id != this.Floors[j].Id && f.DoorStatus != DoorStatus.打开); //if (floor != null) //{ // Error.Alert(String.Format("{0}炉门{1},{2}炉门无法关闭!", floor.Name, floor.DoorStatus, this.Floors[j].Name)); // return; //} if (!this.Floors[j].DoorIsClosing) { this.Floors[j].toCloseDoor = true; } }
private void EditOrSaveButton_Click(object sender, RoutedEventArgs e) { if (Current.App.IsCurrentUserIsEdit) { TengDa.Wpf.Context.UserContext.SaveChanges(); Tip.Alert("修改信息成功保存"); } Current.App.IsCurrentUserIsEdit = !Current.App.IsCurrentUserIsEdit; }
/// <summary> /// 开门 /// </summary> /// <param name="j">炉腔序号</param> /// <returns></returns> public void OpenDoor(int j) { if (!this.Plc.IsPingSuccess) { this.Plc.IsAlive = false; LogHelper.WriteError("无法连接到 " + this.Plc.IP); return; } if (!this.Floors[j].IsNetControlOpen && Current.TaskMode == TaskMode.手动任务) { Tip.Alert(this.Floors[j].Name + "网控未开启,无法远程开门 "); return; } if (this.Floors[j].IsBaking) { LogHelper.WriteError("在运行,无法开门 " + this.Floors[j].Name); return; } if (this.Floors[j].IsVacuum) { LogHelper.WriteError("有真空,无法开门 " + this.Floors[j].Name); return; } if (this.Floors[j].Stations[0].IsOpenDoorIntervene) { LogHelper.WriteError("开门会干涉,无法开门 " + this.Floors[j].Name); return; } //Floor floor = this.Floors.FirstOrDefault(f => f.Id != this.Floors[j].Id && f.DoorStatus != DoorStatus.关闭); //if (floor != null) //{ // Error.Alert(String.Format("{0}炉门{1},{2}炉门无法打开!", floor.Name, floor.DoorStatus, this.Floors[j].Name)); // return; //} if (this.Floors[j].DoorIsClosing) { Tip.Alert(this.Floors[j].Name + "正在关门,此刻不能开门"); return; } if (!this.Floors[j].DoorIsOpenning) { this.Floors[j].DoorStatus = DoorStatus.正在打开; this.Floors[j].DoorIsOpenning = true; this.Floors[j].toOpenDoor = true; } }
private void BtnBatteryBindInit_Click(object sender, EventArgs e) { if (Battery.BatteryBindInit(out string msg)) { Tip.Alert("电池绑定初始化成功!"); } else { Error.Alert("电池绑定初始化失败!msg:" + msg); } }
private void Button_Click(object sender, RoutedEventArgs e) { var originPwsInput = this.OriginPwsInput.Password.Trim(); var newPwsInput = this.NewPwsInput.Password.Trim(); var newPwsReInput = this.NewPwsReInput.Password.Trim(); if (string.IsNullOrEmpty(originPwsInput)) { Tip.Alert("请输入当前密码!"); return; } if (string.IsNullOrEmpty(newPwsInput)) { Tip.Alert("请输入新密码!"); return; } if (string.IsNullOrEmpty(newPwsReInput)) { Tip.Alert("请重新输入新密码!"); return; } if (newPwsInput != newPwsReInput) { Tip.Alert("新密码两次输入不一致!"); return; } if (newPwsInput == originPwsInput) { Tip.Alert("输入的新密码和原密码相同!"); return; } if (AppCurrent.User.Password != TengDa.Encrypt.Base64.EncodeBase64(originPwsInput)) { Tip.Alert("当前密码输入错误!"); return; } AppCurrent.User.Password = TengDa.Encrypt.Base64.EncodeBase64(newPwsInput); try { TengDa.Wpf.Context.UserContext.SaveChanges(); OperationHelper.ShowTips("修改密码成功!", true); } catch (Exception ex) { Error.Alert(ex); } }
private void BtnClampScanNgBackToFeeder_Click(object sender, EventArgs e) { string msg = string.Empty; if (!Current.Feeder.SetScanClampResult(ScanResult.NG, out msg)) { Error.Alert(msg); } else { Tip.Alert("OK"); } }
private void BtnUpload_Click(object sender, EventArgs e) { var barcode = this.tbBarcode.Text.Trim(); var flag = this.tbFlag.Text.Trim(); var terminal = this.tbTerminal.Text.Trim(); var userId = this.tbUserId.Text.Trim(); if (string.IsNullOrEmpty(barcode)) { Tip.Alert("输入电芯条码为空!"); return; } if (string.IsNullOrEmpty(flag)) { Tip.Alert("输入调用类型为空!"); return; } if (string.IsNullOrEmpty(terminal)) { Tip.Alert("输入调用工位为空!"); return; } if (string.IsNullOrEmpty(userId)) { Tip.Alert("输入调用者为空!"); return; } MesRequest request = new MesRequest() { Barcode = barcode, Flag = flag, Terminal = terminal, UserId = userId }; Thread t = new Thread(() => { var response = MES.UploadBatteryInfo(request); this.BeginInvoke(new MethodInvoker(() => { this.tbRtCode.Text = response.Code.ToString(); this.tbRtMsg.Text = response.RtMsg; Color fore = response.Code == 0 ? Color.Green : Color.Red; this.tbRtCode.ForeColor = fore; this.tbRtMsg.ForeColor = fore; })); }); t.Start(); }
private void LogoutHyberlink_Click(object sender, System.Windows.RoutedEventArgs e) { if (AppCurrent.IsRunning) { Tip.Alert("系统正在运行,请先停止!"); return; } if (User.Logout()) { new LoginWindow().Show(); Current.MainWindow.Close(); } }
private void DeleteUserButton_Click(object sender, System.Windows.RoutedEventArgs e) { var user = (User)UserListBox.SelectedItem; if (TengDa.Wpf.Context.UserContext.Users.Any(u => u.Id == user.Id)) { TengDa.Wpf.Context.UserContext.Users.Remove(user); TengDa.Wpf.Context.UserContext.SaveChanges(); Tip.Alert("用户删除成功,重启软件即可生效!"); } else { Tip.Alert("该用户已删除,请勿重复操作!"); } }
/// <summary> /// 放盘 /// </summary> public bool Put(Station fromStation, Station toStation) { var msg = ""; if (!this.Plc.IsPingSuccess) { LogHelper.WriteError("无法连接到 " + this.Plc.IP); return(false); } if (!this.IsReady) { Tip.Alert("RGV未就绪!"); return(false); } //清掉任务完成信号 if (this.IsTaskFinished) { if (!this.Plc.SetInfo("D1015", (ushort)0, out msg)) { Error.Alert(msg); this.Plc.IsAlive = false; return(false); } this.IsTaskFinished = false; } var rgvValue = toStation.GetPutType == GetPutType.料机 ? fromStation.RgvPutFeederValue : toStation.RgvValue; var addr = "D1008"; var val = ushort.Parse(rgvValue); //发送位置编号 if (!this.Plc.SetInfo(addr, val, out msg)) { Error.Alert(msg); this.Plc.IsAlive = false; return(false); } LogHelper.WriteInfo(string.Format("发送放盘货位号给{0},{1}:{2}", this.Plc.Name, addr, val)); Thread.Sleep(30); //启动 return(this.Start(out msg)); }
/// <summary> /// 关门指令 /// </summary> /// <returns></returns> public void CloseDoor() { if (!this.Blanker.Plc.IsPingSuccess) { IsAlive = false; LogHelper.WriteError("无法连接到 " + this.Blanker.Plc.IP); return; } if (Current.rotater.Station.ClampOri != this.Blanker.Stations[0].ClampOri) { Tip.Alert("当前状态无法关门!"); return; } this.Station.toCloseDoor = true; }
/// <summary> /// 停止 /// </summary> /// <param name="j">炉腔序号</param> /// <returns></returns> public void StopBaking(int j) { if (!this.Plc.IsPingSuccess) { this.Plc.IsAlive = false; LogHelper.WriteError("无法连接到 " + this.Plc.IP); return; } if (!this.Floors[j].IsNetControlOpen) { Tip.Alert(this.Floors[j].Name + "网控未开启,无法远程停止运行 "); return; } this.Floors[j].toStopBaking = true; }
private void TsmOvenCloseDoor_Click(object sender, EventArgs e) { if (floor.Stations.Count(s => s.Id == Current.Task.FromStationId) > 0 && Current.Task.Status != TaskStatus.完成) { Tip.Alert(Current.Task.FromStationName + "正在取盘,无法关门!"); return; } if (floor.Stations.Count(s => s.Id == Current.Task.ToStationId) > 0 && Current.Task.Status != TaskStatus.完成) { Tip.Alert(Current.Task.ToStationName + "正在放盘,无法关门!"); return; } floor.AddLog("手动关门"); oven.CloseDoor(oven.Floors.IndexOf(floor)); }
private void BtnStartScan_Click(object sender, EventArgs e) { Thread t = new Thread(() => { var result = this.scaner.StartScan(out string code, out string msg); if (result == TengDa.ScanResult.OK) { Tip.Alert(code); } else { Error.Alert(msg); } }); t.Start(); }
/// <summary> /// 取消抽真空 /// </summary> /// <param name="j">炉腔序号</param> /// <returns></returns> public void CancelLoadVacuum(int j) { if (!this.Plc.IsPingSuccess) { this.Plc.IsAlive = false; LogHelper.WriteError("无法连接到 " + this.Plc.IP); return; } if (!this.Floors[j].IsNetControlOpen) { Tip.Alert(this.Floors[j].Name + "网控未开启,无法远程取消抽真空 "); return; } this.Floors[j].toCancelLoadVacuum = true; }
/// <summary> /// 运行时间清零 /// </summary> /// <param name="j">炉腔序号</param> /// <returns></returns> public void ClearRunTime(int j) { if (!this.Plc.IsPingSuccess) { this.Plc.IsAlive = false; LogHelper.WriteError("无法连接到 " + this.Plc.IP); return; } if (!this.Floors[j].IsNetControlOpen) { Tip.Alert(this.Floors[j].Name + "网控未开启,无法清零运行时间 "); return; } this.Floors[j].toClearRunTime = true; }
private void AfterRegister() { Current.Option.LastLoginUserId = AppCurrent.User.Id; OperationHelper.ShowTips(this.userNameTextBox.Text + "成功注册"); btnLoginOrRegister.Content = "正在注册..."; Thread t = new Thread(() => { Thread.Sleep(2000); Dispatcher.Invoke(new Action(() => { //登录成功,关闭窗口 Current.App.IsLoginWindow = true; btnLoginOrRegister.Content = "登 录"; Tip.Alert(this.userNameTextBox.Text + "成功注册,请让管理员审核后登录"); })); }); t.Start(); }
private void BtnClampScanStart_Click(object sender, EventArgs e) { string code = string.Empty; string msg = string.Empty; ScanResult scanResult = Current.ClampScaner.StartScan(out code, out msg); if (scanResult == ScanResult.OK) { Tip.Alert(code); } else if (scanResult == ScanResult.NG) { Tip.Alert("扫码返回NG!"); } else { Error.Alert(msg); } }
private void BtnReset_Click(object sender, RoutedEventArgs e) { if (Current.App.RunStatus == TengDa.RunStatus.运行) { Tip.Alert("系统正在运行,复位无效,请停止运行后再执行复位操作!"); return; } if (Current.App.RunStatus == TengDa.RunStatus.闲置) { Tip.Alert("系统尚未启动,复位操作无效!"); return; } if (CommunicateControl.CommunicateStop()) { OperationHelper.ShowTips("成功复位!"); Current.App.RunStatus = TengDa.RunStatus.闲置; } }
/// <summary> /// 关门 /// </summary> /// <param name="j">炉腔序号</param> /// <returns></returns> public void CloseDoor(int j) { if (!this.Plc.IsPingSuccess) { this.Plc.IsAlive = false; LogHelper.WriteError("无法连接到 " + this.Plc.IP); return; } if (!this.Floors[j].IsNetControlOpen) { Tip.Alert(this.Floors[j].Name + "网控未开启,无法远程关门 "); return; } //Floor floor = this.Floors.FirstOrDefault(f => f.Id != this.Floors[j].Id && f.DoorStatus != DoorStatus.打开); //if (floor != null) //{ // Error.Alert(String.Format("{0}炉门{1},{2}炉门无法关闭!", floor.Name, floor.DoorStatus, this.Floors[j].Name)); // return; //} if (this.Floors[j].DoorIsOpenning) { Tip.Alert(this.Floors[j].Name + "正在开门,此刻不能关门"); return; } if (!this.Floors[j].DoorIsClosing) { if (this.Floors[j].Stations.Count(s => s.Id == Current.Task.FromStationId) + this.Floors[j].Stations.Count(s => s.Id == Current.Task.ToStationId) > 0) { Tip.Alert(this.Floors[j].Name + "有取放任务,无法远程关门 "); return; } this.Floors[j].DoorStatus = DoorStatus.正在关闭; this.Floors[j].DoorIsClosing = true; this.Floors[j].toCloseDoor = true; } }
private void btnOK_Click(object sender, EventArgs e) { string name = this.tbName.Text.Trim(); string pwd = this.tbPwd.Text.Trim(); if (string.IsNullOrEmpty(name) || string.IsNullOrEmpty(pwd)) { Tip.Alert("用户名或密码为空"); return; } User user = new User(); string msg = string.Empty; List <User> list = User.GetList(string.Format("SELECT * FROM [dbo].[TengDa.Users] WHERE [Name] = '{0}' AND [Password] = '{1}'", name, Base64.EncodeBase64(pwd)), out msg); if (list.Count() < 1) { Tip.Alert("用户名或密码错误"); return; } List <User> listManagers = list.Where(u => u.Group.Level > 2).ToList(); if (listManagers.Count < 1) { Tip.Alert(string.Format("用户 {0} 权限不足!", name)); return; } user = listManagers[0]; if (!user.IsEnable) { Tip.Alert("该用户尚未审核"); return; } this.DialogResult = DialogResult.OK; this.Close(); }
/// <summary> /// 启动 /// </summary> /// <param name="j">炉腔序号</param> /// <returns></returns> public void StartBaking(int j) { if (!this.Plc.IsPingSuccess) { this.Plc.IsAlive = false; LogHelper.WriteError("无法连接到 " + this.Plc.IP); return; } if (!this.Floors[j].IsNetControlOpen) { Tip.Alert(this.Floors[j].Name + "网控未开启,无法远程启动 "); return; } if (this.Floors[j].DoorStatus != DoorStatus.关闭) { Tip.Alert(this.Floors[j].Name + "门未关闭,无法启动!"); return; } this.Floors[j].toStartBaking = true; }
private void OnLogin(object sender, ExecutedRoutedEventArgs e) { string msg = ""; if (User.Login(this.LoginUserNameCombobox.Text, this.LoginUserPasswordBox.Password, out msg)) { //Tip.Alert("成功登录"); AppCurrent.AppViewModel.UserName = Current.User.Name; AppCurrent.AppViewModel.UserGroupName = Current.Role.Name; AppCurrent.AppViewModel.UserProfilePicture = Current.User.ProfilePicture; AppCurrent.AppViewModel.UserNumber = Current.User.Number; AppCurrent.AppViewModel.UserPhoneNumber = Current.User.PhoneNumber; AppCurrent.AppViewModel.UserEmail = Current.User.Email; AppCurrent.AppViewModel.CurrentUserNameTip = Current.User.Name; AppCurrent.AppViewModel.ShowTips(Current.User.Name + "成功登录"); btnLogin.Content = "正在登录..."; Thread t = new Thread(() => { Thread.Sleep(2000); Dispatcher.Invoke(new Action(() => { //登录成功,关闭窗口 this.Close(); AppCurrent.AppViewModel.IsLogin = true; AppCurrent.AppViewModel.MainWindowsBackstageIsOpen = false; })); }); t.Start(); } else { Tip.Alert(msg); } }
private void BtnOK_Click(object sender, EventArgs e) { try { // IzIwMTktMDktMDYkU2hvd0FjdGl2ZU1zZ1RpbWU9MjAxOS0wOS0xOFQwMDowMDowMDtFeHBpcmF0aW9uVGltZT0yMDIwLTA5LTE4VDEyOjAwOjAwO0lzU2hvd01zZz1GYWxzZTtJc0V4cGlyZWQ9RmFsc2U7SXNBY3RpdmF0ZWQ9RmFsc2Uj var activeCode = this.tbActiveCode.Text.Trim(); // #2019-09-06$ShowActiveMsgTime=2019-09-18T00:00:00;ExpirationTime=2020-09-18T12:00:00;IsShowMsg=False;IsExpired=False;IsActivated=False# var codeAfterDecode = TengDa.Encrypt.Base64.DecodeBase64(activeCode); // 2019-09-06 var codeNowDate = codeAfterDecode.Trim('#').Split('$')[0]; if (!DateTime.TryParse(codeNowDate, out DateTime date)) { throw new Exception("激活码格式错误"); } if (date.ToString("yyyy-MM-dd") != DateTime.Now.ToString("yyyy-MM-dd")) { throw new Exception("激活码参数错误"); } // ShowActiveMsgTime=2019-09-18T00:00:00;ExpirationTime=2020-09-18T12:00:00;IsShowMsg=False;IsExpired=False;IsActivated=False var codeParams = codeAfterDecode.Trim('#').Split('$')[1]; var paramList = codeParams.Split(';'); if (paramList.Length != 5) { throw new Exception("激活码格式错误"); } for (int i = 0; i < 5; i++) { var propertyName = paramList[i].Split('=')[0]; if (!new string[] { "ShowActiveMsgTime", "ExpirationTime", "IsShowMsg", "IsExpired", "IsActivated" }.Contains(propertyName)) { throw new Exception("激活码格式错误"); } var sVal = paramList[i].Split('=')[1]; if (propertyName.EndsWith("Time")) { if (!DateTime.TryParse(sVal, out DateTime dVal)) { throw new Exception("激活码格式错误"); } if (!Activation.SetValue(propertyName, dVal)) { throw new Exception("设置激活码出错"); } } else { if (!bool.TryParse(sVal, out bool bVal)) { throw new Exception("激活码格式错误"); } if (!Activation.SetValue(propertyName, bVal)) { throw new Exception("设置激活码出错"); } } } Tip.Alert("输入验证码成功"); } catch (Exception ex) { Error.Alert(ex); } }
private void btnLoginOrRegister_Click(object sender, RoutedEventArgs e) { if (string.IsNullOrEmpty(this.userNameTextBox.Text)) { Tip.Alert("请输入用户名"); return; } if (string.IsNullOrEmpty(this.passwordBox.Text)) { Tip.Alert("请输入密码"); return; } if (!Current.App.IsLoginWindow && string.IsNullOrEmpty(this.confirmPasswordBox.Text)) { Tip.Alert("请输入确认密码"); return; } if (!Current.App.IsLoginWindow && this.confirmPasswordBox.Text != this.passwordBox.Text) { Tip.Alert("两次输入密码不相同"); return; } string msg = string.Empty; //登录 if (Current.App.IsLoginWindow) { //if (Current.Option.IsMesLogin) //{ // if (!Current.Mes.IsPingSuccess) // { // Error.Alert("无法连接至MES服务器,登录失败!"); // return; // } // //MES登录 // if (MES.Login(this.userNameTextBox.Text, this.passwordBox.Password, out msg)) // { // AfterLogin(); // } // else // { // Tip.Alert(msg); // } //} //else //{ //普通登录 if (User.Login(this.userNameTextBox.Text, this.passwordBox.Password, out msg)) { AfterLogin(); } else { Tip.Alert(msg); } //} } else //注册 { if (User.Register(this.userNameTextBox.Text, this.passwordBox.Password, out msg)) { AfterRegister(); } else { Tip.Alert(msg); } } }