Esempio n. 1
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. 2
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);
        }