Пример #1
0
        //同步设置IM群管理员
        //文档: https://www.qcloud.com/document/product/269/1623
        public Response SetIMGroupAdmin(ClubUser obj)
        {
            string role;

            if (obj.IsAdmin)
            {
                role = "Admin";
            }
            else
            {
                role = "Member";
            }
            IMGroup imGroup = new IMGroup();

            imGroup.GroupId        = obj.ClubId;
            imGroup.Member_Account = obj.UserCode;
            imGroup.Role           = role;
            //请求IM接口
            var reqRest = new RestRequest("v4/group_open_http_svc/modify_group_member_info", Method.POST);

            reqRest.AddJsonBody(imGroup);

            var result = RestApiHelper.SendIMRequestAndGetResponse(reqRest);

            return(result);
        }
Пример #2
0
        protected void DeleteGroup(object sender, System.EventArgs e)
        {
            int delID = int.Parse(deleteId.Value);

            IMGroup.Delete(delID);
            pc["IMGroup_CurrentGroup"] = "0";
            Response.Redirect("../Directory/Directory.aspx?Tab=1&IMGroupId=0");
        }
Пример #3
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);
            }
        }
Пример #4
0
        /// <summary>
        /// 同步已有的俱乐部到IM群
        /// </summary>
        /// <param name="clubId"></param>
        /// <returns></returns>
        public Response ImportExistClubToIMGroup(string clubId)
        {
            //新建IM群 文档:https://www.qcloud.com/document/product/269/1615
            var sql = @"
  SELECT 
	TOP 1 
    b.Id AS GroupId,
	c.Code AS Owner_Account,
	b.Name ,
	b.Introduce AS Introduction,
	b.HeadUrl AS FaceUrl
 FROM dbo.ClubUser a
 INNER JOIN dbo.Club b ON a.ClubId=b.Id
 INNER JOIN dbo.UserAccount c ON a.UserId=c.Id
 WHERE ClubId=@ClubId AND a.IsCreator=1 AND a.IsAdmin =1

";
            var cmd = CommandHelper.CreateText <IMGroup>(FetchType.Fetch, sql);

            cmd.Params.Add("@ClubId", clubId);

            var     result = DbContext.GetInstance().Execute(cmd);
            IMGroup obj    = result.FirstEntity <IMGroup>();

            if (obj == null)
            {
                return(ResultHelper.Success());
            }
            if (obj.Name.Length >= 6)
            {
                obj.Name = obj.Name.Substring(0, 5) + "...";
            }

            if (obj.Introduction.Length >= 71)
            {
                obj.Introduction = obj.Introduction.Substring(0, 70);
            }

            obj.Type            = "Public";//Public 是公开群, 最大成员数2000 https://www.qcloud.com/document/product/269/1615
            obj.ApplyJoinOption = "FreeAccess";
            obj.MemberList      = GetUserList(clubId);
            foreach (var item in obj.MemberList)
            {
                if (item.Member_Account == obj.Owner_Account)
                {
                    item.Role = null;
                }
            }
            //请求导入
            var reqRest = new RestRequest("v4/group_open_http_svc/create_group", Method.POST);

            reqRest.AddJsonBody(obj);
            return(RestApiHelper.SendIMRequestAndGetResponse(reqRest));
        }
Пример #5
0
        /// <summary>
        /// 同步IM 移交群给某人
        /// </summary>
        /// <returns></returns>
        public Response ChangeGroupOwner(string clubId, string NewOwner_Account)
        {
            IMGroup obj = new IMGroup();

            obj.GroupId          = clubId;
            obj.NewOwner_Account = NewOwner_Account;
            //请求IM接口
            var reqRest = new RestRequest("v4/group_open_http_svc/change_group_owner", Method.POST);

            reqRest.AddJsonBody(obj);
            return(RestApiHelper.SendIMRequestAndGetResponse(reqRest));
        }
Пример #6
0
        protected void ddlGroup_SelectedIndexChanged(object sender, EventArgs e)
        {
            int groupId = int.Parse(ddlGroup.SelectedValue);

            ddlUser.Items.Clear();
            ddlUser.Items.Add(new ListItem(LocRM.GetString("AnyUser"), "0"));
            using (IDataReader reader = IMGroup.GetListUsers(groupId))
            {
                while (reader.Read())
                {
                    ddlUser.Items.Add(new ListItem(reader["LastName"].ToString() + " " + reader["FirstName"].ToString(), reader["OriginalId"].ToString()));
                }
            }
        }
Пример #7
0
        /// <summary>
        /// 修改IM群
        /// </summary>
        /// <returns></returns>
        public Response UpdateIMGroup(Club club)
        {
            Response result = new Response();
            IMGroup  obj    = new IMGroup();

            obj.GroupId = club.Id;
            obj.FaceUrl = club.HeadUrl;
            obj.Name    = club.Name;
            //请求导入
            var reqRest = new RestRequest("v4/group_open_http_svc/modify_group_base_info", Method.POST);

            reqRest.AddJsonBody(obj);
            return(RestApiHelper.SendIMRequestAndGetResponse(reqRest));
        }
