private async void OnLogin(User user) { string userLogin = user.Login; string userPassword = user.Password; var list = User.DBTable.Select("where " + User.DBTable.CodeKey.Name + " = '" + userLogin + "' and " + User.DBTable.ParseProperty(nameof(User.Password)).Name + " = '" + userPassword + "'").ToList(); if (list.Count != 0) { User row = list[0]; if (row.Status != DBStatus.Actual) { MessageDialog.ShowMessage(ParentWindow, Locale.Get("Login", "User is blocked!"), "Login"); } else { await User.StartSession(row); GuiEnvironment.User = row; //row ["session_start"] = DateTime.Now; if (!row.Super.GetValueOrDefault()) { await GroupPermission.CachePermission(); } MessageDialog.ShowMessage(ParentWindow, string.Format(Locale.Get("Login", "Welcome {0}"), row.Name), "Login"); } } else { MessageDialog.ShowMessage(ParentWindow, Locale.Get("Login", "Authorization Error: check your Login and Password."), "Login"); } }
public async Task Initialize() { Environment.CurrentDirectory = AppDomain.CurrentDomain.BaseDirectory; var schema = new DBSchema("common_database"); schema.Generate(new[] { typeof(Customer).Assembly, typeof(User).Assembly }); DBService.Schems.Add(schema); Assert.IsNotNull(schema); Assert.IsNotNull(Book.DBTable); Assert.IsNotNull(UserGroup.DBTable); Assert.IsNotNull(GroupPermission.DBTable); Assert.IsNotNull(User.DBTable); Assert.IsNotNull(Position.DBTable); Assert.IsNotNull(UserReg.DBTable); Assert.IsNotNull(Company.DBTable); DBService.Save(); schema.Connection = new DBConnection { Name = "test.common", System = DBSystem.SQLite, DataBase = "test.common" }; schema.DropDatabase(); schema.CreateDatabase(); var group = new UserGroup() { Number = "GP1", Name = "Group1" }; await group.Save(); var position = new Position() { Code = "PS1", Name = "Position" }; var user = new User() { Login = "******", Name = "Test User", Password = "******", Position = position, AuthType = UserAuthType.Internal, Access = new AccessValue(new[] { new AccessItem(group, AccessType.Create) }) }; await user.Save(); await User.StartSession("test", "UserCommon1!"); await GroupPermission.CachePermission(); }