private void LoadAvailableWebsitePagesFromReports() { foreach (var reportModel in ManageViewModel.AllAvailableReports) { foreach (var rPage in reportModel.Report.WebsitePages) { //var aWebsitePageModel = ManageViewModel.AllAvailableWebsitePages.FirstOrDefault(wpm => wpm.WebsitePageName == rPage.Name); var aWebsitePageModel = ManageViewModel.AllAvailableWebsitePages.FirstOrDefault(wpm => { if (wpm.PageType == WebsitePageTypeEnum.Static) { return(wpm.WebsitePageName == rPage.Name); } else if (wpm.PageType == WebsitePageTypeEnum.Report) { return(wpm.ReportName == reportModel.Report.Name); // rPage.Report.Name; // For whatever reason, this link is broken. I.e. the ReportPage does not have a link back up to the Report. } else { return(false); } }); if (aWebsitePageModel == null) { aWebsitePageModel = new WebsitePageModel(); ManageViewModel.AllAvailableWebsitePages.Add(aWebsitePageModel); } aWebsitePageModel.WebsitePages.AddIfUnique( new WebsitePage( WebsitePageTypeEnum.Report, rPage.Name, reportModel.Name, rPage.Audience, rPage.Path, rPage.Path, rPage.Url, rPage.IsEditable), (wp, rwp) => wp.Audience == rwp.Audience); var aWebsitePage = aWebsitePageModel.WebsitePages.FirstOrDefault(wp => wp.Audience == rPage.Audience); foreach (var rZone in rPage.WebsitePageZones) { var aZone = aWebsitePage.Zones.FirstOrDefault(z => z.Name == rZone.Name); if (aZone == null) { aZone = new WebsitePageZone( WebsitePageZoneTypeEnum.Zone, rZone.Name, rZone.CodePath, rPage.Audience); aWebsitePage.Zones.Add(aZone); } } } } }
public void OnPreviewWebsitePage(WebsitePageModel activeWebsitePageModel) { if (activeWebsitePageModel == null) { return; } if (activeWebsitePageModel.WebsitePages == null) { return; } if (activeWebsitePageModel.WebsitePages.Count == 0) { return; } //if (activeWebsitePageModel.WebsitePages[0].ReportName.IsNullOrEmpty()) return; ActivePreviewWebsitePageModel = activeWebsitePageModel; SelectedPreviewWebsitePage = ActivePreviewWebsitePageModel.WebsitePages[0]; PreviewSettingsProxy.ResetSettings(); if (ActivePreviewWebsitePageModel.WebsitePages.Count > 1 || true) { RaisePropertyChanged(() => SelectedPreviewWebsitePage); IsPreviewDemoSettingsOpen = true; } else { InternalPreviewWebsitePage(activeWebsitePageModel.WebsitePages[0]); } }
public void DeleteModifiedWebsitePage(WebsitePageModel activeWebsitePageModel) { // Confirmation of deletion. //var warningMessage = string.Format("All custom changes for Website Page \"{0}\" will be lost. Are you sure you want to proceed?", activeWebsitePageModel.WebsitePageName); var warningMessage = string.Format("All modifications will be lost. Are you sure you want to proceed?", activeWebsitePageModel.WebsitePageName); var result = MessageBox.Show(warningMessage, "Custom WebsitePage Deletion Confirmation", MessageBoxButton.YesNo); if (result == MessageBoxResult.No || result == MessageBoxResult.Cancel || result == MessageBoxResult.None) { return; } // Perform Deletion. activeWebsitePageModel.WebsitePages.ForEach(wp => { CurrentWebsite.WebsitePages.Remove(wp); CurrentWebsite.WebsitePages.RemoveAll(cwp => cwp.Name == wp.Name); wp.Id = default(int); wp.Zones.ForEach(z => { z.Id = default(int); z.Contents = ""; }); }); activeWebsitePageModel.IsModified = false; WebsitePageModelsView.Refresh(); }
private void LoadAvailableWebsitePagesFromBaseData() { var baseWebsitePages = WebsiteDataService.GetBaseDataWebsitePages(BDWebsitePageQueryExpression); var baseWebsitePageZones = WebsiteDataService.GetBaseDataWebsitePageZones(_ => true); foreach (var bWebsitePage in baseWebsitePages) { // Find the baseWebsitePage's WebsitePage in AvailableWebsitePages; if cannot find, add it to the AvailableWebsitePages list. var aWebsitePageModel = ManageViewModel.AllAvailableWebsitePages.FirstOrDefault(wpm => wpm.WebsitePageName == bWebsitePage.Name); if (aWebsitePageModel == null) { aWebsitePageModel = new WebsitePageModel(new WebsitePage(bWebsitePage), false); ManageViewModel.AllAvailableWebsitePages.Add(aWebsitePageModel); } else { aWebsitePageModel.WebsitePages.AddIfUnique(new WebsitePage(bWebsitePage), (a, b) => a.Audience == b.Audience); } // Find the WebsitePage and BaseWebsitePageZones (using Name[from above] and Audience[below]) var aWebsitePage = aWebsitePageModel.WebsitePages.First(wp => wp.Audience == bWebsitePage.Audience); var bZones = baseWebsitePageZones.Where(bZone => bZone.WebsitePageName == aWebsitePage.Name && bZone.Audience == aWebsitePage.Audience); // Add BaseZones to their respective WebsitePage in AllAvailableWebsitePages. foreach (var bZone in bZones) { var aZone = aWebsitePage.Zones.FirstOrDefault(z => z.Name == bZone.Name); if (aZone == null) { aZone = new WebsitePageZone(bZone); aWebsitePage.Zones.Add(aZone); } } } }
private bool DoAudienceFilter(WebsitePageModel model) { switch (SelectedAudienceFilter) { case WebsitePageModelAudienceFilterValues.ALL_AUDIENCES: return(true); case WebsitePageModelAudienceFilterValues.CONSUMER_ONLY: return(model.Audiences.Contains(Infrastructure.Entities.Domain.Reports.Audience.Consumers)); case WebsitePageModelAudienceFilterValues.PROFESSIONAL_ONLY: return(model.Audiences.Contains(Infrastructure.Entities.Domain.Reports.Audience.Professionals)); } ; return(true); }
private bool DoPageTypeFilter(WebsitePageModel model) { switch (SelectedPageTypeFilter) { case WebsitePageModelPageTypeFilterValues.ALL_PAGES: return(true); case WebsitePageModelPageTypeFilterValues.STATIC_PAGES: return(model.WebsitePages[0].PageType == WebsitePageTypeEnum.Static); case WebsitePageModelPageTypeFilterValues.REPORT_PAGES: return(model.WebsitePages[0].PageType == WebsitePageTypeEnum.Report); } ; return(true); }
public void EditContent(WebsitePageModel activeWebsitePageModel) { switch (activeWebsitePageModel.PageType) { case WebsitePageTypeEnum.Static: ParentModel.WebsitePagesEditStaticViewModel.ActiveWebsitePageModel = activeWebsitePageModel; ParentModel.WebsitePageState = WebsitePageStateEnum.EditStatic; LoadWebsitePageDataFromTemplateFiles(activeWebsitePageModel); break; case WebsitePageTypeEnum.Report: ParentModel.WebsitePagesEditReportViewModel.ActiveWebsitePageModel = activeWebsitePageModel; ParentModel.WebsitePageState = WebsitePageStateEnum.EditReport; LoadWebsitePageDataFromTemplateFiles(activeWebsitePageModel); break; } }
private bool DoPropertyFilter(WebsitePageModel model) { switch (SelectedPropertyFilter) { // case WebsitePageModelPropertyFilterValues.NONE: // return true; case WebsitePageModelPropertyFilterValues.PAGE_NAME: if (string.IsNullOrEmpty(PropertyFilterInputText)) { return(true); } else { return(model.WebsitePages[0].Name.ToLower().Contains(PropertyFilterInputText.ToLower())); } } ; return(true); }
public void OnPreviewContent(WebsitePageModel activeWebsitePageModel) { if (activeWebsitePageModel == null) { return; } if (activeWebsitePageModel.WebsitePages == null) { return; } if (activeWebsitePageModel.WebsitePages.Count == 0) { return; } if (activeWebsitePageModel.WebsitePages[0].ReportName.IsNullOrEmpty()) { return; } PreviewReport = ManageViewModel.AllAvailableReports.SingleOrDefault(r => r.Name == activeWebsitePageModel.WebsitePages[0].ReportName); IsPreviewOpen = true; }
private void LoadWebsitePageDataFromTemplateFiles(WebsitePageModel websitePageModel) { if (websitePageModel.IsModified) { return; } websitePageModel.WebsitePages.ForEach(websitePage => { websitePage.Zones.ForEach(zone => { if (!zone.Contents.IsNullOrEmpty()) { return; } switch (zone.ZoneType) { case WebsitePageZoneTypeEnum.Page: var baseDirectoryPath = AppDomain.CurrentDomain.BaseDirectory; var templateDirectoryPath = Path.Combine(baseDirectoryPath, "resources\\templates\\site\\"); var filePath = Path.Combine(templateDirectoryPath, websitePage.TemplateRelativePath); // var filePath = Path.Combine(CurrentWebsite.OutPutDirectory, websitePage.TemplateRelativePath); if (!File.Exists(filePath)) { return; } zone.Contents = File.ReadAllText(filePath); break; case WebsitePageZoneTypeEnum.Zone: //throw new NotImplementedException("Not currently possible."); break; } }); }); }
private void ComputeWebsitePageList() { if (CurrentWebsite == null) { return; } // Start with the loaded 'modified' WebsitePages. // - Care has to be taken that: // A) (for Static Pages,) Pages with the same name get added to the same WebsitePageModel. or // B) (for Report Pages,) Pages with the same Report get added to the same WebsitePageModel // - ^^ (A) happens because in DB, pages are considered unique per Audience. // - ^^ (B) happens because we currently allow Headers/Footers, to be edited at the Report (per Audience) level. WebsitePageModels.Clear(); CurrentWebsite.WebsitePages.ForEach(wp => { //var model = WebsitePageModels.FirstOrDefault(wpm => wpm.WebsitePageName == wp.Name); var model = WebsitePageModels.FirstOrDefault(wpm => { if (wpm.PageType == WebsitePageTypeEnum.Static) { return(wpm.WebsitePageName == wp.Name); } else if (wpm.PageType == WebsitePageTypeEnum.Report) { return(wpm.ReportName == wp.ReportName); } else { return(false); } }); if (model == null) { model = new WebsitePageModel(); WebsitePageModels.Add(model); } model.WebsitePages.Add(new WebsitePage(wp)); model.IsModified = true; }); // Insert any missing/unmodified WebsitePages from Available List (BaseData). foreach (var aWebsitePageModel in ManageViewModel.AllAvailableWebsitePages) { //var oWebsitePageModel = WebsitePageModels.FirstOrDefault(wpm => wpm.WebsitePageName == aWebsitePageModel.WebsitePageName); var oWebsitePageModel = WebsitePageModels.FirstOrDefault(wpm => { if (wpm.PageType == WebsitePageTypeEnum.Static) { return(wpm.WebsitePageName == aWebsitePageModel.WebsitePageName); } else if (wpm.PageType == WebsitePageTypeEnum.Report) { return(wpm.ReportName == aWebsitePageModel.ReportName); } else { return(false); } }); if (oWebsitePageModel == null) { oWebsitePageModel = new WebsitePageModel(aWebsitePageModel); WebsitePageModels.Add(oWebsitePageModel); continue; // We're adding the entire PageModel from BaseData, thus we have all the Pages(by audience) and their zones also. } foreach (var aPage in aWebsitePageModel.WebsitePages) { var oWebsitePage = oWebsitePageModel.WebsitePages.FirstOrDefault(wp => wp.Audience == aPage.Audience && wp.Name == aPage.Name); if (oWebsitePage == null) { oWebsitePage = new WebsitePage(aPage); oWebsitePageModel.WebsitePages.Add(oWebsitePage); } foreach (var aZone in aPage.Zones) { var oZone = oWebsitePage.Zones.FirstOrDefault(c => c.Name == aZone.Name); if (oZone == null) { oZone = new WebsitePageZone(aZone); oWebsitePage.Zones.Add(oZone); } } } } // Filter out: // Any Pages that are not associated with one of this websites selected Audiences. // Any (Report) Pages that are not associated with one of the websites selected Reports. // Any Model that does not have at least one Editable Page. WebsitePageModels = WebsitePageModels.Where(wpm => { return (CurrentWebsite.Audiences.ContainsAny(wpm.Audiences) && (wpm.WebsitePages[0].PageType == WebsitePageTypeEnum.Static || wpm.WebsitePages[0].PageType == WebsitePageTypeEnum.Report && CurrentWebsite.Reports.Any(r => { // We are forced to check Report.Datasets here because CurrentWebsite.Reports are not kept up to date; // particularly on Dataset delete. return wpm.WebsitePages[0].ReportName == r.Report.Name && CurrentWebsite.Datasets.AnyIn(r.Report.Datasets, (cwd, rd) => cwd.Dataset.ContentType.Name == rd); }) ) && wpm.WebsitePages.Any(wp => wp.IsEditable)); //return // CurrentWebsite.Audiences.Any(a => wpm.WebsitePage.Audiences.Contains(a)) && // CurrentWebsite.Reports.Any(r => // { // return // wpm.WebsitePage.PageType == WebsitePageTypeEnum.Static || // wpm.WebsitePage.ReportName == r.Report.Name; // }); }).ToList(); InitializeWebsitePageView(); }