public ActionResult EditArticle(EditArticleModel edited, string[] tags, string imageCondition) { if (!ModelState.IsValid) { return(View(edited)); } var baseArticle = repo.GetItem(edited.Id); if (baseArticle == null || baseArticle.UserId != User.Identity.GetUserId <int>()) { return(HttpNotFound()); } var changesExist = false; if (imageCondition == "Empty") { baseArticle.Image = "Empty"; changesExist = true; } if (edited.Image != null) { var fileHelper = new FileHelper(); var isChanged = fileHelper.SaveFIle(Server.MapPath(ConfigurationManager.AppSettings["ArticleImagesFolder"]), edited.Image, baseArticle.Id); if (isChanged) { baseArticle.Image = edited.Image.FileName; changesExist = true; } } if (baseArticle.Title != edited.Title) { baseArticle.Title = edited.Title; changesExist = true; } if (baseArticle.ShortDescription != edited.ShortDescription) { baseArticle.ShortDescription = edited.ShortDescription; changesExist = true; } if (baseArticle.FullDescription != edited.FullDescription) { baseArticle.FullDescription = edited.FullDescription; changesExist = true; } baseArticle.Tags.Clear(); if (tags != null) { IEnumerable <Tag> newTags = TagsHelper.CreateTagList(tags, tagRepo); TagsHelper.SetTagForModel(baseArticle, newTags); changesExist = true; } if (changesExist) { repo.Save(baseArticle); } return(RedirectToAction("Article", new { Title = edited.Title, Id = edited.Id })); }
public IEnumerable <ContentData> GetContentsByTag(Tag tag) { if (tag == null) { return(Enumerable.Empty <ContentData>()); } var contentLinks = new List <Guid>(); if (tag.PermanentLinks == null) { var tempTerm = _tagService.GetTagByNameAndGroup(tag.Name, tag.GroupKey); if (tempTerm != null) { contentLinks = tempTerm.PermanentLinks.ToList(); } } else { contentLinks = tag.PermanentLinks.ToList(); } return(contentLinks .Select(contentGuid => _contentLoader.Get <ContentData>(TagsHelper.GetContentReference(contentGuid))) .ToList()); }
/// <summary> /// Lists the resources in a resource group. /// </summary> private async Task <ResponseWithContinuation <JObject[]> > ListResourcesInResourceGroup() { var filterQuery = QueryFilterBuilder .CreateFilter( subscriptionId: null, resourceGroup: this.ResourceGroupNameEquals, resourceType: this.ResourceType, resourceName: this.ResourceNameEquals, tagName: TagsHelper.GetTagNameFromParameters(this.Tag, this.TagName), tagValue: TagsHelper.GetTagValueFromParameters(this.Tag, this.TagValue), filter: this.ODataQuery, resourceGroupNameContains: this.ResourceGroupNameContains, nameContains: this.ResourceNameContains); return(await this .GetResourcesClient() .ListResources <JObject>( subscriptionId: this.SubscriptionId.Value, resourceGroupName: null, apiVersion: this.DefaultApiVersion, top: this.Top, filter: filterQuery, cancellationToken: this.CancellationToken.Value) .ConfigureAwait(continueOnCapturedContext: false)); }
private void ExecuteDeployment() { if (RollbackToLastDeployment && !string.IsNullOrEmpty(RollBackDeploymentName)) { WriteExceptionError(new ArgumentException(ProjectResources.InvalidRollbackParameters)); } var parameters = new PSDeploymentCmdletParameters() { ScopeType = DeploymentScopeType.ResourceGroup, ResourceGroupName = ResourceGroupName, DeploymentName = Name, DeploymentMode = Mode, TemplateFile = TemplateUri ?? this.TryResolvePath(TemplateFile), TemplateObject = TemplateObject, TemplateParameterObject = GetTemplateParameterObject(TemplateParameterObject), ParameterUri = TemplateParameterUri, DeploymentDebugLogLevel = GetDeploymentDebugLogLevel(DeploymentDebugLogLevel), Tags = TagsHelper.ConvertToTagsDictionary(Tag), OnErrorDeployment = RollbackToLastDeployment || !string.IsNullOrEmpty(RollBackDeploymentName) ? new OnErrorDeployment { Type = RollbackToLastDeployment ? OnErrorDeploymentType.LastSuccessful : OnErrorDeploymentType.SpecificDeployment, DeploymentName = RollbackToLastDeployment ? null : RollBackDeploymentName } : null }; if (!string.IsNullOrEmpty(parameters.DeploymentDebugLogLevel)) { WriteWarning(ProjectResources.WarnOnDeploymentDebugSetting); } WriteObject(ResourceManagerSdkClient.ExecuteResourceGroupDeployment(parameters)); }
public string RendHtml() { XmlNode xmlNode = TagsHelper.FindCommentNode(this.CommentId, "category"); StringBuilder stringBuilder = new StringBuilder(); if (xmlNode != null) { stringBuilder.AppendFormat("<div class=\"category cssEdite\" type=\"category\" id=\"comments_{0}\" >", this.CommentId).AppendLine(); int parentCategoryId = 0; int maxNum = 0; int.TryParse(xmlNode.Attributes["CategoryId"].Value, out parentCategoryId); int.TryParse(xmlNode.Attributes["MaxNum"].Value, out maxNum); IList <CategoryInfo> maxSubCategories = CategoryBrowser.GetMaxSubCategories(parentCategoryId, maxNum); if (maxSubCategories != null && maxSubCategories.Count > 0) { stringBuilder.AppendLine("<ul>"); foreach (CategoryInfo current in maxSubCategories) { stringBuilder.AppendFormat("<li><a target=\"_blank\" href=\"{0}\">{1}</a></li>", Globals.GetSiteUrls().SubCategory(current.CategoryId, current.RewriteName), current.Name).AppendLine(); } stringBuilder.AppendLine("</ul>"); } stringBuilder.AppendLine("</div>"); } return(stringBuilder.ToString()); }
protected override void Initialize() { TagsGroup ag = TagsHelper.GetTagsGroup(); DetailGridView.DataSource = ag.Items; DetailGridView.DataBind(); }
/// <summary> /// Gets the resource body. /// </summary> private JToken GetResourceBody() { if (this.ShouldUsePatchSemantics()) { var resourceBody = this.GetPatchResourceBody(); return(resourceBody == null ? null : resourceBody.ToJToken()); } else { var getResult = this.GetResource().Result; if (getResult.CanConvertTo <Resource <JToken> >()) { var resource = getResult.ToResource(); return(new Resource <JToken>() { Kind = this.Kind ?? resource.Kind, Plan = this.Plan.ToDictionary(addValueLayer: false).ToJson().FromJson <ResourcePlan>() ?? resource.Plan, Sku = this.Sku.ToDictionary(addValueLayer: false).ToJson().FromJson <ResourceSku>() ?? resource.Sku, Tags = TagsHelper.GetTagsDictionary(this.Tag) ?? resource.Tags, Location = resource.Location, Properties = this.Properties == null ? resource.Properties : this.Properties.ToResourcePropertiesBody() }.ToJToken()); } else { return(this.Properties.ToJToken()); } } }
public string RendHtml() { XmlNode xmlNode = TagsHelper.FindCommentNode(this.CommentId, "category"); StringBuilder stringBuilder = new StringBuilder(); if (xmlNode != null) { stringBuilder.AppendFormat("<div class=\"category cssEdite\" type=\"category\" id=\"comments_{0}\" >", this.CommentId).AppendLine(); int parentCategoryId = 0; int count = 0; int.TryParse(xmlNode.Attributes["CategoryId"].Value, out parentCategoryId); int.TryParse(xmlNode.Attributes["MaxNum"].Value, out count); IEnumerable <CategoryInfo> subCategories = CatalogHelper.GetSubCategories(parentCategoryId); if (subCategories != null) { stringBuilder.AppendLine("<ul>"); IEnumerable <CategoryInfo> enumerable = subCategories.Take(count); foreach (CategoryInfo item in enumerable) { string arg = (!string.IsNullOrEmpty(item.RewriteName)) ? base.GetRouteUrl("subCategory_Rewrite", new { rewrite = item.RewriteName, categoryId = item.CategoryId }) : base.GetRouteUrl("subCategory", new { categoryId = item.CategoryId }); stringBuilder.AppendFormat("<li><a target=\"_blank\" href=\"{0}\">{1}</a></li>", arg, item.Name).AppendLine(); } stringBuilder.AppendLine("</ul>"); } stringBuilder.AppendLine("</div>"); } return(stringBuilder.ToString()); }
public override string Execute() { var tags = _tagService.GetAllTags().ToList(); var pageGuids = GetTaggedPageGuids(tags); foreach (var pageGuid in pageGuids) { if (_stop) { return("Geta Tags maintenance was stopped"); } PageData page = null; try { page = DataFactory.Instance.GetPage(TagsHelper.GetPageReference(pageGuid)); } catch (PageNotFoundException) {} if (page == null || page.IsDeleted) { RemoveFromAllTags(pageGuid, tags); continue; } CheckPageProperties(page, tags); } return("Geta Tags maintenance completed successfully"); }
/// <summary> /// Constructs the resource /// </summary> private JToken GetResource(string resourceId, string apiVersion) { var resource = this.GetExistingResource(resourceId, apiVersion).Result.ToResource(); var applicationObject = new Application { Name = this.Name, Location = resource.Location, Plan = this.Plan == null ? resource.Plan : this.Plan.ToDictionary(addValueLayer: false).ToJson().FromJson <ResourcePlan>(), Properties = new ApplicationProperties { ManagedResourceGroupId = string.IsNullOrEmpty(this.ManagedResourceGroupName) ? resource.Properties["managedResourceGroupId"].ToString() : string.Format("/subscriptions/{0}/resourcegroups/{1}", Guid.Parse(DefaultContext.Subscription.Id), this.ManagedResourceGroupName), ApplicationDefinitionId = this.ManagedApplicationDefinitionId ?? resource.Properties["applicationDefinitionId"].ToString(), Parameters = this.Parameter == null ? (resource.Properties["parameters"] != null ? JObject.Parse(resource.Properties["parameters"].ToString()) : null) : JObject.Parse(this.GetObjectFromParameter(this.Parameter).ToString()) }, Tags = TagsHelper.GetTagsDictionary(this.Tag) ?? resource.Tags }; return(applicationObject.ToJToken()); }
public string RendHtml() { XmlNode node = TagsHelper.FindCommentNode(this.CommentId, "category"); StringBuilder builder = new StringBuilder(); if (node != null) { builder.AppendFormat("<div class=\"category cssEdite\" type=\"category\" id=\"comments_{0}\" >", this.CommentId).AppendLine(); int result = 0; int num2 = 0; int.TryParse(node.Attributes["CategoryId"].Value, out result); int.TryParse(node.Attributes["MaxNum"].Value, out num2); IList <CategoryInfo> maxSubCategories = CategoryBrowser.GetMaxSubCategories(result, num2); if ((maxSubCategories != null) && (maxSubCategories.Count > 0)) { builder.AppendLine("<ul>"); foreach (CategoryInfo info in maxSubCategories) { builder.AppendFormat("<li><a target=\"_blank\" href=\"{0}\">{1}</a></li>", Globals.GetSiteUrls().SubCategory(info.CategoryId, info.RewriteName), info.Name).AppendLine(); } builder.AppendLine("</ul>"); } builder.AppendLine("</div>"); } return(builder.ToString()); }
public virtual void OnMetadataCreated(ModelMetadata metadata) { var extendedMetadata = metadata as ExtendedMetadata; if (extendedMetadata == null) { return; } var groupKeyAttribute = extendedMetadata .Attributes .FirstOrDefault(a => typeof(TagsGroupKeyAttribute) == a.GetType()) as TagsGroupKeyAttribute; var cultureSpecificAttribute = extendedMetadata .Attributes .FirstOrDefault(a => typeof(CultureSpecificAttribute) == a.GetType()) as CultureSpecificAttribute; var ownerContent = extendedMetadata.FindOwnerContent(); extendedMetadata.ClientEditingClass = "geta-tags/TagsSelection"; extendedMetadata.CustomEditorSettings["uiType"] = extendedMetadata.ClientEditingClass; extendedMetadata.CustomEditorSettings["uiWrapperType"] = UiWrapperType.Floating; extendedMetadata.EditorConfiguration["GroupKey"] = TagsHelper.GetGroupKeyFromAttributes(groupKeyAttribute, cultureSpecificAttribute, ownerContent); extendedMetadata.EditorConfiguration["allowSpaces"] = AllowSpaces; extendedMetadata.EditorConfiguration["allowDuplicates"] = AllowDuplicates; extendedMetadata.EditorConfiguration["caseSensitive "] = CaseSensitive; extendedMetadata.EditorConfiguration["readOnly "] = ReadOnly; extendedMetadata.EditorConfiguration["tagLimit"] = TagLimit; }
private void OnPublishedContent(object sender, ContentEventArgs e) { var content = e.Content; CleanupOldTags(content); var contentType = _contentTypeRepository.Load(content.ContentTypeID); var tagProperties = contentType.PropertyDefinitions.Where(p => p.TemplateHint == "Tags").ToArray(); if (!tagProperties.Any()) { return; } foreach (var tagProperty in tagProperties) { var tagPropertyInfo = contentType.ModelType.GetProperty(tagProperty.Name); var tags = GetPropertyTags(content as ContentData, tagProperty); if (tagPropertyInfo == null) { return; } var groupKeyAttribute = tagPropertyInfo.GetCustomAttribute(typeof(TagsGroupKeyAttribute)) as TagsGroupKeyAttribute; var cultureSpecificAttribute = tagPropertyInfo.GetCustomAttribute(typeof(CultureSpecificAttribute)) as CultureSpecificAttribute; var groupKey = TagsHelper.GetGroupKeyFromAttributes(groupKeyAttribute, cultureSpecificAttribute, content); _tagService.Save(content.ContentGuid, tags, groupKey); } }
/// <summary> /// Constructs the resource /// </summary> private JToken GetResource(string resourceId, string apiVersion) { var resource = this.GetExistingResource(resourceId, apiVersion).Result.ToResource(); var applicationDefinitionObject = new ApplicationDefinition { Name = this.Name, Location = resource.Location, Properties = new ApplicationDefinitionProperties { LockLevel = (ApplicationLockLevel)Enum.Parse(typeof(ApplicationLockLevel), resource.Properties["lockLevel"].ToString(), true), Description = this.Description ?? (resource.Properties["description"] != null ? resource.Properties["description"].ToString() : null), DisplayName = this.DisplayName ?? (resource.Properties["displayName"] != null ? resource.Properties["displayName"].ToString() : null), PackageFileUri = this.PackageFileUri ?? null, Authorizations = this.Authorization != null ? JArray.Parse(this.GetAuthorizationObject(this.Authorization).ToString()).ToJson().FromJson <ApplicationProviderAuthorization[]>() : JArray.Parse(resource.Properties["authorizations"].ToString()).ToJson().FromJson <ApplicationProviderAuthorization[]>() }, Tags = TagsHelper.GetTagsDictionary(this.Tag) ?? resource.Tags }; return(applicationDefinitionObject.ToJToken()); }
public string RendHtml() { XmlNode xmlNode = TagsHelper.FindCommentNode(this.CommentId, "keyword"); StringBuilder stringBuilder = new StringBuilder(); if (xmlNode != null) { int categoryId = 0; int categoryId2 = 0; int hotKeywordsNum = 0; int.TryParse(xmlNode.Attributes["CategoryId"].Value, out categoryId2); int.TryParse(xmlNode.Attributes["MaxNum"].Value, out hotKeywordsNum); CategoryInfo category = CatalogHelper.GetCategory(categoryId2); if (category != null) { categoryId = category.TopCategoryId; } List <HotkeywordInfo> hotKeywords = CommentBrowser.GetHotKeywords(categoryId, hotKeywordsNum); stringBuilder.AppendFormat("<ul class=\"keyword cssEdite\" type=\"keyword\" id=\"comments_{0}\" >", this.CommentId).AppendLine(); if (hotKeywords != null && hotKeywords.Count > 0) { foreach (HotkeywordInfo item in hotKeywords) { stringBuilder.AppendFormat("<li><a target=\"_blank\" href=\"{0}\">{1}</a></li>", base.GetRouteUrl("subCategory", new { categoryId = item.CategoryId }) + "?keywords=" + Globals.UrlEncode(item.Keywords), item.Keywords).AppendLine(); } } stringBuilder.AppendLine("</ul>"); } return(stringBuilder.ToString()); }
private void CheckPageProperties(PageData page, IList <Tag> tags) { var pageType = _pageTypeRepository.Load(page.PageTypeID); foreach (var propertyDefinition in pageType.PropertyDefinitions) { if (!TagsHelper.IsTagProperty(propertyDefinition)) { continue; } var tagNames = page[propertyDefinition.Name] as string; IList <Tag> allTags = tags; if (tagNames == null) { RemoveFromAllTags(page.PageGuid, allTags); continue; } var addedTags = ParseTags(tagNames); // make sure the tags it has added has the pagereference ValidateTags(allTags, page.PageGuid, addedTags); // make sure there's no pagereference to this pagereference in the rest of the tags RemoveFromAllTags(page.PageGuid, allTags); } }
private void ToggleZoomedState(CarouselSlotBehavior carouselSlotBehavior) { if (isInContentTransition) { return; } if (eventAudioManager != null) { eventAudioManager.PlayAudio(); } var isZoomed = carouselSlotBehavior.IsZoomed; if (Souvenir.IsInActiveState) { UpdateGrid(); } else { Souvenir.ToggleActiveState(); } if (!isZoomed) { var yOffset = GetGameObjectHeight(Souvenir.gameObject); var zoomedCoordsObject = TagsHelper.FindChildWithTag(photoArrangement, TagsHelper.ZoomedPictureCoords); var position = transform.InverseTransformPoint(zoomedCoordsObject.transform.position) - transform.InverseTransformVector(new Vector3(0, yOffset, 0)); carouselSlotBehavior.EnableZoomedMode(position); } }
public string RendHtml() { StringBuilder stringBuilder = new StringBuilder(); XmlNode xmlNode = TagsHelper.FindProductNode(this.SubjectId, "floor"); if (xmlNode != null) { stringBuilder.AppendFormat("<div class=\"floor{0} cssEdite\" type=\"floor\" id=\"products_{1}\" >", xmlNode.Attributes["ImageSize"].Value, this.SubjectId).AppendLine(); this.RenderHeader(xmlNode, stringBuilder); stringBuilder.AppendLine("<div class=\"floor_bd\">"); if (!string.IsNullOrEmpty(xmlNode.Attributes["AdImage"].Value)) { stringBuilder.AppendFormat("<div class=\"floor_ad\"><img src=\"{0}\" /></div>", xmlNode.Attributes["AdImage"].Value).AppendLine(); } else { stringBuilder.AppendFormat("<div class=\"floor_ad\"><img src=\"{0}\" /></div>", SettingsManager.GetMasterSettings(true).DefaultProductImage).AppendLine(); } stringBuilder.AppendLine("<div class=\"floor_pro\">"); DataTable productList = this.GetProductList(xmlNode); if (productList != null && productList.Rows.Count > 0) { stringBuilder.AppendLine("<ul>"); foreach (DataRow dataRow in productList.Rows) { SiteSettings masterSettings = SettingsManager.GetMasterSettings(false); string str = masterSettings.DefaultProductImage; if (dataRow["ThumbnailUrl" + xmlNode.Attributes["ImageSize"].Value] != DBNull.Value) { str = dataRow["ThumbnailUrl" + xmlNode.Attributes["ImageSize"].Value].ToString(); } stringBuilder.AppendLine("<li>"); stringBuilder.AppendFormat("<div class=\"pic\"><a target=\"_blank\" href=\"{0}\"><img src=\"{1}\" alt=\"{2}\" /></a></div>", Globals.GetSiteUrls().UrlData.FormatUrl("productDetails", new object[] { dataRow["ProductId"] }), Globals.ApplicationPath + str, dataRow["ProductName"]).AppendLine(); stringBuilder.AppendFormat("<div class=\"name\"><a target=\"_blank\" href=\"{0}\">{1}</a></div>", Globals.GetSiteUrls().UrlData.FormatUrl("productDetails", new object[] { dataRow["ProductId"] }), dataRow["ProductName"]).AppendLine(); string arg = string.Empty; if (dataRow["MarketPrice"] != DBNull.Value) { arg = Globals.FormatMoney((decimal)dataRow["MarketPrice"]); } stringBuilder.AppendFormat("<div class=\"price\"><b><em>¥</em>{0}</b><span><em>¥</em>{1}</span></div>", Globals.FormatMoney((decimal)dataRow["RankPrice"]), arg).AppendLine(); stringBuilder.AppendFormat("<a class=\"productview\" target=\"_blank\" href=\"{0}\">查看详细</a>", Globals.GetSiteUrls().UrlData.FormatUrl("productDetails", new object[] { dataRow["ProductId"] })).AppendLine(); stringBuilder.AppendLine("</li>"); } stringBuilder.AppendLine("</ul>"); } stringBuilder.AppendLine("</div>"); stringBuilder.AppendLine("</div>"); stringBuilder.AppendLine("</div>"); } return(stringBuilder.ToString()); }
protected IEnumerable <AudioMetaData> GetAudioMetaDatasForDirectory(DirectoryInfo directory) { try { if (!CachedAudioDatas.ContainsKey(directory.FullName)) { var filesInMetaDataFolder = directory.GetFiles("*.mp3", SearchOption.TopDirectoryOnly); var metaDatasForFilesInFolder = new List <AudioMetaData>(); foreach (var fileInMetaDataFolder in filesInMetaDataFolder) { var metaData = TagsHelper.MetaDataForFile(fileInMetaDataFolder.FullName, true); metaDatasForFilesInFolder.Add(metaData.Data); } CachedAudioDatas.Add(directory.FullName, metaDatasForFilesInFolder); } return(CachedAudioDatas[directory.FullName]); } catch (Exception ex) { Logger.LogError(ex); } return(new AudioMetaData[0]); }
public IEnumerable <PageReference> GetPageReferencesByTags(IEnumerable <Tag> tags) { var matches = new Dictionary <PageReference, int>(); foreach (Tag tag in tags) { if (tag != null && tag.PermanentLinks != null) { foreach (Guid pageGuid in tag.PermanentLinks) { var pageReference = TagsHelper.GetPageReference(pageGuid); if (matches.ContainsKey(pageReference)) { matches[pageReference] += 1; } else { matches.Add(pageReference, 1); } } } } matches = matches.OrderByDescending(t => t.Value).ToDictionary(pair => pair.Key, pair => pair.Value); return(matches.Keys); }
public string RendHtml() { XmlNode node = TagsHelper.FindCommentNode(this.CommentId, "keyword"); StringBuilder builder = new StringBuilder(); if (node != null) { int categoryId = 0; int result = 0; int num3 = 0; int.TryParse(node.Attributes["CategoryId"].Value, out result); int.TryParse(node.Attributes["MaxNum"].Value, out num3); CategoryInfo category = CategoryBrowser.GetCategory(result); if (category != null) { categoryId = category.TopCategoryId; } DataTable hotKeywords = CommentBrowser.GetHotKeywords(categoryId, num3); builder.AppendFormat("<ul class=\"keyword cssEdite\" type=\"keyword\" id=\"comments_{0}\" >", this.CommentId).AppendLine(); if ((hotKeywords != null) && (hotKeywords.Rows.Count > 0)) { foreach (DataRow row in hotKeywords.Rows) { builder.AppendFormat("<li><a target=\"_blank\" href=\"{0}\">{1}</a></li>", Globals.GetSiteUrls().SubCategory((int)row["CategoryId"], null) + "?keywords=" + Globals.UrlEncode((string)row["Keywords"]), row["Keywords"]).AppendLine(); } } builder.AppendLine("</ul>"); } return(builder.ToString()); }
public IEnumerable <ContentData> GetContentsByTag(Tag tag, ContentReference rootContentReference) { if (tag == null || tag.PermanentLinks == null) { return(null); } IEnumerable <ContentReference> descendantContentReferences = this._contentLoader.GetDescendents(rootContentReference); if (descendantContentReferences == null || !descendantContentReferences.Any()) { return(null); } var items = new List <ContentData>(); foreach (Guid contentGuid in tag.PermanentLinks) { var contentReference = TagsHelper.GetContentReference(contentGuid); if (descendantContentReferences.FirstOrDefault(p => p.ID == contentReference.ID) != null) { items.Add(this._contentLoader.Get <PageData>(contentReference)); } } return(items); }
public override OperationResult <string> Process(DirectoryInfo directory) { var result = new OperationResult <string>(); var data = string.Empty; var found = 0; var modified = 0; var metaDatasForFilesInFolder = GetAudioMetaDatasForDirectory(directory); if (metaDatasForFilesInFolder.Any()) { found = metaDatasForFilesInFolder.Count(); var firstMetaData = metaDatasForFilesInFolder.OrderBy(x => x.TrackNumber).First(); var release = firstMetaData.Release; foreach (var metaData in metaDatasForFilesInFolder.Where(x => x.Release != release)) { modified++; Console.WriteLine($"╟ Setting Release to [{ release }], was [{ metaData.Release }] on file [{ metaData.FileInfo.Name}"); metaData.Release = release; if (!Configuration.Inspector.IsInReadOnlyMode) { TagsHelper.WriteTags(metaData, metaData.Filename); } } data = $"Found [{ found }] files, Modified [{ modified }] files"; } result.Data = data; result.IsSuccess = true; return(result); }
public PageDataCollection GetPagesByTag(Tag tag) { if (tag == null) { return(null); } var pageLinks = new List <Guid>(); if (tag.PermanentLinks == null) { var tempTerm = this._tagService.GetTagByName(tag.Name); if (tempTerm != null) { pageLinks = tempTerm.PermanentLinks.ToList(); } } else { pageLinks = tag.PermanentLinks.ToList(); } var pages = new PageDataCollection(); foreach (Guid pageGuid in pageLinks) { pages.Add(this._contentLoader.Get <PageData>(TagsHelper.GetContentReference(pageGuid))); } return(pages); }
public IEnumerable <ContentReference> GetContentReferencesByTags(IEnumerable <Tag> tags) { var matches = new Dictionary <ContentReference, int>(); foreach (var tag in tags) { if (tag?.PermanentLinks == null) { continue; } foreach (var contentGuid in tag.PermanentLinks) { var contentReference = TagsHelper.GetContentReference(contentGuid); if (matches.ContainsKey(contentReference)) { matches[contentReference] += 1; } else { matches.Add(contentReference, 1); } } } matches = matches.OrderByDescending(t => t.Value).ToDictionary(pair => pair.Key, pair => pair.Value); return(matches.Keys); }
public PageDataCollection GetPagesByTag(Tag tag, PageReference rootPageReference) { if (tag == null || tag.PermanentLinks == null) { return(null); } IList <PageReference> descendantPageReferences = DataFactory.Instance.GetDescendents(rootPageReference); if (descendantPageReferences == null || descendantPageReferences.Count < 1) { return(null); } var pages = new PageDataCollection(); foreach (Guid pageGuid in tag.PermanentLinks) { var pageReference = TagsHelper.GetContentReference(pageGuid); if (descendantPageReferences.FirstOrDefault(p => p.ID == pageReference.ID) != null) { pages.Add(this._contentLoader.Get <PageData>(pageReference)); } } return(pages); }
/// <summary> /// Lists resources in a type collection. /// </summary> private async Task <ResponseWithContinuation <JObject[]> > ListResourcesTypeCollection() { var resourceCollectionId = ResourceIdUtility.GetResourceId( subscriptionId: this.SubscriptionId.AsArray().CoalesceEnumerable().Cast <Guid?>().FirstOrDefault(), resourceGroupName: null, resourceType: this.ResourceType, resourceName: null, extensionResourceType: this.ExtensionResourceType, extensionResourceName: null); var odataQuery = QueryFilterBuilder.CreateFilter( subscriptionId: null, resourceGroup: this.ResourceGroupNameEquals, resourceType: null, resourceName: this.ResourceNameEquals, tagName: TagsHelper.GetTagNameFromParameters(this.Tag, this.TagName), tagValue: TagsHelper.GetTagValueFromParameters(this.Tag, this.TagValue), filter: this.ODataQuery, resourceGroupNameContains: this.ResourceGroupNameContains, nameContains: this.ResourceNameContains); return(await this .GetResourcesClient() .ListObjectColleciton <JObject>( resourceCollectionId: resourceCollectionId, apiVersion: this.DefaultApiVersion, cancellationToken: this.CancellationToken.Value, odataQuery: odataQuery) .ConfigureAwait(continueOnCapturedContext: false)); }
private void CheckContentProperties(IContent content, IList <Tag> tags) { var contentType = _contentTypeRepository.Load(content.ContentTypeID); foreach (var propertyDefinition in contentType.PropertyDefinitions) { if (!TagsHelper.IsTagProperty(propertyDefinition)) { continue; } var tagNames = GetTagNames(content, propertyDefinition); var allTags = tags; if (tagNames == null) { RemoveFromAllTags(content.ContentGuid, allTags); continue; } var addedTags = ParseTags(tagNames); // make sure the tags it has added has the ContentReference ValidateTags(allTags, content.ContentGuid, addedTags); // make sure there's no ContentReference to this ContentReference in the rest of the tags RemoveFromAllTags(content.ContentGuid, allTags); } }
protected override void OnProcessRecord() { string whatIfMessage = this.ShouldExecuteWhatIf() ? this.ExecuteWhatIf() : null; string warningMessage = $"{Environment.NewLine}{ProjectResources.ConfirmDeploymentMessage}"; string captionMessage = $"{(char)27}[1A{Color.Reset}{whatIfMessage}"; // {(char)27}[1A for cursor up. if (ShouldProcess(whatIfMessage, warningMessage, captionMessage)) { var parameters = new PSDeploymentCmdletParameters() { ScopeType = DeploymentScopeType.Subscription, Location = Location, DeploymentName = Name, DeploymentMode = DeploymentMode.Incremental, TemplateFile = TemplateUri ?? this.TryResolvePath(TemplateFile), TemplateObject = TemplateObject, TemplateParameterObject = GetTemplateParameterObject(TemplateParameterObject), ParameterUri = TemplateParameterUri, DeploymentDebugLogLevel = GetDeploymentDebugLogLevel(DeploymentDebugLogLevel), Tags = TagsHelper.ConvertToTagsDictionary(Tag) }; if (!string.IsNullOrEmpty(parameters.DeploymentDebugLogLevel)) { WriteWarning(ProjectResources.WarnOnDeploymentDebugSetting); } WriteObject(ResourceManagerSdkClient.ExecuteDeployment(parameters)); } }
/// <summary> /// Constructs the resource /// </summary> private JToken GetResource() { var applicationDefinitionObject = new ApplicationDefinition { Name = this.Name, Location = this.Location, Properties = new ApplicationDefinitionProperties { LockLevel = this.LockLevel, Description = this.Description, DisplayName = this.DisplayName, PackageFileUri = this.PackageFileUri ?? null, Authorizations = JArray.Parse(this.GetAuthorizationObject(this.Authorization).ToString()).ToJson().FromJson <ApplicationProviderAuthorization[]>() }, Tags = TagsHelper.GetTagsDictionary(this.Tag) }; if (!string.IsNullOrEmpty(this.MainTemplate) && !string.IsNullOrEmpty(this.CreateUiDefinition)) { applicationDefinitionObject.Properties.MainTemplate = JObject.Parse(this.GetObjectFromParameter(this.MainTemplate).ToString()); applicationDefinitionObject.Properties.CreateUiDefinition = JObject.Parse(this.GetObjectFromParameter(this.CreateUiDefinition).ToString()); } return(applicationDefinitionObject.ToJToken()); }