Exemplo n.º 1
0
        private string BindOrdinaryTree(int parentId)
        {
            List <JsonTreeNode> nodes = new List <JsonTreeNode>();

            using (IDataReader reader = SecureGroup.GetListChildGroups(parentId))
            {
                while (reader.Read())
                {
                    int          iGroupId = (int)reader["GroupId"];
                    JsonTreeNode node     = new JsonTreeNode();
                    node.icon = "../../../Layouts/Images/icons/regular.gif";
                    if (iGroupId < 9 && iGroupId != 6)
                    {
                        node.icon = "../../../Layouts/Images/icons/Admins.gif";
                    }
                    if (SecureGroup.IsPartner(iGroupId) || iGroupId == 6)
                    {
                        node.icon = "../../../Layouts/Images/icons/Partners.gif";
                    }
                    node.iconCls = "iconStdCls";

                    node.leaf = true;
                    using (IDataReader rdr = SecureGroup.GetListChildGroups(iGroupId))
                    {
                        if (rdr.Read())
                        {
                            node.leaf = false;
                        }
                    }
                    node.text = CHelper.GetResFileString(reader["GroupName"].ToString());
                    node.cls  = "nodeCls";

                    node.href       = "../../../Directory/Directory.aspx?Tab=0&SGroupID=" + iGroupId.ToString(CultureInfo.InvariantCulture);
                    node.hrefTarget = "right";

                    node.id             = Guid.NewGuid().ToString("N");
                    node.itemid         = iGroupId.ToString();
                    node.staticParentId = _rootId;

                    nodes.Add(node);
                }
            }

            if (nodes.Count > 0)
            {
                return(UtilHelper.JsonSerialize(nodes));
            }
            else
            {
                return(String.Empty);
            }
        }
