public ApiMessage GetAdminActions() { ApiMessage message = new ApiMessage() { Status = "ok" }; List <BAdminCategoryAction> actions = new List <BAdminCategoryAction>(); HttpContextBase context = (HttpContextBase)Request.Properties["MS_HttpContext"]; HttpRequestBase request = context.Request; string user_id = User.Identity.Name; UserManager userMgr = new UserManager(int.Parse(user_id), null); BUser user = userMgr.CurrentUser; PermissionManagement permissionMgt = new PermissionManagement(userMgr.CurrentUser, userMgr.Shop, userMgr.CurrentUserPermission); int role_id = 0; int.TryParse(request["role"], out role_id); try { actions = permissionMgt.GetActionsByCategory(role_id); message.Item = actions; } catch (KMJXCException kex) { message.Status = "failed"; message.Message = kex.Message; } catch { } finally { } return(message); }
static void Main(string[] args) { log4net.Config.XmlConfigurator.Configure(); Logger = log4net.LogManager.GetLogger("Main..."); if (args.Length == 0) { Console.WriteLine("Please provide the command."); return; } string command = args[0]; Logger.Info("command:" + command); switch (command) { case "syncpermissions": PermissionManagement pgt = new PermissionManagement(3); pgt.SyncPermissionsWithDB(); break; case "getstatus": GetStatus(); break; default: break; } }
private void loadsecuritycode() { // updating token try { int roleId = Convert.ToInt32(ddlRole.SelectedValue.ToString()); AccessToken token = new AccessToken(); string accessToken = AccessToken.ReturnEmptyToken(); //accessToken = ReadPermissions(accessToken, token); // loading existing token int roleid = Conversion.ParseInt(ddlRole.SelectedValue); int subroleid = Conversion.ParseInt(ddlSubRole.SelectedValue); DataTable dt = RoleManagement.GetRoleSubroleNGroupByIds(roleid, subroleid); List <int> groupids = new List <int>(); if (dt != null && dt.Rows.Count > 0) { for (int j = 0; j < dt.Rows.Count; j++) { string groupid = dt.Rows[j]["intGroupID"].ToString(); groupids.Add(Convert.ToInt32(groupid)); } System.Data.DataTable resourceTopics = GroupPages.GetAllResources(); for (int i = 0; i < resourceTopics.Rows.Count; i++) { DataRow row = resourceTopics.Rows[i]; int resourceid = Convert.ToInt32(row["intResourceId"].ToString()); //foreach (ResourceType item in Enum.GetValues(typeof(ResourceType))) //{ List <string> securityTokens = new List <string>(); foreach (int gid in groupids) { securityTokens.Add(RoleManagement.GetSecurityToken(Convert.ToInt32(gid))); } canView = canAdd = canUpdate = canDelete = false; foreach (string st in securityTokens) { PermissionManagement.GetPermissionOnlyFalsed(resourceid, ref canView, ref canAdd, ref canUpdate, ref canDelete, st); } accessToken = ReadDetailPermissions(resourceid, canView, canAdd, canUpdate, canDelete, accessToken, token); //} } } // generating new token RoleManagement.UpdateSecurityTokenbyRoleId(subroleid, accessToken); } catch (Exception ex) { new SqlLog().InsertSqlLog(0, "GroupPermission.aspx.loadsecuritycode", ex); } }
public void GetPermission(ResourceType resourceType, ref bool canView, ref bool canAdd, ref bool canUpdate, ref bool canDelete) { UserInfo user = UserInfo.GetCurrentUserInfo(); HttpCookie cookie = HttpContext.Current.Request.Cookies.Get("securityToken"); string securityToken = string.Empty; if (cookie == null || string.IsNullOrEmpty(cookie.Value)) { //string[] GroupsArray = user.UserGroupsCommaSeprated.Split(','); //int groupid = Convert.ToInt32(Convert.ToString(GroupsArray[0])); securityToken = RoleManagement.GetSecurityTokenByRoleId(user.RoleId); //StringBuilder sb = new StringBuilder(250); //sb.Append(user.RoleId); //sb.Append("|"); //sb.Append(user.MemberId); //sb.Append("|"); //sb.Append(securityToken); HttpCookie securityCookie = new HttpCookie("securityToken"); //Decoder d= Encoding.UTF8.GetDecoder(); ///securityCookie.Value = Encryption.Encrypt(securityToken); //////securityCookie.Value = Server.UrlEncode(sb.ToString()); securityCookie.Value = Server.UrlEncode(securityToken); HttpContext.Current.Response.Cookies.Add(securityCookie); } else { //securityToken = Encryption.Decrypt(cookie.Value); securityToken = Server.UrlDecode(cookie.Value); //string cookieSecurityToken = string.Empty; //cookieSecurityToken = Server.UrlDecode(cookie.Value); //string[] cookieValue = GetInfoFromCookie(cookieSecurityToken); //if (cookieValue != null) //{ // if (user.MemberId == Convert.ToInt32(cookieValue[0])) // { } // if (user.RoleId == Convert.ToInt32(cookieValue[1])) // { } // securityToken = cookieValue[2].ToString(); //} } PermissionManagement.GetPermission(resourceType, ref canView, ref canAdd, ref canUpdate, ref canDelete, securityToken); }
public void GetPermission(ResourceType resourceType, int memberId, ref bool canView, ref bool canAdd, ref bool canUpdate, ref bool canDelete) { UserInfo user = UserInfo.UserTopRole(memberId); HttpCookie cookie = HttpContext.Current.Request.Cookies.Get("securityToken"); string securityToken = string.Empty; if (user != null) { securityToken = RoleManagement.GetSecurityTokenByRoleId(user.RoleId); PermissionManagement.GetPermission(resourceType, ref canView, ref canAdd, ref canUpdate, ref canDelete, securityToken); } }
public void GetPermission(ResourceType resourceType, ref bool canView, ref bool canAdd, ref bool canUpdate, ref bool canDelete, string groupid) { HttpCookie cookie = HttpContext.Current.Request.Cookies.Get("securityToken"); string securityToken = string.Empty; if (cookie == null || string.IsNullOrEmpty(cookie.Value)) { securityToken = RoleManagement.GetSecurityToken(Convert.ToInt32(groupid)); HttpCookie securityCookie = new HttpCookie("securityToken"); securityCookie.Value = Server.UrlEncode(securityToken); HttpContext.Current.Response.Cookies.Add(securityCookie); } else { securityToken = Server.UrlDecode(cookie.Value); } PermissionManagement.GetPermission(resourceType, ref canView, ref canAdd, ref canUpdate, ref canDelete, securityToken); }
public ApiMessage CreateRole() { ApiMessage message = new ApiMessage() { Status = "ok" }; List <BAdminRole> roles = new List <BAdminRole>(); HttpContextBase context = (HttpContextBase)Request.Properties["MS_HttpContext"]; HttpRequestBase request = context.Request; string user_id = User.Identity.Name; UserManager userMgr = new UserManager(int.Parse(user_id), null); BUser user = userMgr.CurrentUser; PermissionManagement permissionMgt = new PermissionManagement(userMgr.CurrentUser, userMgr.Shop, userMgr.CurrentUserPermission); string role_name = request["role"]; string desc = request["desc"]; int shop_id = 0; int.TryParse(request["shop_id"], out shop_id); try { int[] actions = this.ConvertToIntArrar(request["actions"]); if (string.IsNullOrEmpty(role_name)) { message.Status = "failed"; message.Message = "分组名字不能为空"; return(message); } BAdminRole role = permissionMgt.CreateRole(role_name, desc, actions, shop_id); message.Item = role; } catch (KMJXCException kex) { message.Status = "failed"; message.Message = kex.Message; } catch { } finally { } return(message); }
public ApiMessage UpdateUserRoles() { ApiMessage message = new ApiMessage() { Status = "ok" }; HttpContextBase context = (HttpContextBase)Request.Properties["MS_HttpContext"]; HttpRequestBase request = context.Request; string user_id = User.Identity.Name; UserManager userMgr = new UserManager(int.Parse(user_id), null); BUser user = userMgr.CurrentUser; PermissionManagement permissionMgt = new PermissionManagement(userMgr.CurrentUser, userMgr.Shop, userMgr.CurrentUserPermission); int[] role_id = null; int uid = 0; int.TryParse(request["user"], out uid); try { role_id = this.ConvertToIntArrar(request["roles"]); if (role_id != null && role_id.Length > 0) { permissionMgt.UpdateUserRoles(role_id, uid); } else { message.Status = "failed"; message.Message = "请选择正确的权限分组"; } } catch (KMJXCException kex) { message.Status = "failed"; message.Message = kex.Message; } catch { } finally { } return(message); }
public ApiMessage SetAdminRoleStatus() { ApiMessage message = new ApiMessage() { Status = "ok" }; List <BAdminRole> roles = new List <BAdminRole>(); HttpContextBase context = (HttpContextBase)Request.Properties["MS_HttpContext"]; HttpRequestBase request = context.Request; string user_id = User.Identity.Name; UserManager userMgr = new UserManager(int.Parse(user_id), null); BUser user = userMgr.CurrentUser; PermissionManagement permissionMgt = new PermissionManagement(userMgr.CurrentUser, userMgr.Shop, userMgr.CurrentUserPermission); int role_id = 0; bool status = true; int.TryParse(request["role"], out role_id); if (!string.IsNullOrEmpty(request["status"]) && request["status"] == "1") { status = true; } else if (!string.IsNullOrEmpty(request["status"]) && request["status"] == "0") { status = false; } try { permissionMgt.SetAdminRoleStatus(role_id, status); } catch (KMJXCException kex) { message.Status = "failed"; message.Message = kex.Message; } catch { } finally { } return(message); }
public PlayerData(Player player, int playerId, string username, string motto, string look, int homeRoom, int rank, int achievementScore, string clientVolume, bool chatPreference, bool allowMessengerInvites, bool focusPreference, int vipRank) { _player = player; _playerId = playerId; _username = username; _motto = motto; _look = look; _homeRoom = homeRoom; _rank = rank; _achievementScore = achievementScore; _clientVolumes = new List <int>(); _chatPreference = chatPreference; _allowMessengerInvites = allowMessengerInvites; _focusPreference = focusPreference; _vipRank = vipRank; _permissionManagement = new PermissionManagement(_player); _playerAchievements = new ConcurrentDictionary <string, PlayerAchievement>(); _favouriteRoomIds = new List <int>(); _mutedUsers = new List <int>(); _badgeManagement = new BadgeManagement(_player); _inventoryManagement = new InventoryManagement(_player); _playerQuests = new Dictionary <int, int>(); _playerBuddies = new Dictionary <int, MessengerBuddy>(); _playersRooms = new List <RoomInformation>(); _playerRelationships = new Dictionary <int, PlayerRelationship>(); _effectManagement = new EffectManagement(_player); _clothingManagement = new ClothingManagement(_player); _logManager = Sahara.GetServer().GetLogManager(); _processor = new PlayerProcessor(_player); foreach (var volumeString in clientVolume.Split(',')) { if (string.IsNullOrEmpty(volumeString)) { continue; } var volumeValue = 0; _clientVolumes.Add(int.TryParse(volumeString, out volumeValue) ? int.Parse(volumeString) : 100); } }
public void GetPermission(ResourceType resourceType, int memberId, ref bool canView, ref bool canAdd, ref bool canUpdate, ref bool canDelete) { UserInfo user = UserInfo.UserTopRole(memberId); HttpCookie cookie = HttpContext.Current.Request.Cookies.Get("securityToken"); string securityToken = string.Empty; if (user != null) { securityToken = RoleManagement.GetSecurityTokenByRoleId(user.RoleId); //DataSet ds= RoleManagement.GetSecurityTokenByGroupIds(user.UserGroupsCommaSeprated); //if (ds != null && ds.Tables.Count > 0 && ds.Tables[0].Rows.Count > 0) //{ // foreach (DataRow row in ds.Tables[0].Rows) // { //securityToken = Conversion.ParseDBNullString(row["vchSecurityCode"]); PermissionManagement.GetPermission(resourceType, ref canView, ref canAdd, ref canUpdate, ref canDelete, securityToken); // } //} } }
public ApiMessage GetAdminRoles() { ApiMessage message = new ApiMessage() { Status = "ok" }; List <BAdminRole> roles = new List <BAdminRole>(); HttpContextBase context = (HttpContextBase)Request.Properties["MS_HttpContext"]; HttpRequestBase request = context.Request; string user_id = User.Identity.Name; UserManager userMgr = new UserManager(int.Parse(user_id), null); BUser user = userMgr.CurrentUser; PermissionManagement permissionMgt = new PermissionManagement(userMgr.CurrentUser, userMgr.Shop, userMgr.CurrentUserPermission); bool enabled = true; if (request["enabled"] != null && request["enabled"] == "0") { enabled = false; } int shop = 0; int.TryParse(request["shop"], out shop); try { roles = permissionMgt.GetAdminRoles(shop, enabled); message.Item = roles; } catch (KMJXCException kex) { message.Status = "failed"; message.Message = kex.Message; } catch { } finally { } return(message); }
static void Main(string[] args) { Logger = KMLogger.GetLogger(); args = new string[] { "getstatus" }; if (args.Length == 0) { Console.WriteLine("Please provide the command."); return; } string command = args[0]; Logger.Info("command:" + command); switch (command) { case "syncpermissions": PermissionManagement pgt = new PermissionManagement(3); pgt.SyncPermissionsWithDB(); break; case "getstatus": //GetStatus(); Console.WriteLine("Six threads will be started in every 8 seconds to query order status..."); Logger.Info("Six threads will be started in every 8 seconds to query order status..."); GetStatus(); break; case "qr": if (args.Length <= 1 || string.IsNullOrEmpty(args[1])) { Console.WriteLine("Content cannot be empty when trying to generate qr file."); return; } GenerateQRFile(args[1]); break; default: break; } }
public ApiMessage UpdateRoleActions() { ApiMessage message = new ApiMessage() { Status = "ok" }; HttpContextBase context = (HttpContextBase)Request.Properties["MS_HttpContext"]; HttpRequestBase request = context.Request; string user_id = User.Identity.Name; UserManager userMgr = new UserManager(int.Parse(user_id), null); BUser user = userMgr.CurrentUser; PermissionManagement permissionMgt = new PermissionManagement(userMgr.CurrentUser, userMgr.Shop, userMgr.CurrentUserPermission); int role_id = 0; int[] actions = null; int.TryParse(request["role"], out role_id); try { actions = this.ConvertToIntArrar(request["actions"]); if (actions != null) { permissionMgt.UpdateRoleActions(role_id, actions); } } catch (KMJXCException kex) { message.Status = "failed"; message.Message = kex.Message; } catch { } finally { } return(message); }
public BUser GetUserInfo(string email) { if (string.IsNullOrEmpty(email)) { return(null); } BUser user = null; using (chargebitEntities db = new chargebitEntities()) { user = new BUser(); user.User = (from u in db.Users where u.Email == email select u).FirstOrDefault <Users>(); Admin_Users au = (from ausr in db.Admin_Users where ausr.User_Id == user.User.Id select ausr).FirstOrDefault <Admin_Users>(); if (au != null) { user.IsSuperAdmin = au.IsSuperAdmin; user.IsWebMaster = au.IsWebMaster; user.IsAdmin = true; } if (!user.IsSuperAdmin) { user.Permission = PermissionManagement.GetUserPermissions(user.User.Id); } else { user.Permission = new Permissions(); System.Reflection.FieldInfo[] fields = typeof(Permissions).GetFields(); foreach (System.Reflection.FieldInfo field in fields) { field.SetValue(user.Permission, 1); } } } return(user); }
static void Main(string[] args) { PermissionManagement.SyncPermissionWithAction(); PermissionManagement.SyncUserAction(); }