Пример #8
0
        //同步设置IM群成员昵称
        //文档: https://www.qcloud.com/document/product/269/1623
        public Response SetIMGroupAdmin(ClubUser obj)
        {
            IMGroup imGroup = new IMGroup();

            imGroup.GroupId        = obj.ClubId;
            imGroup.Member_Account = obj.UserCode;
            imGroup.NameCard       = obj.PetName;
            //请求IM接口
            var reqRest = new RestRequest("v4/group_open_http_svc/modify_group_member_info", Method.POST);

            reqRest.AddJsonBody(imGroup);

            var result = RestApiHelper.SendIMRequestAndGetResponse(reqRest);

            return(result);
        }
Пример #9
0
        /// <summary>
        /// 删除IM群成员
        /// </summary>
        /// <returns></returns>
        public Response RemoveGroupMember(Request <ClubUser> req)
        {
            IMGroup obj = new IMGroup();

            obj.Silence = 1;
            obj.GroupId = req.Entities.First().ClubId;//列表里面的所有clubId 都是一样的
            foreach (var clubUser in req.Entities)
            {
                obj.MemberToDel_Account.Add(clubUser.UserCode);
            }
            //请求腾讯IM接口
            var reqRest = new RestRequest("v4/group_open_http_svc/delete_group_member", Method.POST);

            reqRest.AddJsonBody(obj);
            return(RestApiHelper.SendIMRequestAndGetResponse(reqRest));
        }
Пример #10
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));
                    }
                }
            }
        }
Пример #11
0
        /// <summary>
        /// 同步导入这个人到腾讯IM群(无消息)
        /// </summary>
        /// <param name="clubId"></param>
        /// <param name="userCode"></param>
        /// <returns></returns>
        public Response ImportToIMGroup(string clubId, string userCode)
        {
            IMGroup obj = new IMGroup();

            obj.GroupId = clubId;
            IMGroupMember groupMember = new IMGroupMember();

            groupMember.Member_Account = userCode;
            obj.MemberList.Add(groupMember);

            //请求IM接口
            var reqRest = new RestRequest("v4/group_open_http_svc/import_group_member", Method.POST);

            reqRest.AddJsonBody(obj);

            var result = RestApiHelper.SendIMRequestAndGetResponse(reqRest);

            return(result);
        }
Пример #12
0
        private void BindDefaultValues()
        {
            int groupId      = GroupID;
            int cloneGroupID = CloneGroupID;

            tbGroupTitle.Text = "";
            tbColor.Text      = "2B6087";

            int id = 0;

            if (groupId > 0)
            {
                id = groupId;
            }
            else if (cloneGroupID > 0)
            {
                id = cloneGroupID;
            }
            imgLogo.Src = "../../Common/GroupLogo.aspx?GroupID=" + id;


            using (DataTable table = IMGroup.GetListIMGroup())
            {
                foreach (DataRow row in table.Rows)
                {
                    int    imGroupId   = (int)row["IMGroupId"];
                    string imGroupName = row["IMGroupName"].ToString();

                    if (groupId == 0 || groupId != imGroupId)
                    {
                        string imGroupIdString = imGroupId.ToString(CultureInfo.InvariantCulture);

                        lbVisible.Items.Add(new ListItem(imGroupName, imGroupIdString));
                        lbCU.Items.Add(new ListItem(imGroupName, imGroupIdString));
                    }
                }
            }
        }
Пример #13
0
        private void BindStatusLog()
        {
            bool logUserStatus = PortalConfig.PortalLogUserStatus;

            tdStatusLog.Visible = logUserStatus;
            if (logUserStatus)
            {
                btnGenerate.Text = LocRM.GetString("Generate");

                ddlGroup.Items.Add(new ListItem(LocRM.GetString("AnyGroup"), "0"));
                using (DataTable table = IMGroup.GetListIMGroup())
                {
                    foreach (DataRow row in table.Rows)
                    {
                        ddlGroup.Items.Add(new ListItem(row["IMGroupName"].ToString(), ((int)row["IMGroupId"]).ToString(CultureInfo.InvariantCulture)));
                    }
                }

                ddlUser.Items.Add(new ListItem(LocRM.GetString("AnyUser"), "0"));

                fromDate.SelectedDate = DateTime.Now.Date.AddDays(-DateTime.Now.Day + 1);
            }
        }
Пример #14
0
        private void BindToolBar()
        {
            if (GroupID > 0)
            {
                secHeader.Title = LocRM.GetString("EditGroup");
            }
            else if (CloneGroupID > 0)
            {
                secHeader.Title = LocRM.GetString("CloneGroup");
            }
            else
            {
                using (DataTable table = IMGroup.GetGroup(GroupID))
                {
                    if (table.Rows.Count > 0)
                    {
                        secHeader.Title = LocRM.GetString("CreateIMGroup");
                    }
                }
            }

            secHeader.AddLink("<img alt='' src='../Layouts/Images/cancel.gif'/> " + LocRM.GetString("Back"), "../Directory/Directory.aspx");
        }
