Esempio n. 1
0
        }        //end page_load

        protected void ShowGroupSelect(int userId)
        {
            groupMessage.Text = "";

            GroupDa gda = new GroupDa();

            //get users existing groups
            DataSet uds = gda.GetUserGroupsByUserId(userId);

            rptUserGroups.DataSource = uds.Tables[0].DefaultView;
            rptUserGroups.DataBind();

            if (uds.Tables[0].Rows.Count == 0)
            {
                groupMessage.Text = "No Groups Assigned";
            }

            //get groups
            DataSet gds = gda.GetGroups();

            UserGroup.DataSource     = gds.Tables[0].DefaultView;
            UserGroup.DataValueField = "GroupId";
            UserGroup.DataTextField  = "GroupName";
            UserGroup.DataBind();
            UserGroup.Items.Insert(0, new ListItem(""));

            SelectGroupTable.Visible = true;
        }
        }        //end page_load

        protected void ShowGroupSelect(int datasetId)
        {
            datasetMessage.Text = "";

            GroupDatasetDa da = new GroupDatasetDa();

            //get users existing groups
            DataSet ds = da.GetGroupsByDatasetId(datasetId);

            rptDatasetGroups.DataSource = ds.Tables[0].DefaultView;
            rptDatasetGroups.DataBind();

            if (ds.Tables[0].Rows.Count == 0)
            {
                datasetMessage.Text = "No Groups Assigned";
            }

            //get groups
            GroupDa gda = new GroupDa();
            DataSet gds = gda.GetGroups();

            Group.DataSource     = gds.Tables[0].DefaultView;
            Group.DataValueField = "GroupId";
            Group.DataTextField  = "GroupName";
            Group.DataBind();
            Group.Items.Insert(0, new ListItem(""));

            SelectDatasetTable.Visible = true;
        }
Esempio n. 3
0
        /// <summary>
        /// Save tab names assigned to user group
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        protected void UpdateCodesBtn_Click(object sender, CommandEventArgs e)
        {
            StringBuilder sb = new StringBuilder();

            if (!SbGroup.SelectedValue.Equals(""))
            {
                for (int i = 0; i < TabCheckBoxList.Items.Count; i++)
                {
                    if (TabCheckBoxList.Items[i].Selected)
                    {
                        if (sb.Length > 0)
                        {
                            sb.Append(",");
                        }
                        sb.Append(TabCheckBoxList.Items[i].Text);
                    }
                }

                //update db
                GroupDa da = new GroupDa();
                da.UpdateGroupAccessCode(int.Parse(SbGroup.SelectedValue), sb.ToString());

                //refresh item in cache
                CacheManager.RefreshTabListCache();
            }
        }
Esempio n. 4
0
        /// <summary>
        ///
        /// </summary>
        private void BuildUserGroups()
        {
            GroupDa  gda    = new GroupDa();
            DataView groups = gda.GetGroups().Tables[0].DefaultView;

            GroupsRptr.DataSource = groups;
            GroupsRptr.DataBind();

            GroupsCount.Text = groups.Count.ToString();
        }
Esempio n. 5
0
        /// <summary>
        /// Creates list of tabs names that should be available to user based on the user group(s)
        /// </summary>
        /// <param name="datasetIdVal">datasetId</param>
        public string SetGroupViewCode(int datasetId, string userName)
        {
            UserDa uda = new UserDa();

            DataSet uds    = uda.GetByUserName(userName); //TODO: replace this with call to GetUserId and set output variable UserId
            int     userId = int.Parse(uds.Tables[0].Rows[0][User.UserId].ToString());

            GroupDa da = new GroupDa();
            DataSet ds = da.GetGroupAccessCode(userId, datasetId);

            List <string> tabs = new List <string>();

            foreach (DataRow row in ds.Tables[0].Rows)
            {
                foreach (string s in row[Group.GroupAccessCode].ToString().Split(','))
                {
                    if (!tabs.Contains(s))
                    {
                        tabs.Add(s);
                    }
                }
            }

            // TODO: merge tabs

            //StringBuilder sb = new StringBuilder();
            // TODO: this ALWAYS RETURNS ONE COMMA Deliminated ROW. Don't need all of the below
            // user may be part of many groups and access to tabs must be cumulative

            /*
             * foreach (DataRow dr in ds.Tables[0].Rows)
             * {
             *  sb.Append(dr[Group.GroupAccessCode].ToString());
             * }
             *
             * string[] tabNameList = sb.ToString().Split(new Char[] { ',' });
             *
             * string showTabs = "";
             *
             * // now remove duplicates from list
             *
             * foreach (string s in tabNameList)
             * {
             *  if (showTabs.IndexOf(s) == -1)
             *  {
             *      showTabs += s;
             *  }
             * }
             */
            // in v 4.1 this method moved to UserController for access by other pages. Session references removed.
            //Session[SessionKey.GroupViewCode] = showTabs;
            //string tabs = ds.Tables[0].Rows[0][Group.GroupAccessCode].ToString();

            return(string.Join(",", tabs.ToArray()));
        }
Esempio n. 6
0
        protected void ShowGroupList()
        {
            RepeaterDiv.Visible   = true;
            AddGroupTable.Visible = false;

            GroupDa gda = new GroupDa();
            DataSet uds = gda.GetGroups();

            rptGroups.DataSource = uds.Tables[0].DefaultView;
            rptGroups.DataBind();
        }