Exemplo n.º 2
0
        private void ShowStep(int step)
        {
            for (int i = 0; i <= _stepCount; i++)
            {
                ((Panel)steps[i]).Visible = false;
            }

            ((Panel)steps[step - 1]).Visible = true;

            if (step == _stepCount)
            {
                if (user_type == 1 && rbAccount.SelectedItem.Value == "0")
                {
                    lblstep4.Text = LocRM.GetString("tTextForRegularAccount");
                }
                if ((user_type == 2 && rbAccount.SelectedItem.Value == "0") || (user_type == 3))
                {
                    lblstep4.Text = LocRM.GetString("tTextForPendingAccount");
                }
                if (user_type < 3 && rbAccount.SelectedItem.Value == "1")
                {
                    lblstep4.Text = LocRM.GetString("tTextForExternalAccount");
                }
                if (user_type < 3 && rbAccount.SelectedItem.Value == "2")
                {
                    lblstep4.Text = LocRM.GetString("tTextForPartnerAccount");
                }
            }
            if (step == 2)
            {
                lstTimeZone.DataSource     = User.GetListTimeZone();
                lstTimeZone.DataTextField  = "DisplayName";
                lstTimeZone.DataValueField = "TimeZoneId";
                lstTimeZone.DataBind();
                EmaiDuplication.Enabled = true;

                int TimeZoneId = Security.CurrentUser.TimeZoneId;
                lstTimeZone.ClearSelection();
                ListItem li = lstTimeZone.Items.FindByValue(TimeZoneId.ToString());
                if (li != null)
                {
                    li.Selected = true;
                }
            }
            if (step == 2 && user_type < 3)
            {
                if (rbAccount.SelectedItem.Value == "1")
                {
                    trLogin.Visible   = false;
                    trPass.Visible    = false;
                    trConfirm.Visible = false;
                }
                else
                {
                    trLogin.Visible   = true;
                    trPass.Visible    = true;
                    trConfirm.Visible = true;
                }
            }

            if (step == 3)
            {
                ViewState["password"] = txtPassword.Text;
            }

            if (user_type == 1 && step == 3)
            {
                if (rbAccount.SelectedItem.Value == "1")
                {
                    fsGroups.Visible        = false;
                    trIMGroup.Visible       = false;
                    fsRole.Visible          = false;
                    fsTextExt.Visible       = true;
                    EmaiDuplication.Enabled = true;
                    fsPartner.Visible       = false;
                }
                else if (rbAccount.SelectedItem.Value == "0")
                {
                    fsPartner.Visible       = false;
                    fsTextExt.Visible       = false;
                    fsGroups.Visible        = true;
                    trIMGroup.Visible       = true;
                    fsRole.Visible          = true;
                    EmaiDuplication.Enabled = true;
                    string    sGroups  = iGroups.Value;
                    ArrayList alGroups = new ArrayList();
                    while (sGroups.Length > 0)
                    {
                        alGroups.Add(Int32.Parse(sGroups.Substring(0, sGroups.IndexOf(","))));
                        sGroups = sGroups.Remove(0, sGroups.IndexOf(",") + 1);
                    }
                    foreach (int i in alGroups)
                    {
                        ListItem lItm = lbAvailableGroups.Items.FindByValue(i.ToString());
                        if (lItm != null)
                        {
                            lbAvailableGroups.Items.Remove(lItm);
                            lbSelectedGroups.Items.Add(lItm);
                        }
                    }
                }
                else
                {
                    EmaiDuplication.Enabled        = true;
                    fsGroups.Visible               = false;
                    trIMGroup.Visible              = false;
                    fsRole.Visible                 = false;
                    fsTextExt.Visible              = false;
                    fsPartner.Visible              = true;
                    ddPartnerGroups.DataTextField  = "GroupName";
                    ddPartnerGroups.DataValueField = "GroupId";
                    ddPartnerGroups.DataSource     = SecureGroup.GetListChildGroups((int)InternalSecureGroups.Partner);
                    ddPartnerGroups.DataBind();
                }
            }

            #region Save
            if (step == _stepCount + 1)
            {
                try
                {
                    if (user_type == 1)
                    {
                        if (rbAccount.SelectedItem.Value == "0")
                        {
                            ArrayList alGroups = new ArrayList();
                            string    sGroups  = iGroups.Value;
                            while (sGroups.Length > 0)
                            {
                                alGroups.Add(Int32.Parse(sGroups.Substring(0, sGroups.IndexOf(","))));
                                sGroups = sGroups.Remove(0, sGroups.IndexOf(",") + 1);
                            }
                            if (cbRole.Items[0].Selected)
                            {
                                alGroups.Add(4);
                            }
                            if (cbRole.Items[1].Selected)
                            {
                                alGroups.Add(3);
                            }
                            if (cbRole.Items[2].Selected)
                            {
                                alGroups.Add(5);
                            }
                            ViewState["UserID"] = User.Create(txtLogin.Text, ViewState["password"].ToString(), txtFirstName.Text, txtLastName.Text,
                                                              txtEMail.Text, true, alGroups, int.Parse(ddIMGroup.SelectedItem.Value), txtWorkPhone.Text,
                                                              "", txtMobilePhone.Text, txtPosition.Text, txtDepartment.Text, txtCompany.Text,
                                                              txtLocation.Text, int.Parse(lstTimeZone.SelectedItem.Value), int.Parse(ddLang.SelectedItem.Value), txtWelcome.Text, "", null, "", -1);
                        }
                        else if (rbAccount.SelectedItem.Value == "1")
                        {
                            ViewState["UserID"] = User.CreateExternal(txtFirstName.Text, txtLastName.Text, txtEMail.Text,
                                                                      new ArrayList(),
                                                                      true, txtWorkPhone.Text, "", txtMobilePhone.Text, txtPosition.Text, txtDepartment.Text,
                                                                      txtCompany.Text, txtLocation.Text, int.Parse(lstTimeZone.SelectedItem.Value), int.Parse(ddLang.SelectedItem.Value),
                                                                      txtWelcome.Text, "", null);
                        }
                        else
                        {
                            ViewState["UserID"] = User.CreatePartnerUser(txtLogin.Text, ViewState["password"].ToString(), txtFirstName.Text, txtLastName.Text,
                                                                         txtEMail.Text, true, int.Parse(ddPartnerGroups.SelectedItem.Value), txtWorkPhone.Text,
                                                                         "", txtMobilePhone.Text, txtPosition.Text, txtDepartment.Text, txtCompany.Text,
                                                                         txtLocation.Text, int.Parse(lstTimeZone.SelectedItem.Value), int.Parse(ddLang.SelectedItem.Value), txtWelcome.Text, "", null, -1);
                        }
                    }
                    else if (user_type == 2)
                    {
                        if (rbAccount.SelectedItem.Value == "0")
                        {
                            ViewState["UserID"] = User.CreatePending(txtLogin.Text, ViewState["password"].ToString(), txtFirstName.Text, txtLastName.Text,
                                                                     txtEMail.Text, new ArrayList(), txtWorkPhone.Text, "", txtMobilePhone.Text, txtPosition.Text,
                                                                     txtDepartment.Text, txtCompany.Text, txtLocation.Text, int.Parse(lstTimeZone.SelectedItem.Value), int.Parse(ddLang.SelectedItem.Value), txtWelcome.Text, "", null);
                        }
                        else
                        {
                            ViewState["UserID"] = User.CreateExternal(txtFirstName.Text, txtLastName.Text, txtEMail.Text, new ArrayList(),
                                                                      true, txtWorkPhone.Text, "", txtMobilePhone.Text, txtPosition.Text, txtDepartment.Text,
                                                                      txtCompany.Text, txtLocation.Text, int.Parse(lstTimeZone.SelectedItem.Value), int.Parse(ddLang.SelectedItem.Value),
                                                                      txtWelcome.Text, "", null);
                        }
                    }
                    else
                    {
                        ViewState["UserID"] = User.CreatePending(txtLogin.Text, ViewState["password"].ToString(), txtFirstName.Text, txtLastName.Text,
                                                                 txtEMail.Text, new ArrayList(), txtWorkPhone.Text, "", txtMobilePhone.Text, txtPosition.Text,
                                                                 txtDepartment.Text, txtCompany.Text, txtLocation.Text, int.Parse(lstTimeZone.SelectedItem.Value), int.Parse(ddLang.SelectedItem.Value), txtWelcome.Text, "", null);
                    }
                }
                catch (MaxUsersCountException)
                {
                    lblError.Text    = LocRM.GetString("MaxUsersCount");
                    lblError.Visible = true;
                }
                catch (EmailDuplicationException)
                {
                    int    iUserId   = User.GetUserByEmail(txtEMail.Text);
                    string sUserName = String.Empty;
                    if (iUserId > 0)
                    {
                        sUserName = CommonHelper.GetUserStatusPureName(iUserId);
                    }
                    lblError.Text    = LocRM.GetString("EmailDuplicate") + " (" + sUserName + ")";
                    lblError.Visible = true;
                }
                catch (LoginDuplicationException)
                {
                    lblError.Text    = LocRM.GetString("DuplicatedLogin");
                    lblError.Visible = true;
                }
            }
            #endregion
        }
