/// <summary>
    /// Launches a dialog that allows the user to select the team to which
    /// the selected list of users will be assigned.
    /// </summary>
    public void AddToTeam(IList <string> targetIds)
    {
        var             srv = ApplicationContext.Current.Services.Get <IGroupContextService>();
        EntityGroupInfo currentEntityGroupInfo = srv.GetGroupContext().CurrentGroupInfo;

        Type entityContext = null;

        switch (currentEntityGroupInfo.EntityName)
        {
        case "User":
            entityContext = typeof(IUser);
            break;

        case "Team":
            entityContext = typeof(ITeam);
            break;

        case "Department":
            entityContext = typeof(IDepartment);
            break;
        }

        Dialog.DialogParameters.Clear();
        Dialog.DialogParameters.Add("selectedIds", targetIds);
        Dialog.DialogParameters.Add("context", entityContext);
        Dialog.SetSpecs(210, 350, "AddToTeam");
        Dialog.ShowDialog();
    }
    /// <summary>
    /// Handles the Click event of the ok button control.
    /// </summary>
    /// <param name="sender">The source of the event.</param>
    /// <param name="e">The <see cref="System.EventArgs"/> instance containing the event data.</param>
    protected void OK_Click(object sender, EventArgs e)
    {
        AddUserOptions options = GetOptions();
        IList <IUser>  list    = UserManagementService.AddUsers(options);

        if (list.Count > 1)
        {
            StringBuilder sb    = new StringBuilder();
            int           index = 0;
            int           count = list.Count;
            foreach (IUser user in list)
            {
                index++;
                sb.AppendFormat(index == count ? "'{0}'" : "'{0}',", user.Id);
            }

            IGroupContextService srv = ApplicationContext.Current.Services.Get <IGroupContextService>() as GroupContextService;
            if (srv != null)
            {
                string tableName = "USERSECURITY";
                srv.CurrentTable = tableName;

                EntityGroupInfo currentEntityGroupInfo = srv.GetGroupContext().CurrentGroupInfo;
                currentEntityGroupInfo.LookupTempGroup.ClearConditions();
                currentEntityGroupInfo.LookupTempGroup.AddLookupCondition(string.Format("{0}:UserId", tableName), " IN ", string.Format("({0})", sb));
                currentEntityGroupInfo.LookupTempGroup.GroupXML = GroupInfo.RebuildGroupXML(currentEntityGroupInfo.LookupTempGroup.GroupXML);
                srv.CurrentGroupID = GroupContext.LookupResultsGroupID;
            }
            Response.Redirect(string.Format("~/{0}.aspx?", "User"), false);
        }
        else
        {
            Response.Redirect(string.Format("~/{0}.aspx?entityId={1}", "User", list[0].Id), false);
        }
    }
