Esempio n. 1
0
        private void DeleteExistedMailTemplates()
        {
            var mailTemplateFolderXpath = XPathHelper.GetXpath(
                _documentTypeAliasProvider.GetDataFolder(),
                _documentTypeAliasProvider.GetMailTemplateFolder());

            var publishedContent = _umbracoHelper.TypedContentSingleAtXPath(mailTemplateFolderXpath);

            if (publishedContent == null)
            {
                return;
            }

            bool IsForRemove(IPublishedContent content)
            {
                var templateType = content.GetPropertyValue <NotificationTypeEnum>(UmbracoContentMigrationConstants.MailTemplate.EmailTypePropName);

                return(templateType.In(NotificationTypeEnum.CommentLikeAdded, NotificationTypeEnum.MonthlyMail));
            }

            var publishedContentToRemove = publishedContent.Children.Where(IsForRemove);
            var contentToRemove          = _contentService.GetByIds(publishedContentToRemove.Select(c => c.Id)).ToList();

            contentToRemove.ForEach(c => _contentService.Delete(c));
        }
        public override void OnActionExecuting(ActionExecutingContext filterContext)
        {
            Guid?activityId = null;

            if (filterContext.ActionParameters.TryGetValue(ActivityIdParameterName, out var obj))
            {
                activityId = obj as Guid?;
            }

            var activityServices = DependencyResolver.Current.GetServices <IIntranetActivityService <IIntranetActivity> >();
            var activity         = activityServices.Select(service => service.Get(activityId.GetValueOrDefault())).FirstOrDefault(a => a != null);

            if (activity == null || activity.IsHidden)
            {
                var umbracoHelper = DependencyResolver.Current.GetService <UmbracoHelper>();
                var aliasProvider = DependencyResolver.Current.GetService <IDocumentTypeAliasProvider>();

                var errorPage = umbracoHelper.ContentSingleAtXPath(XPathHelper.GetXpath(aliasProvider.GetHomePage(), aliasProvider.GetErrorPage()));
                if (errorPage != null)
                {
                    filterContext.Controller.ControllerContext.HttpContext.Response.StatusCode = HttpStatusCode.NotFound.GetHashCode();
                    filterContext.Controller.ControllerContext.HttpContext.Response.End();
                }

                filterContext.Result = new HttpNotFoundResult();
            }
        }
Esempio n. 3
0
        private IEnumerable <IPublishedContent> GetMailTemplates()
        {
            var mailTemplateXpath = XPathHelper.GetXpath(_documentTypeAliasProvider.GetDataFolder(), _documentTypeAliasProvider.GetMailTemplateFolder(),
                                                         _documentTypeAliasProvider.GetMailTemplate());

            return(_umbracoHelper.TypedContentAtXPath(mailTemplateXpath));
        }
Esempio n. 4
0
        private void DeleteExistedMailTemplates()
        {
            var contentService            = DependencyResolver.Current.GetService <IContentService>();
            var umbracoHelper             = DependencyResolver.Current.GetService <UmbracoHelper>();
            var documentTypeAliasProvider = DependencyResolver.Current.GetService <IDocumentTypeAliasProvider>();

            var mailTemplateFolderXpath = XPathHelper.GetXpath(documentTypeAliasProvider.GetDataFolder(), documentTypeAliasProvider.GetMailTemplateFolder());
            var publishedContent        = umbracoHelper.TypedContentSingleAtXPath(mailTemplateFolderXpath);

            bool IsForRemove(IPublishedContent content)
            {
                var templateType = content.GetPropertyValue <NotificationTypeEnum>(UmbracoContentMigrationConstants.MailTemplate.EmailTypePropName);

                return(((Enum)templateType).In(
                           LegacyNotificationTypes.Event,
                           NotificationTypeEnum.EventUpdated,
                           NotificationTypeEnum.EventHidden,
                           NotificationTypeEnum.BeforeStart,
                           LegacyNotificationTypes.News,
                           LegacyNotificationTypes.Idea,
                           NotificationTypeEnum.ActivityLikeAdded,
                           NotificationTypeEnum.CommentAdded,
                           NotificationTypeEnum.CommentEdited,
                           NotificationTypeEnum.CommentReplied));
            }

            var publishedContentToRemove = publishedContent.Children.Where(IsForRemove);
            var contentToRemove          = contentService.GetByIds(publishedContentToRemove.Select(c => c.Id)).ToList();

            contentToRemove.ForEach(c => contentService.Delete(c));
        }
