Пример #1
0
        private static string FilterPreviewHtml(string html)
        {
            var e = new DivvyEventArgs()
            {
                PreviewHtml = html
            };

            OnAfterGeneratePreviewHtml(null, e);
            return(e.PreviewHtml);
        }
Пример #2
0
        private static IContent CreateContent(ContentRequest contentRequest, DivvyTypeMapping mapping)
        {
            // Run the event. The target node might change in here
            var e = new DivvyEventArgs()
            {
                ContentRequest   = contentRequest,
                IntendedParent   = mapping.ParentNode,
                IntendedTypeName = mapping.EpiserverPageTypeName
            };

            OnBeforeContentCreation(null, e);

            if (e.CancelAction)
            {
                return(null);
            }

            var parent = repo.Get <PageData>(e.IntendedParent);

            DivvyLogManager.LogRequest($"Creating New Content", new { Type = e.IntendedTypeName, ParentId = parent.ContentGuid, ParentName = parent.Name });

            try
            {
                // Get the type ID. For whatever reason, we can't create content with a type name, we have to have the ID...
                var type = typeRepo.Load(e.IntendedTypeName);

                // Create the content
                var content = repo.GetDefault <IContent>(e.IntendedParent, type.ID);
                content.Name = contentRequest.Title;
                repo.Save(content, AccessLevel.NoAccess);

                // There's an edge case where we have a mappng already because the Episerver content got deleted
                if (!DivvyContentMapping.HasDivvyMapping(content.ContentLink.ID))
                {
                    DivvyContentMapping.Create(content.ContentLink.ID, contentRequest.Id);
                }

                DivvyLogManager.LogRequest("Created New Content", new { Id = content.ContentGuid });

                return(content);
            }
            catch (Exception ex)
            {
                DivvyLogManager.LogRequest($"Error Creating New Content", ex);
                return(null);
            }
        }
Пример #3
0
        private static string FilterInput(string input)
        {
            // Filter the raw input
            var e = new DivvyEventArgs()
            {
                RawInput = input
            };

            OnBeforeParseContentGatewayRequest(null, e);

            if (e.CancelAction)
            {
                return(null);
            }

            return(e.RawInput);
        }
Пример #4
0
        private static ContentRequest ParseContentRequest(string input)
        {
            var contentRequest = ContentRequest.ParseJson(input);

            // Filter parsed value
            var e = new DivvyEventArgs()
            {
                ContentRequest = contentRequest
            };

            OnAfterParseContentGatewayRequest(null, e);

            if (e.CancelAction)
            {
                return(null);
            }

            return(contentRequest);
        }