public ActionResult Edit(Guid?guid) { var vm = new EditWebhookViewModel(); vm.Webhook = (guid == null) ? new WebhookPostModel() : new WebhookPostModel(_repo.GetWebhook(guid.Value)); if (vm.Webhook.ParentId > 0) { var parentRef = new ContentReference(vm.Webhook.ParentId); if (!ContentReference.IsNullOrEmpty(parentRef)) { var parentContent = _contentLoader.Get <IContent>(parentRef); if (parentContent != null) { vm.CurrentContentName = parentContent.Name; vm.CurrentContentAncestors = _contentLoader.GetAncestors(parentRef).Select(x => x.ContentLink.ID).ToList(); } } } vm.ContentTypes = _typeRepo.List().Select(x => new SelectListItem { Text = x.DisplayName ?? x.Name, Value = x.ID.ToString() }).ToList(); vm.EventTypes = new List <SelectListItem>(); foreach (var eventType in _repo.GetEventTypes()) { vm.EventTypes.Add(new SelectListItem { Value = eventType.Key, Text = _localizationService.GetString("/Webhooks/EventTypes/" + eventType.Key, eventType.Key) }); } return(View(vm)); }
public ActionResult Index() { var contentTypes = _contentTypeRepository.List() .Select(CreateContentTypeModel) .OrderBy(contentType => contentType.Name) .ToList(); var model = new OverviewModel { PageTypes = contentTypes .Where(x => x.Category == ContentTypeModel.ContentTypeCategory.Page) .ToList(), BlockTypes = contentTypes .Where(x => x.Category == ContentTypeModel.ContentTypeCategory.Block) .ToList(), MediaTypes = contentTypes .Where(x => x.Category == ContentTypeModel.ContentTypeCategory.Media) .ToList(), OtherTypes = contentTypes .Where(x => new[] { ContentTypeModel.ContentTypeCategory.Page, ContentTypeModel.ContentTypeCategory.Block, ContentTypeModel.ContentTypeCategory.Media }.Contains(x.Category) == false) .ToList(), EditUrls = contentTypes.ToDictionary(x => x.Id, CreateEditContentTypeUrl) }; return(View(string.Empty, model)); }
public static IEnumerable <ContentType> GetAvailableEpiContentTypes(IContentTypeRepository contentTypeRepository) { return(contentTypeRepository .List() .Where(x => x.ModelType != null && !GraphTypeFilter.ShouldFilter(x.ModelType) )); }
/// <summary> /// Lists all content types available in the site base on group name (AdministrationSetttings group) /// </summary> /// <returns></returns> public static IEnumerable <ContentType> ListAllContentTypes() { // Only list the types with specified group name var contentTypes = _contentTypeRepo.List().Where((t) => { var settings = _settingsService.GetAttribute(t); return(settings.Visible); }).OrderByDescending(p => _settingsService.GetAttribute(p).GroupName); return(contentTypes); }
/// <summary> /// Lists all content types available in the site base on group name (AdministrationSetttings group) /// </summary> /// <returns></returns> public static IEnumerable <ContentType> ListAllContentTypes(string groupName) { // Only list the types with specified group name var contentTypes = _contentTypeRepo.List().Where((t) => { var settings = _settingsService.GetAttribute(t); return(settings.Visible && string.Equals(settings.GroupName.ToLower(), groupName, StringComparison.OrdinalIgnoreCase)); }).OrderByDescending(p => _settingsService.GetAttribute(p).GroupName); return(contentTypes); }
private TableCell CreateBlockTypeCell( string controlId, ContentType selectedPageType, ContentType disabledPageType) { TableCell tableCell = new TableCell(); DropDownList dropDownList = new DropDownList(); dropDownList.ID = controlId; dropDownList.DataSource = _contentTypeRepository.List().OfType <BlockType>(); dropDownList.AutoPostBack = true; dropDownList.DataTextField = "LocalizedName"; dropDownList.DataValueField = nameof(ID); dropDownList.SelectedIndexChanged += BlockTypeChanged; if (controlId == ToBlockTypeId) { _ddlTo = dropDownList; } tableCell.Style.Add("border-bottom", "none"); tableCell.Controls.Add(dropDownList); tableCell.DataBind(); int id; if (disabledPageType != null) { ListItemCollection items = dropDownList.Items; id = disabledPageType.ID; string str = id.ToString(); ListItem byValue = items.FindByValue(str); if (byValue != null) { dropDownList.Items.Remove(byValue); } } if (!(selectedPageType != null)) { return(tableCell); } ListItemCollection items1 = dropDownList.Items; id = selectedPageType.ID; string str1 = id.ToString(); ListItem byValue1 = items1.FindByValue(str1); if (byValue1 == null) { return(tableCell); } byValue1.Selected = true; return(tableCell); }
public string Execute(params string[] parameters) { int cnt = 0; foreach (var r in _trepo.List()) { OnCommandOutput?.Invoke(this, r); cnt++; } return($"Done, listing {cnt} content types"); }
/// <summary> /// Returns a list of content types where "content type is T" /// </summary> /// <typeparam name="T"></typeparam> /// <returns></returns> public List <ContentTypeAudit> GetContentTypesOfType <T>() { return(_contentTypeRepository.List() .Where(ct => ct is T) .Select(ct => new ContentTypeAudit { ContentTypeId = ct.ID, Name = string.IsNullOrEmpty(ct.DisplayName) ? ct.Name : ct.DisplayName, Usages = new List <ContentTypeAudit.ContentItem>() }) .ToList()); }
public ActionResult GetContentTypes(string type) { var contentTypes = _contentTypeRepository.List().Where(o => o.Name != "SysRoot" && o.Name != "SysRecycleBin" && IsValidType(type, o.ModelType)) .Select(o => new { o.ID, o.GUID, o.Name, o.DisplayName, }) .OrderBy(o => o.Name); return(new ContentResult { Content = JsonConvert.SerializeObject(contentTypes), ContentType = "application/json", }); }
public ActionResult Index() { BoostingViewModel model = new BoostingViewModel(); var pageTypes = _pageTypeRepository.List() .Where(p => p.ModelType != null) .OrderBy(p => p.LocalizedName); foreach (var type in pageTypes) { var currentBoosting = _boostingRepository.GetByType(type.ModelType); var indexableProps = type.ModelType .GetIndexableProps(false) .Select(p => p.Name); var propsWithBoost = type.PropertyDefinitions .Where(p => indexableProps.Contains(p.Name)) .OrderBy(p => p.Tab.Name) .ThenBy(p => p.TranslateDisplayName()) .Select(p => new BoostItem { TypeName = p.Name, DisplayName = p.TranslateDisplayName(), GroupName = p.Tab.Name, Weight = 1 }) .ToList(); foreach (var boost in currentBoosting) { if (propsWithBoost.Any(p => p.TypeName == boost.Key)) { propsWithBoost.First(p => p.TypeName == boost.Key).Weight = boost.Value; } } if (propsWithBoost.Count > 0) { model.BoostingByType.Add(type.ModelType.GetTypeName(), propsWithBoost); } } return(View("~/Views/ElasticSearchAdmin/Boosting/Index.cshtml", model)); }
// GET: PublishHome public ActionResult Index() { var formContainerBlockType = typeof(FormContainerBlock); var formContentTypes = _contentTypeRepository.List().Where(x => x.ModelType != null && (x.ModelType.IsSubclassOf(formContainerBlockType) || x.ModelType == formContainerBlockType)).ToList(); Dictionary <string, string> contentTypeDictionary = new Dictionary <string, string>(); foreach (var contentType in formContentTypes) { contentTypeDictionary.Add(contentType.GUID.ToString(), string.IsNullOrEmpty(contentType.DisplayName) ? contentType.Name.Trim() : contentType.DisplayName.Trim()); } var viewModel = new EpiFormTypeViewModel { SiteHomePages = ConsolidateContentController.GetSiteHomePageDefinitions(), ContentTypeDictionary = contentTypeDictionary }; return(View(viewModel)); }
public SingleTranslationsViewModel[] ModelsForAllTranslations() { var models = new List <SingleTranslationsViewModel>(); var typeNames = _contentTypeRepository.List().Select(t => t.Name).ToArray(); foreach (var name in typeNames) { var translations = _translationRepository.TranslationsFor(name, ignoreLanguage: false).ToArray(); if (!translations.Any()) { continue; } var innerModel = new SingleTranslationsViewModel { ContentTypeName = name, Translations = translations }; models.Add(innerModel); } models.Add(GlobalTranslationsModel()); return(models.ToArray()); }
public IEnumerable <ContentType> GetMediaTypes() { var contentTypeList = _contentTypeRepository.List(); var allContentTypes = contentTypeList as IList <ContentType> ?? contentTypeList; var mediaList = new List <ContentType>(); allContentTypes.ToList().ForEach(i => { try { if (i.ModelType.IsSubclassOf(typeof(MediaData))) { mediaList.Add(i); } } catch (Exception e) { Console.WriteLine(e); } }); return(mediaList); }
private void SetupExperimentEventTrackingProperty() { CreateOrDeleteTab(ExperimentEventsTabName, true); var allowMappingType = typeof(IExperimentTracking); foreach (var modelType in _contentTypeRepository.List()) { var contentType = _contentTypeRepository.Load(modelType.ID); if (contentType != null) { if (allowMappingType.IsAssignableFrom(contentType.ModelType)) { CreateUpdatePropertyDefinition(contentType, ExperimentEventsPropertyName, _localizationService.GetString("/episerver/experimentation/eventracking", "Events to track"), typeof(EPiServer.SpecializedProperties.PropertyContentArea), ExperimentEventsTabName, 10); } } } }
public override CheckResult PerformCheck() { //Check how many content types are there. If any of them are not used. If any are overlapping. var types = typeRepo.List().ToList(); int pagetypes = types.Where(tp => tp.Base.ToString() == "Page").Count(); int blocktypes = types.Where(tp => tp.Base.ToString() == "Block").Count(); var groups = types.GroupBy(tp => tp.Base.ToString()); var groupstring = string.Join(", ", groups.Select(grp => grp.Count().ToString() + " " + grp.Key).ToArray()); if (pagetypes > 50) { return(base.CreateCheckResult(HealthStatusType.BadPractice, $"You have more than {pagetypes} page types. That can make it hard to find the right one to use. Consider refactoring.")); } if (blocktypes > 80) { return(base.CreateCheckResult(HealthStatusType.BadPractice, $"You have more than {blocktypes} block types. That can make it hard to find the right one to use. Consider refactoring.")); } if (pagetypes < 2) { return(base.CreateCheckResult(HealthStatusType.BadPractice, $"You only have {pagetypes} page types. This could indicate a site with very unstructured content.")); } //Warnings if a page has more than X properties //Any types specified in database and not in code? int typesfromdb = types.Where(tp => tp.ModelType == null).Count(); //Types that are not used //Types that should inherit from each other? //Too many visible types to the editor? return(CreateCheckResult(statusText: $"{groupstring}.")); }
public override string Execute() { var contentTypes = contentTypeRepository.List(); var removedPropertyDefinitions = new List <Tuple <string, string> >(); foreach (var contentType in contentTypes) { var missingProperties = GetContentTypeMissingProperties(contentType); foreach (var missingProperty in missingProperties) { propertyDefinitionRepository.Delete(missingProperty); removedPropertyDefinitions.Add(Tuple.Create(contentType.Name, missingProperty.Name)); } } if (removedPropertyDefinitions.Any()) { return(FormatResultMessage(removedPropertyDefinitions)); } return("No property has been deleted, schema is up to date."); }
public override CheckResult PerformCheck() { //Check how many content types are there. If any of them are not used. If any are overlapping. var types = typeRepo.List().ToList(); var groups = types.GroupBy(tp => tp.Base.ToString()); var groupstring = string.Join(", ", groups.Select(grp => grp.Count().ToString() + " " + grp.Key).ToArray()); //Warnings if a page has more than X properties //Any types specified in database and not in code? int typesfromdb = types.Where(tp => tp.ModelType == null).Count(); var orphans = types.Where(tp => tp.ModelType != null).SelectMany(tp => tp.PropertyDefinitions).Where(pd => !pd.ExistsOnModel).ToList(); if (orphans.Count > 0) { string example = orphans.Select(o => o.Name + " on " + typeRepo.Load(o.ContentTypeID).Name).First(); return(CreateCheckResult(HealthStatusType.Fault, $"You have {orphans.Count} properties not defined in code on content types that are defined in code. For example {example}.")); } return(CreateCheckResult(statusText: $"{typesfromdb} types defined in database only (and not in code).")); }
public ContentTypeLoader(IContentTypeRepository contentTypeRepository) { _registredContentTypes = contentTypeRepository .List() .Where(contentType => contentType.ModelType != null); }
protected void BtnImportItem_OnClick(object sender, EventArgs e) { var importCounter = 0; var itemName = string.Empty; Client = new GcConnectClient(_credentialsStore.First().ApiKey, _credentialsStore.First().Email); // This is to make sure we only fetch mappings associated with this GcAccount. _mappingsStore = GcDynamicUtilities.RetrieveStore <GcDynamicTemplateMappings>(). FindAll(i => i.AccountId == _credentialsStore.First().AccountId); // Fetch the mapping for current template. var currentMapping = _mappingsStore.First(i => i.TemplateId == Session["TemplateId"].ToString()); // There is a duplicate value called 'Default' in the list of SaveActions. So, it needs to be removed. _saveActions.RemoveAt(1); // For all the items that were selected in the checkbox, foreach (var key in Request.Form) { // If the key is not of checkbox type, then continue. if (!key.ToString().Contains("chkImport")) { continue; } // Set the flag initially to 'true'. var importItemFlag = true; // The key consists of repeater Id in the first part. We only need the second part where 'chkImport' is present // and it is after '$'. So, we split the string on '$'. var itemSplitString = key.ToString().Split('$'); // ItemId is extracted from the checkbox Id. The first part of it is always 'chkImport'. So, the Id to be extracted // from the 9th index. var itemId = itemSplitString[2].Substring(9); // Get the itemId from GatherContentConnect API with the Id we extracted in the previous step. var item = Client.GetItemById(itemId); // Get the item's name. This will be used for displaying the import message. itemName = item.Name; // We know that the item's parent path Id is in the drop down. And, both checkbox and drop down share the similar // naming convention. So, we just get the key that contains the value of that drop down's selected value. var parentId = Request.Form[key.ToString().Replace("chkImport", "ddl")]; // Filtered files list contains only files that user wants to import. List <GcFile> filteredFiles; // Since the post type of the item is known beforehand, we can separate the import process for different post types. switch (currentMapping.PostType) { case "PageType": var pageParent = parentId.IsEmpty() ? ContentReference.RootPage : ContentReference.Parse(parentId); var selectedPageType = currentMapping.EpiContentType; var pageTypes = _contentTypeRepository.List().OfType <PageType>().ToList(); foreach (var pageType in pageTypes) { if (selectedPageType.Substring(5) != pageType.Name) { continue; } var newPage = _contentRepository.GetDefault <PageData>(pageParent, pageType.ID); foreach (var cs in _contentStore) { try { if (cs.ItemId != item.Id) { continue; } Response.Write("<script> alert('Page Already Exists!') </script>"); importItemFlag = false; importCounter = 0; break; } catch (TypeMismatchException ex) { Console.WriteLine(ex); } } newPage.PageName = item.Name; filteredFiles = MapValuesFromGcToEpi(newPage, pageType, currentMapping, item); if (!importItemFlag) { continue; } { var saveAction = SaveContent(newPage, item, currentMapping); filteredFiles.ForEach(async i => { await GcEpiContentParser.FileParserAsync(i, "PageType", newPage.ContentLink, saveAction, "Import"); }); var dds = new GcDynamicImports(newPage.ContentGuid, item.Id, DateTime.Now.ToLocalTime()); GcDynamicUtilities.SaveStore(dds); importCounter++; } } break; case "BlockType": var blockParent = parentId.IsEmpty() ? ContentReference.GlobalBlockFolder : ContentReference.Parse(parentId); var selectedBlockType = currentMapping.EpiContentType; var blockTypes = _contentTypeRepository.List().OfType <BlockType>().ToList(); foreach (var blockType in blockTypes) { if (selectedBlockType.Substring(6) != blockType.Name) { continue; } var newBlock = _contentRepository.GetDefault <BlockData>(blockParent, blockType.ID); foreach (var cs in _contentStore) { try { if (cs.ItemId != item.Id) { continue; } Response.Redirect("<script> alert('Block Already Exists!') </script>"); importItemFlag = false; importCounter = 0; break; } catch (TypeMismatchException ex) { Console.WriteLine(ex); } } // ReSharper disable once SuspiciousTypeConversion.Global var content = newBlock as IContent; // ReSharper disable once PossibleNullReferenceException content.Name = item.Name; filteredFiles = MapValuesFromGcToEpi(content, blockType, currentMapping, item); if (!importItemFlag) { continue; } { var saveAction = SaveContent(content, item, currentMapping); filteredFiles.ForEach(async i => { await GcEpiContentParser.FileParserAsync(i, "BlockType", content.ContentLink, saveAction, "Import"); }); var dds = new GcDynamicImports(content.ContentGuid, item.Id, DateTime.Now.ToLocalTime()); GcDynamicUtilities.SaveStore(dds); importCounter++; } } break; } } string responseMessage; if (importCounter == 1) { responseMessage = $"alert('{itemName} successfully imported!');"; } else if (importCounter > 1) { responseMessage = $"alert('{itemName} and {importCounter - 1} other items successfully imported!');"; } else { responseMessage = "alert('No items selected! Please select the checkbox next to the item you would " + "like to import!');"; } Response.Write($"<script> {responseMessage} window.location = '/modules/GcEpiPlugin/ReviewItemsForImport.aspx?" + $"&TemplateId={Session["TemplateId"]}&ProjectId={Session["ProjectId"]}'</script>"); }
public Stream ExportContent(ContentExport contentExport, ContentReference root) { var exporter = _dataExporterAccessor(); var exportedContentTypes = new HashSet <int>(); var sources = new List <ExportSource>(); if ((contentExport & ContentExport.ExportContentTypes) == ContentExport.ExportContentTypes) { _contentTypeRepository.List().ForEach(x => { exporter.AddContentType(x); exportedContentTypes.Add(x.ID); }); } if ((contentExport & ContentExport.ExportFrames) == ContentExport.ExportFrames) { _frameRepository().List().ForEach(exporter.AddFrame); } if ((contentExport & ContentExport.ExportTabDefinitions) == ContentExport.ExportTabDefinitions) { _tabDefinitionRepository.List().ForEach(exporter.AddTabDefinition); } if ((contentExport & ContentExport.ExportDynamicPropertyDefinitions) == ContentExport.ExportDynamicPropertyDefinitions) { _propertyDefinitionRepository.ListDynamic().ForEach(exporter.AddDynamicProperty); } if ((contentExport & ContentExport.ExportCategories) == ContentExport.ExportCategories) { ExportCategories(exporter, _categoryRepository.GetRoot()); } if ((contentExport & ContentExport.ExportPages) == ContentExport.ExportPages) { sources.Add(new ExportSource(root, ExportSource.RecursiveLevelInfinity)); } if ((contentExport & ContentExport.ExportVisitorGroups) == ContentExport.ExportVisitorGroups) { _visitorGroupRepository.List().ForEach(exporter.AddVisitorGroup); } var options = new ExportOptions { IncludeReferencedContentTypes = (contentExport & ContentExport.ExportContentTypeDependencies) == ContentExport.ExportContentTypeDependencies, ExportPropertySettings = (contentExport & ContentExport.ExportPropertySettings) == ContentExport.ExportPropertySettings, ExcludeFiles = false, AutoCloseStream = false }; var stream = new MemoryStream(); exporter.Export(stream, sources, options); ((DefaultDataExporter)exporter)?.Close(); stream.Position = 0; return(stream); }
public string Execute(ref bool stopSignal, Func <string, bool> onStatusChanged) { if (stopSignal) { return($"Execution of {this.GetType().Name} was aborted by stop signal"); } InaccessibleContentLocatorData results = new InaccessibleContentLocatorData(); foreach (ContentType tajp in _contentTypeRepository.List()) // get all page/block types, TODO: ability to configure excluded types? { if (stopSignal) { return("aborted"); } onStatusChanged($"Counting blocks and pages of type {tajp.Name}..."); // Exclude system types if (tajp.Name.StartsWith("Sys")) { continue; } TypeAccessabilityReport typeReport = new TypeAccessabilityReport() { TypeName = tajp.Name }; if (!_contentModelUsage.IsContentTypeUsed(tajp)) { typeReport.InaccessibleUsages = 0; typeReport.TotalUsages = 0; results.TypesWithNoUsages.Add(typeReport); continue; } IEnumerable <IContent> allUsages = _contentModelUsage.ListContentOfContentType(tajp) // get all usages .Select(usage => _contentRepository.Get <IContent>(usage.ContentLink.ToReferenceWithoutVersion())) // pick latest version .Distinct(); // exclude duplicates int usagesBeforeVisitorFilter = allUsages.Count(); // count all existing pages/blocks typeReport.TotalUsages = usagesBeforeVisitorFilter; if (allUsages.First() is BlockData || allUsages.First() is MediaData) { List <IContent> allUsagesList = allUsages.ToList(); new FilterPublished().Filter(allUsagesList); int InaccessibleUsages = 0; foreach (IContent block in allUsagesList) // check every block if it is used anywhere and if the pages/blocks its used in is used anywhere (recursive) { IEnumerable <ReferenceInformation> usedOn = _contentRepository.GetReferencesToContent(block.ContentLink, false); if (!usedOn.Any() || !usedOn.Any(usage => IsBlockVisibleToVisitor(usage.OwnerID))) { // Block is not used or not visible, record it InaccessibleUsages++; typeReport.Usages.Add(new ContentReportItem() { ContentLinkId = block.ContentLink.ID, ContentName = block.Name }); } } typeReport.InaccessibleUsages = InaccessibleUsages; if (InaccessibleUsages == 0) { results.TypesWithoutIssues.Add(typeReport); } else { results.TypesWithInaccessibleContent.Add(typeReport); } } else if (allUsages.First() is PageData page) { // If type does not have a template, count the number of usages but do not analyse the content on them if (!page.HasTemplate()) { typeReport.InaccessibleUsages = typeReport.TotalUsages; results.TypesWithoutIssues.Add(typeReport); continue; } // remove all pages from allUsages that passes the FilterForVisitors filter IEnumerable <IContent> allFilteredUsages = allUsages.Except(FilterForVisitor.Filter(allUsages)); typeReport.InaccessibleUsages = allFilteredUsages.Count(); foreach (IContent unusedContent in allFilteredUsages) { typeReport.Usages.Add(new ContentReportItem() { ContentLinkId = unusedContent.ContentLink.ID, ContentName = unusedContent.Name }); } if (typeReport.InaccessibleUsages == 0) { results.TypesWithoutIssues.Add(typeReport); } else { results.TypesWithInaccessibleContent.Add(typeReport); } } } DataStorage.WriteObjectToFile(results); return("I am done, doobie damm damm"); }
public IEnumerable <PageType> GetAllPageTypes() { return(_contentTypeRepository.List().OfType <PageType>()); }
private void PopulateForm() { if (_credentialsStore.IsNullOrEmpty()) { Response.Write("<script>alert('Please setup your GatherContent config first!');" + "window.location='/modules/GcEpiPlugin/GatherContentConfigSetup.aspx'</script>"); Visible = false; return; } if (Session["ProjectId"] == null || Session["TemplateId"] == null || Session["PostType"] == null || (string)Session["PostType"] == "-1") { Response.Write("<script>alert('Please set the MetaDataProducer Defaults!');" + "window.location='/modules/GcEpiPlugin/NewGcMappingStep3.aspx'</script>"); Visible = false; return; } // Variables initialization. _client = new GcConnectClient(_credentialsStore.ToList().First().ApiKey, _credentialsStore.ToList().First().Email); var projectId = Convert.ToInt32(Session["ProjectId"]); var templateId = Convert.ToInt32(Session["TemplateId"]); var gcFields = _client.GetTemplateById(templateId).Config.ToList(); gcFields.ForEach(i => _elements.AddRange(i.Elements)); // Setting the mark-up labels. projectName.Text = _client.GetProjectById(projectId).Name; templateName.Text = _client.GetTemplateById(templateId).Name; templateDescription.Text = _client.GetTemplateById(templateId).Description; // Table rows instantiation and updating. var tHeadRow = new TableRow { Height = 42 }; tHeadRow.Cells.Add(new TableCell { Text = "GatherContent Field" }); tHeadRow.Cells.Add(new TableCell { Text = "Mapped EPiServer Field" }); tableMappings.Rows.Add(tHeadRow); foreach (var element in _elements.OrderByDescending(i => i.Type)) { var tRow = new TableRow(); tableMappings.Rows.Add(tRow); for (var cellIndex = 1; cellIndex <= 2; cellIndex++) { var tCell = new TableCell { Width = 500 }; if (cellIndex is 1) { tCell.Text = $"<span style='font-weight: Bold;'>{element.Label + element.Title}</span><br>Type: {element.Type}<br>Limit: " + $"{element.Limit}<br>Description: {element.MicroCopy}<br>"; } else { if (Session["EpiContentType"].ToString().StartsWith("block-")) { var blockTypes = _contentTypeRepository.List().OfType <BlockType>(); tCell.Controls.Add(MetaDataProducer(blockTypes, element, 6)); } else if (Session["EpiContentType"].ToString().StartsWith("page-")) { var pageTypes = _contentTypeRepository.List().OfType <PageType>(); tCell.Controls.Add(MetaDataProducer(pageTypes, element, 5)); } else { var gcEpiMisc = new GcEpiMiscUtility(); var dropDownList = MetaDataProducer(gcEpiMisc.GetMediaTypes(), element, 6); tCell.Controls.Add(dropDownList); } } tRow.Cells.Add(tCell); } } }
public virtual IHttpActionResult ListContentTypes() { return(Ok(_typerepo.List().Select(ct => ConstructExpandoObject(ct)).ToList())); }
public string Execute(ref bool stopSignal, Func <string, bool> onStatusChanged) { if (stopSignal) { return($"Execution of {this.GetType().Name} was aborted by stop signal"); } InaccessibleContentLocatorData results = new InaccessibleContentLocatorData(); foreach (ContentType tajp in _contentTypeRepository.List()) // get all page/block types { if (stopSignal) { return("aborted"); } onStatusChanged($"Counting blocks and pages of type {tajp.Name}..."); // Exclude system types if (tajp.Name.StartsWith("sys")) { continue; } if (!_contentModelUsage.IsContentTypeUsed(tajp)) { // not used at all results.TypesOverview.Add(new TypeUsageCount() { TypeName = tajp.Name, UnfilteredUsages = 0, UnavailableUsages = 0 }); } else { IEnumerable <IContent> allUsages = _contentModelUsage.ListContentOfContentType(tajp) // get all usages .Select(usage => _contentRepository.Get <IContent>(usage.ContentLink.ToReferenceWithoutVersion())) // pick latest version .Distinct(); // exclude duplicates int usagesBeforeVisitorFilter = allUsages.Count(); // count all existing pages/blocks if (allUsages.First() is BlockData) { List <IContent> allUsagesList = allUsages.ToList(); new FilterPublished().Filter(allUsagesList); int unavailabeUsages = 0; foreach (IContent block in allUsagesList) // check every block if it is used anywhere and if the pages/blocks its used in is used anywhere (recursive) { IEnumerable <ReferenceInformation> usedOn = _contentRepository.GetReferencesToContent(block.ContentLink, false); if (!usedOn.Any() || !usedOn.Any(usage => IsBlockVisibleToVisitor(usage.OwnerID))) { // Block is not used or not visible, record it unavailabeUsages++; if (!results.TypeDetails.ContainsKey(tajp.Name)) { results.TypeDetails.Add(tajp.Name, new List <ContentReportItem>()); } results.TypeDetails[tajp.Name].Add(new ContentReportItem() { ContentLinkId = block.ContentLink.ID, ContentName = block.Name }); } } results.TypesOverview.Add(new TypeUsageCount() { TypeName = tajp.Name, UnfilteredUsages = usagesBeforeVisitorFilter, UnavailableUsages = unavailabeUsages }); } else if (allUsages.First() is PageData) { // remove all pages from allUsages that passes the FilterForVisitors filter IEnumerable <IContent> allFilteredUsages = allUsages.Except(FilterForVisitor.Filter(allUsages)); int unavailableUsages = allFilteredUsages.Count(); // recount results.TypesOverview.Add(new TypeUsageCount() { TypeName = tajp.Name, UnfilteredUsages = usagesBeforeVisitorFilter, UnavailableUsages = unavailableUsages }); foreach (IContent unusedContent in allFilteredUsages) { if (!results.TypeDetails.ContainsKey(tajp.Name)) { results.TypeDetails.Add(tajp.Name, new List <ContentReportItem>()); } results.TypeDetails[tajp.Name].Add(new ContentReportItem() { ContentLinkId = unusedContent.ContentLink.ID, ContentName = unusedContent.Name }); } } } } DataStorage.WriteObjectToFile <InaccessibleContentLocatorData>(results); return("I am done, doobie damm damm"); }
private void PopulateForm() { if (_credentialsStore.IsNullOrEmpty()) { Response.Write("<script>alert('Please setup your GatherContent config first!');" + "window.location='/modules/GcEpiPlugin/GatherContentConfigSetup.aspx'</script>"); Visible = false; return; } if (Session["ProjectId"] == null || Session["TemplateId"] == null) { Response.Write("<script>alert('Please select the GatherContent Template!');" + "window.location='/modules/GcEpiPlugin/NewGcMappingStep2.aspx'</script>"); Visible = false; return; } EnableDdl(); // Clear all the statically created drop down items to avoid data persistence on post-back. ddlAuthors.Items.Clear(); ddlStatuses.Items.Clear(); _client = new GcConnectClient(_credentialsStore.ToList().First().ApiKey, _credentialsStore.ToList().First().Email); var projectId = Convert.ToInt32(Session["ProjectId"]); var templateId = Convert.ToInt32(Session["TemplateId"]); projectName.Text = _client.GetProjectById(projectId).Name; templateName.Text = _client.GetTemplateById(templateId).Name; templateDescription.Text = _client.GetTemplateById(templateId).Description; var userProvider = ServiceLocator.Current.GetInstance <UIUserProvider>(); var epiUsers = userProvider.GetAllUsers(0, 200, out int _); epiUsers.ToList().ForEach(epiUser => ddlAuthors.Items.Add(new ListItem(epiUser.Username, epiUser.Username))); var saveActions = Enum.GetValues(typeof(SaveAction)).Cast <SaveAction>().ToList(); saveActions.RemoveAt(1); saveActions.ToList().ForEach(i => ddlStatuses.Items.Add(new ListItem(i.ToString(), i.ToString()))); if (Session["PostType"] == null || Session["Author"] == null || Session["DefaultStatus"] == null) { ddlPostTypes.SelectedIndex = 0; ddlAuthors.SelectedIndex = 0; ddlStatuses.SelectedIndex = 0; Session["PostType"] = ddlPostTypes.SelectedValue; Session["Author"] = ddlAuthors.SelectedValue; Session["DefaultStatus"] = ddlStatuses.SelectedValue; } else { ddlPostTypes.Items.Remove(ddlPostTypes.Items.FindByValue("-1")); ddlPostTypes.SelectedValue = Session["PostType"].ToString(); ddlAuthors.SelectedValue = Session["Author"].ToString(); ddlStatuses.SelectedValue = Session["DefaultStatus"].ToString(); // Clear all the statically created drop down items to avoid data persistence on post-back. ddlEpiContentTypes.Items.Clear(); if (Session["PostType"].ToString() is "PageType") { var contentTypeList = _contentTypeRepository.List().OfType <PageType>(); var pageTypes = contentTypeList as IList <PageType> ?? contentTypeList.ToList(); pageTypes.ToList().ForEach(i => { if (i.ID != 1 && i.ID != 2) { ddlEpiContentTypes.Items.Add(new ListItem(i.DisplayName, "page-" + i.Name)); } }); ddlEpiContentTypes.Enabled = true; btnNextStep.Enabled = true; } else if (Session["PostType"].ToString() is "BlockType") { var contentTypeList = _contentTypeRepository.List().OfType <BlockType>(); var blockTypes = contentTypeList as IList <BlockType> ?? contentTypeList.ToList(); blockTypes.ToList().ForEach(i => ddlEpiContentTypes.Items.Add(new ListItem(i.DisplayName, "block-" + i.Name))); ddlEpiContentTypes.Enabled = true; btnNextStep.Enabled = true; } else { var gcEpiMisc = new GcEpiMiscUtility(); gcEpiMisc.GetMediaTypes().ToList(). ForEach(i => ddlEpiContentTypes.Items.Add(new ListItem(i.DisplayName, "media-" + i.Name))); ddlEpiContentTypes.Enabled = true; btnNextStep.Enabled = true; } if (Session["EpiContentType"] != null) { ddlEpiContentTypes.SelectedValue = Session["EpiContentType"].ToString(); } } var gcStatuses = _client.GetStatusesByProjectId(projectId); var tHeadRow = new TableRow { Height = 42 }; tHeadRow.Cells.Add(new TableCell { Text = "GatherContent Status" }); tHeadRow.Cells.Add(new TableCell { Text = "Mapped EPiServer Status" }); //tHeadRow.Cells.Add(new TableCell { Text = "On Import, Change GatherContent Status" }); tableGcStatusesMap.Rows.Add(tHeadRow); foreach (var status in gcStatuses) { var tRow = new TableRow(); tableGcStatusesMap.Rows.Add(tRow); for (var cellIndex = 1; cellIndex <= 2; cellIndex++)//Need to make it the highest index, 3 in the next version. { var tCell = new TableCell(); if (cellIndex is 3) { var ddlOnImportGcStatuses = new DropDownList { Height = 30, Width = 250, CssClass = "chosen-select" }; ddlOnImportGcStatuses.Items.Add(new ListItem("Do Not Change", "1")); gcStatuses.ToList().ForEach(i => ddlOnImportGcStatuses.Items.Add(new ListItem(i.Name, i.Id))); ddlOnImportGcStatuses.ID = "onImportGc-" + status.Id; tCell.Controls.Add(ddlOnImportGcStatuses); } else if (cellIndex is 2) { var ddlEpiStatuses = new DropDownList { Height = 30, Width = 250, CssClass = "chosen-select" }; ddlEpiStatuses.Items.Add(new ListItem("Use Default Status", "Use Default Status")); saveActions.ToList().ForEach(i => ddlEpiStatuses.Items.Add(new ListItem(i.ToString(), i.ToString()))); ddlEpiStatuses.ID = "mappedEPi-" + status.Id; tCell.Controls.Add(ddlEpiStatuses); } else if (cellIndex is 1) { tCell.Text = status.Name; } tRow.Cells.Add(tCell); } } }