Пример #15
0
        protected void Page_Load(object sender, System.EventArgs e)
        {
            Response.ContentType = "image/jpeg";

            int bufferSize = 100;

            byte[] outbyte = new byte[bufferSize];
            long   retVal;
            long   startIndex = 0;

            using (IDataReader reader = IMGroup.GetBinaryClientLogo(IMGroupID))
            {
                if (reader.Read())
                {
                    startIndex = 0;
                    retVal     = reader.GetBytes(0, startIndex, outbyte, 0, bufferSize);

                    if (retVal == 0)
                    {
                        Response.Redirect(GlobalResourceManager.Strings["IMGroupLogoUrl"], true);
                    }

                    Stream stream = Response.OutputStream;
                    while (retVal == bufferSize)
                    {
                        stream.Write(outbyte, 0, bufferSize);
                        startIndex += bufferSize;
                        retVal      = reader.GetBytes(0, startIndex, outbyte, 0, bufferSize);
                    }
                    stream.Write(outbyte, 0, System.Convert.ToInt32(retVal));
                }
                else
                {
                    Response.Redirect(GlobalResourceManager.Strings["IMGroupLogoUrl"], true);
                }
            }
        }
Пример #16
0
        private void BindStep1()
        {
            lgdContactInf.InnerText          = LocRM.GetString("tContactInformation");
            lgdCompanyinf.InnerText          = LocRM.GetString("tCompanyInformation");
            lgdSelGroup.InnerText            = LocRM.GetString("tSelectIBNGroups");
            lgdTextPartner.InnerText         = LocRM.GetString("tSelectPartnerGroup");
            lblGroupsTitle.Text              = LocRM.GetString("tPartnerGroups");
            lgdLang.InnerText                = LocRM.GetString("tDefLanguage");
            lgdRole.InnerText                = LocRM.GetString("tRole");
            lgdTextExt.InnerText             = LocRM.GetString("tExternalAdding");
            lgdWelcome.InnerText             = LocRM.GetString("tWelcomeComments");
            txtRELoginValidator.ErrorMessage = LocRM.GetString("LoginReg");
            lblSelected.Text  = LocRM.GetString("tSelected");
            lblAvailable.Text = LocRM.GetString("tAvailable");

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

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

            if (user_type == 1 || user_type == 2)
            {
                rbAccount.Items.Add(new ListItem(" " + LocRM.GetString("tIBNAccount"), "0"));
                if (User.CanCreateExternal())
                {
                    rbAccount.Items.Add(new ListItem(" " + LocRM.GetString("tExternalAccount"), "1"));
                }
                if (user_type != 2 && User.CanCreatePartner())
                {
                    rbAccount.Items.Add(new ListItem(" " + LocRM.GetString("tPartnerAccount"), "2"));
                }
                rbAccount.SelectedIndex = 0;
            }
            if (user_type == 3)
            {
                lblUserType.Text = LocRM.GetString("tOnlyPending");
            }

            cbRole.Items.Add(new ListItem(" " + LocRM.GetString("tPPM"), "0"));
            cbRole.Items.Add(new ListItem(" " + LocRM.GetString("tPM"), "1"));
            cbRole.Items.Add(new ListItem(" " + LocRM.GetString("tHDM"), "2"));
            cbRole.RepeatColumns = 3;

            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()));
                }
            }

            ddLang.DataSource     = Common.GetListLanguages();
            ddLang.DataTextField  = "FriendlyName";
            ddLang.DataValueField = "LanguageId";
            ddLang.DataBind();

            ddIMGroup.DataTextField  = "IMGroupName";
            ddIMGroup.DataValueField = "IMGroupId";
            ddIMGroup.DataSource     = IMGroup.GetListIMGroupsWithoutPartners();
            ddIMGroup.DataBind();
        }
Пример #17
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();
        }
