コード例 #1
0
        public EditActionLink(IPortalContext portalContext, GridMetadata gridMetadata, int languageCode, EditAction action,
                              bool enabled = false, string portalName = null,
                              string label = null, string tooltip     = null,
                              string queryStringIdParameterName = "id")
            : base(portalContext, languageCode, action, LinkActionType.Edit, enabled, portalName, label, tooltip)
        {
            Initialize();

            QueryStringIdParameterName = !string.IsNullOrWhiteSpace(action.RecordIdQueryStringParameterName)
                                ? action.RecordIdQueryStringParameterName
                                : queryStringIdParameterName;

            if (gridMetadata.EditFormDialog == null)
            {
                return;
            }

            Modal.CloseButtonCssClass   = gridMetadata.EditFormDialog.CloseButtonCssClass;
            Modal.CloseButtonText       = gridMetadata.EditFormDialog.CloseButtonText.GetLocalizedString(languageCode);
            Modal.CssClass              = gridMetadata.EditFormDialog.CssClass;
            Modal.DismissButtonSrText   = gridMetadata.EditFormDialog.DismissButtonSrText.GetLocalizedString(languageCode);
            Modal.LoadingMessage        = gridMetadata.EditFormDialog.LoadingMessage.GetLocalizedString(languageCode);
            Modal.PrimaryButtonCssClass = gridMetadata.EditFormDialog.PrimaryButtonCssClass;
            Modal.PrimaryButtonText     = gridMetadata.EditFormDialog.PrimaryButtonText.GetLocalizedString(languageCode);
            Modal.Size          = gridMetadata.EditFormDialog.Size;
            Modal.Title         = gridMetadata.EditFormDialog.Title.GetLocalizedString(languageCode);
            Modal.TitleCssClass = gridMetadata.EditFormDialog.TitleCssClass;
        }
        /// <summary>
        /// Initializes a new instance of the <see cref="CreateRelatedRecordActionLink" /> class.
        /// </summary>
        /// <param name="portalContext">The portal context.</param>
        /// <param name="gridMetadata">The grid metadata.</param>
        /// <param name="languageCode">The language code.</param>
        /// <param name="action">The action.</param>
        /// <param name="enabled">if set to <c>true</c> [enabled].</param>
        /// <param name="portalName">Name of the portal.</param>
        /// <param name="label">The label.</param>
        /// <param name="tooltip">The tooltip.</param>
        /// <param name="queryStringIdParameterName">Name of the query string identifier parameter.</param>
        public CreateRelatedRecordActionLink(IPortalContext portalContext, GridMetadata gridMetadata, int languageCode, CreateRelatedRecordAction action,
                                             bool enabled = false, string portalName = null, string label = null, string tooltip = null, string queryStringIdParameterName = "id")
            : base(portalContext, languageCode, action, LinkActionType.CreateRelatedRecord, enabled, portalName, label, tooltip)
        {
            this.Initialize();

            this.QueryStringIdParameterName = !string.IsNullOrWhiteSpace(action.RecordIdQueryStringParameterName)
                                ? action.RecordIdQueryStringParameterName
                                : queryStringIdParameterName;

            if (gridMetadata.CreateFormDialog == null)
            {
                return;
            }

            this.Modal.CloseButtonCssClass   = gridMetadata.CreateRelatedRecordDialog.CloseButtonCssClass;
            this.Modal.CloseButtonText       = gridMetadata.CreateRelatedRecordDialog.CloseButtonText.GetLocalizedString(languageCode);
            this.Modal.CssClass              = gridMetadata.CreateRelatedRecordDialog.CssClass;
            this.Modal.DismissButtonSrText   = gridMetadata.CreateRelatedRecordDialog.DismissButtonSrText.GetLocalizedString(languageCode);
            this.Modal.LoadingMessage        = gridMetadata.CreateRelatedRecordDialog.LoadingMessage.GetLocalizedString(languageCode);
            this.Modal.PrimaryButtonCssClass = gridMetadata.CreateRelatedRecordDialog.PrimaryButtonCssClass;
            this.Modal.PrimaryButtonText     = this.Tooltip;
            this.Modal.Size          = gridMetadata.CreateRelatedRecordDialog.Size;
            this.Modal.Title         = this.Label;
            this.Modal.TitleCssClass = gridMetadata.CreateRelatedRecordDialog.TitleCssClass;

            this.FilterCriteria = action.FilterCriteria;
            this.EntityName     = action.EntityName;
            this.ParentRecord   = action.ParentRecord;
            this.Relationship   = action.Relationship;
        }
