Ejemplo n.º 1
0
        public string GetJsonDataSource(string nodeId)
        {
            List <JsonTreeNode> nodes = new List <JsonTreeNode>();

            int          userIMGroupId = 0;
            DataTable    dt            = null;
            JsonTreeNode node;

            if (!IMGroup.CanCreate())
            {
                using (IDataReader rdr = Mediachase.IBN.Business.User.GetUserInfo(Mediachase.IBN.Business.Security.CurrentUser.UserID))
                {
                    rdr.Read();
                    userIMGroupId = (int)rdr["IMGroupId"];
                }

                dt = IMGroup.GetListIMGroupsYouCanSee(userIMGroupId);

                string imGroupName = IMGroup.GetIMGroupName(userIMGroupId, null);
                if (imGroupName != null)
                {
                    DataRow dr = dt.NewRow();

                    dr["IMGroupId"]   = userIMGroupId;
                    dr["IMGroupName"] = imGroupName;

                    dt.Rows.InsertAt(dr, 0);
                }
            }
            else
            {
                dt = IMGroup.GetListIMGroup();
            }

            foreach (DataRow dr in dt.Rows)
            {
                int imGroupId = (int)dr["IMGroupId"];
                node            = new JsonTreeNode();
                node.icon       = "../../../Layouts/Images/icons/ibngroup.gif";
                node.iconCls    = "iconStdCls";
                node.text       = dr["IMGroupName"].ToString();
                node.cls        = "nodeCls";
                node.href       = "../../../Directory/Directory.aspx?Tab=1&IMGroupID=" + imGroupId.ToString();
                node.hrefTarget = "right";
                node.leaf       = true;
                nodes.Add(node);
            }

            if (nodes.Count > 0)
            {
                return(UtilHelper.JsonSerialize(nodes));
            }
            else
            {
                return(String.Empty);
            }
        }
Ejemplo n.º 2
0
        private void BindSavedData()
        {
            int id = 0;

            if (GroupID > 0)
            {
                id = GroupID;
            }
            else if (CloneGroupID > 0)
            {
                id = CloneGroupID;
            }

            if (id > 0)
            {
                using (DataTable table = IMGroup.GetGroup(id))
                {
                    if (table.Rows.Count > 0)
                    {
                        DataRow row = table.Rows[0];

                        if (CloneGroupID == 0)
                        {
                            tbGroupTitle.Text = HttpUtility.HtmlDecode(row["IMGroupName"].ToString());
                        }
                        tbColor.Text = HttpUtility.HtmlDecode(row["Color"].ToString());
                    }
                }

                using (DataTable table = IMGroup.GetListIMGroupsYouCanSee(id))
                {
                    foreach (DataRow row in table.Rows)
                    {
                        CommonHelper.SafeMultipleSelect(lbVisible, ((int)row["IMGroupId"]).ToString(CultureInfo.InvariantCulture));
                    }
                }

                using (DataTable table = IMGroup.GetListIMGroupsCanSeeYou(id))
                {
                    foreach (DataRow row in table.Rows)
                    {
                        CommonHelper.SafeMultipleSelect(lbCU, ((int)row["IMGroupId"]).ToString(CultureInfo.InvariantCulture));
                    }
                }
            }
        }