Пример #18
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 + 1)
            {
                ArrayList alGroups = new ArrayList();
                using (IDataReader reader = SecureGroup.GetListGroups())
                {
                    while (reader.Read())
                    {
                        int iGroupId = (int)reader["GroupId"];
                        if (iGroupId > 8)
                        {
                            alGroups.Add(iGroupId);
                            break;
                        }
                    }
                }
                int iIMGroup = 0;
                using (DataTable table = IMGroup.GetListIMGroup())
                {
                    if (table.Rows.Count > 0)
                    {
                        iIMGroup = (int)table.Rows[0]["IMGroupId"];
                    }
                }

                #region txtEMail1
                if (txtEMail1.Text != "")
                {
                    int id = User.GetUserByEmail(txtEMail1.Text);
                    if (id <= 0)
                    {
                        string strLogin = txtEMail1.Text.Substring(0, txtEMail1.Text.IndexOf("@"));
                        int    i        = 0;
                        bool   fl       = false;
                        do
                        {
                            string tmpLogin = strLogin;
                            if (i > 0)
                            {
                                tmpLogin = tmpLogin + i.ToString();
                            }
                            using (IDataReader reader = User.GetUserInfoByLogin(tmpLogin))
                            {
                                if (reader.Read())
                                {
                                    fl = true;
                                }
                                else
                                {
                                    fl = false;
                                }
                            }
                            i++;
                        }while (fl);

                        string sFirst = (txtFirstName1.Text == "") ? strLogin : txtFirstName1.Text;
                        string sLast  = (txtLastName1.Text == "") ? strLogin : txtLastName1.Text;
                        if (i > 1)
                        {
                            strLogin = strLogin + (i - 1).ToString();
                        }

                        User.Create(strLogin, "ibn", sFirst, sLast, txtEMail1.Text,
                                    alGroups, iIMGroup, "", "", "", "", "", "", Security.CurrentUser.LanguageId, "");
                    }
                }
                #endregion

                #region txtEMail2
                if (txtEMail2.Text != "")
                {
                    int id = User.GetUserByEmail(txtEMail2.Text);
                    if (id <= 0)
                    {
                        string strLogin = txtEMail2.Text.Substring(0, txtEMail2.Text.IndexOf("@"));
                        int    i        = 0;
                        bool   fl       = false;
                        do
                        {
                            string tmpLogin = strLogin;
                            if (i > 0)
                            {
                                tmpLogin = tmpLogin + i.ToString();
                            }
                            using (IDataReader reader = User.GetUserInfoByLogin(tmpLogin))
                            {
                                if (reader.Read())
                                {
                                    fl = true;
                                }
                                else
                                {
                                    fl = false;
                                }
                            }
                            i++;
                        }while (fl);
                        string sFirst = (txtFirstName2.Text == "") ? strLogin : txtFirstName2.Text;
                        string sLast  = (txtLastName2.Text == "") ? strLogin : txtLastName2.Text;
                        if (i > 1)
                        {
                            strLogin = strLogin + (i - 1).ToString();
                        }

                        User.Create(strLogin, "ibn", sFirst, sLast, txtEMail2.Text,
                                    alGroups, iIMGroup, "", "", "", "", "", "", Security.CurrentUser.LanguageId, "");
                    }
                }
                #endregion

                #region txtEMail3
                if (txtEMail3.Text != "")
                {
                    int id = User.GetUserByEmail(txtEMail3.Text);
                    if (id <= 0)
                    {
                        string strLogin = txtEMail3.Text.Substring(0, txtEMail3.Text.IndexOf("@"));
                        int    i        = 0;
                        bool   fl       = false;
                        do
                        {
                            string tmpLogin = strLogin;
                            if (i > 0)
                            {
                                tmpLogin = tmpLogin + i.ToString();
                            }
                            using (IDataReader reader = User.GetUserInfoByLogin(tmpLogin))
                            {
                                if (reader.Read())
                                {
                                    fl = true;
                                }
                                else
                                {
                                    fl = false;
                                }
                            }
                            i++;
                        }while (fl);
                        string sFirst = (txtFirstName3.Text == "") ? strLogin : txtFirstName3.Text;
                        string sLast  = (txtLastName3.Text == "") ? strLogin : txtLastName3.Text;
                        if (i > 1)
                        {
                            strLogin = strLogin + (i - 1).ToString();
                        }
                        User.Create(strLogin, "ibn", sFirst, sLast, txtEMail3.Text,
                                    alGroups, iIMGroup, "", "", "", "", "", "", Security.CurrentUser.LanguageId, "");
                    }
                }
                #endregion

                #region txtEMail4
                if (txtEMail4.Text != "")
                {
                    int id = User.GetUserByEmail(txtEMail4.Text);
                    if (id <= 0)
                    {
                        string strLogin = txtEMail4.Text.Substring(0, txtEMail4.Text.IndexOf("@"));
                        int    i        = 0;
                        bool   fl       = false;
                        do
                        {
                            string tmpLogin = strLogin;
                            if (i > 0)
                            {
                                tmpLogin = tmpLogin + i.ToString();
                            }
                            using (IDataReader reader = User.GetUserInfoByLogin(tmpLogin))
                            {
                                if (reader.Read())
                                {
                                    fl = true;
                                }
                                else
                                {
                                    fl = false;
                                }
                            }
                            i++;
                        }while (fl);
                        string sFirst = (txtFirstName4.Text == "") ? strLogin : txtFirstName4.Text;
                        string sLast  = (txtLastName4.Text == "") ? strLogin : txtLastName4.Text;
                        if (i > 1)
                        {
                            strLogin = strLogin + (i - 1).ToString();
                        }
                        User.Create(strLogin, "ibn", sFirst, sLast, txtEMail4.Text,
                                    alGroups, iIMGroup, "", "", "", "", "", "", Security.CurrentUser.LanguageId, "");
                    }
                }
                #endregion

                UserLightPropertyCollection pc = Security.CurrentUser.Properties;
                PortalConfig.PortalShowAdminWizard = cbShowNextTime.Checked;
                if (pc["USetup_ShowStartupWizard"] == null || pc["USetup_ShowStartupWizard"] == "True")
                {
                    Page.ClientScript.RegisterStartupScript(this.GetType(), Guid.NewGuid().ToString(),
                                                            "try{window.opener.top.right.location.href='" + ResolveClientUrl("~/Workspace/default.aspx") + "?BTab=Workspace&wizard=1';} catch (e) {} window.close();",
                                                            true);
                }
                else
                {
                    Page.ClientScript.RegisterStartupScript(this.GetType(), Guid.NewGuid().ToString(),
                                                            "try{window.opener.top.location.href='" + ResolveClientUrl("~/Apps/Shell/Pages/default.aspx") + "';} catch (e) {} window.close();",
                                                            true);
                }
            }
        }