コード例 #3
0
        public DeactivateActionLink(IPortalContext portalContext, GridMetadata gridMetadata, int languageCode,
                                    DeactivateAction action, bool enabled = true, UrlBuilder url = null, string portalName = null)
            : this(portalContext, languageCode, action, enabled, url, portalName)
        {
            if (gridMetadata.DeactivateDialog == null)
            {
                return;
            }

            Modal.CloseButtonCssClass   = gridMetadata.DeactivateDialog.CloseButtonCssClass;
            Modal.CloseButtonText       = gridMetadata.DeactivateDialog.CloseButtonText.GetLocalizedString(languageCode);
            Modal.CssClass              = gridMetadata.DeactivateDialog.CssClass;
            Modal.DismissButtonSrText   = gridMetadata.DeactivateDialog.DismissButtonSrText.GetLocalizedString(languageCode);
            Modal.PrimaryButtonCssClass = gridMetadata.DeactivateDialog.PrimaryButtonCssClass;
            Modal.PrimaryButtonText     = gridMetadata.DeactivateDialog.PrimaryButtonText.GetLocalizedString(languageCode);
            Modal.Size          = gridMetadata.DeactivateDialog.Size;
            Modal.Title         = gridMetadata.DeactivateDialog.Title.GetLocalizedString(languageCode);
            Modal.TitleCssClass = gridMetadata.DeactivateDialog.TitleCssClass;
        }
コード例 #4
0
        public InsertActionLink(IPortalContext portalContext, GridMetadata gridMetadata, int languageCode, CreateAction action,
                                bool enabled = false, string portalName = null, string label = null, string tooltip = null)
            : base(portalContext, languageCode, action, LinkActionType.Insert, enabled, portalName, label, tooltip)
        {
            Initialize();

            if (gridMetadata.CreateFormDialog == null)
            {
                return;
            }

            Modal.CloseButtonCssClass   = gridMetadata.CreateFormDialog.CloseButtonCssClass;
            Modal.CloseButtonText       = gridMetadata.CreateFormDialog.CloseButtonText.GetLocalizedString(languageCode);
            Modal.CssClass              = gridMetadata.CreateFormDialog.CssClass;
            Modal.DismissButtonSrText   = gridMetadata.CreateFormDialog.DismissButtonSrText.GetLocalizedString(languageCode);
            Modal.LoadingMessage        = gridMetadata.CreateFormDialog.LoadingMessage.GetLocalizedString(languageCode);
            Modal.PrimaryButtonCssClass = gridMetadata.CreateFormDialog.PrimaryButtonCssClass;
            Modal.PrimaryButtonText     = gridMetadata.CreateFormDialog.PrimaryButtonText.GetLocalizedString(languageCode);
            Modal.Size          = gridMetadata.CreateFormDialog.Size;
            Modal.Title         = gridMetadata.CreateFormDialog.Title.GetLocalizedString(languageCode);
            Modal.TitleCssClass = gridMetadata.CreateFormDialog.TitleCssClass;
        }
コード例 #5
0
        public WorkflowActionLink(IPortalContext portalContext, EntityReference workflow, GridMetadata gridMetadata,
                                  int languageCode, WorkflowAction action, bool enabled = true, UrlBuilder url = null, string portalName = null)
            : this(portalContext, workflow, languageCode, action, enabled, url, portalName)
        {
            if (gridMetadata.WorkflowDialog == null)
            {
                return;
            }

            Modal.CloseButtonCssClass   = gridMetadata.WorkflowDialog.CloseButtonCssClass;
            Modal.CloseButtonText       = gridMetadata.WorkflowDialog.CloseButtonText.GetLocalizedString(languageCode);
            Modal.CssClass              = gridMetadata.WorkflowDialog.CssClass;
            Modal.DismissButtonSrText   = gridMetadata.WorkflowDialog.DismissButtonSrText.GetLocalizedString(languageCode);
            Modal.PrimaryButtonCssClass = gridMetadata.WorkflowDialog.PrimaryButtonCssClass;
            Modal.Size          = gridMetadata.WorkflowDialog.Size;
            Modal.TitleCssClass = gridMetadata.WorkflowDialog.TitleCssClass;

            var customPrimaryButtonText = action.WorkflowDialogPrimaryButtonText.GetLocalizedString(languageCode);

            Modal.PrimaryButtonText = !string.IsNullOrEmpty(customPrimaryButtonText)
                                ? customPrimaryButtonText
                                : gridMetadata.WorkflowDialog.PrimaryButtonText.GetLocalizedString(languageCode);

            var customCancelButtonText = action.WorkflowDialogCloseButtonText.GetLocalizedString(languageCode);

            Modal.CloseButtonText = !string.IsNullOrEmpty(customCancelButtonText)
                                ? customCancelButtonText
                                : gridMetadata.WorkflowDialog.CloseButtonText.GetLocalizedString(languageCode);

            var customTitle = action.WorkflowDialogTitle.GetLocalizedString(languageCode);

            Modal.Title = !string.IsNullOrEmpty(customTitle)
                                ? customTitle
                                : gridMetadata.WorkflowDialog.Title.GetLocalizedString(languageCode);
        }