Esempio n. 5
0
        static MailConfiguration()
        {
            var docTypeAliasProvider = HttpContext.Current.GetService <IDocumentTypeAliasProvider>();

            MailTemplateXpath = XPathHelper.GetXpath(
                docTypeAliasProvider.GetDataFolder(),
                docTypeAliasProvider.GetMailTemplateFolder(),
                docTypeAliasProvider.GetMailTemplate());
        }
Esempio n. 6
0
        private int?GetEmailTemplatePublishedContentId(NotificationTypeEnum mailTemplateTypeEnum)
        {
            var    docTypeAliasProvider = HttpContext.Current.GetService <IDocumentTypeAliasProvider>();
            string mailTemplateXpath    = XPathHelper.GetXpath(docTypeAliasProvider.GetDataFolder(), docTypeAliasProvider.GetMailTemplateFolder(), docTypeAliasProvider.GetMailTemplate());
            var    mailTemplates        = _umbracoHelper.TypedContentAtXPath(mailTemplateXpath);
            var    mailTemplateContent  = mailTemplates?.FirstOrDefault(template => template.GetPropertyValue <NotificationTypeEnum>(MailTemplatePropertiesConstants.EmailType) == mailTemplateTypeEnum);

            return(mailTemplateContent?.Id);
        }
Esempio n. 7
0
        private static IPublishedContent GetErrorPage()
        {
            var homePage = AliasProvider.GetHomePage();

            var errorPage = AliasProvider.GetErrorPage();

            var xpath = XPathHelper.GetXpath(homePage, errorPage);

            return(UmbracoHelper.TypedContentSingleAtXPath(xpath));
        }
        private void CreateHomeBulletinsPages()
        {
            var homePageXpath = XPathHelper.GetXpath(DocumentTypeAliasConstants.HomePage);

            CreateBulletinsOverviewPage(homePageXpath, "bulletinsOverviewPageGrid.json");
            var homeBulletinsOverviewPageXpath = XPathHelper.GetXpath(DocumentTypeAliasConstants.HomePage, DocumentTypeAliasConstants.BulletinsOverviewPage);

            CreateBulletinsEditPage(homeBulletinsOverviewPageXpath, "bulletinsEditPageGrid.json");
            CreateBulletinsDetailsPage(homeBulletinsOverviewPageXpath, "bulletinsDetailsPageGrid.json");
        }
        private void CreateHomeEventsPages()
        {
            var homePageXpath = XPathHelper.GetXpath(DocumentTypeAliasConstants.HomePage);

            CreateEventsOverviewPage(homePageXpath, "eventsOverviewPageGrid.json");
            var homeEventsOverviewPageXpath = XPathHelper.GetXpath(DocumentTypeAliasConstants.HomePage, DocumentTypeAliasConstants.EventsOverviewPage);

            CreateEventsCreatePage(homeEventsOverviewPageXpath, "eventsCreatePageGrid.json");
            CreateEventsEditPage(homeEventsOverviewPageXpath, "eventsEditPageGrid.json");
            CreateEventsDetailsPage(homeEventsOverviewPageXpath, "eventsDetailsPageGrid.json");
        }
        private void CreatePage()
        {
            var groupsOverviewPage = _umbracoHelper.TypedContentSingleAtXPath(XPathHelper.GetXpath(DocumentTypeAliasConstants.HomePage, DocumentTypeAliasConstants.GroupsOverviewPage));

            var content = _contentService.CreateContent("My Groups", groupsOverviewPage.Id, DocumentTypeAliasConstants.GroupsMyGroupsOverviewPage);

            content.SetValue(NavigationPropertiesConstants.NavigationNamePropName, "My Groups");
            content.SetValue(NavigationPropertiesConstants.IsHideFromLeftNavigationPropName, false);
            content.SetValue(NavigationPropertiesConstants.IsHideFromSubNavigationPropName, false);

            _contentMigration.SetGridValueAndSaveAndPublishContent(content, "groupsMyGroupsOverviewPageGrid.json");
        }
        private void CreateGroupsNewsPages()
        {
            var groupsPageXpath = XPathHelper.GetXpath(DocumentTypeAliasConstants.HomePage, DocumentTypeAliasConstants.GroupsOverviewPage, DocumentTypeAliasConstants.GroupsRoomPage);

            CreateNewsOverviewPage(groupsPageXpath, "groupsNewsOverviewPageGrid.json");
            var groupsNewsOverviewPageXpath = XPathHelper.GetXpath(DocumentTypeAliasConstants.HomePage, DocumentTypeAliasConstants.GroupsOverviewPage,
                                                                   DocumentTypeAliasConstants.GroupsRoomPage, DocumentTypeAliasConstants.NewsOverviewPage);

            CreateNewsCreatePage(groupsNewsOverviewPageXpath, "groupsNewsCreatePageGrid.json");
            CreateNewsEditPage(groupsNewsOverviewPageXpath, "groupsNewsEditPageGrid.json");
            CreateNewsDetailsPage(groupsNewsOverviewPageXpath, "groupsNewsDetailsPageGrid.json");
        }