Exemplo n.º 3
0
        private void BinddgGroupsUsers()
        {
            dgGroupsUsers.Columns[2].HeaderText = LocRM.GetString("GroupUser");
            dgGroupsUsers.Columns[3].HeaderText = LocRM.GetString("Email");

            DataTable dt = new DataTable();

            dt.Columns.Add("ObjectId", typeof(int));
            dt.Columns.Add("Type");
            dt.Columns.Add("Title");
            dt.Columns.Add("Email");
            dt.Columns.Add("sortTitle");
            dt.Columns.Add("ActionView");
            dt.Columns.Add("ActionEdit");
            dt.Columns.Add("HasChildren", typeof(bool));
            dt.Columns.Add("IsActive", typeof(bool));

            bool    CanUpdate = SecureGroup.CanUpdate();
            DataRow dr;

            if (GroupID != 1)             // [..]
            {
                int iParentId = SecureGroup.GetParentGroup(GroupID);
                dr                = dt.NewRow();
                dr["ObjectId"]    = 0;
                dr["Type"]        = "Group";
                dr["Title"]       = "<span style='padding-left:15px'>&nbsp;</span><a href='../Directory/directory.aspx?Tab=0&amp;SGroupID=" + iParentId.ToString() + "'>[..]</a>";
                dr["HasChildren"] = true;
                dr["IsActive"]    = true;
                dt.Rows.Add(dr);
            }
            using (IDataReader reader = SecureGroup.GetListChildGroups(GroupID))
            {
                while (reader.Read())
                {
                    dr             = dt.NewRow();
                    dr["ObjectId"] = reader["GroupId"];
                    dr["Type"]     = "Group";
                    int iGroupId = (int)reader["GroupId"];
                    dr["Title"]       = CommonHelper.GetGroupLink(iGroupId, CommonHelper.GetResFileString((string)reader["GroupName"]));
                    dr["sortTitle"]   = CommonHelper.GetResFileString(reader["GroupName"].ToString());
                    dr["HasChildren"] = reader["HasChildren"];
                    dr["IsActive"]    = true;

                    if (CanUpdate && iGroupId > 9)
                    {
                        dr["ActionEdit"] = "<a href='../Directory/AddGroup.aspx?Type=0&amp;Edit=1&amp;GroupID=" + iGroupId.ToString() + "'>" + "<img alt='' src='../layouts/images/edit.GIF'/></a>";
                    }
                    dt.Rows.Add(dr);
                }
            }

            if (dt.Rows.Count == 1 && GroupID == 6)             // Partner
            {
                PartnerLabel.Text    = LocRM.GetString("CreatePartnerGroup");
                PartnerLabel.Visible = true;
            }
            else
            {
                PartnerLabel.Visible = false;
            }

            //SELECT PrincipalId AS UserId, Login, FirstName, LastName, Email, IsActive, IMGroupId

            CanUpdate = User.CanUpdateUserInfo();
            bool bIsPartner = SecureGroup.IsPartner(GroupID);

            using (IDataReader reader = SecureGroup.GetListUsersInGroup(GroupID))
            {
                while (reader.Read())
                {
                    byte Activity   = (byte)reader["Activity"];
                    bool IsExternal = (bool)reader["IsExternal"];

                    dr             = dt.NewRow();
                    dr["ObjectId"] = reader["UserId"];

                    dr["Type"]      = "User";
                    dr["Title"]     = CommonHelper.GetUserStatus((int)reader["UserId"]);
                    dr["sortTitle"] = CommonHelper.GetUserStatusPureName((int)reader["UserId"]);
                    dr["Email"]     = "<a href='mailto:" + (string)reader["Email"] + "'>" + (string)reader["Email"] + "</a>";
                    if (CanUpdate)
                    {
                        if (Activity == (byte)User.UserActivity.Pending)
                        {
                            dr["ActionEdit"] = "<a href='../Directory/UserEdit.aspx?UserID=" + reader["UserId"].ToString() + "' title='" + LocRM.GetString("tApprove") + "'>"
                                               + "<img alt='' src='../layouts/images/icon-key.GIF'/></a>";
                        }
                        else if (GroupID == (int)InternalSecureGroups.Partner || bIsPartner)
                        {
                            dr["ActionEdit"] = "<a href='../Directory/PartnerEdit.aspx?UserID=" + reader["UserId"].ToString() + "' title='" + LocRM.GetString("tEdit") + "'>"
                                               + "<img alt='' src='../layouts/images/edit.GIF'/></a>";
                        }
                        else if (IsExternal)
                        {
                            dr["ActionEdit"] = "<a href='../Directory/ExternalEdit.aspx?UserID=" + reader["UserId"].ToString() + "' title='" + LocRM.GetString("tEdit") + "'>"
                                               + "<img alt='' src='../layouts/images/edit.GIF'/></a>";
                        }
                        else
                        {
                            dr["ActionEdit"] = "<a href='../Directory/UserEdit.aspx?UserID=" + reader["UserId"].ToString() + "' title='" + LocRM.GetString("tEdit") + "'>"
                                               + "<img alt='' src='../layouts/images/edit.GIF'/></a>";
                        }
                    }
                    dr["ActionView"] = "<a href='../Directory/UserView.aspx?UserID=" + reader["UserId"].ToString() + "' title='" + LocRM.GetString("tViewDetails") + "'>"
                                       + "<img alt='' src='../layouts/images/Icon-Search.GIF'/></a>";

                    dr["HasChildren"] = false;
                    dr["IsActive"]    = (Activity > 1);

                    dt.Rows.Add(dr);
                }
            }

            if (!SecureGroup.CanDelete())
            {
                dgGroupsUsers.Columns[6].Visible = false;
            }

            DataView dv = dt.DefaultView;

            dv.Sort = "Type, IsActive DESC, sortTitle";
            dgGroupsUsers.DataSource = dv;
            dgGroupsUsers.DataBind();

            foreach (DataGridItem dgi in dgGroupsUsers.Items)
            {
                int    ID            = int.Parse(dgi.Cells[0].Text);
                bool   UserCanDelete = User.CanDelete(ID);
                string type          = dgi.Cells[1].Text;
                bool   HasChildren   = bool.Parse(dgi.Cells[7].Text);

                ImageButton ib = (ImageButton)dgi.FindControl("ibDelete");
                if (type == "Group" && !HasChildren && ID >= 9)
                {
                    ib.Attributes.Add("onclick", "return confirm('" + LocRM.GetString("Warning") + "')");
                }
                else
                if (type != "Group" && UserCanDelete)
                {
                    ib.Attributes.Add("onclick", String.Format("return DeleteUser({0}, {1})", ID, GroupID));
                }
                else
                {
                    ib.Visible = false;
                }
            }
        }