コード例 #6
0
        protected override void CreateChildControls()
        {
            Controls.Clear();

            var portalContext  = PortalCrmConfigurationManager.CreatePortalContext(PortalName);
            var serviceContext = PortalCrmConfigurationManager.CreateServiceContext(PortalName);

            Entity entitylist;
            bool   updateEntityListReference;

            if (!TryGetEntityList(portalContext, serviceContext, out entitylist, out updateEntityListReference))
            {
                Visible = false;

                return;
            }

            if (updateEntityListReference)
            {
                EntityListReference = entitylist.ToEntityReference();
            }

            if (LanguageCode <= 0)
            {
                LanguageCode = this.Context.GetPortalSolutionsDetails().OrganizationBaseLanguageCode;
            }

            RegisterClientSideDependencies(this);

            var registerStartupScript = entitylist.GetAttributeValue <string>("adx_registerstartupscript");

            if (!string.IsNullOrWhiteSpace(registerStartupScript))
            {
                var html = Mvc.Html.EntityExtensions.GetHtmlHelper(PortalName, Page.Request.RequestContext, Page.Response);

                var control = new HtmlGenericControl()
                {
                };

                var script = html.ScriptAttribute(serviceContext, entitylist, "adx_registerstartupscript");

                control.InnerHtml = script.ToString();

                Controls.Add(control);
            }

            var entityName       = entitylist.GetAttributeValue <string>("adx_entityname");
            var primaryKeyName   = entitylist.GetAttributeValue <string>("adx_primarykeyname");
            var view             = entitylist.GetAttributeValue <string>("adx_view"); // old comma delimited list of views
            var viewMetadataJson = entitylist.GetAttributeValue <string>("adx_views");

            EnableEntityPermissions = entitylist.GetAttributeValue <bool?>("adx_entitypermissionsenabled").GetValueOrDefault(false);

            if (string.IsNullOrWhiteSpace(entityName))
            {
                throw new ApplicationException("Entity Name (adx_entityname) attribute on Entity List (adx_entitylist) is null or empty. Please specify the logical name of the entity.");
            }

            if (!string.IsNullOrWhiteSpace(entityName) && string.IsNullOrWhiteSpace(primaryKeyName))
            {
                primaryKeyName = MetadataHelper.GetEntityPrimaryKeyAttributeLogicalName(serviceContext, entityName);
            }

            if (string.IsNullOrWhiteSpace(primaryKeyName))
            {
                throw new ApplicationException(string.Format("The entity primary key logical name couldn't be determined.", entityName));
            }

            if (string.IsNullOrWhiteSpace(view) && string.IsNullOrWhiteSpace(viewMetadataJson))
            {
                throw new ApplicationException("View selection on Entity List (adx_entitylist) is null or empty. Specify the savedquery views.");
            }

            var          gridMetadataJson = entitylist.GetAttributeValue <string>("adx_settings");
            GridMetadata gridMetadata     = null;

            if (!string.IsNullOrWhiteSpace(gridMetadataJson))
            {
                try
                {
                    gridMetadata = JsonConvert.DeserializeObject <GridMetadata>(gridMetadataJson,
                                                                                new JsonSerializerSettings
                    {
                        ContractResolver = JsonConfigurationContractResolver.Instance,
                        TypeNameHandling = TypeNameHandling.Objects,
                        Converters       = new List <JsonConverter> {
                            new GuidConverter()
                        },
                        Binder = new ActionSerializationBinder()
                    });
                }
                catch (Exception e)
                {
                    ADXTrace.Instance.TraceError(TraceCategory.Application, e.ToString());
                }
            }

            var viewConfigurations = new List <ViewConfiguration>();

            if (string.IsNullOrWhiteSpace(viewMetadataJson))
            {
                if (string.IsNullOrWhiteSpace(view))
                {
                    return;
                }
                var viewids   = view.Split(',');
                var viewGuids = viewids.Length < 1 ? null : Array.ConvertAll(viewids, Guid.Parse);

                if (viewGuids == null || !viewGuids.Any())
                {
                    throw new ApplicationException(
                              ResourceManager.GetString("ADX_View_Attribute_On_Entity_List_Contains_Invalid_Data_Exception"));
                }

                viewConfigurations =
                    viewGuids.Select(
                        viewGuid =>
                        new ViewConfiguration(portalContext, serviceContext, entitylist, entityName, primaryKeyName, viewGuid,
                                              gridMetadata, PortalName, LanguageCode, EnableEntityPermissions, PageQueryStringField, FilterQueryStringField,
                                              SearchQueryStringField, SortQueryStringField, FilterByUserOptionLabel, ActionLinksColumnWidth,
                                              MetadataFilterQueryStringField, DefaultDetailsButtonLabel, ActionLinkDetailsViewTooltipLabel,
                                              DefaultCreateButtonLabel, ActionLinkInsertTooltipLabel, DefaultEmptyListText)).ToList();
            }
            else
            {
                ViewMetadata viewMetadata = null;
                try
                {
                    viewMetadata = JsonConvert.DeserializeObject <ViewMetadata>(viewMetadataJson,
                                                                                new JsonSerializerSettings {
                        ContractResolver = JsonConfigurationContractResolver.Instance, TypeNameHandling = TypeNameHandling.Objects, Binder = new ActionSerializationBinder(), Converters = new List <JsonConverter> {
                            new GuidConverter()
                        }
                    });
                }
                catch (Exception e)
                {
                    ADXTrace.Instance.TraceError(TraceCategory.Application, e.ToString());
                }

                if (viewMetadata != null && viewMetadata.Views != null && viewMetadata.Views.Any())
                {
                    foreach (var viewMeta in viewMetadata.Views)
                    {
                        var viewConfiguration = new ViewConfiguration(portalContext, serviceContext, entitylist, entityName,
                                                                      primaryKeyName, viewMeta.ViewId,
                                                                      gridMetadata, PortalName, LanguageCode, EnableEntityPermissions, PageQueryStringField, FilterQueryStringField,
                                                                      SearchQueryStringField, SortQueryStringField, FilterByUserOptionLabel, ActionLinksColumnWidth,
                                                                      MetadataFilterQueryStringField, DefaultDetailsButtonLabel, ActionLinkDetailsViewTooltipLabel,
                                                                      DefaultCreateButtonLabel, ActionLinkInsertTooltipLabel, DefaultEmptyListText);
                        if (viewMeta.DisplayName != null)
                        {
                            var displayName = Localization.GetLocalizedString(viewMeta.DisplayName, LanguageCode);
                            if (!string.IsNullOrWhiteSpace(displayName))
                            {
                                viewConfiguration.ViewDisplayName = displayName;
                            }
                        }
                        viewConfigurations.Add(viewConfiguration);
                    }
                }
            }

            var crmEntityListView = new CrmEntityListView
            {
                EnableEntityPermissions = EnableEntityPermissions,
                EntityListReference     = EntityListReference,
                ViewConfigurations      = viewConfigurations,
                ListCssClass            = ListCssClass,
                PortalName   = PortalName,
                LanguageCode = LanguageCode,
                ViewQueryStringParameterName = ViewQueryStringField,
                IsGallery = IsGallery
            };

            if (gridMetadata != null)
            {
                if (gridMetadata.ErrorDialog != null)
                {
                    crmEntityListView.ErrorModal = new ViewErrorModal
                    {
                        CloseButtonCssClass = gridMetadata.ErrorDialog.CloseButtonCssClass,
                        CloseButtonText     = gridMetadata.ErrorDialog.CloseButtonText.GetLocalizedString(LanguageCode),
                        CssClass            = gridMetadata.ErrorDialog.CssClass,
                        DismissButtonSrText = gridMetadata.ErrorDialog.DismissButtonSrText.GetLocalizedString(LanguageCode),
                        Body          = gridMetadata.ErrorDialog.Body.GetLocalizedString(LanguageCode),
                        Size          = gridMetadata.ErrorDialog.Size,
                        Title         = gridMetadata.ErrorDialog.Title.GetLocalizedString(LanguageCode),
                        TitleCssClass = gridMetadata.ErrorDialog.TitleCssClass
                    };
                }
            }

            Controls.Add(crmEntityListView);
        }