Ejemplo n.º 1
0
        /// <summary>
        /// Get the roles for the requested project and user.
        /// </summary>
        /// <param name="project">string: Project name.</param>
        /// <param name="user">string: Username.</param>
        /// <returns>System.Collections.Generic.List: as type Role.</returns>
        private List<IRole> GetRoles(string project, string user)
        {
            List<IRole> roles = new List<IRole>();
            Data.UserRolesDs.UserRoleViewDataTable dataTable =
                new UserRolesDs.UserRoleViewDataTable();
            Data.UserRolesDsTableAdapters.UserRoleViewTableAdapter tableAdapter =
                new iCampaign.TACS.Data.UserRolesDsTableAdapters.UserRoleViewTableAdapter();
            tableAdapter.Connection = new SqlConnection(TacsSession.ConnectionString);

            //  Get project roles for requested user
            try
            {
                tableAdapter.Connection.Open();
                tableAdapter.FillByUserProject(dataTable, user, project);
            }
            catch (Exception ex)
            {
                throw ex;
            }
            finally
            {
                tableAdapter.Connection.Close();
            }

            //  Load into the generic list collection
            foreach (Data.UserRolesDs.UserRoleViewRow row in dataTable)
            {
                roles.Add(new Role(row.RoleName, (AccessLevelEnum)row.AccessLevel));
            }
            return roles;
        }