/// <summary> /// Thêm các thông tin về nhân sự dự án /// </summary> private void SetPeople() { //Create the staff dbset if (this.ProjectStaffDbset == null) { this.ProjectStaffDbset = this.Conn.Set <ProjectStaffs>(); } else { this.ProjectStaffDbset.Local.Clear(); } //Create the permission db set if (this.ProjectPermissionDbset == null) { this.ProjectPermissionDbset = this.Conn.Set <Data.UserProjectPermission>(); } if (this.SelectedStaff == null) { this.SelectedStaff = new List <Data.Staff>(); this.SelectedStaff.Add(MainWindow.LoggedInStaff); } //Create the assignment and permission foreach (Staff s in SelectedStaff) { var newAssign = this.ProjectStaffDbset.Create(); if (IsProjectOwner(s.Key)) { this.NewProject.ProjectOwner = s.Key; } newAssign.StaffKey = s.Key; newAssign.ProjectKey = this.NewProject.Key; newAssign.Key = Encryption.GetUniqueKey(16); newAssign.AddedBy = this.MainWindow.StaffKey; newAssign.AddedOn = ExtendedFunctions.GetNetworkTime().ToString(); //Create a permission record UserProjectPermission permission = this.ProjectPermissionDbset.Create(); permission.ProjectStaffKey = newAssign.Key; permission.IsAdmin = IsProjectOwner(newAssign.StaffKey); newAssign.PermissionKey = Encryption.GetPermisionKey(permission); this.ProjectPermissionDbset.Add(permission); this.ProjectStaffDbset.Add(newAssign); } }
internal static string GetPermisionKey(UserProjectPermission permission) { string key = ""; key = key + (permission.CanAddLinks ? "+" : "-"); key = key + (permission.CanAddUpdate ? "+" : "-"); key = key + (permission.CanCreateTask ? "+" : "-"); key = key + (permission.CanUpdateAllTask ? "+" : "-"); key = key + (permission.CanUpdateMessageAndFile ? "+" : "-"); key = key + (permission.CanUpdateNoteBook ? "+" : "-"); key = key + (permission.CanUpdateRisk ? "+" : "-"); key = key + (permission.CanViewEstimatedTime ? "+" : "-"); key = key + (permission.CanViewLinks ? "+" : "-"); key = key + (permission.CanViewMessageAndFile ? "+" : "-"); key = key + (permission.CanViewNoteBook ? "+" : "-"); key = key + (permission.CanViewRisk ? "+" : "-"); key = key + (permission.CanViewTask ? "+" : "-"); key = key + (permission.CanViewUpdate ? "+" : "-"); return(key); }