Beispiel #1
0
        public GroupProperties GetUTSGroups(string groupName)
        {
            DataTable       dtUsers  = new DataTable();
            DataTable       dtShares = new DataTable();
            GroupProperties group    = new GroupProperties();

            try
            {
                SqlCommand getUsers = new SqlCommand(@"SELECT DISTINCT UsersName from Groups
                                                      JOIN Groups_User on GroupsID = GroupsIDGroups_User
                                                      JOIN USERS on UsersID = UserIDGroups_User
                                                      WHERE GroupsID IN (SELECT GroupsID from Groups WHERE GroupsName = '" + groupName + "')", sqlConnection);

                SqlCommand getShares = new SqlCommand(@"SELECT DISTINCT ShareName, Share_GroupGroupPermissions from Share
                                                        JOIN Share_Groups on Share_GroupShareID = ShareID
                                                        WHERE Share_GroupGroupID IN (SELECT GroupsID from Groups WHERE GroupsName = '" + groupName + "')", sqlConnection);

                sqlConnection.Open();

                SqlDataReader myReader = getUsers.ExecuteReader();
                dtUsers.Load(myReader);
                myReader = getShares.ExecuteReader();
                dtShares.Load(myReader);

                sqlConnection.Close();
            }
            catch (Exception e)
            {
                throw (e);
            }

            if (dtUsers.Rows.Count > 0)
            {
                group.users = new List <string>();
                foreach (DataRow row in dtUsers.Rows)
                {
                    group.users.Add(row[0].ToString());
                }
            }

            if (dtShares.Rows.Count > 0)
            {
                group.shares = new List <Tuple <string, string> >();
                foreach (DataRow row in dtShares.Rows)
                {
                    string sName = row[0].ToString();
                    sName = sName.Substring(sName.LastIndexOf(@"\") + 1);
                    group.shares.Add(new Tuple <string, string>(sName, row[1].ToString()));
                }
            }

            return(group);
        }
        public GroupProperties GetUTSGroups(string groupName)
        {
            DataTable dtUsers = new DataTable();
            DataTable dtShares = new DataTable();
            GroupProperties group = new GroupProperties();
            try
            {
                SqlCommand getUsers = new SqlCommand(@"SELECT DISTINCT UsersName from Groups
                                                      JOIN Groups_User on GroupsID = GroupsIDGroups_User
                                                      JOIN USERS on UsersID = UserIDGroups_User
                                                      WHERE GroupsID IN (SELECT GroupsID from Groups WHERE GroupsName = '" + groupName + "')", sqlConnection);

                SqlCommand getShares = new SqlCommand(@"SELECT DISTINCT ShareName, Share_GroupGroupPermissions from Share
                                                        JOIN Share_Groups on Share_GroupShareID = ShareID
                                                        WHERE Share_GroupGroupID IN (SELECT GroupsID from Groups WHERE GroupsName = '" + groupName + "')", sqlConnection);

                sqlConnection.Open();

                SqlDataReader myReader = getUsers.ExecuteReader();
                dtUsers.Load(myReader);
                myReader = getShares.ExecuteReader();
                dtShares.Load(myReader);

                sqlConnection.Close();
            }
            catch (Exception e)
            {
                throw (e);
            }

            if (dtUsers.Rows.Count > 0)
            {
                group.users = new List<string>();
                foreach (DataRow row in dtUsers.Rows)
                {
                    group.users.Add(row[0].ToString());
                }
            }

            if (dtShares.Rows.Count > 0)
            {
                group.shares = new List<Tuple<string, string>>();
                foreach (DataRow row in dtShares.Rows)
                {
                    string sName = row[0].ToString();
                    sName = sName.Substring(sName.LastIndexOf(@"\") + 1);
                    group.shares.Add(new Tuple<string, string>(sName, row[1].ToString()));
                }
            }

            return group;
        }