コード例 #1
0
        internal static common.UserRoleAuth GetHighestRole(List <common.UserRoleAuth> list)
        {
            common.UserRoleAuth highestRole = null;
            int higheRoleRank = 0;

            list.ForEach(ura =>
            {
                if (RolesLevel[ura.RoleId] > higheRoleRank)
                {
                    highestRole   = ura;
                    higheRoleRank = RolesLevel[ura.RoleId];
                }
            });

            return(highestRole);
        }
コード例 #2
0
ファイル: Factory.cs プロジェクト: netthanhhung/Mimosa
        public static UserRoleAuth UserRoleAuth(System.Data.IDataReader reader)
        {
            UserRoleAuth result = null;

            if (null != reader && reader.Read())
            {
                result = new UserRoleAuth();
                PopulateUserRoleAuth(result, reader);
            }

            return result;
        }
コード例 #3
0
ファイル: Factory.cs プロジェクト: netthanhhung/Mimosa
        public static void PopulateUserRoleAuth(UserRoleAuth input, System.Data.IDataReader reader)
        {
            input.RecordId = input.UserRoleAuthId = Utilities.ToInt(reader[Mimosa.Apartment.Common.UserRoleAuth.ColumnNames.UserRoleAuthId]);
            input.UserId = Utilities.ToGuid(reader[Mimosa.Apartment.Common.UserRoleAuth.ColumnNames.UserId]);
            input.RoleId = Utilities.ToGuid(reader[Mimosa.Apartment.Common.UserRoleAuth.ColumnNames.RoleId]);
            input.WholeOrg = Utilities.ToNBool(reader[Mimosa.Apartment.Common.UserRoleAuth.ColumnNames.WholeOrg]);
            input.SiteGroupId = Utilities.ToNInt(reader[Mimosa.Apartment.Common.UserRoleAuth.ColumnNames.SiteGroupId]);
            input.SiteId = Utilities.ToNInt(reader[Mimosa.Apartment.Common.UserRoleAuth.ColumnNames.SiteId]);

            input.UserName = Utilities.ToString(reader[Mimosa.Apartment.Common.UserRoleAuth.ColumnNamesExtended.UserName]);
            input.RoleName = Utilities.ToString(reader[Mimosa.Apartment.Common.UserRoleAuth.ColumnNamesExtended.RoleName]);

            input.SiteGroup = Utilities.ToString(reader[Mimosa.Apartment.Common.UserRoleAuth.ColumnNamesExtended.SiteGroup]);
            input.Site = Utilities.ToString(reader[Mimosa.Apartment.Common.UserRoleAuth.ColumnNamesExtended.Site]);
        }
コード例 #4
0
        void CreateAspUserCompleted(AspUser aspUser)
        {
            //if (!string.IsNullOrEmpty(aspUser.ErrorMessage))
            //{
            //    Globals.IsBusy = false;
            //    MessageBox.Show(aspUser.ErrorMessage);
            //    return;
            //}
            //_aspUsers.Add(aspUser);
            //SavedAspUser = aspUser;
            //if (SaveUserAccountComplete != null)
            //{
            //    SaveUserAccountComplete(this, null);
            //}
            //Dictionary<Guid, string> userItemSource = uiUsers.ItemsSource as Dictionary<Guid, string>;
            //userItemSource.Add(aspUser.UserId, aspUser.UserName);
            //userItemSource.OrderBy(i => i.Value);
            //uiUsers.ItemsSource = null;
            //uiUsers.ItemsSource = userItemSource;
            //uiUsers.SelectedValue = aspUser.UserId;
            //RebindUserAccountData();
            //Globals.IsBusy = false;
            //MessageBox.Show(Globals.UserMessages.RecordsSaved);

            if (!string.IsNullOrEmpty(aspUser.ErrorMessage))
            {
                Globals.IsBusy = false;
                MessageBox.Show(aspUser.ErrorMessage);
                return;
            }
            _aspUsers.Add(aspUser);
            SavedAspUser = aspUser;
            if (SaveUserAccountComplete != null)
            {
                SaveUserAccountComplete(this, null);
            }
            Dictionary<Guid, string> userItemSource = uiUsers.ItemsSource as Dictionary<Guid, string>;
            userItemSource.Add(aspUser.UserId, aspUser.UserName);
            userItemSource.OrderBy(i => i.Value);
            uiUsers.ItemsSource = null;
            uiUsers.ItemsSource = userItemSource;
            uiUsers.SelectedValue = aspUser.UserId;
            RebindUserAccountData();
            if (Globals.UserLogin.IsUserPortalAdministrator)
            {
                UserRoleAuth uraOrgAdmin = new UserRoleAuth();
                uraOrgAdmin.RoleId = SecurityHelper.OrganisationAdministratorRoleId;
                uraOrgAdmin.WholeOrg = true;
                uraOrgAdmin.UserId = aspUser.UserId;
                uraOrgAdmin.IsChanged = true;
                uraOrgAdmin.CreatedBy = uraOrgAdmin.UpdatedBy = Globals.UserLogin.UserName;

                UserRoleAuth uraSecurityAdmin = new UserRoleAuth();
                uraSecurityAdmin.RoleId = SecurityHelper.SecurityAdminRoleId;
                uraSecurityAdmin.WholeOrg = true;
                uraSecurityAdmin.UserId = aspUser.UserId;
                uraSecurityAdmin.IsChanged = true;
                uraSecurityAdmin.CreatedBy = uraSecurityAdmin.UpdatedBy = Globals.UserLogin.UserName;

                List<UserRoleAuth> saveList = new List<UserRoleAuth>();
                saveList.Add(uraOrgAdmin);
                saveList.Add(uraSecurityAdmin);
                DataServiceHelper.SaveUserRoleAuthAsync(saveList, SaveUserRoleAuthCompleted);
            }
            else
            {
                Globals.IsBusy = false;
                MessageBox.Show(Globals.UserMessages.RecordsSaved);
            }
        }