Esempio n. 7
0
        public int GetTabCount(int datasetId, string userName)
        {
            // TODO: should just use SetGroupViewCode; parse the string array on the .aspx page so you can use the tab count; dont need this method
            UserDa  uda    = new UserDa();
            DataSet uds    = uda.GetByUserName(userName); //TODO: replace this with call to GetUserId and set output variable UserId
            int     userId = int.Parse(uds.Tables[0].Rows[0][User.UserId].ToString());

            GroupDa da   = new GroupDa();
            DataSet ds   = da.GetGroupAccessCode(userId, datasetId);
            string  tabs = ds.Tables[0].Rows[0][Group.GroupAccessCode].ToString();

            string[] tabNameList = tabs.ToString().Split(new Char[] { ',' });
            return(tabNameList.Length);
        }
Esempio n. 8
0
 override protected void Page_Load(object sender, System.EventArgs e)
 {
     if (!IsPostBack)
     {
         //get groups
         GroupDa gda = new GroupDa();
         DataSet gds = gda.GetGroups();
         SbGroup.DataSource     = gds.Tables[0].DefaultView;
         SbGroup.DataValueField = "GroupId";
         SbGroup.DataTextField  = "GroupName";
         SbGroup.DataBind();
         SbGroup.Items.Insert(0, new ListItem(""));
     }
 }
Esempio n. 9
0
        private void BuildUserGroups(int?userId)
        {
            GroupsList.Items.Clear();

            if (userId.HasValue)
            {
                GroupDa  da         = new GroupDa();
                DataView groupsList = da.GetGroupsByUser(userId.Value).DefaultView;
                groupsList.Sort = BOL.Group.GroupName + " ASC";

                // build list of avialble groups
                // groupsList.RowFilter = BOL.UserGroup.UserGroupId + " IS NULL";
                GroupsList.DataSource = groupsList;
                GroupsList.DataBind();
                SetGroupCheckBox(GroupsList, groupsList.Table);

                // build list of current groups
                groupsList.RowFilter             = BOL.UserGroup.UserGroupId + " IS NOT NULL";
                UserGroupsPanel.Visible          = true;
                CurrentUserGroupsRptr.DataSource = groupsList;
                CurrentUserGroupsRptr.DataBind();

                BuildUserAttributes(userId.Value);

                AddUserGroupText.Visible = true;
            }
            else
            {
                DataView groupsList = BOL.BusinessObject.GetAllAsDataView <BOL.Group>();
                groupsList.Sort = BOL.Group.GroupName + " ASC";

                // build list of avialble groups
                GroupsList.DataSource = groupsList;
                GroupsList.DataBind();

                // build list of current groups (empty)
                UserGroupsPanel.Visible          = false;
                CurrentUserGroupsRptr.DataSource = null;
                CurrentUserGroupsRptr.DataBind();

                AddUserGroupText.Visible = false;
            }
        }
Esempio n. 10
0
        protected void DeleteButtonClick(object sender, CommandEventArgs e)
        {
            RepeaterDiv.Visible = false;

            GroupDa groupDa       = new GroupDa();
            int     groupId       = int.Parse(e.CommandName);
            DataSet ds            = groupDa.GetUsersInGroup(groupId);
            string  numberOfUsers = "";

            if (ds.Tables[0].Rows.Count > 0)
            {
                numberOfUsers = ds.Tables[0].Rows[0]["UserCount"].ToString();

                valMsg.Text = "There are " + numberOfUsers + " users associated with this group. Are you sure you want to delete it?";
            }
            else
            {
                valMsg.Text = "There are currently no users associated with this group. Confirm delete?";
            }
            valMsg.Text += "<br><br><a href=\"AdminGroups.aspx?delete=yes&groupId=" + groupId + "\">Yes</a>&nbsp;&nbsp;&nbsp;&nbsp;<a href=\"AdminGroups.aspx\">No</a>";
        }
Esempio n. 11
0
        protected override void Page_Load(object sender, EventArgs e)
        {
            // validate GROUP access
            string  userName       = new Security.SecurityController().GetUserName();
            GroupDa da             = new GroupDa();
            var     userGroupNames = da.GetUserGroups(userName).Tables[0].AsEnumerable().Select(r => r[BOL.Group.GroupName].ToString());

            // if user is not in special group, end response
            if (RESTRICTED_GROUPS.Intersect(userGroupNames).Count() == 0)
            {
                Page.Visible = false;
                Response.End();
            }

            base.Page_Load(sender, e);
            base.EnableViewState = true;
            if (!Page.IsPostBack)
            {
                // default dates
                FromDate.Text = DateTime.Today.AddMonths(-1).ToShortDateString();
                ToDate.Text   = DateTime.Today.ToShortDateString();
            }
        }
Esempio n. 12
0
        protected void EditButtonClick(object sender, CommandEventArgs e)
        {
            RepeaterDiv.Visible   = false;
            AddGroupTable.Visible = true;
            UpdateBtn.Visible     = true;
            AddBtn.Visible        = false;

            this.PopulateRolesSelect();

            GroupDa groupDa = new GroupDa();
            int     groupId = int.Parse(e.CommandName);
            DataSet ds      = groupDa.GetGroupsRecord(groupId);

            if (ds.Tables[0].Rows.Count > 0)
            {
                GroupId.Value   = groupId.ToString();
                GroupName.Value = ds.Tables[0].Rows[0][Group.GroupName].ToString();
                GroupDesc.Value = ds.Tables[0].Rows[0][Group.GroupDescription].ToString();
                GroupRole.Value = ds.Tables[0].Rows[0][Group.RoleId].ToString();
            }


            //this.Page_Load(sender, (System.EventArgs)e);
        }