Exemplo n.º 4
0
        private void BindValues()
        {
            BindVisibility();

            btnAddOneGr.Attributes.Add("onclick", "MoveOne(" + lbAvailableGroups.ClientID + "," + lbSelectedGroups.ClientID + "); return false;");
            btnAddAllGr.Attributes.Add("onclick", "MoveAll(" + lbAvailableGroups.ClientID + "," + lbSelectedGroups.ClientID + "); return false;");
            btnRemoveOneGr.Attributes.Add("onclick", "MoveOne(" + lbSelectedGroups.ClientID + "," + lbAvailableGroups.ClientID + "); return false;");
            btnRemoveAllGr.Attributes.Add("onclick", "MoveAll(" + lbSelectedGroups.ClientID + "," + lbAvailableGroups.ClientID + ");return false;");

            lbAvailableGroups.Attributes.Add("ondblclick", "MoveOne(" + lbAvailableGroups.ClientID + "," + lbSelectedGroups.ClientID + "); return false;");
            lbSelectedGroups.Attributes.Add("ondblclick", "MoveOne(" + lbSelectedGroups.ClientID + "," + lbAvailableGroups.ClientID + "); return false;");

            ddlIMGroup.DataTextField  = "IMGroupName";
            ddlIMGroup.DataValueField = "IMGroupId";
            ddlIMGroup.DataSource     = IMGroup.GetListIMGroupsWithoutPartners();
            ddlIMGroup.DataBind();

            using (IDataReader reader = SecureGroup.GetListGroupsWithParameters(false, false, false, false, false, false, false, false, false, false, false))
            {
                while (reader.Read())
                {
                    lbAvailableGroups.Items.Add(new ListItem(CommonHelper.GetResFileString(reader["GroupName"].ToString()), reader["GroupId"].ToString()));
                }
            }

            lbSecurityRoles.Items.Clear();
            int      iRoleId   = (int)InternalSecureGroups.Administrator;
            ListItem liSecRole = new ListItem(GetGroupTitleById(iRoleId), iRoleId.ToString());

            lbSecurityRoles.Items.Add(liSecRole);

            iRoleId   = (int)InternalSecureGroups.HelpDeskManager;
            liSecRole = new ListItem(GetGroupTitleById(iRoleId), iRoleId.ToString());
            lbSecurityRoles.Items.Add(liSecRole);

            iRoleId   = (int)InternalSecureGroups.PowerProjectManager;
            liSecRole = new ListItem(GetGroupTitleById(iRoleId), iRoleId.ToString());
            lbSecurityRoles.Items.Add(liSecRole);

            iRoleId   = (int)InternalSecureGroups.ProjectManager;
            liSecRole = new ListItem(GetGroupTitleById(iRoleId), iRoleId.ToString());

            if (Configuration.ProjectManagementEnabled)
            {
                liSecRole.Selected = true;
            }

            lbSecurityRoles.Items.Add(liSecRole);

            iRoleId   = (int)InternalSecureGroups.ExecutiveManager;
            liSecRole = new ListItem(GetGroupTitleById(iRoleId), iRoleId.ToString());
            lbSecurityRoles.Items.Add(liSecRole);

            iRoleId   = (int)InternalSecureGroups.TimeManager;
            liSecRole = new ListItem(GetGroupTitleById(iRoleId), iRoleId.ToString());
            lbSecurityRoles.Items.Add(liSecRole);

            lstLang.DataSource     = Common.GetListLanguages();
            lstLang.DataTextField  = "FriendlyName";
            lstLang.DataValueField = "LanguageId";
            lstLang.DataBind();
            int LanguageId = Security.CurrentUser.LanguageId;

            Util.CommonHelper.SafeSelect(lstLang, LanguageId.ToString());

            lstTimeZone.DataSource     = User.GetListTimeZone();
            lstTimeZone.DataTextField  = "DisplayName";
            lstTimeZone.DataValueField = "TimeZoneId";
            lstTimeZone.DataBind();

            int TimeZoneId = Security.CurrentUser.TimeZoneId;

            lstTimeZone.ClearSelection();
            ListItem li = lstTimeZone.Items.FindByValue(TimeZoneId.ToString());

            if (li != null)
            {
                li.Selected = true;
            }

            using (IDataReader reader = SecureGroup.GetListChildGroups((int)InternalSecureGroups.Partner))
            {
                while (reader.Read())
                {
                    ddPartnerGroups.Items.Add(new ListItem(CommonHelper.GetResFileString(reader["GroupName"].ToString()), reader["GroupId"].ToString()));
                }
            }

            if (ddPartnerGroups.Items.Count == 0)
            {
                ListItem liUserType = ddUserType.Items.FindByValue("1");
                if (liUserType != null)
                {
                    ddUserType.Items.Remove(liUserType);
                    if (ddUserType.SelectedIndex < 0)
                    {
                        ddUserType.SelectedIndex = 0;
                    }
                    BindVisibility();
                }
            }

            EntityObject[] profiles = BusinessManager.List(CustomizationProfileEntity.ClassName, (new FilterElementCollection()).ToArray(), (new SortingElementCollection(new SortingElement("Name", SortingElementType.Asc))).ToArray());
            foreach (CustomizationProfileEntity profile in profiles)
            {
                ProfileList.Items.Add(new ListItem(CommonHelper.GetResFileString(profile.Name), profile.PrimaryKeyId.ToString()));
            }
            ListItem liProfile = ProfileList.Items.FindByValue("-1");

            if (liProfile != null)
            {
                liProfile.Selected = true;
            }

            SelectGroup();
        }