Пример #19
0
        private void BindData()
        {
            bool isExternal = false;
            bool isPending  = false;

            try
            {
                using (IDataReader rdr = User.GetUserInfo(UserID))
                {
                    //UserId, Login, FirstName, LastName, Email, IsActive, IMGroupId, IsPending, IsExternal
                    if (rdr.Read())
                    {
                        lblLogin.Text       = (string)rdr["Login"];
                        lbWindowsLogin.Text = rdr["WindowsLogin"].ToString();
                        isPending           = (bool)rdr["IsPending"];
                        if ((bool)rdr["IsExternal"])
                        {
                            isExternal = true;
                            lblIMGroupTitle.Visible = false;
                            lblLoginTitle.Visible   = false;
                            lblLogin.Visible        = false;
                        }
                        else
                        {
                            isExternal = false;
                        }

                        if (isPending)
                        {
                            if (lblLogin.Text.IndexOf("___PENDING_USER___") >= 0)
                            {
                                lblLogin.Visible      = false;
                                lblLoginTitle.Visible = false;
                            }
                            lblIMGroupTitle.Visible = false;

                            lblProfileTitle.Visible = false;
                            lblProfile.Visible      = false;
                        }
                        else if (isExternal)
                        {
                            lblIMGroupTitle.Visible = false;

                            lblProfileTitle.Visible = false;
                            lblProfile.Visible      = false;
                        }

                        if (PortalConfig.UseIM && rdr["Login"].ToString().ToLower() != "alert")
                        {
                            if (rdr["IMGroupId"] != DBNull.Value)
                            {
                                int    imGroupId   = (int)rdr["IMGroupId"];
                                string imGroupName = IMGroup.GetIMGroupName(imGroupId, null);
                                if (imGroupName != null)
                                {
                                    lblGroup.Text = string.Format(CultureInfo.InvariantCulture, "<a href='../Directory/Directory.aspx?Tab=1&amp;IMGroupID={0}'><img alt='' src='../layouts/images/icons/ibngroup.gif'/>{1}</a>", imGroupId, imGroupName);
                                }
                            }
                        }
                        else
                        {
                            lblGroup.Visible        = false;
                            lblIMGroupTitle.Visible = false;
                        }
                    }
                    else
                    {
                        Response.Redirect("../Common/NotExistingId.aspx?UserId=1");
                    }
                }
            }
            catch (AccessDeniedException)
            {
                Response.Redirect("~/Common/NotExistingID.aspx?AD=1");
            }

            using (IDataReader rdr = User.GetUserProfile(UserID))
            {
                //UserId, phone, fax, mobile, position, department, company, location, PictureUrl
                if (rdr.Read())
                {
                    lblPhone.Text      = (string)rdr["phone"];
                    lblFax.Text        = (string)rdr["fax"];
                    lblMobile.Text     = (string)rdr["mobile"];
                    lblDepartment.Text = (string)rdr["department"];
                    lblLocation.Text   = (string)rdr["location"];
                    lblJobTitle.Text   = (string)rdr["position"];
                    lblCompany.Text    = (string)rdr["company"];
                    imgPhoto.Src       = "~/Common/GetUserPhoto.aspx?UserID=" + UserID.ToString() + "&amp;t=" + DateTime.Now.Millisecond.ToString();
                }
            }

            try
            {
                int            profileId   = -1;
                EntityObject[] userProfile = BusinessManager.List(CustomizationProfileUserEntity.ClassName, new FilterElement[] { FilterElement.EqualElement(CustomizationProfileUserEntity.FieldPrincipalId, UserID) });
                if (userProfile.Length > 0)
                {
                    profileId = ((CustomizationProfileUserEntity)userProfile[0]).ProfileId;
                }

                EntityObject entity = BusinessManager.Load(CustomizationProfileEntity.ClassName, (PrimaryKeyId)profileId);
                if (entity != null)
                {
                    lblProfile.Text = CommonHelper.GetResFileString(((CustomizationProfileEntity)entity).Name);
                }
            }
            catch { }
        }
