public OnlineSettings() { StarsUpgradeValve = 4; DefaultOpen = true; ShowOnlineCount = 200; string iconPath = Globals.GetRelativeUrl(SystemDirecotry.Assets_OnlineIcon); RolesInOnline = new RoleInOnlineCollection(); RolesInOnline.Add(new RoleInOnline(Role.Administrators.RoleID, 1, Role.Administrators.Name, UrlUtil.JoinUrl(iconPath, "admin.gif"))); RolesInOnline.Add(new RoleInOnline(Role.SuperModerators.RoleID, 2, Role.SuperModerators.Name, UrlUtil.JoinUrl(iconPath, "supermod.gif")));//超级版主 RolesInOnline.Add(new RoleInOnline(Role.CategoryModerators.RoleID, 3, Role.CategoryModerators.Name, UrlUtil.JoinUrl(iconPath, "sbm.gif")));//分类版主 RolesInOnline.Add(new RoleInOnline(Role.Moderators.RoleID, 4, Role.Moderators.Name, UrlUtil.JoinUrl(iconPath, "mod.gif")));//版主 RolesInOnline.Add(new RoleInOnline(Role.Users.RoleID, 5, Role.Users.Name, UrlUtil.JoinUrl(iconPath, "user.gif"))); RolesInOnline.Add(new RoleInOnline(Role.Guests.RoleID, 6, Role.Guests.Name, UrlUtil.JoinUrl(iconPath, "guest.gif"))); }
public bool SaveSettings() { MessageDisplay msgDisplay = CreateMessageDisplay("rolename", "logourl"); RoleInOnlineCollection tempCollection = new RoleInOnlineCollection(); RoleInOnline temp; foreach (Role r in RoleSettings.Roles) { if (_Request.Get(r.RoleID.ToString(), Method.Post) == "1") { temp = GetData(r.RoleID); tempCollection.Add(temp); } } /*注册用户和游客不能删除, 始终都必须有*/ temp = GetData(Role.Users.RoleID); tempCollection.Add(temp); temp = GetData(Role.Guests.RoleID); tempCollection.Add(temp); /*======================================*/ //重新排序序号, 并且避免重复 bool flag = false; do { flag = false; for (int i = 0; i < tempCollection.Count - 1; i++) { for (int j = i + 1; j < tempCollection.Count; j++) { if (tempCollection[j].SortOrder == tempCollection[i].SortOrder) { tempCollection[j].SortOrder++; flag = true; } } } } while (flag); for (int i = 0; i < tempCollection.Count; i++) { if (string.IsNullOrEmpty(tempCollection[i].RoleName)) { msgDisplay.AddError("rolename", i, Lang_Error.Online_EmpryRoleNameError); } if (string.IsNullOrEmpty(tempCollection[i].LogoUrlSrc)) { msgDisplay.AddError("logourl", i, Lang_Error.Online_EmptyLogoUrlError); } } if (msgDisplay.HasAnyError()) { m_RolesInOnlineList = tempCollection; msgDisplay.AddError(new DataNoSaveError()); } else { OnlineSettings.RolesInOnline = tempCollection; SettingManager.SaveSettings(OnlineSettings); OnlineUserPool.Instance.UpdateUsersOnlineRole(); //OnlineManager.UpdateUserOnlineRoleLogo(); } return true; }
public bool SaveSettings() { MessageDisplay msgDisplay = CreateMessageDisplay("rolename", "logourl"); RoleInOnlineCollection tempCollection = new RoleInOnlineCollection(); RoleInOnline temp; foreach (Role r in RoleSettings.Roles) { if (_Request.Get(r.RoleID.ToString(), Method.Post) == "1") { temp = GetData(r.RoleID); tempCollection.Add(temp); } } /*注册用户和游客不能删除, 始终都必须有*/ temp = GetData(Role.Users.RoleID); tempCollection.Add(temp); temp = GetData(Role.Guests.RoleID); tempCollection.Add(temp); /*======================================*/ //重新排序序号, 并且避免重复 bool flag = false; do { flag = false; for (int i = 0; i < tempCollection.Count - 1; i++) { for (int j = i + 1; j < tempCollection.Count; j++) { if (tempCollection[j].SortOrder == tempCollection[i].SortOrder) { tempCollection[j].SortOrder++; flag = true; } } } } while (flag); for (int i = 0; i < tempCollection.Count; i++) { if (string.IsNullOrEmpty(tempCollection[i].RoleName)) { msgDisplay.AddError("rolename", i, Lang_Error.Online_EmpryRoleNameError); } if (string.IsNullOrEmpty(tempCollection[i].LogoUrlSrc)) { msgDisplay.AddError("logourl", i, Lang_Error.Online_EmptyLogoUrlError); } } if (msgDisplay.HasAnyError()) { m_RolesInOnlineList = tempCollection; msgDisplay.AddError(new DataNoSaveError()); } else { OnlineSettings.RolesInOnline = tempCollection; SettingManager.SaveSettings(OnlineSettings); OnlineUserPool.Instance.UpdateUsersOnlineRole(); //OnlineManager.UpdateUserOnlineRoleLogo(); } return(true); }