Exemplo n.º 5
0
		private void BinddgGroupsUsers()
		{
			dgUsers.Columns[2].HeaderText = LocRM.GetString("GroupUser");
			dgUsers.Columns[3].HeaderText = LocRM.GetString("Email");

			DataTable dt = new DataTable();
			dt.Columns.Add("ObjectId", typeof(int));
			dt.Columns.Add("Type");
			dt.Columns.Add("Title");
			dt.Columns.Add("Email");
			dt.Columns.Add("ActionView");
			DataRow dr;

			if (GroupID > 1) // [..]
			{
				bool retval = false;
				int iParentId = GroupID;
				while (iParentId > 1)
				{
					iParentId = SecureGroup.GetParentGroup(iParentId);
					if (VisibleUnpartnerGroups.Contains(iParentId) || VisiblePartnerGroups.Contains(iParentId) || iParentId == 6)
					{
						retval = true;
						break;
					}
				}
				if (retval)
					iParentId = SecureGroup.GetParentGroup(GroupID);
				else
					iParentId = 1;
				dr = dt.NewRow();
				dr["ObjectId"] = 0;
				dr["Type"] = "Group";
				dr["Title"] = "<span style='padding-left:15px'>&nbsp;</span><a href='../Directory/directory.aspx?Tab=0&amp;SGroupID=" + iParentId.ToString() + "'>[..]</a>";
				dt.Rows.Add(dr);
			}

			if ((GroupID != 1 && GroupID != 6) ||
				(GroupID == 1 && VisibleUnpartnerGroups.Contains(1)) ||
				(GroupID == 6 && VisibleUnpartnerGroups.Contains(6)))
			{
				using (IDataReader reader = SecureGroup.GetListChildGroups(GroupID))
				{
					while (reader.Read())
					{
						dr = dt.NewRow();
						dr["ObjectId"] = reader["GroupId"];
						dr["Type"] = "Group";
						int iGroupId = (int)reader["GroupId"];
						dr["Title"] = CommonHelper.GetGroupLink(iGroupId, CommonHelper.GetResFileString((string)reader["GroupName"]));
						dt.Rows.Add(dr);
					}
				}

				using (IDataReader reader = SecureGroup.GetListUsersInGroup(GroupID))
				{
					while (reader.Read())
					{

						dr = dt.NewRow();
						dr["ObjectId"] = reader["UserId"];

						dr["Type"] = "User";
						dr["Title"] = CommonHelper.GetUserStatus((int)reader["UserId"]);
						dr["Email"] = "<a href='mailto:" + (string)reader["Email"] + "'>" + (string)reader["Email"] + "</a>";
						dr["ActionView"] = "<a href='../Directory/UserView.aspx?UserID=" + reader["UserId"].ToString() + "'>"
							+ "<img alt='' src='../layouts/images/Icon-Search.GIF'/></a>";
						dt.Rows.Add(dr);
					}
				}
			}
			else if (GroupID == 1 && !VisibleUnpartnerGroups.Contains(1))
			{
				foreach (int iGroup in VisibleUnpartnerGroups)
				{
					dr = dt.NewRow();
					dr["ObjectId"] = iGroup;
					dr["Type"] = "Group";
					dr["Title"] = CommonHelper.GetGroupLink(iGroup);
					dt.Rows.Add(dr);
				}
				dr = dt.NewRow();
				dr["ObjectId"] = 6;
				dr["Type"] = "Group";
				dr["Title"] = CommonHelper.GetGroupLink(6);
				dt.Rows.Add(dr);
			}
			else if (GroupID == 6 && !VisibleUnpartnerGroups.Contains(6))
			{
				foreach (int iGroup in VisiblePartnerGroups)
				{
					dr = dt.NewRow();
					dr["ObjectId"] = iGroup;
					dr["Type"] = "Group";
					dr["Title"] = CommonHelper.GetGroupLink(iGroup);
					dt.Rows.Add(dr);
				}
			}

			dgUsers.DataSource = dt.DefaultView;
			dgUsers.DataBind();
		}