Пример #20
0
        protected void btnSave_Click(object sender, System.EventArgs e)
        {
            Page.Validate();
            if (!Page.IsValid)
            {
                return;
            }

            ArrayList YCS = new ArrayList();

            foreach (ListItem li in lbVisible.Items)
            {
                if (li.Selected)
                {
                    YCS.Add(int.Parse(li.Value));
                }
            }

            ArrayList CSY = new ArrayList();

            foreach (ListItem li in lbCU.Items)
            {
                if (li.Selected)
                {
                    CSY.Add(int.Parse(li.Value));
                }
            }

            byte[] GroupLogo = null;
            if (fLogo.PostedFile != null && fLogo.PostedFile.ContentLength > 0)
            {
                GroupLogo = new byte[fLogo.PostedFile.ContentLength];
                fLogo.PostedFile.InputStream.Read(GroupLogo, 0, fLogo.PostedFile.ContentLength);
            }
            else if (GroupID == 0)
            {
                FileInfo   fi = new FileInfo(Server.MapPath(GlobalResourceManager.Strings["IMGroupLogoUrl"]));
                FileStream fs = fi.OpenRead();
                GroupLogo = new byte[fi.Length];
                int nBytesRead = fs.Read(GroupLogo, 0, (int)fi.Length);
            }

            int outid = 1;

            if (GroupID > 0)
            {
                IMGroup.Update(GroupID, tbGroupTitle.Text, tbColor.Text, GroupLogo, YCS, CSY);
                outid = GroupID;
            }
            else if (CloneGroupID > 0)
            {
                outid = IMGroup.Clone(CloneGroupID, tbGroupTitle.Text, tbColor.Text, GroupLogo, YCS, CSY);
            }
            else
            {
                outid = IMGroup.Create(tbGroupTitle.Text, tbColor.Text, GroupLogo, YCS, CSY);
            }

            if (outid != -1)
            {
                Response.Redirect("../Directory/Directory.aspx?Tab=1&IMGroupID=0");
            }
        }
Пример #21
0
        private void BindValues()
        {
            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());
            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();

            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;
            }

            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()));
            }
            EntityObject[] list = BusinessManager.List(CustomizationProfileUserEntity.ClassName, new FilterElement[] { FilterElement.EqualElement(CustomizationProfileUserEntity.FieldPrincipalId, UID) });
            if (list.Length > 0)
            {
                li = ProfileList.Items.FindByValue(((CustomizationProfileUserEntity)list[0]).ProfileId.ToString());
                if (li != null)
                {
                    li.Selected = true;
                }
            }
            else
            {
                li = ProfileList.Items.FindByValue("-1");
                if (li != null)
                {
                    li.Selected = true;
                }
            }

            if (UID != 0)
            {
                if (Security.IsUserInGroup(InternalSecureGroups.Administrator))
                {
                    tdWindowsLoginLabel.Visible   = false;
                    tdWindowsLoginTextBox.Visible = true;
                }
                else
                {
                    tdWindowsLoginLabel.Visible   = true;
                    tdWindowsLoginTextBox.Visible = false;
                }
                using (IDataReader reader = User.GetUserInfo(UID))
                {
                    if (reader.Read())
                    {
                        if ((bool)reader["IsExternal"])
                        {
                            ViewState[UID + "IsExternal"] = true;
                        }
                        else
                        {
                            ViewState[UID + "IsExternal"] = false;
                        }

                        if ((bool)reader["IsPending"])
                        {
                            ViewState[UID + "IsPending"] = true;
                            btnSave.Text     = LocRM.GetString("btnapprove");
                            chbIsActive.Text = LocRM.GetString("active") + ",&nbsp;<font color='red'>" + LocRM.GetString("PendingUser") + "</font>";
                        }
                        else
                        {
                            ViewState[UID + "IsPending"] = false;
                        }

                        string sLogin = reader["Login"].ToString();
                        if (sLogin.ToLower() == "alert")                                // AlertService user
                        {
                            groupInfoRow.Visible   = false;
                            chbIsActive.Enabled    = false;
                            tbWindowsLogin.Enabled = false;
                            txtPassword.Enabled    = false;
                            txtConfirm.Enabled     = false;
                        }

                        if (!(bool)ViewState[UID + "IsExternal"])
                        {
                            trTimeZone.Visible         = false;
                            trLang.Visible             = false;
                            PasswordValidator1.Enabled = false;
                            if (sLogin.IndexOf("___PENDING_USER___") < 0)
                            {
                                txtLogin.Visible            = false;
                                txtLoginRFValidator.Enabled = false;
                                txtRELoginValidator.Enabled = false;
                                txtLogin.Text    = "";
                                lblLogin.Text    = sLogin;
                                lblLogin.Visible = true;
                            }
                        }
                        txtFirstName.Text = HttpUtility.HtmlDecode(reader["FirstName"].ToString());
                        txtLastName.Text  = HttpUtility.HtmlDecode(reader["LastName"].ToString());
                        txtEmail.Text     = HttpUtility.HtmlDecode(reader["Email"].ToString());
                        if (reader["IMGroupId"] != null)
                        {
                            CommonHelper.SafeSelect(ddlIMGroup, reader["IMGroupId"].ToString());
                        }
                        if (!(bool)reader["IsActive"])
                        {
                            chbIsActive.Checked = false;
                        }

                        lbWindowsLogin.Text = tbWindowsLogin.Text = reader["WindowsLogin"].ToString();

                        if (reader["Password"].ToString() != string.Empty)
                        {
                            userHasEmptyPassword = false;
                        }
                    }
                }

                //if(!(bool)ViewState[UID + "IsExternal"] && !(bool)ViewState[UID + "IsPending"])
                //{
                using (IDataReader reader = User.GetListSecureGroup(UID))
                {
                    while (reader.Read())
                    {
                        lbSelectedGroups.Items.Add(new ListItem(CommonHelper.GetResFileString(reader["GroupName"].ToString()), reader["GroupId"].ToString()));
                    }
                }
                foreach (ListItem liSelectedGroup in lbSelectedGroups.Items)
                {
                    CommonHelper.SafeMultipleSelect(lbSecurityRoles, liSelectedGroup.Value);
                }
                lbSelectedGroups.Items.Remove(lbSelectedGroups.Items.FindByValue(((int)InternalSecureGroups.Everyone).ToString()));
                lbSelectedGroups.Items.Remove(lbSelectedGroups.Items.FindByValue(((int)InternalSecureGroups.Administrator).ToString()));
                lbSelectedGroups.Items.Remove(lbSelectedGroups.Items.FindByValue(((int)InternalSecureGroups.HelpDeskManager).ToString()));
                lbSelectedGroups.Items.Remove(lbSelectedGroups.Items.FindByValue(((int)InternalSecureGroups.PowerProjectManager).ToString()));
                lbSelectedGroups.Items.Remove(lbSelectedGroups.Items.FindByValue(((int)InternalSecureGroups.ProjectManager).ToString()));
                lbSelectedGroups.Items.Remove(lbSelectedGroups.Items.FindByValue(((int)InternalSecureGroups.ExecutiveManager).ToString()));
                lbSelectedGroups.Items.Remove(lbSelectedGroups.Items.FindByValue(((int)InternalSecureGroups.TimeManager).ToString()));
                lbSelectedGroups.DataBind();
                //}

                for (int i = 0; i < lbSelectedGroups.Items.Count; i++)
                {
                    if (lbAvailableGroups.Items.FindByValue(lbSelectedGroups.Items[i].Value) != null)
                    {
                        lbAvailableGroups.Items.Remove(lbAvailableGroups.Items.FindByValue(lbSelectedGroups.Items[i].Value));
                    }
                    iGroups.Value += lbSelectedGroups.Items[i].Value + ",";
                }

                if (!User.CanUpdateSecureFields(UID))
                {
                    trGroups.Visible         = false;
                    ddlIMGroup.Enabled       = false;
                    chbIsActive.Enabled      = false;
                    tblSecurityRoles.Visible = false;
                    ProfileRow.Visible       = false;
                }

                using (IDataReader reader = User.GetUserProfile(UID))
                {
                    if (reader.Read())
                    {
                        txtPhone.Text      = HttpUtility.HtmlDecode(reader["phone"].ToString());
                        txtFax.Text        = HttpUtility.HtmlDecode(reader["fax"].ToString());
                        txtMobile.Text     = HttpUtility.HtmlDecode(reader["mobile"].ToString());
                        txtJobTitle.Text   = HttpUtility.HtmlDecode(reader["position"].ToString());
                        txtDepartment.Text = HttpUtility.HtmlDecode(reader["department"].ToString());
                        txtLocation.Text   = HttpUtility.HtmlDecode(reader["location"].ToString());
                        txtCompany.Text    = HttpUtility.HtmlDecode(reader["company"].ToString());
                        if (reader["PictureUrl"] == DBNull.Value || (string)reader["PictureUrl"] == "")
                        {
                            Picture.Visible  = false;
                            cbDelete.Visible = false;
                        }
                        else
                        {
                            imgPhoto.Src     = "~/Common/GetUserPhoto.aspx?UserID=" + UID.ToString() + "&t=" + DateTime.Now.Millisecond.ToString();
                            Picture.Visible  = true;
                            cbDelete.Text    = "&nbsp;" + LocRM.GetString("tDeletePhoto");
                            cbDelete.Visible = true;
                        }
                    }
                }
            }
        }