Esempio n. 12
0
        private void ResortGroupTabs()
        {
            var groupsRoomPage = _umbracoHelper.TypedContentSingleAtXPath(XPathHelper.GetXpath(DocumentTypeAliasConstants.HomePage,
                                                                                               DocumentTypeAliasConstants.GroupsOverviewPage, DocumentTypeAliasConstants.GroupsRoomPage));

            var sortedContentIds = groupsRoomPage.Children
                                   .Select(c => (
                                               rank: c.DocumentTypeAlias == DocumentTypeAliasConstants.GroupsDocumentsPage,
                                               contentId: _contentService.GetById(c.Id)))
                                   .OrderByDescending(ordered => ordered.rank)
                                   .Select(ordered => ordered.contentId);

            _contentService.Sort(sortedContentIds);
        }
Esempio n. 13
0
        private static void TransferRequestToErrorPage(ActionExecutingContext filterContext)
        {
            var umbracoHelper = DependencyResolver.Current.GetService <UmbracoHelper>();
            var aliasProvider = DependencyResolver.Current.GetService <IDocumentTypeAliasProvider>();

            var errorPage = umbracoHelper.TypedContentSingleAtXPath(XPathHelper.GetXpath(aliasProvider.GetHomePage(), aliasProvider.GetErrorPage()));

            if (errorPage != null)
            {
                filterContext.Controller.ControllerContext.HttpContext.Server.TransferRequest(errorPage.Url);
                return;
            }

            filterContext.Result = new HttpNotFoundResult();
        }
Esempio n. 14
0
        private static void TransferRequestToErrorPage()
        {
            var umbracoHelper = DependencyResolver.Current.GetService <UmbracoHelper>();
            var aliasProvider = DependencyResolver.Current.GetService <IDocumentTypeAliasProvider>();

            var errorPage = umbracoHelper
                            .TypedContentSingleAtXPath(XPathHelper.GetXpath(
                                                           aliasProvider.GetHomePage(),
                                                           aliasProvider.GetErrorPage()));

            if (errorPage != null)
            {
                HttpContext.Current.Server.TransferRequest(errorPage.Url);
            }
        }
        private void CreateGroupsDeactivatedGroupPage()
        {
            var newsOverviewPage = _umbracoHelper.TypedContentSingleAtXPath(XPathHelper.GetXpath(DocumentTypeAliasConstants.HomePage, DocumentTypeAliasConstants.GroupsOverviewPage, DocumentTypeAliasConstants.GroupsRoomPage));

            if (newsOverviewPage.Children.Any(el => el.DocumentTypeAlias.Equals(DocumentTypeAliasConstants.GroupsDeactivatedGroupPage)))
            {
                return;
            }

            var content = _contentService.CreateContent("Disabled", newsOverviewPage.Id, DocumentTypeAliasConstants.GroupsDeactivatedGroupPage);

            content.SetValue(NavigationPropertiesConstants.NavigationNamePropName, "Disabled");
            content.SetValue(NavigationPropertiesConstants.IsHideFromLeftNavigationPropName, true);
            content.SetValue(NavigationPropertiesConstants.IsHideFromSubNavigationPropName, false);

            SetGridValueAndSaveAndPublishContent(content, "groupsDeactivatedGroupPageGrid.json");
        }
        public void UpdateActivitiesGrids()
        {
            UpdateGrid(XPathHelper.GetXpath(DocumentTypeAliasConstants.HomePage), "homePageGrid.json");
            UpdateGrid(XPathHelper.GetXpath(DocumentTypeAliasConstants.HomePage, DocumentTypeAliasConstants.NewsOverviewPage), "newsOverviewPageGrid.json");
            UpdateGrid(XPathHelper.GetXpath(DocumentTypeAliasConstants.HomePage, DocumentTypeAliasConstants.NewsOverviewPage, DocumentTypeAliasConstants.NewsCreatePage), "newsCreatePageGrid.json");
            UpdateGrid(XPathHelper.GetXpath(DocumentTypeAliasConstants.HomePage, DocumentTypeAliasConstants.NewsOverviewPage, DocumentTypeAliasConstants.NewsEditPage), "newsEditPageGrid.json");
            UpdateGrid(XPathHelper.GetXpath(DocumentTypeAliasConstants.HomePage, DocumentTypeAliasConstants.NewsOverviewPage, DocumentTypeAliasConstants.NewsDetailsPage), "newsDetailsPageGrid.json");

            UpdateGrid(XPathHelper.GetXpath(DocumentTypeAliasConstants.HomePage, DocumentTypeAliasConstants.EventsOverviewPage), "eventsOverviewPageGrid.json");
            UpdateGrid(XPathHelper.GetXpath(DocumentTypeAliasConstants.HomePage, DocumentTypeAliasConstants.EventsOverviewPage, DocumentTypeAliasConstants.EventsCreatePage), "eventsCreatePageGrid.json");
            UpdateGrid(XPathHelper.GetXpath(DocumentTypeAliasConstants.HomePage, DocumentTypeAliasConstants.EventsOverviewPage, DocumentTypeAliasConstants.EventsEditPage), "eventsEditPageGrid.json");
            UpdateGrid(XPathHelper.GetXpath(DocumentTypeAliasConstants.HomePage, DocumentTypeAliasConstants.EventsOverviewPage, DocumentTypeAliasConstants.EventsDetailsPage), "eventsDetailsPageGrid.json");

            UpdateGrid(XPathHelper.GetXpath(DocumentTypeAliasConstants.HomePage, DocumentTypeAliasConstants.BulletinsOverviewPage), "bulletinsOverviewPageGrid.json");
            UpdateGrid(XPathHelper.GetXpath(DocumentTypeAliasConstants.HomePage, DocumentTypeAliasConstants.BulletinsOverviewPage, DocumentTypeAliasConstants.BulletinsEditPage), "bulletinsEditPageGrid.json");
            UpdateGrid(XPathHelper.GetXpath(DocumentTypeAliasConstants.HomePage, DocumentTypeAliasConstants.BulletinsOverviewPage, DocumentTypeAliasConstants.BulletinsDetailsPage), "bulletinsDetailsPageGrid.json");
        }