Exemplo n.º 6
0
        public string GetJsonDataSource(string nodeId)
        {
            List <JsonTreeNode> nodes = new List <JsonTreeNode>();

            int parentId;

            if (!int.TryParse(nodeId, out parentId) || parentId < 1)
            {
                parentId = 1;
            }

            if (Mediachase.IBN.Business.Security.IsUserInGroup(InternalSecureGroups.Partner) && (parentId == 1 || parentId == 6))
            {
                int       iCurGroupId            = -1;
                ArrayList VisiblePartnerGroups   = new ArrayList();
                ArrayList VisibleUnpartnerGroups = new ArrayList();
                using (IDataReader reader = Mediachase.IBN.Business.User.GetListSecureGroup(Mediachase.IBN.Business.Security.CurrentUser.UserID))
                {
                    if (reader.Read())
                    {
                        iCurGroupId = (int)reader["GroupId"];
                    }
                }
                VisiblePartnerGroups.Clear();
                VisibleUnpartnerGroups.Clear();
                VisiblePartnerGroups.Add(iCurGroupId);
                using (IDataReader reader = SecureGroup.GetListGroupsByPartner(iCurGroupId))
                {
                    while (reader.Read())
                    {
                        int iGroupId = (int)reader["GroupId"];
                        if (SecureGroup.IsPartner(iGroupId))
                        {
                            VisiblePartnerGroups.Add(iGroupId);
                        }
                        else
                        {
                            VisibleUnpartnerGroups.Add(iGroupId);
                        }
                    }
                }
                ClearUnpartnerGroups(VisibleUnpartnerGroups);
                if (VisibleUnpartnerGroups.Contains(1))
                {
                    return(BindOrdinaryTree(parentId));
                }

                ArrayList children = new ArrayList();
                if (parentId == 1)
                {
                    children.AddRange(VisibleUnpartnerGroups);
                    children.Add(6);
                }
                else if (parentId == 6)
                {
                    children.AddRange(VisiblePartnerGroups);
                }
                children.Sort();
                foreach (int iGroupId in children)
                {
                    JsonTreeNode node = new JsonTreeNode();
                    node.icon = "../../../Layouts/Images/icons/regular.gif";
                    if (iGroupId < 9 && iGroupId != 6)
                    {
                        node.icon = "../../../Layouts/Images/icons/Admins.gif";
                    }
                    if (SecureGroup.IsPartner(iGroupId) || iGroupId == 6)
                    {
                        node.icon = "../../../Layouts/Images/icons/Partners.gif";
                    }
                    node.iconCls = "iconStdCls";

                    using (IDataReader rdr = SecureGroup.GetGroup(iGroupId))
                    {
                        if (rdr.Read())
                        {
                            node.text = CHelper.GetResFileString(rdr["GroupName"].ToString());
                        }
                    }
                    node.cls = "nodeCls";

                    node.href       = "../../../Directory/Directory.aspx?Tab=0&SGroupID=" + iGroupId.ToString();
                    node.hrefTarget = "right";

                    node.id             = Guid.NewGuid().ToString("N");
                    node.itemid         = iGroupId.ToString();
                    node.staticParentId = _rootId;

                    node.leaf = true;
                    if (iGroupId == 6)
                    {
                        node.leaf = false;
                    }
                    else
                    {
                        using (IDataReader rdr = SecureGroup.GetListChildGroups(iGroupId))
                        {
                            if (rdr.Read())
                            {
                                node.leaf = false;
                            }
                        }
                    }

                    nodes.Add(node);
                }
            }
            else
            {
                return(BindOrdinaryTree(parentId));
            }

            if (nodes.Count > 0)
            {
                return(UtilHelper.JsonSerialize(nodes));
            }
            else
            {
                return(String.Empty);
            }
        }