Пример #22
0
        private int MakeUser(string sfirst, string slast, string semail, bool badmin)
        {
            ArrayList alGroups = new ArrayList();

            alGroups.Add((int)InternalSecureGroups.ProjectManager);
            using (IDataReader reader = SecureGroup.GetListGroups())
            {
                while (reader.Read())
                {
                    int iGroupId = (int)reader["GroupId"];
                    if (iGroupId > 8)
                    {
                        alGroups.Add(iGroupId);
                        break;
                    }
                }
            }
            int iIMGroup = 0;

            using (DataTable table = IMGroup.GetListIMGroup())
            {
                foreach (DataRow row in table.Rows)
                {
                    if (!(bool)row["is_partner"])
                    {
                        iIMGroup = (int)row["IMGroupId"];
                        break;
                    }
                }
            }

            int userId = -1;

            #region makeuser
            if (semail != "")
            {
                int id = User.GetUserByEmail(semail);
                if (id <= 0)
                {
                    string strLogin = semail.Substring(0, semail.IndexOf("@"));
                    int    i        = 0;
                    bool   fl       = false;
                    do
                    {
                        string tmpLogin = strLogin;
                        if (i > 0)
                        {
                            tmpLogin = tmpLogin + i.ToString();
                        }
                        using (IDataReader reader = User.GetUserInfoByLogin(tmpLogin))
                        {
                            if (reader.Read())
                            {
                                fl = true;
                            }
                            else
                            {
                                fl = false;
                            }
                        }
                        i++;
                    }while (fl);

                    string sFirst = (sfirst == "") ? strLogin : sfirst;
                    string sLast  = (slast == "") ? strLogin : slast;
                    if (i > 1)
                    {
                        strLogin = strLogin + (i - 1).ToString();
                    }

                    ArrayList newList = new ArrayList(alGroups);
                    if (badmin)
                    {
                        newList.Add((int)InternalSecureGroups.Administrator);
                    }

                    userId = User.Create(strLogin, "ibn", sFirst, sLast, semail, true,
                                         newList, iIMGroup, "", "", "", "", "", "", "", Security.CurrentUser.TimeZoneId,
                                         Security.CurrentUser.LanguageId, null, null, -1);
                }
            }
            #endregion

            return(userId);
        }
