Exemplo n.º 1
0
    public void ShowDialog(string type, string smartPart, string entityId, string title, bool isCentered, int top, int left, int height, int width, IDictionary <string, string> dialogParameters = null, ChildInsertInformation childInsertInfo = null)
    {
        Type entityType = Type.GetType(type);

        Dialog.SetSpecs(top, left, height, width, smartPart, title, isCentered);
        Dialog.EntityID   = entityId;
        Dialog.EntityType = entityType;
        if (dialogParameters != null)
        {
            foreach (var param in dialogParameters)
            {
                Dialog.DialogParameters.Remove(param.Key);
                Dialog.DialogParameters.Add(param.Key, param.Value);
            }
        }
        Dialog.ChildInsertInfo = childInsertInfo;
        Dialog.ShowDialog();
    }
Exemplo n.º 2
0
    private void HandleLinkRequest(object sender, EventArgs e)
    {
        if (_state.Value == string.Empty)
        {
            return;
        }

        var jso = new Dictionary <string, object>();

        JsonConvert.PopulateObject(_state.Value, jso);

        string request                   = GetValue(jso, "request");
        string kind                      = GetValue(jso, "kind");
        string type                      = GetValue(jso, "type");
        string id                        = GetValue(jso, "id");
        string selectionInfoKey          = GetValue(jso, "selectionInfoKey");
        string recurDate                 = string.Empty;
        Dictionary <string, string> args = GetArgs(jso);

        switch (request)
        {
        case "Schedule":
            if (type == "CompleteActivity")
            {
                Link.ScheduleCompleteActivity();
            }
            break;

        case "EntityDetail":
            Link.EntityDetail(id, kind);
            break;

        case "MergeRecords":
            Link.MergeRecords(selectionInfoKey);
            break;

        case "ShowDialog":
            //dialog properties
            string smartPart   = GetValue(jso, "smartPart");
            string entityId    = GetValue(jso, "entityId");
            string title       = GetValue(jso, "dialogTitle");
            bool   isCentered  = Convert.ToBoolean(GetValue(jso, "isCentered"));
            int    top         = Convert.ToInt16(GetValue(jso, "dialogTop"));
            int    left        = Convert.ToInt16(GetValue(jso, "dialogLeft"));
            int    height      = Convert.ToInt16(GetValue(jso, "dialogHeight"));
            int    width       = Convert.ToInt16(GetValue(jso, "dialogWidth"));
            var    dialogParam = new Dictionary <string, string>();
            if (GetValue(jso, "dialogParameters") != null)
            {
                var dialogParameters = JsonConvert.DeserializeObject <DialogParameterOption>(GetValue(jso, "dialogParameters"));
                dialogParam.Add(dialogParameters.Key, dialogParameters.Value);
            }
            var childInfo = new ChildInsertInformation();
            if (GetValue(jso, "childInsertInfo") != null)
            {
                var childInsertInfo = JsonConvert.DeserializeObject <ChildInsertInfo>(GetValue(jso, "childInsertInfo"));
                childInfo.ChildEntityType           = childInsertInfo.ChildType;
                childInfo.ParentEntityType          = childInsertInfo.ParentType;
                childInfo.ParentReferenceProperty   = childInsertInfo.ChildType.GetProperty(childInsertInfo.ChildRelationshipProperty);
                childInfo.ParentsCollectionProperty = childInsertInfo.ParentType.GetProperty(childInsertInfo.ParentRelationshipProperty);
            }
            Link.ShowDialog(type, smartPart, entityId, title, isCentered, top, left, height, width, dialogParam, childInfo);
            break;

        case "Administration":
            if (type == "AddUsers")
            {
                Link.NewUsers();
            }
            else if (type == "CopyUser")
            {
                Link.CopyUser(GetSelectedIds(selectionInfoKey));
            }
            else if (type == "CopyUserProfile")
            {
                Link.CopyUserProfile(GetSelectedIds(selectionInfoKey));
            }
            else if (type == "DeleteUsers")
            {
                Link.DeleteUsers(GetSelectedIds(selectionInfoKey));
            }
            else if (type == "AddToTeam")
            {
                Link.AddToTeam(GetSelectedIds(selectionInfoKey));
            }
            else if (type == "RemoveFromTeam")
            {
                //Link.RemoveUsersFromTeam(GetSelectedIds(selectionInfoKey));
            }
            else if (type == "AssignRole")
            {
                Link.AssignRoleToUsers(GetSelectedIds(selectionInfoKey));
            }
            else if (type == "RemoveFromAllTeams")
            {
                Link.RemoveFromAllTeams(GetSelectedIds(selectionInfoKey));
            }
            else if (type == "ReplaceTeamMember")
            {
                Link.ReplaceTeamMember(GetSelectedIds(selectionInfoKey));
            }
            else if (type == "RedirectToUser")
            {
                Sage.Entity.Interfaces.IOwner owner = Sage.Platform.EntityFactory.GetById <Sage.Entity.Interfaces.IOwner>(id);
                Response.Redirect(string.Format("User.aspx?entityId={0}", owner.User.Id.ToString()), true);
            }
            else if (type == "EditSecurityProfile")
            {
                Link.ShowEditSecurityProfileDialog(selectionInfoKey);
            }
            else if (type == "DeleteTeam")
            {
                Link.DeleteTeam(GetSelectedIds(selectionInfoKey));
            }
            else if (type == "DeleteDepartment")
            {
                Link.DeleteDepartment(GetSelectedIds(selectionInfoKey));
            }
            else if (type == "CopyTeam")
            {
                Link.CopyTeam(GetSelectedIds(selectionInfoKey));
            }
            else if (type == "CopyDepartment")
            {
                Link.CopyDepartment(GetSelectedIds(selectionInfoKey));
            }
            else if (type == "SetUsersToStandardRole")
            {
                Link.SetUsersToStandardRole();
            }
            break;
        }

        // Clear the state, otherwise performing the same action again won't work
        // (but remove the state changed event first, otherwise clearing the state will
        //  trigger another postback with the same data -- if a dialog is closed,
        //  it would open immediately after being closed, for example)
        _state.ValueChanged -= HandleLinkRequest;
        _state.Value         = string.Empty;
    }