/// <summary> /// Get access group base on group id from DB /// </summary> /// <returns>one group access object</returns> public static GroupAccess GetAccessGroupById(string groupId) { GroupAccess groupAccesses = null; DataTable dt = null; try { ServiceReference1.WSACUSoapClient client = new ServiceReference1.WSACUSoapClient(); DataSet ds = client.GroupAccessQuery("Q", groupId, ""); dt = ds.Tables[0]; foreach (DataRow dr in dt.Rows) { string Id = dr["groupId"].ToString(); string Name = dr["groupName"].ToString(); string description = dr["groupDescription"].ToString(); //Get user in group List <Users> users = Users.LoadUsersByACGroup(Id); //Get Guser in group List <GroupUser> groupUsers = GroupUser.LoadUserGroupByACGroup(Id); //Get Access Lv in group List <AccessLevel> accessLevels = AccessLevel.LoadAccessLevelByACGroup(Id); groupAccesses = new GroupAccess(Id, Name, description, accessLevels, users, groupUsers); } return(groupAccesses); } catch (Exception ex) { return(null); } }
/// <summary> /// Auto generate access group id base on max group id from DB /// </summary> /// <returns>Group ID: ACGxxxxxxx</returns> public static string GenGroupId() { string Id = ""; DataTable dt = null; try { ServiceReference1.WSACUSoapClient client = new ServiceReference1.WSACUSoapClient(); DataSet ds = client.GroupAccessQuery("S", "", ""); dt = ds.Tables[0]; Id = dt.Rows[0][0].ToString(); return(Id); } catch (Exception ex) { return(""); } }
/// <summary> /// Get all access group from DB /// </summary> /// <returns>list of access group</returns> public static List <GroupAccess> GetAllAccessGroup() { List <GroupAccess> groupAccesses = new List <GroupAccess>(); DataTable dt = null; try { ServiceReference1.WSACUSoapClient client = new ServiceReference1.WSACUSoapClient(); DataSet ds = client.GroupAccessQuery("Q", "", ""); dt = ds.Tables[0]; foreach (DataRow dr in dt.Rows) { string Id = dr["groupID"].ToString(); GroupAccess group = GroupAccess.GetAccessGroupById(Id); groupAccesses.Add(group); } return(groupAccesses); } catch (Exception ex) { return(null); } }