private void Dispose(bool disposing) { if (disposing) { if (this.startUpPage != null) { this.startUpPage.Dispose(); this.startUpPage = null; } } }
public SetupTestWithPage(string url) { startUpPage = new StartUpPage(SeleniumWebDriver.Browser.Chrome); //baseUrl = DeployURL.Host; baseUrl = url; }
public static void SaveInfo(int?iD, RfidContext db, bool isImageExist, string imagePath, Grid userInfoGrid, Grid workTimeInfoGrid, Grid contactManInfoGrid, Grid rfidGrid, Grid departmentInfoGrid) { //add or update user info if (iD != null) { var user = db.C_Users.Find(iD); UpdateUserInfo(userInfoGrid, workTimeInfoGrid, user); UpdateContactsInfo(contactManInfoGrid, user); UpdateInOutTimes(workTimeInfoGrid, user); user.Photo = GetPhotoPath(user, isImageExist, imagePath); //rfid checks and update var newRfid = Convert.ToInt64(((TextBox)userInfoGrid.FindName("ShowRfid")).Text); if (!(user.P_Rfids.FirstOrDefault().RfidID == newRfid)) { foreach (var item in db.C_Rfids) { if (item.RfidID == newRfid && item.IsArhive) { item.IsArhive = false; user.P_Rfids = new List <M_Rfids> { item }; } else if (item.RfidID == newRfid && !item.IsArhive) { MessageBox.Show((string)Application.Current.Resources[StringsMapper.ErrorBindingRfid], (string)Application.Current.Resources[StringsMapper.ErrorHeader], MessageBoxButton.OK, MessageBoxImage.Error); return; } else { user.P_Rfids = new List <M_Rfids> { GetRfidInfo(rfidGrid) }; } } } //departments checks and update var newDepName = ((TextBox)departmentInfoGrid.FindName("TB_DepName")).Text; var newDepCode = ((TextBox)departmentInfoGrid.FindName("TB_DepCode")).Text; var isNoFind = true; foreach (var dep in db.C_Departments) { if (dep.Name == newDepName && dep.CodeFull == newDepCode) { var userDepartmentDirector = user.P_Departments.DepartmentDirectorName.FirstOrDefault(); var userDepartmentPhone = user.P_Departments.DepartmentDirectorPhone.FirstOrDefault(); var departmentDirector = dep.DepartmentDirectorName.FirstOrDefault(); var departmentPhone = dep.DepartmentDirectorPhone.FirstOrDefault(); user.P_Departments.CodeFull = dep.CodeFull; user.P_Departments.Name = dep.Name; userDepartmentDirector.NameFirst = departmentDirector?.NameFirst; userDepartmentDirector.NameLast = departmentDirector?.NameLast; userDepartmentDirector.NameThird = departmentDirector?.NameThird; userDepartmentPhone.PhoneNumber = departmentPhone?.PhoneNumber; isNoFind = false; break; } } if (isNoFind) { user.P_Departments = GetDepartmentInfo(departmentInfoGrid, user); } } else { //create new user with input info var newUser = GetNewUserInfo(userInfoGrid, workTimeInfoGrid); newUser.P_ManForContact = GetAllContactsInfo(contactManInfoGrid, newUser); newUser.P_InOutValidTimes = GetInOutValidTimes(workTimeInfoGrid); newUser.Photo = GetPhotoPath(newUser, isImageExist, imagePath); //department adding & checking for existing departments var isNoFind = true; foreach (var dep in db.C_Departments) { if (dep.Name == ((TextBox)departmentInfoGrid.FindName("TB_DepName")).Text && dep.CodeFull == ((TextBox)departmentInfoGrid.FindName("TB_DepCode")).Text) { dep.P_Users.Add(newUser); isNoFind = false; break; } } if (isNoFind) { newUser.P_Departments = GetDepartmentInfo(departmentInfoGrid, newUser); } //rfid checks and adding var changeRfid = true; foreach (var itemRfid in db.C_Rfids) { if (itemRfid.RfidID == Convert.ToInt64(((TextBox)userInfoGrid.FindName("ShowRfid")).Text) && itemRfid.IsArhive) { itemRfid.IsArhive = false; itemRfid.P_Users = newUser; changeRfid = false; break; } if (itemRfid.RfidID == Convert.ToInt64(((TextBox)userInfoGrid.FindName("ShowRfid")).Text) && !itemRfid.IsArhive) { MessageBox.Show((string)Application.Current.Resources[StringsMapper.ErrorBindingRfid], (string)Application.Current.Resources[StringsMapper.ErrorHeader], MessageBoxButton.OK, MessageBoxImage.Error); return; } } if (changeRfid) { newUser.P_Rfids = new List <M_Rfids> { GetRfidInfo(rfidGrid) }; } db.C_Users.Add(newUser); } db.SaveChanges(); var p = new StartUpPage(); Singelton.Frame.NavigationService.Navigate(p); }