/// <summary> /// 授予用户特定渠道权限 /// </summary> /// <param name="userId"></param> /// <param name="softId"></param> /// <param name="channelRight"></param> public static void DeleteUserChannelRight(int userId, int softId, ChannelRight channelRight) { string cmdText = string.Format( "delete from R_UserChannelRights where UserID={0} and SoftID={1} and ChannelID={2} and ChannelType={3}", userId, softId, channelRight.ChannelID, (int)channelRight.ChannelType); MySqlHelper.ExecuteNonQuery(DACommonHelper.ConnectionString, cmdText); }
/// <summary> /// 授予用户特定渠道权限 /// </summary> /// <param name="userId"></param> /// <param name="softId"></param> /// <param name="channelRight"></param> public static void AddUserChannelRight(int userId, int softId, ChannelRight channelRight) { string cmdText = string.Format(@"insert into R_UserChannelRights(UserID,SoftID,ChannelType,ChannelID) select {0},{1},{2},{3} from dual where not exists(select * from R_UserChannelRights where UserID={0} and SoftID={1} and ChannelID={3} and ChannelType={2})" , userId, softId, (int)channelRight.ChannelType, channelRight.ChannelID); MySqlHelper.ExecuteNonQuery(DACommonHelper.ConnectionString, cmdText); }
/// <summary> /// 获取指定渠道有权限的用户列表 /// </summary> /// <param name="softId"></param> /// <param name="channelRight"></param> /// <returns></returns> public List <int> GetUserIds(int softId, ChannelRight channelRight) { loginService.HaveAdminRight(DACommonHelper.REPORT_SYS_ID); if (loginService.LoginUser.AccountType == UserTypeOptions.ProductAdmin && !loginService.AvailableSofts.Exists(a => a.ID == softId)) { throw new NotRightException(); } return(DAChannelsHelper.GetUserIds(softId, channelRight)); }
/// <summary> /// 授予用户特定渠道权限 /// </summary> /// <param name="userId"></param> /// <param name="softId"></param> /// <param name="channelRight"></param> public void DeleteUserChannelRight(int userId, int softId, ChannelRight channelRight) { //权限判断 loginService.HaveAdminRightForUserGrantSoft(userId, softId); DAChannelsHelper.DeleteUserChannelRight(userId, softId, channelRight); //记录登录日志 loginService.AddLog( "DeleteUserChannelRight", string.Format("删除用户渠道权限(UserID={0},SoftID={1},ChannelType={2},ChannelID={3})", userId, softId, channelRight.ChannelType, channelRight.ChannelID)); }
/// <summary> /// 获取指定渠道有权限的用户列表 /// </summary> /// <param name="softId"></param> /// <param name="channelRight"></param> /// <returns></returns> public static List <int> GetUserIds(int softId, ChannelRight channelRight) { string cmdText = string.Format( "select UserID from R_UserChannelRights where SoftID={0} and ChannelType={1} and ChannelID={2}", softId, (int)channelRight.ChannelType, channelRight.ChannelID); List <int> userIds = new List <int>(); using (MySqlDataReader reader = MySqlHelper.ExecuteReader(DACommonHelper.ConnectionString, cmdText)) { while (reader.Read()) { userIds.Add(Convert.ToInt32(reader["UserID"])); } } return(userIds); }
/// <summary> /// 获取用户资源权限 /// </summary> /// <param name="userId"></param> /// <param name="softId"></param> /// <returns></returns> public static List <ChannelRight> GetUserChannelRights(int userId, int softId) { string cmdText = string.Format( "SELECT distinct ChannelType,ChannelID FROM R_UserChannelRights WHERE UserID={0} and SoftID={1}", userId, softId); List <ChannelRight> rights = new List <ChannelRight>(); using (MySqlDataReader reader = MySqlHelper.ExecuteReader(DACommonHelper.ConnectionString, cmdText)) { while (reader.Read()) { ChannelRight right = new ChannelRight { ChannelID = Convert.ToInt32(reader["ChannelID"]), ChannelType = (ChannelTypeOptions)Convert.ToInt32(reader["ChannelType"]) }; rights.Add(right); } } return(rights); }