/// <summary> /// Sprawdza czy dany użytkownik ma rozszerzone uprawnienia /// </summary> public static bool isRoot(User user) { if (user.vname == "system") { return true; } return false; }
/// <summary> /// Tworzy nowego użytkownika i umieszcza rekord w bazie danych /// </summary> public static User createUser(String name, String surname, DateTime birthDate, UserRole role, SexEnum sex, String login, String pass) { User user = new User(); List<User> list = SessionFactory.GetNewSession().CreateQuery("from User u WHERE u.login = :login").SetParameter("login", login).List<User>().ToList<User>(); if (list.Count > 0) { throw new Exception("User with given login exists"); } user.vlogin = login; user.vpassword = EncodePassword(pass); user.vRole = role.vid; user.vsex = sex; user.vname = name; user.vSureName = surname; user.vDateOfBirth = birthDate; return user; }
/// <summary> /// Dodajemy dane do przechowywania sesji /// </summary> /// <param name="identity">Zalogowany user</param> public void WriteIdentity(User identity) { this.identity = identity; }
/// <summary> /// Czyœcimy dane o u¿ytkowniku /// </summary> public void ClearIdentity() { this.identity = null; }
public virtual void SetOrganizer(User organizer) { this.organizer = organizer.vid; }
public void SetOrganizer(User organizer) { this.organizer = organizer; }
public bool SaveFileForUser(User user, String filename) { throw new System.Exception("Not implemented"); }
public String[] GetFilesForUser(User user) { throw new System.Exception("Not implemented"); }
public void SetOrganizer(User organizer) { throw new System.Exception("Not implemented"); }
public void WriteIdentity(User identity) { throw new System.Exception("Not implemented"); }
/// <summary> /// Zapisuje plik z danymi u¿ytkownika na dysk /// </summary> public bool SaveFileForUser(User user, String filename) { FileAdapter<User> forUser = new FileAdapter<User>(); return true; }
/// <summary> /// Zwraca nazwy plików dla danego u¿ytkownika /// </summary> public String[] GetFilesForUser(User user) { return new string[] { }; }
private void UserEditorForm_Load(object sender, EventArgs e) { ICollection<UserRole> userRoles = DbService.GetAll<UserRole>(); this.comboBoxRole.Items.Clear(); this.comboBoxRole.Items.Insert(0, ""); foreach (UserRole ur in userRoles) { this.comboBoxRole.Items.Insert(ur.vid, ur.vname); } userAuth = AuthAdapter.GetInstance().getIdentity(); if (!UserFactory.isRoot(userAuth)) { this.button2.Visible = false; this.comboBoxRole.Visible = false; } this.plec.Items.Insert((int)SexEnum.Male, "mężczyzna"); this.plec.Items.Insert((int)SexEnum.Female, "kobieta"); this.textBoxName.Text = userAuth.GetName(); this.textBoxSureName.Text = userAuth.GetSureName(); this.dateOfBirthTimePicker.Value = userAuth.GetDateOfBirth(); this.plec.SelectedIndex = (int) userAuth.GetSex(); this.comboBoxRole.SelectedIndex = userAuth.vRole; }