Beispiel #3
0
    /// <summary>
    ///
    /// </summary>
    /// <param name="grpType">"ACCOUNT" or "CONTACT"</param>
    private void InitializeGroupList(string grpType)
    {
        cbxGroupName.Items.Clear();
        GroupContext.GetGroupContext().CurrentTable = grpType;
        EntityGroupInfo groupCache = GroupContext.GetGroupContext().GetGroupInfoForTable(grpType);

        foreach (var gi in groupCache.GroupsList)
        {
            cbxGroupName.Items.Add(new ListItem(gi.GroupName, gi.GroupID));
        }
    }
    public void RedirectToNewGroupDetail(IList <IUser> newUserList)
    {
        var srv = ApplicationContext.Current.Services.Get <IGroupContextService>();

        if (srv != null)
        {
            if (Dialog != null)
            {
                Dialog.CloseEventHappened(null, null);
            }

            const string tableName = "USERSECURITY";
            srv.CurrentTable = tableName;

            EntityGroupInfo currentEntityGroupInfo = srv.GetGroupContext().CurrentGroupInfo;
            currentEntityGroupInfo.LookupTempGroup.ClearConditions();
            StringBuilder sb = new StringBuilder();

            if (newUserList.Count > 1)
            {
                foreach (IUser user in newUserList)
                {
                    sb.AppendFormat("'{0}',", user.Id);
                }
                string idList = sb.ToString();
                if (idList.EndsWith(","))
                {
                    idList = idList.TrimEnd(new char[] { ',' });
                }

                idList = string.Format("({0})", idList);
                currentEntityGroupInfo.LookupTempGroup.AddLookupCondition(string.Format("{0}:UserId", tableName), "IN", idList);
                currentEntityGroupInfo.LookupTempGroup.GroupXML = GroupInfo.RebuildGroupXML(currentEntityGroupInfo.LookupTempGroup.GroupXML);
                srv.CurrentGroupID = GroupContext.LookupResultsGroupID;
                HttpContext.Current.Response.Redirect(string.Format("~/{0}.aspx", "User"), false);
            }
            else
            {
                currentEntityGroupInfo.LookupTempGroup.AddLookupCondition(string.Format("{0}:UserId", tableName), "=", newUserList[0].Id.ToString());
                currentEntityGroupInfo.LookupTempGroup.GroupXML = GroupInfo.RebuildGroupXML(currentEntityGroupInfo.LookupTempGroup.GroupXML);
                srv.CurrentGroupID = GroupContext.LookupResultsGroupID;
                HttpContext.Current.Response.Redirect(string.Format("~/{0}.aspx?entityId={1}", "User", newUserList[0].Id), false);
            }
        }
    }
    public void ReplaceTeamMember(IList <string> targetIds)
    {
        var             srv = ApplicationContext.Current.Services.Get <IGroupContextService>();
        EntityGroupInfo currentEntityGroupInfo = srv.GetGroupContext().CurrentGroupInfo;

        var    ehs    = ApplicationContext.Current.Services.Get <IEntityHistoryService>();
        object lastId = null;

        switch (currentEntityGroupInfo.EntityName)
        {
        case "User":
            lastId = ehs.GetLastIdForType <IUser>();
            if (lastId != null)
            {
                targetIds = new List <string> {
                    lastId.ToString()
                };
                ReplaceTeamMember(targetIds, typeof(IUser));
            }
            break;

        case "Team":
            lastId = ehs.GetLastIdForType <ITeam>();
            if (lastId != null)
            {
                targetIds = new List <string> {
                    lastId.ToString()
                };
                ReplaceTeamMember(targetIds, typeof(ITeam));
            }
            break;

        case "Department":
            lastId = ehs.GetLastIdForType <IDepartment>();
            if (lastId != null)
            {
                targetIds = new List <string> {
                    lastId.ToString()
                };
                ReplaceTeamMember(targetIds, typeof(IDepartment));
            }
            break;
        }
    }
    public void RemoveFromAllTeams(IList <string> targetIds)
    {
        var             srv = ApplicationContext.Current.Services.Get <IGroupContextService>();
        EntityGroupInfo currentEntityGroupInfo = srv.GetGroupContext().CurrentGroupInfo;

        switch (currentEntityGroupInfo.EntityName)
        {
        case "User":
            RemoveUserFromAllTeams(targetIds);
            break;

        case "Team":
            RemoveTeamFromAllTeams(targetIds);
            break;

        case "Department":
            RemoveDepartmentFromAllTeams(targetIds);
            break;
        }
    }
    public void MergeRecords(String selectionContextKey)
    {
        Dialog.SetSpecs(-1, -1, 750, 650, "MergeRecords");
        IGroupContextService srv = ApplicationContext.Current.Services.Get <IGroupContextService>() as GroupContextService;
        EntityGroupInfo      currentEntityGroupInfo = srv.GetGroupContext().CurrentGroupInfo;
        ISelectionService    selectionService       = (ISelectionService)SelectionServiceRequest.GetSelectionService();
        ISelectionContext    selectionContext       = selectionService.GetSelectionContext(selectionContextKey);
        IList <string>       list = selectionContext.GetSelectedIds();

        if (list != null)
        {
            MergeArguments mergeArguments = new MergeArguments(list[0], list[1], currentEntityGroupInfo.EntityType, currentEntityGroupInfo.EntityType);
            Dialog.DialogParameters.Add("mergeArguments", mergeArguments);
            Dialog.ShowDialog();
        }
        else
        {
            throw new ValidationException("The selection service does not contain any selected records.");
        }
    }
    public void ReplaceTeamMember(IList <string> targetIds)
    {
        IGroupContextService srv = ApplicationContext.Current.Services.Get <IGroupContextService>() as GroupContextService;
        EntityGroupInfo      currentEntityGroupInfo = srv.GetGroupContext().CurrentGroupInfo;

        switch (currentEntityGroupInfo.EntityName)
        {
        case "User":
            ReplaceTeamMemberUser(targetIds);
            break;

        case "Team":
            ReplaceTeamMemberTeam(targetIds);
            break;

        case "Department":
            ReplaceTeamMemberDepartment(targetIds);
            break;
        }
    }
Beispiel #9
0
 public VM_TreeCadPart(FileInfo f, EntityGroupInfo info) : base(f)
 {
 }