Пример #23
0
        private void BindToolbar()
        {
            ComponentArt.Web.UI.MenuItem topMenuItem = new ComponentArt.Web.UI.MenuItem();
            topMenuItem.Text                = /*"<img border='0' src='../Layouts/Images/downbtn.gif' width='9px' height='5px' align='absmiddle'/>&nbsp;" + */ LocRM2.GetString("Actions");
            topMenuItem.Look.LeftIconUrl    = ResolveUrl("~/Layouts/Images/downbtn1.gif");
            topMenuItem.Look.LeftIconHeight = Unit.Pixel(5);
            topMenuItem.Look.LeftIconWidth  = Unit.Pixel(16);
            topMenuItem.LookId              = "TopItemLook";
            ComponentArt.Web.UI.MenuItem subItem;

            #region Create/Clone
            if (IMGroup.CanCreate())
            {
                subItem = new ComponentArt.Web.UI.MenuItem();
                subItem.Look.LeftIconWidth  = Unit.Pixel(16);
                subItem.Look.LeftIconHeight = Unit.Pixel(16);
                if (GroupID == 0)
                {
                    subItem.Look.LeftIconUrl = "~/Layouts/Images/icons/ibngroup_create.gif";
                    subItem.NavigateUrl      = "~/Directory/AddIMGroup.aspx";
                    subItem.Text             = LocRM.GetString("AddGroup");
                }
                else
                {
                    subItem.Look.LeftIconUrl = "~/Layouts/Images/icons/ibngroupclone.gif";
                    subItem.NavigateUrl      = "~/Directory/AddIMGroup.aspx?CloneGroupID=" + GroupID;
                    subItem.Text             = LocRM.GetString("Clone");
                }
                topMenuItem.Items.Add(subItem);
            }
            #endregion

            #region Edit
            if (GroupID > 0 && IMGroup.CanUpdate())
            {
                subItem = new ComponentArt.Web.UI.MenuItem();
                subItem.Look.LeftIconUrl    = "~/Layouts/Images/icons/ibngroup_edit.gif";
                subItem.Look.LeftIconWidth  = Unit.Pixel(16);
                subItem.Look.LeftIconHeight = Unit.Pixel(16);
                subItem.NavigateUrl         = "~/Directory/AddIMGroup.aspx?GroupID=" + GroupID;
                subItem.Text = LocRM.GetString("EditGroup");
                topMenuItem.Items.Add(subItem);
            }
            #endregion

            #region Delete
            if (GroupID > 0 && IMGroup.CanDelete(GroupID))
            {
                subItem = new ComponentArt.Web.UI.MenuItem();
                subItem.Look.LeftIconUrl    = "~/Layouts/Images/icons/ibngroup_delete.gif";
                subItem.Look.LeftIconWidth  = Unit.Pixel(16);
                subItem.Look.LeftIconHeight = Unit.Pixel(16);
                subItem.ClientSideCommand   = "javascript:DeleteGroup(" + GroupID.ToString() + ")";
                subItem.Text = LocRM.GetString("DeleteGroup");
                topMenuItem.Items.Add(subItem);
            }
            #endregion

            #region new user
            if (GroupID > 0 && IMGroup.CanUpdate())
            {
                subItem = new ComponentArt.Web.UI.MenuItem();
                subItem.Look.LeftIconUrl    = "~/Layouts/Images/icons/newuser.gif";
                subItem.Look.LeftIconWidth  = Unit.Pixel(16);
                subItem.Look.LeftIconHeight = Unit.Pixel(16);
                subItem.NavigateUrl         = "~/Directory/MultipleUserEdit.aspx";
                subItem.Text = LocRM.GetString("AddUser");
                topMenuItem.Items.Add(subItem);
            }
            #endregion

            if (topMenuItem.Items.Count > 0)
            {
                secHeader.ActionsMenu.Items.Add(topMenuItem);
            }

            if (GroupID > 0)
            {
                string imGroupName = IMGroup.GetIMGroupName(GroupID, null);
                if (imGroupName != null)
                {
                    secHeader.Title = imGroupName;
                }
            }
            else
            {
                secHeader.Title = LocRM.GetString("tContactGroups");
            }
        }
Пример #24
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();
        }