Esempio n. 17
0
        public override ActionResult LeftNavigation()
        {
            var groupPageXpath = XPathHelper.GetXpath(_documentTypeAliasProvider.GetHomePage(), _documentTypeAliasProvider.GetGroupOverviewPage());
            var groupPage      = _umbracoHelper.TypedContentSingleAtXPath(groupPageXpath);

            var isPageActive = GetIsPageActiveFunc(_umbracoHelper.AssignedContentItem);

            var menuItems = GetMenuItems(groupPage);

            var result = new GroupLeftNavigationMenuViewModel
            {
                Items = menuItems,
                GroupOverviewPageUrl = groupPage.Url,
                IsActive             = isPageActive(groupPage)
            };

            return(PartialView(LeftNavigationPath, result));
        }
        private void CreateEventMailTemplate()
        {
            var mailTemplatesFolder = _umbracoHelper.TypedContentSingleAtXPath(XPathHelper.GetXpath(DocumentTypeAliasConstants.DataFolder, DocumentTypeAliasConstants.MailTemplatesFolder));

            if (mailTemplatesFolder.Children.Any(el => el.GetPropertyValue <LegacyNotificationTypes>(UmbracoContentMigrationConstants.MailTemplate.EmailTypePropName) == LegacyNotificationTypes.Event))
            {
                return;
            }

            var content = _contentService.CreateContentWithIdentity("Event", mailTemplatesFolder.Id, DocumentTypeAliasConstants.MailTemplate);

            content.SetValue(UmbracoContentMigrationConstants.MailTemplate.SubjectPropName, "Event");
            content.SetValue(UmbracoContentMigrationConstants.MailTemplate.BodyPropName, "<p>Event</p><p>FullName: ##FullName##</p>");
            content.SetValue(UmbracoContentMigrationConstants.MailTemplate.ExtraTokensPropName, "##FullName##");
            content.SetValue(UmbracoContentMigrationConstants.MailTemplate.EmailTypePropName, LegacyNotificationTypes.Event.ToString());

            _contentService.SaveAndPublishWithStatus(content);
        }