Ejemplo n.º 3
0
        private void BinddgGroupsUsers()
        {
            dgUsers.Columns[1].HeaderText = LocRM.GetString("GroupUser");
            dgUsers.Columns[2].HeaderText = LocRM.GetString("Email");

            if (GroupID == 0)
            {
                dgUsers.Columns[2].Visible = false;
            }

            DataTable dt = new DataTable();

            dt.Columns.Add(new DataColumn("ID", typeof(int)));
            dt.Columns.Add(new DataColumn("Type", typeof(int)));             //0-IMGroup, 1- User
            dt.Columns.Add(new DataColumn("GroupName", typeof(string)));
            dt.Columns.Add(new DataColumn("Email", typeof(string)));
            dt.Columns.Add(new DataColumn("ActionEdit", typeof(string)));
            dt.Columns.Add(new DataColumn("ActionDelete", typeof(string)));

            DataView dv;
            DataRow  dr;

            if (GroupID > 0)             // Bind Users
            {
                // [..]
                dr              = dt.NewRow();
                dr["ID"]        = 0;
                dr["Type"]      = 0;
                dr["GroupName"] = "<span style='padding-left:30px'>&nbsp;</span><a href='../Directory/directory.aspx?Tab=1&amp;IMGroupID=0'>[..]</a>";
                dt.Rows.Add(dr);

                using (IDataReader rdr = IMGroup.GetListUsers(GroupID))
                {
                    while (rdr.Read())
                    {
                        dr = dt.NewRow();
                        int iUserId = (int)rdr["UserId"];
                        dr["ID"]    = iUserId;
                        dr["Type"]  = 1;
                        dr["Email"] = rdr["Email"].ToString();
                        if (User.CanUpdateUserInfo(iUserId))
                        {
                            dr["ActionEdit"] = String.Format("<a href='../Directory/UserEdit.aspx?UserID={0}'><img alt='{1}' src='../Layouts/Images/edit.gif' title='{1}'/></a>", iUserId.ToString(), LocRM.GetString("Edit"));
                        }
                        if (User.CanDelete(iUserId))
                        {
                            dr["ActionDelete"] = String.Format("<a href='javascript:DeleteUser({0})'><img alt='{1}' src='../Layouts/Images/delete.gif' title='{1}'/></a>", iUserId.ToString(), LocRM.GetString("Delete"));
                        }
                        dt.Rows.Add(dr);
                    }
                }
                dv = dt.DefaultView;
            }
            else              // Bind IMGroups
            {
                int userIMGroupId = 0;

                if (!IMGroup.CanCreate())
                {
                    using (IDataReader rdr = User.GetUserInfo(Security.CurrentUser.UserID))
                    {
                        rdr.Read();
                        if (rdr["IMGroupId"] != DBNull.Value)
                        {
                            userIMGroupId = (int)rdr["IMGroupId"];
                        }
                    }

                    if (userIMGroupId > 0)
                    {
                        using (DataTable table = IMGroup.GetListIMGroupsYouCanSee(userIMGroupId))
                        {
                            foreach (DataRow row in table.Rows)
                            {
                                dr = dt.NewRow();

                                int groupId = (int)row["IMGroupId"];
                                dr["ID"]        = groupId;
                                dr["Type"]      = 0;
                                dr["GroupName"] = row["IMGroupName"].ToString();
                                if (IMGroup.CanUpdate())
                                {
                                    dr["ActionEdit"] = String.Format("<a href='../Directory/AddIMGroup.aspx?GroupID={0}'><img alt='{1}' src='../Layouts/Images/edit.gif' title='{1}'/></a>", groupId, LocRM.GetString("Edit"));
                                }
                                if (IMGroup.CanDelete(groupId))
                                {
                                    dr["ActionDelete"] = String.Format("<a href='javascript:DeleteGroup({0})'><img alt='{1}' src='../Layouts/Images/delete.gif' title='{1}'/></a>", groupId, LocRM.GetString("Delete"));
                                }

                                dt.Rows.Add(dr);
                            }
                        }

                        string imGroupName = IMGroup.GetIMGroupName(userIMGroupId, null);
                        if (imGroupName != null)
                        {
                            dr = dt.NewRow();

                            dr["ID"]        = userIMGroupId;
                            dr["Type"]      = 0;
                            dr["GroupName"] = imGroupName;
                            if (IMGroup.CanUpdate())
                            {
                                dr["ActionEdit"] = String.Format("<a href='../Directory/AddIMGroup.aspx?GroupID={0}'><img alt='{1}' src='../Layouts/Images/edit.gif' title='{1}'/></a>", userIMGroupId, LocRM.GetString("Edit"));
                            }

                            dt.Rows.Add(dr);
                        }
                    }
                }
                else
                {
                    using (DataTable table = IMGroup.GetListIMGroup())
                    {
                        foreach (DataRow row in table.Rows)
                        {
                            dr = dt.NewRow();

                            int groupId = (int)row["IMGroupId"];
                            dr["ID"]        = groupId;
                            dr["Type"]      = 0;
                            dr["GroupName"] = row["IMGroupName"].ToString();
                            if (IMGroup.CanUpdate())
                            {
                                dr["ActionEdit"] = string.Format("<a href='../Directory/AddIMGroup.aspx?GroupID={0}'><img alt='{1}' src='../Layouts/Images/edit.gif' title='{1}'/></a>", groupId, LocRM.GetString("Edit"));
                            }
                            if (IMGroup.CanDelete(groupId))
                            {
                                dr["ActionDelete"] = string.Format("<a href='javascript:DeleteGroup({0})'><img alt='{1}' src='../Layouts/Images/delete.gif' title='{1}'/></a>", groupId, LocRM.GetString("Delete"));
                            }

                            dt.Rows.Add(dr);
                        }
                    }
                }
                dv      = dt.DefaultView;
                dv.Sort = "GroupName";
            }

            dgUsers.DataSource = dv;
            dgUsers.DataBind();
        }