Esempio n. 19
0
        private void CreateGroupsDocumentsPageContent()
        {
            var groupsRoomPage = _umbracoHelper.TypedContentSingleAtXPath(XPathHelper.GetXpath(DocumentTypeAliasConstants.HomePage, DocumentTypeAliasConstants.GroupsOverviewPage, DocumentTypeAliasConstants.GroupsRoomPage));

            if (groupsRoomPage.Children.Any(el => el.DocumentTypeAlias.Equals(DocumentTypeAliasConstants.GroupsDocumentsPage)))
            {
                return;
            }

            var content = _contentService.CreateContent("Group Documents", groupsRoomPage.Id, DocumentTypeAliasConstants.GroupsDocumentsPage);

            content.SetValue(NavigationPropertiesConstants.NavigationNamePropName, "Group Documents");
            content.SetValue(NavigationPropertiesConstants.IsHideFromLeftNavigationPropName, true);
            content.SetValue(NavigationPropertiesConstants.IsHideFromSubNavigationPropName, false);

            var gridContent = EmbeddedResourcesUtils.ReadResourceContent($"{Assembly.GetExecutingAssembly().GetName().Name}.Core.Updater.Migrations._0._0._0._1.PreValues.ContentPageJsons.groupsDocumentsPageGrid.json");

            content.SetValue(UmbracoContentMigrationConstants.Grid.GridPropName, gridContent);

            _contentService.SaveAndPublishWithStatus(content);
        }
        private void CreateCommentRepliedMailTemplate()
        {
            var mailTemplatesFolder = _umbracoHelper.TypedContentSingleAtXPath(XPathHelper.GetXpath(DocumentTypeAliasConstants.DataFolder, DocumentTypeAliasConstants.MailTemplatesFolder));

            if (mailTemplatesFolder.Children.Any(el => el.GetPropertyValue <NotificationTypeEnum>(UmbracoContentMigrationConstants.MailTemplate.EmailTypePropName) == NotificationTypeEnum.CommentReplied))
            {
                return;
            }

            var content = _contentService.CreateContentWithIdentity("CommentReplied", mailTemplatesFolder.Id, DocumentTypeAliasConstants.MailTemplate);

            content.SetValue(UmbracoContentMigrationConstants.MailTemplate.SubjectPropName, "CommentReplied");
            content.SetValue(UmbracoContentMigrationConstants.MailTemplate.BodyPropName, @"<p>CommentReplyed</p>
<p>FullName: ##FullName##</p>
<p> </p>
<p>ActivityTitle: ##ActivityTitle##</p>
<p><span>Url: </span><a rel=""noopener noreferrer"" href=""##Url##"" target=""_blank"">link</a></p>");
            content.SetValue(UmbracoContentMigrationConstants.MailTemplate.ExtraTokensPropName, "##ActivityTitle##, ##Url##, ##FullName##");
            content.SetValue(UmbracoContentMigrationConstants.MailTemplate.EmailTypePropName, NotificationTypeEnum.CommentReplied.ToString());

            _contentService.SaveAndPublishWithStatus(content);
        }
        public ExecutionResult Execute()
        {
            var mailTemplateXpath = XPathHelper.GetXpath(
                _documentTypeAliasProvider.GetDataFolder(),
                _documentTypeAliasProvider.GetMailTemplateFolder(),
                _documentTypeAliasProvider.GetMailTemplate());

            var templates = _umbracoHelper.TypedContentAtXPath(mailTemplateXpath);

            var mailTemplateFolderXpath = XPathHelper.GetXpath(_documentTypeAliasProvider.GetDataFolder(), _documentTypeAliasProvider.GetMailTemplateFolder());

            if (!templates.Any())
            {
                var folder = _umbracoHelper.TypedContentSingleAtXPath(mailTemplateFolderXpath);
                if (folder != null)
                {
                    var folderContent = _contentService.GetById(folder.Id);
                    _contentService.Delete(folderContent);
                }
            }

            return(ExecutionResult.Success);
        }
Esempio n. 22
0
 private string GetPageUrl(IEnumerable <string> xPath)
 {
     return(_umbracoHelper.TypedContentSingleAtXPath(XPathHelper.GetXpath(xPath.Where(x => x != null)))?.Url);
 }
Esempio n. 23
0
 public IPublishedContent GetSearchPage()
 {
     return(_umbracoHelper.TypedContentSingleAtXPath(XPathHelper.GetXpath(_documentTypeAliasProvider.GetHomePage(), _documentTypeAliasProvider.GetSearchResultPage())));
 }