static void AutoFillProperties(IContentBase model) { var mediaFileSystem = FileSystemProviderManager.Current.GetFileSystemProvider<MediaFileSystem>(); foreach (var p in model.Properties) { var uploadFieldConfigNode = UmbracoConfig.For.UmbracoSettings().Content.ImageAutoFillProperties .FirstOrDefault(x => x.Alias == p.Alias); if (uploadFieldConfigNode != null) { //now we need to check if there is a value if (p.Value is string && ((string) p.Value).IsNullOrWhiteSpace() == false) { //there might be multiple, we can only process the first one! var split = ((string) p.Value).Split(new[] {','}, StringSplitOptions.RemoveEmptyEntries); if (split.Any()) { var fullPath = mediaFileSystem.GetFullPath(mediaFileSystem.GetRelativePath(split[0])); var umbracoFile = new UmbracoMediaFile(fullPath); FillProperties(uploadFieldConfigNode, model, umbracoFile); } } else { //there's no value so need to reset to zero ResetProperties(uploadFieldConfigNode, model); } } } }
protected internal Content(IContentBase contentBase) : base(contentBase) { ContentBase = contentBase; _version = ContentBase.Version; _versionDate = ContentBase.UpdateDate; _versionDateInitialized = true; }
private static string GetUrlSegmentSource(IContentBase content) { string source = null; if (content.HasProperty(Constants.Conventions.Content.UrlName)) source = (content.GetValue<string>(Constants.Conventions.Content.UrlName) ?? string.Empty).Trim(); if (string.IsNullOrWhiteSpace(source)) source = content.Name; return source; }
public Member(string name, string email, string username, string password, IContentBase parent, IMemberType contentType) : base(name, parent, contentType, new PropertyCollection()) { Mandate.ParameterNotNull(contentType, "contentType"); _contentType = contentType; _email = email; _username = username; _password = password; }
public string GetUrlSegment(IContentBase content) { if (!content.HasProperty(PropertyName)) return null; try { var metadata = JsonConvert.DeserializeObject<SeoMetadata>(content.GetValue<string>(PropertyName)); if (metadata == null || String.IsNullOrWhiteSpace(metadata.UrlName)) return null; return metadata.UrlName.ToUrlSegment(); } catch { return null; } }
/// <summary> /// export the basics of content items, the stuff shared by both /// Content Items and Media Items /// </summary> /// <param name="type">the doctype or mediatype name</param> /// <param name="item">the item it's self</param> /// <param name="mapProps">are we mapping the ids?</param> /// <returns></returns> public static XElement ExportContentBase(string type, IContentBase item, bool mapProps = true) { XElement xml = new XElement(type); Guid _guid = ImportPairs.GetSourceGuid(item.Key); xml.Add(new XAttribute("guid", _guid)); xml.Add(new XAttribute("id", item.Id)); xml.Add(new XAttribute("nodeName", item.Name)); xml.Add(new XAttribute("isDoc", "")); xml.Add(new XAttribute("updated", item.UpdateDate)); LogHelper.Debug<uSyncXmlHelper>(">> Starting property loop"); foreach (var property in item.Properties.Where(p => p != null)) { LogHelper.Debug<uSyncXmlHelper>("Property: {0}", () => property.Alias); XElement propXml = null; try { propXml = property.ToXml(); } // if it can't be serialized catch { propXml = new XElement(property.Alias, string.Empty); } string xmlVal = ""; if (mapProps) { xmlVal = ReplaceIdsWithGuid(GetInnerXML(propXml)); } else { xmlVal = GetInnerXML(propXml); } XElement p = XElement.Parse(string.Format("<{0}>{1}</{0}>", propXml.Name.ToString(), xmlVal), LoadOptions.PreserveWhitespace); LogHelper.Debug<uSyncXmlHelper>("Parse {0}", () => p.ToString()); xml.Add(p); } LogHelper.Debug<uSyncXmlHelper>("<< finished property loop"); return xml; }
public string GetUrlSegment(IContentBase content) { if (content != null) { var contentType = Services.ContentTypeService.GetContentType(content.ContentTypeId); if (contentType != null && contentType.Alias == "Vacancyitem") { //This will add the level before the node name. //For example /developer/ becomes /junior-developer/ var level = content.GetValue<VacancyLevel>("level"); return level.ToString().ToUrlSegment() + "-" + content.Name.ToUrlSegment(); } } return null; }
/// <summary> /// Make sure the isApproved and isLockedOut fields are setup properly in the index /// </summary> /// <param name="e"></param> /// <param name="node"></param> /// <remarks> /// these fields are not consistently updated in the XML fragment when a member is saved (as they may never get set) so we have to do this. /// </remarks> private void EnsureMembershipFlags(IndexingNodeDataEventArgs e, IContentBase node) { Func<string, bool> valueExists = fieldName => { return e.Node.Nodes().Any(n => n is XElement ? (n as XElement).Name == fieldName : false); }; if (!valueExists(Constants.Conventions.Member.IsLockedOut) || !valueExists(Constants.Conventions.Member.IsLockedOut)) { // We need to augment from the database. var member = ApplicationContext.Current.Services.MemberService.GetById(e.NodeId); if (!e.Fields.ContainsKey(Constants.Conventions.Member.IsLockedOut) && !valueExists(Constants.Conventions.Member.IsLockedOut)) { e.Fields.Add(Constants.Conventions.Member.IsLockedOut, member.IsLockedOut.ToString().ToLower()); } if (!e.Fields.ContainsKey(Constants.Conventions.Member.IsApproved) && !valueExists(Constants.Conventions.Member.IsApproved)) { e.Fields.Add(Constants.Conventions.Member.IsApproved, member.IsApproved.ToString().ToLower()); } } }
public static void SetPropertyTags(IContentBase content, Property property, object convertedPropertyValue, string delimiter, bool replaceTags, string tagGroup, TagValueType valueType) { if (convertedPropertyValue == null) { convertedPropertyValue = ""; } switch (valueType) { case TagValueType.FromDelimitedValue: var tags = convertedPropertyValue.ToString().Split(new[] { delimiter }, StringSplitOptions.RemoveEmptyEntries); content.SetTags(property.Alias, tags, replaceTags, tagGroup); break; case TagValueType.CustomTagList: //for this to work the object value must be IENumerable<string> var stringList = convertedPropertyValue as IEnumerable<string>; if (stringList != null) { content.SetTags(property.Alias, stringList, replaceTags, tagGroup); } break; } }
/// <summary> /// Sets the tag values on the content property based on the property editor's tags attribute /// </summary> /// <param name="content"></param> /// <param name="property"></param> /// <param name="propertyData"></param> /// <param name="convertedPropertyValue"></param> /// <param name="attribute"></param> public static void SetPropertyTags(IContentBase content, Property property, ContentPropertyData propertyData, object convertedPropertyValue, SupportTagsAttribute attribute) { //check for a custom definition if (attribute.TagPropertyDefinitionType != null) { //try to create it TagPropertyDefinition def; try { def = (TagPropertyDefinition) Activator.CreateInstance(attribute.TagPropertyDefinitionType, propertyData, attribute); } catch (Exception ex) { LogHelper.Error<TagExtractor>("Could not create custom " + attribute.TagPropertyDefinitionType + " tag definition", ex); throw; } SetPropertyTags(content, property, convertedPropertyValue, def.Delimiter, def.ReplaceTags, def.TagGroup, attribute.ValueType); } else { SetPropertyTags(content, property, convertedPropertyValue, attribute.Delimiter, attribute.ReplaceTags, attribute.TagGroup, attribute.ValueType); } }
/// <summary>Static getter for Page Title</summary> public static string GetPageTitle(IContentBase that) { return(that.GetPropertyValue <string>("pageTitle")); }
private static void SetFileOnContent(IContentBase content, string propertyTypeAlias, string name, Stream fileStream) { var property = content.Properties.FirstOrDefault(x => x.Alias == propertyTypeAlias); if (property == null) return; var numberedFolder = MediaSubfolderCounter.Current.Increment(); var fileName = UmbracoSettings.UploadAllowDirectories ? Path.Combine(numberedFolder.ToString(CultureInfo.InvariantCulture), name) : numberedFolder + "-" + name; var extension = Path.GetExtension(name).Substring(1).ToLowerInvariant(); //the file size is the length of the stream in bytes var fileSize = fileStream.Length; var fs = FileSystemProviderManager.Current.GetFileSystemProvider<MediaFileSystem>(); fs.AddFile(fileName, fileStream); //Check if file supports resizing and create thumbnails var supportsResizing = ("," + UmbracoSettings.ImageFileTypes + ",").Contains(string.Format(",{0},", extension)); //the config section used to auto-fill properties XmlNode uploadFieldConfigNode = null; //Check for auto fill of additional properties if (UmbracoSettings.ImageAutoFillImageProperties != null) { uploadFieldConfigNode = UmbracoSettings.ImageAutoFillImageProperties.SelectSingleNode( string.Format("uploadField [@alias = \"{0}\"]", propertyTypeAlias)); } if (supportsResizing) { //get the original image from the original stream if (fileStream.CanSeek) fileStream.Seek(0, 0); using (var originalImage = Image.FromStream(fileStream)) { // Make default thumbnail Resize(fs, fileName, extension, 100, "thumb", originalImage); //Look up Prevalues for this upload datatype - if it is an upload datatype var uploadFieldId = new Guid(Constants.PropertyEditors.UploadField); if (property.PropertyType.DataTypeId == uploadFieldId) { //Get Prevalues by the DataType's Id: property.PropertyType.DataTypeId var values = ApplicationContext.Current.Services.DataTypeService.GetPreValuesByDataTypeId(property.PropertyType.DataTypeDefinitionId); var thumbnailSizes = values.FirstOrDefault(); //Additional thumbnails configured as prevalues on the DataType if (thumbnailSizes != null) { char sep = (!thumbnailSizes.Contains("") && thumbnailSizes.Contains(",")) ? ',' : ';'; foreach (var thumb in thumbnailSizes.Split(sep)) { int thumbSize; if (thumb != "" && int.TryParse(thumb, out thumbSize)) { Resize(fs, fileName, extension, thumbSize, string.Format("thumb_{0}", thumbSize), originalImage); } } } } //while the image is still open, we'll check if we need to auto-populate the image properties if (uploadFieldConfigNode != null) { SetPropertyValue(content, uploadFieldConfigNode, "widthFieldAlias", originalImage.Width.ToString(CultureInfo.InvariantCulture)); SetPropertyValue(content, uploadFieldConfigNode, "heightFieldAlias", originalImage.Height.ToString(CultureInfo.InvariantCulture)); } } } //if auto-fill is true, then fill the remaining, non-image properties if (uploadFieldConfigNode != null) { SetPropertyValue(content, uploadFieldConfigNode, "lengthFieldAlias", fileSize.ToString(CultureInfo.InvariantCulture)); SetPropertyValue(content, uploadFieldConfigNode, "extensionFieldAlias", extension); } //Set the value of the property to that of the uploaded file's url property.Value = fs.GetUrl(fileName); }
/// <summary> /// Returns the children for the content base item /// </summary> /// <param name="content"></param> /// <param name="services"></param> /// <returns></returns> /// <remarks> /// This is a bit of a hack because we need to type check! /// </remarks> internal static IEnumerable<IContentBase> Children(IContentBase content, ServiceContext services) { if (content is IContent) { return services.ContentService.GetChildren(content.Id); } if (content is IMedia) { return services.MediaService.GetChildren(content.Id); } return null; }
private static dynamic GetGrid(IContentBase content) => content.Properties.Contains("grid") ? content.Properties["grid"]?.Value?.ToString().Deserialize <dynamic>() : null;
public static IEnumerable <string> GetDirtyUserProperties(this IContentBase entity) { return(entity.Properties.Where(x => x.IsDirty()).Select(x => x.Alias)); }
/// <summary> /// Gets the <see cref="IProfile"/> for the Creator of this content item. /// </summary> public static IProfile GetCreatorProfile(this IContentBase content, IUserService userService) { return(userService.GetProfileById(content.CreatorId)); }
private static void SetFileOnContent(IContentBase content, string propertyTypeAlias, string name, Stream fileStream) { var property = content.Properties.FirstOrDefault(x => x.Alias == propertyTypeAlias); if (property == null) return; bool supportsResizing = false; var numberedFolder = MediaSubfolderCounter.Current.Increment(); string fileName = UmbracoSettings.UploadAllowDirectories ? Path.Combine(numberedFolder.ToString(CultureInfo.InvariantCulture), name) : numberedFolder + "-" + name; string extension = Path.GetExtension(name).Substring(1).ToLowerInvariant(); var fs = FileSystemProviderManager.Current.GetFileSystemProvider<MediaFileSystem>(); fs.AddFile(fileName, fileStream); //Check if file supports resizing and create thumbnails if (("," + UmbracoSettings.ImageFileTypes + ",").Contains(string.Format(",{0},", extension))) { supportsResizing = true; // Make default thumbnail var thumbUrl = Resize(fs, fileName, extension, 100, "thumb"); //Look up Prevalues for this upload datatype - if it is an upload datatype var uploadFieldId = new Guid("5032a6e6-69e3-491d-bb28-cd31cd11086c"); if (property.PropertyType.DataTypeId == uploadFieldId) { //Get Prevalues by the DataType's Id: property.PropertyType.DataTypeId var values = ApplicationContext.Current.Services.DataTypeService.GetPreValuesByDataTypeId(property.PropertyType.DataTypeDefinitionId); var thumbnailSizes = values.FirstOrDefault(); //Additional thumbnails configured as prevalues on the DataType if (thumbnailSizes != null) { char sep = (!thumbnailSizes.Contains("") && thumbnailSizes.Contains(",")) ? ',' : ';'; foreach (string thumb in thumbnailSizes.Split(sep)) { int thumbSize; if (thumb != "" && int.TryParse(thumb, out thumbSize)) { Resize(fs, fileName, extension, thumbSize, string.Format("thumb_{0}", thumbSize)); } } } } } //Check for auto fill of additional properties if (UmbracoSettings.ImageAutoFillImageProperties != null) { XmlNode uploadFieldConfigNode = UmbracoSettings.ImageAutoFillImageProperties.SelectSingleNode( string.Format("uploadField [@alias = \"{0}\"]", propertyTypeAlias)); if (uploadFieldConfigNode != null) { //Only add dimensions to web images if (supportsResizing) { SetPropertyValue(content, uploadFieldConfigNode, "widthFieldAlias", GetDimensions(fs, fileName).Item1.ToString(CultureInfo.InvariantCulture)); SetPropertyValue(content, uploadFieldConfigNode, "heightFieldAlias", GetDimensions(fs, fileName).Item2.ToString(CultureInfo.InvariantCulture)); } else { SetPropertyValue(content, uploadFieldConfigNode, "widthFieldAlias", string.Empty); SetPropertyValue(content, uploadFieldConfigNode, "heightFieldAlias", string.Empty); } SetPropertyValue(content, uploadFieldConfigNode, "lengthFieldAlias", fs.GetSize(fileName).ToString(CultureInfo.InvariantCulture)); SetPropertyValue(content, uploadFieldConfigNode, "extensionFieldAlias", extension); } } //Set the value of the property to that of the uploaded file's url property.Value = fs.GetUrl(fileName); }
/// <summary> /// Part of the export of IContent and IMedia which is shared /// </summary> /// <param name="contentBase">Base Content or Media to export</param> /// <param name="nodeName">Name of the node</param> /// <returns><see cref="XElement"/></returns> private XElement Export(IContentBase contentBase, string nodeName) { //NOTE: that one will take care of umbracoUrlName var url = contentBase.GetUrlSegment(); var xml = new XElement(nodeName, new XAttribute("id", contentBase.Id), new XAttribute("parentID", contentBase.Level > 1 ? contentBase.ParentId : -1), new XAttribute("level", contentBase.Level), new XAttribute("creatorID", contentBase.CreatorId), new XAttribute("sortOrder", contentBase.SortOrder), new XAttribute("createDate", contentBase.CreateDate.ToString("s")), new XAttribute("updateDate", contentBase.UpdateDate.ToString("s")), new XAttribute("nodeName", contentBase.Name), new XAttribute("urlName", url), new XAttribute("path", contentBase.Path), new XAttribute("isDoc", "")); foreach (var property in contentBase.Properties.Where(p => p != null)) xml.Add(property.ToXml()); return xml; }
/// <summary> /// Remove tags. /// </summary> /// <param name="content">The content item.</param> /// <param name="propertyTypeAlias">The property alias.</param> /// <param name="tags">The tags.</param> /// <param name="culture">A culture, for multi-lingual properties.</param> public static void RemoveTags(this IContentBase content, string propertyTypeAlias, IEnumerable <string> tags, string culture = null) { content.GetTagProperty(propertyTypeAlias).RemoveTags(tags, culture); }
public string GetUrlSegment(IContentBase content, CultureInfo culture) { return GetUrlSegment(content); }
/// <summary> /// Gets the default url segment for a specified content. /// </summary> /// <param name="content">The content.</param> /// <returns>The url segment.</returns> public string GetUrlSegment(IContentBase content) { return GetUrlSegmentSource(content).ToUrlSegment(); }
public static void ArchiveFile(string path, IContentBase node, bool media = false) { LogHelper.Debug<FileHelper>("Archiving. {0} {1}", ()=> path, ()=> node.Name); string _root = _mappedRoot; string _ext = ".content"; if (media) { LogHelper.Debug<FileHelper>("Archiving a Media Item"); _root = _mappedMediaRoot; _ext = ".media"; } string filename = string.Format("{0}{1}", CleanFileName(node.Name), _ext); string fullpath = Path.Combine(string.Format("{0}{1}", _root, path), filename); if ( System.IO.File.Exists(fullpath) ) { if ( uSyncContentSettings.Versions ) { string archiveFolder = Path.Combine(string.Format("{0}{1}", _mappedArchive, path)); if (!Directory.Exists(archiveFolder)) Directory.CreateDirectory(archiveFolder); string archiveFile = Path.Combine(archiveFolder, string.Format("{0}_{1}{2}", CleanFileName(node.Name), DateTime.Now.ToString("ddMMyy_HHmmss"),_ext)); System.IO.File.Copy(fullpath, archiveFile); } System.IO.File.Delete(fullpath); } }
public static void RenameFile(string path, IContentBase node, string oldName) { LogHelper.Info<FileHelper>("Rename {0} {1} {2}", () => path, ()=> oldName, ()=> node.GetType().Name); string _root = _mappedRoot ; string _ext = ".content"; if (node.GetType() == typeof(Media)) { LogHelper.Info<FileHelper>("Renaming a Media Item"); _root = _mappedMediaRoot; _ext = ".media"; } string folderRoot = String.Format("{0}{1}", _root, path); string oldFile = Path.Combine(folderRoot, String.Format("{0}{1}", CleanFileName(oldName), _ext)); if (System.IO.File.Exists(oldFile)) System.IO.File.Delete(oldFile); string oldFolder = Path.Combine(folderRoot, CleanFileName(oldName)); string newFolder = Path.Combine(folderRoot, CleanFileName(node.Name)); if (Directory.Exists(oldFolder)) Directory.Move(oldFolder, newFolder); }
private ReadOnlyContentBaseAdapter(IContentBase content) { _content = content ?? throw new ArgumentNullException(nameof(content)); }
public string GetUrlSegment(IContentBase content, System.Globalization.CultureInfo culture) { return GetUrlSegment(content); }
/// <summary> /// This removes associated tags from the entity - used generally when an entity is recycled /// </summary> /// <param name="entity"></param> /// <param name="tagRepo"></param> protected void ClearEntityTags(IContentBase entity, ITagRepository tagRepo) { tagRepo.ClearTagsFromEntity(entity.Id); }
protected override IEnumerable <ContentPropertyDisplay> GetCustomGenericProperties(IContentBase content) { var member = (IMember)content; var membersProvider = Core.Security.MembershipProviderExtensions.GetMembersMembershipProvider(); var genericProperties = new List <ContentPropertyDisplay> { new ContentPropertyDisplay { Alias = $"{Constants.PropertyEditors.InternalGenericPropertiesPrefix}id", Label = _localizedTextService.Localize("general/id"), Value = new List <string> { member.Id.ToString(), member.Key.ToString() }, View = "idwithguid" }, new ContentPropertyDisplay { Alias = $"{Constants.PropertyEditors.InternalGenericPropertiesPrefix}doctype", Label = _localizedTextService.Localize("content/membertype"), Value = _localizedTextService.UmbracoDictionaryTranslate(member.ContentType.Name), View = Current.PropertyEditors[Constants.PropertyEditors.Aliases.Label].GetValueEditor().View }, GetLoginProperty(_memberService, member, _localizedTextService), new ContentPropertyDisplay { Alias = $"{Constants.PropertyEditors.InternalGenericPropertiesPrefix}email", Label = _localizedTextService.Localize("general/email"), Value = member.Email, View = "email", Validation = { Mandatory = true } }, new ContentPropertyDisplay { Alias = $"{Constants.PropertyEditors.InternalGenericPropertiesPrefix}password", Label = _localizedTextService.Localize("password"), // NOTE: The value here is a json value - but the only property we care about is the generatedPassword one if it exists, the newPassword exists // only when creating a new member and we want to have a generated password pre-filled. Value = new Dictionary <string, object> { // TODO: why ignoreCase, what are we doing here?! { "generatedPassword", member.GetAdditionalDataValueIgnoreCase("GeneratedPassword", null) }, { "newPassword", member.GetAdditionalDataValueIgnoreCase("NewPassword", null) }, }, // TODO: Hard coding this because the changepassword doesn't necessarily need to be a resolvable (real) property editor View = "changepassword", // initialize the dictionary with the configuration from the default membership provider Config = new Dictionary <string, object>(membersProvider.GetConfiguration(_userService)) { // the password change toggle will only be displayed if there is already a password assigned. { "hasPassword", member.RawPasswordValue.IsNullOrWhiteSpace() == false } } }, new ContentPropertyDisplay { Alias = $"{Constants.PropertyEditors.InternalGenericPropertiesPrefix}membergroup", Label = _localizedTextService.Localize("content/membergroup"), Value = GetMemberGroupValue(member.Username), View = "membergroups", Config = new Dictionary <string, object> { { "IsRequired", true } } } }; return(genericProperties); }
private static void SetFileOnContent(IContentBase content, string propertyTypeAlias, string filename, Stream fileStream) { var property = content.Properties.FirstOrDefault(x => x.Alias == propertyTypeAlias); if (property == null) return; //TODO: ALl of this naming logic needs to be put into the ImageHelper and then we need to change FileUploadPropertyValueEditor to do the same! var numberedFolder = MediaSubfolderCounter.Current.Increment(); var fileName = UmbracoConfig.For.UmbracoSettings().Content.UploadAllowDirectories ? Path.Combine(numberedFolder.ToString(CultureInfo.InvariantCulture), filename) : numberedFolder + "-" + filename; var extension = Path.GetExtension(filename).Substring(1).ToLowerInvariant(); //the file size is the length of the stream in bytes var fileSize = fileStream.Length; var fs = FileSystemProviderManager.Current.GetFileSystemProvider<MediaFileSystem>(); fs.AddFile(fileName, fileStream); //Check if file supports resizing and create thumbnails var supportsResizing = UmbracoConfig.For.UmbracoSettings().Content.ImageFileTypes.InvariantContains(extension); //the config section used to auto-fill properties IImagingAutoFillUploadField uploadFieldConfigNode = null; //Check for auto fill of additional properties if (UmbracoConfig.For.UmbracoSettings().Content.ImageAutoFillProperties != null) { uploadFieldConfigNode = UmbracoConfig.For.UmbracoSettings().Content.ImageAutoFillProperties .FirstOrDefault(x => x.Alias == propertyTypeAlias); } if (supportsResizing) { //get the original image from the original stream if (fileStream.CanSeek) fileStream.Seek(0, 0); using (var originalImage = Image.FromStream(fileStream)) { var additionalSizes = new List<int>(); //Look up Prevalues for this upload datatype - if it is an upload datatype - get additional configured sizes if (property.PropertyType.PropertyEditorAlias == Constants.PropertyEditors.UploadFieldAlias) { //Get Prevalues by the DataType's Id: property.PropertyType.DataTypeId var values = ApplicationContext.Current.Services.DataTypeService.GetPreValuesByDataTypeId(property.PropertyType.DataTypeDefinitionId); var thumbnailSizes = values.FirstOrDefault(); //Additional thumbnails configured as prevalues on the DataType if (thumbnailSizes != null) { var sep = (thumbnailSizes.Contains("") == false && thumbnailSizes.Contains(",")) ? ',' : ';'; foreach (var thumb in thumbnailSizes.Split(sep)) { int thumbSize; if (thumb != "" && int.TryParse(thumb, out thumbSize)) { additionalSizes.Add(thumbSize); } } } } ImageHelper.GenerateMediaThumbnails(fs, fileName, extension, originalImage, additionalSizes); //while the image is still open, we'll check if we need to auto-populate the image properties if (uploadFieldConfigNode != null) { content.SetValue(uploadFieldConfigNode.WidthFieldAlias, originalImage.Width.ToString(CultureInfo.InvariantCulture)); content.SetValue(uploadFieldConfigNode.HeightFieldAlias, originalImage.Height.ToString(CultureInfo.InvariantCulture)); } } } //if auto-fill is true, then fill the remaining, non-image properties if (uploadFieldConfigNode != null) { content.SetValue(uploadFieldConfigNode.LengthFieldAlias, fileSize.ToString(CultureInfo.InvariantCulture)); content.SetValue(uploadFieldConfigNode.ExtensionFieldAlias, extension); } //Set the value of the property to that of the uploaded file's url property.Value = fs.GetUrl(fileName); }
public static string GetPageTitle(IContentBase that) => that.Value <string>("pageTitle");
/// <summary> /// Returns properties that do not belong to a group /// </summary> /// <param name="content"></param> /// <returns></returns> public static IEnumerable <IProperty> GetNonGroupedProperties(this IContentBase content) { return(content.Properties .Where(x => x.PropertyType.PropertyGroupId == null) .OrderBy(x => x.PropertyType.SortOrder)); }
/// <summary> /// Returns a collection of custom generic properties that exist on the generic properties tab /// </summary> /// <returns></returns> protected virtual IEnumerable <ContentPropertyDisplay> GetCustomGenericProperties(IContentBase content) => Enumerable.Empty <ContentPropertyDisplay>();
public static bool WasAnyUserPropertyDirty(this IContentBase entity) { return(entity.Properties.Any(x => x.WasDirty())); }
/// <summary> /// Gets the URL segment for a specified content and culture. /// </summary> /// <param name="content">The content.</param> /// <param name="culture">The culture.</param> /// <returns>The URL segment.</returns> public string GetUrlSegment(IContentBase content, string culture = null) { return(GetUrlSegmentSource(content, culture).ToUrlSegment(_shortStringHelper, culture)); }
private static string contentReplace(string content, IContentBase entity) { var ptypes = entity.PropertyTypes; string contenttypename = ApplicationContext.Current.Services.EntityService.Get(entity.ContentTypeId, true).Name; foreach (var ptype in ptypes) { PreValueCollection coll = ApplicationContext.Current.Services.DataTypeService.GetPreValuesCollectionByDataTypeId(ptype.DataTypeDefinitionId); if (coll.PreValuesAsDictionary.Count == 0) { string value = entity.GetValue<string>(ptype.Alias); content = content.Replace("{{" + contenttypename + "." + ptype.Alias + "}}", entity.GetValue<string>(ptype.Alias)); } else { foreach (var item in coll.PreValuesAsDictionary) { var kk = entity.GetValue<int>(ptype.Alias); if (item.Value.Id.Equals(entity.GetValue<int>(ptype.Alias))) { string strval = item.Value.Value; content = content.Replace("{{" + contenttypename + "." + ptype.Alias + "}}", strval); } } } } return content; }
/// <summary> /// Checks if the IContentBase has children /// </summary> /// <param name="content"></param> /// <param name="services"></param> /// <returns></returns> /// <remarks> /// This is a bit of a hack because we need to type check! /// </remarks> internal static bool HasChildren(IContentBase content, ServiceContext services) { if (content is IContent) { return services.ContentService.HasChildren(content.Id); } if (content is IMedia) { return services.MediaService.HasChildren(content.Id); } return false; }
public static Newtonsoft.Json.Linq.JToken GetBodyText(IContentBase that) => that.Value <Newtonsoft.Json.Linq.JToken>("bodyText");
private bool ValidAction(IContentBase cmsNode, char actionLetter) { var currentAction = BusinessLogic.Actions.Action.GetPermissionAssignable().First(a => a.Letter == actionLetter); return CheckPermissions(cmsNode, currentAction); }
/// <summary>Static getter for Nested Content</summary> public static IEnumerable <IPublishedContent> GetNestedContent(IContentBase that) { return(that.GetPropertyValue <IEnumerable <IPublishedContent> >("nestedContent")); }
/// <summary> /// Checks if the current user has permissions to execute this action against this node /// </summary> /// <param name="node"></param> /// <param name="currentAction"></param> /// <returns></returns> /// <remarks> /// This used to do a recursive check for all descendent nodes but this is not required and is a massive CPU hog. /// See: http://issues.umbraco.org/issue/U4-2632, https://groups.google.com/forum/?fromgroups=#!topic/umbraco-dev/L1D4LwVSP2Y /// </remarks> private bool CheckPermissions(IContentBase node, IAction currentAction) { var currUserPermissions = new UserPermissions(CurrentUser); var lstCurrUserActions = currUserPermissions.GetExistingNodePermission(node.Id); return lstCurrUserActions.Contains(currentAction); }
/// <summary> /// Maps a list of <see cref="Property" /> to a list of <see cref="ContentPropertyDisplay" /> /// </summary> /// <param name="content"></param> /// <param name="properties"></param> /// <param name="context"></param> /// <returns></returns> protected virtual List <ContentPropertyDisplay> MapProperties(IContentBase content, List <IProperty> properties, MapperContext context) => context.MapEnumerable <IProperty, ContentPropertyDisplay>(properties.OrderBy(x => x.PropertyType?.SortOrder)) .WhereNotNull().ToList();
private static void ResetProperties(IImagingAutoFillUploadField uploadFieldConfigNode, IContentBase content) { if (content.Properties.Contains(uploadFieldConfigNode.WidthFieldAlias)) { content.Properties[uploadFieldConfigNode.WidthFieldAlias].Value = string.Empty; } if (content.Properties.Contains(uploadFieldConfigNode.HeightFieldAlias)) { content.Properties[uploadFieldConfigNode.HeightFieldAlias].Value = string.Empty; } if (content.Properties.Contains(uploadFieldConfigNode.LengthFieldAlias)) { content.Properties[uploadFieldConfigNode.LengthFieldAlias].Value = string.Empty; } if (content.Properties.Contains(uploadFieldConfigNode.ExtensionFieldAlias)) { content.Properties[uploadFieldConfigNode.ExtensionFieldAlias].Value = string.Empty; } }
private static void FillProperties(IImagingAutoFillUploadField uploadFieldConfigNode, IContentBase content, UmbracoMediaFile um) { var size = um.SupportsResizing ? (Size?)um.GetDimensions() : null; if (content.Properties.Contains(uploadFieldConfigNode.WidthFieldAlias)) content.Properties[uploadFieldConfigNode.WidthFieldAlias].Value = size.HasValue ? size.Value.Width.ToInvariantString() : string.Empty; if (content.Properties.Contains(uploadFieldConfigNode.HeightFieldAlias)) content.Properties[uploadFieldConfigNode.HeightFieldAlias].Value = size.HasValue ? size.Value.Height.ToInvariantString() : string.Empty; if (content.Properties.Contains(uploadFieldConfigNode.LengthFieldAlias)) content.Properties[uploadFieldConfigNode.LengthFieldAlias].Value = um.Length; if (content.Properties.Contains(uploadFieldConfigNode.ExtensionFieldAlias)) content.Properties[uploadFieldConfigNode.ExtensionFieldAlias].Value = um.Extension; }
private static void FillProperties(IImagingAutoFillUploadField uploadFieldConfigNode, IContentBase content, UmbracoMediaFile um) { if (uploadFieldConfigNode == null) { throw new ArgumentNullException("uploadFieldConfigNode"); } if (content == null) { throw new ArgumentNullException("content"); } if (um == null) { throw new ArgumentNullException("um"); } var size = um.SupportsResizing ? (Size?)um.GetDimensions() : null; if (content.Properties.Contains(uploadFieldConfigNode.WidthFieldAlias)) { content.Properties[uploadFieldConfigNode.WidthFieldAlias].Value = size.HasValue ? size.Value.Width.ToInvariantString() : string.Empty; } if (content.Properties.Contains(uploadFieldConfigNode.HeightFieldAlias)) { content.Properties[uploadFieldConfigNode.HeightFieldAlias].Value = size.HasValue ? size.Value.Height.ToInvariantString() : string.Empty; } if (content.Properties.Contains(uploadFieldConfigNode.LengthFieldAlias)) { content.Properties[uploadFieldConfigNode.LengthFieldAlias].Value = um.Length; } if (content.Properties.Contains(uploadFieldConfigNode.ExtensionFieldAlias)) { content.Properties[uploadFieldConfigNode.ExtensionFieldAlias].Value = um.Extension; } }
private static void ResetProperties(IImagingAutoFillUploadField uploadFieldConfigNode, IContentBase content) { if (content.Properties.Contains(uploadFieldConfigNode.WidthFieldAlias)) content.Properties[uploadFieldConfigNode.WidthFieldAlias].Value = string.Empty; if (content.Properties.Contains(uploadFieldConfigNode.HeightFieldAlias)) content.Properties[uploadFieldConfigNode.HeightFieldAlias].Value = string.Empty; if (content.Properties.Contains(uploadFieldConfigNode.LengthFieldAlias)) content.Properties[uploadFieldConfigNode.LengthFieldAlias].Value = string.Empty; if (content.Properties.Contains(uploadFieldConfigNode.ExtensionFieldAlias)) content.Properties[uploadFieldConfigNode.ExtensionFieldAlias].Value = string.Empty; }
private static void SetFileOnContent(IContentBase content, string propertyTypeAlias, string name, Stream fileStream) { var property = content.Properties.FirstOrDefault(x => x.Alias == propertyTypeAlias); if (property == null) { return; } bool supportsResizing = false; var numberedFolder = MediaSubfolderCounter.Current.Increment(); string fileName = UmbracoSettings.UploadAllowDirectories ? Path.Combine(numberedFolder.ToString(CultureInfo.InvariantCulture), name) : numberedFolder + "-" + name; string extension = Path.GetExtension(name).Substring(1).ToLowerInvariant(); var fs = FileSystemProviderManager.Current.GetFileSystemProvider <MediaFileSystem>(); fs.AddFile(fileName, fileStream); //Check if file supports resizing and create thumbnails if (("," + UmbracoSettings.ImageFileTypes + ",").Contains(string.Format(",{0},", extension))) { supportsResizing = true; // Make default thumbnail var thumbUrl = Resize(fs, fileName, extension, 100, "thumb"); //Look up Prevalues for this upload datatype - if it is an upload datatype var uploadFieldId = new Guid("5032a6e6-69e3-491d-bb28-cd31cd11086c"); if (property.PropertyType.DataTypeId == uploadFieldId) { //Get Prevalues by the DataType's Id: property.PropertyType.DataTypeId var values = ApplicationContext.Current.Services.DataTypeService.GetPreValuesByDataTypeId(property.PropertyType.DataTypeDefinitionId); var thumbnailSizes = values.FirstOrDefault(); //Additional thumbnails configured as prevalues on the DataType if (thumbnailSizes != null) { char sep = (!thumbnailSizes.Contains("") && thumbnailSizes.Contains(",")) ? ',' : ';'; foreach (string thumb in thumbnailSizes.Split(sep)) { int thumbSize; if (thumb != "" && int.TryParse(thumb, out thumbSize)) { Resize(fs, fileName, extension, thumbSize, string.Format("thumb_{0}", thumbSize)); } } } } } //Check for auto fill of additional properties if (UmbracoSettings.ImageAutoFillImageProperties != null) { XmlNode uploadFieldConfigNode = UmbracoSettings.ImageAutoFillImageProperties.SelectSingleNode( string.Format("uploadField [@alias = \"{0}\"]", propertyTypeAlias)); if (uploadFieldConfigNode != null) { //Only add dimensions to web images if (supportsResizing) { SetPropertyValue(content, uploadFieldConfigNode, "widthFieldAlias", GetDimensions(fs, fileName).Item1.ToString(CultureInfo.InvariantCulture)); SetPropertyValue(content, uploadFieldConfigNode, "heightFieldAlias", GetDimensions(fs, fileName).Item2.ToString(CultureInfo.InvariantCulture)); } else { SetPropertyValue(content, uploadFieldConfigNode, "widthFieldAlias", string.Empty); SetPropertyValue(content, uploadFieldConfigNode, "heightFieldAlias", string.Empty); } SetPropertyValue(content, uploadFieldConfigNode, "lengthFieldAlias", fs.GetSize(fileName).ToString(CultureInfo.InvariantCulture)); SetPropertyValue(content, uploadFieldConfigNode, "extensionFieldAlias", extension); } } //Set the value of the property to that of the uploaded file's url property.Value = fs.GetUrl(fileName); }
/// <summary> /// Assign tags. /// </summary> /// <param name="content">The content item.</param> /// <param name="propertyTypeAlias">The property alias.</param> /// <param name="tags">The tags.</param> /// <param name="merge">A value indicating whether to merge the tags with existing tags instead of replacing them.</param> /// <param name="culture">A culture, for multi-lingual properties.</param> public static void AssignTags(this IContentBase content, string propertyTypeAlias, IEnumerable <string> tags, bool merge = false, string culture = null) { content.GetTagProperty(propertyTypeAlias).AssignTags(tags, merge, culture); }
/// <summary> /// Gets the <see cref="IProfile"/> for the Creator of this content/media item. /// </summary> public static IProfile GetCreatorProfile(this IContentBase content) { return(ApplicationContext.Current.Services.UserService.GetProfileById(content.CreatorId)); }
public static ReadOnlyContentBaseAdapter Create(IContentBase content) => new ReadOnlyContentBaseAdapter(content);
public void DeleteContentItem(IContentBase item) => throw new NotImplementedException();
public string GetUrlSegment(IContentBase content, CultureInfo culture) { return(GetUrlSegment(content)); }
/// <summary> /// Overridden to assign the IsSensitive property values /// </summary> /// <param name="umbracoContext"></param> /// <param name="content"></param> /// <param name="properties"></param> /// <returns></returns> protected override List <ContentPropertyDisplay> MapProperties(UmbracoContext umbracoContext, IContentBase content, List <Property> properties) { var result = base.MapProperties(umbracoContext, content, properties); var member = (IMember)content; var memberType = member.ContentType; //now update the IsSensitive value foreach (var prop in result) { //check if this property is flagged as sensitive var isSensitiveProperty = memberType.IsSensitiveProperty(prop.Alias); //check permissions for viewing sensitive data if (isSensitiveProperty && umbracoContext.Security.CurrentUser.HasAccessToSensitiveData() == false) { //mark this property as sensitive prop.IsSensitive = true; //mark this property as readonly so that it does not post any data prop.Readonly = true; //replace this editor with a sensitivevalue prop.View = "sensitivevalue"; //clear the value prop.Value = null; } } return(result); }
public UserProfile GetOwner(IContentBase source, MapperContext context) { var profile = source.GetCreatorProfile(_userService); return(profile == null ? null : context.Map <IProfile, UserProfile>(profile)); }
internal override async Task <DocumentUnit> MappingInsertAsync(IContentBase entity, IIdentityContext identity) { DocumentUnit documentUnit = new DocumentUnit(); try { UDSBuildModel udsBuildModel = (UDSBuildModel)entity; #region [ Base ] documentUnit.EntityId = 0; documentUnit.UniqueId = udsBuildModel.UniqueId; documentUnit.Environment = udsBuildModel.UDSRepository.DSWEnvironment; documentUnit.Year = udsBuildModel.Year.Value; documentUnit.Number = udsBuildModel.Number.Value; documentUnit.RegistrationDate = udsBuildModel.RegistrationDate.Value; documentUnit.RegistrationUser = udsBuildModel.RegistrationUser; documentUnit.LastChangedDate = null; documentUnit.LastChangedUser = null; documentUnit.Subject = udsBuildModel.Subject; documentUnit.Title = string.Concat(udsBuildModel.Year.Value, "/", udsBuildModel.Number.Value.ToString("0000000")); documentUnit.DocumentUnitName = udsBuildModel.Title; documentUnit.Status = DocumentUnitStatus.Active; #endregion #region [ Navigation Properties ] //TODO: Category, Container e Authorizations dovrebbero arrivare già completi di UniqueId. Va modificata l'UDS nella DSW. documentUnit.UDSRepository = MapUDSRepositoryModel(new UDSRepository(), udsBuildModel.UDSRepository); Category category = await _webApiClient.GetCategoryAsync(udsBuildModel.Category.IdCategory.Value); if (category.UniqueId != Guid.Empty) { documentUnit.Category = category; } Container container = await _webApiClient.GetContainerAsync(udsBuildModel.Container.IdContainer.Value); if (container.UniqueId != Guid.Empty) { documentUnit.Container = container; } documentUnit.Fascicle = await _webApiClient.GetFascicleAsync(udsBuildModel.UniqueId); foreach (RoleModel item in udsBuildModel.Roles) { Role role = await _webApiClient.GetRoleAsync(item); documentUnit.DocumentUnitRoles.Add(new DocumentUnitRole() { UniqueIdRole = role.UniqueId, RoleLabel = item.RoleLabel, RegistrationDate = DateTimeOffset.UtcNow, RegistrationUser = identity.User, AuthorizationRoleType = GetRoleType(string.Empty) }); } foreach (UserModel item in udsBuildModel.Users) { documentUnit.DocumentUnitUsers.Add(new DocumentUnitUser() { Account = item.Account, RegistrationDate = DateTimeOffset.UtcNow, RegistrationUser = identity.User, AuthorizationType = AuthorizationRoleType.Accounted }); } foreach (UDSDocumentModel document in udsBuildModel.Documents) { switch (document.DocumentType) { case UDSDocumentType.Document: AddUDSDocumentUnitChain(documentUnit, document, ChainType.MainChain, identity); break; case UDSDocumentType.DocumentAttachment: AddUDSDocumentUnitChain(documentUnit, document, ChainType.AttachmentsChain, identity); break; case UDSDocumentType.DocumentAnnexed: AddUDSDocumentUnitChain(documentUnit, document, ChainType.AnnexedChain, identity); break; case UDSDocumentType.DocumentDematerialisation: AddUDSDocumentUnitChain(documentUnit, document, ChainType.DematerialisationChain, identity); break; } } #endregion } catch (Exception ex) { _logger.WriteError(new LogMessage("UDS, MappingInsertAsync Error: "), ex, LogCategories); throw ex; } return(documentUnit); }
/// <summary>Static getter for Content</summary> public static Newtonsoft.Json.Linq.JToken GetBodyText(IContentBase that) { return(that.GetPropertyValue <Newtonsoft.Json.Linq.JToken>("bodyText")); }
internal override async Task <DocumentUnit> MappingUpdateAsync(IContentBase entity, DocumentUnit documentUnit, IIdentityContext identity) { try { UDSBuildModel udsBuildModel = (UDSBuildModel)entity; #region [ Base ] documentUnit.LastChangedDate = udsBuildModel.LastChangedDate; documentUnit.LastChangedUser = udsBuildModel.LastChangedUser; documentUnit.Subject = udsBuildModel.Subject; documentUnit.Title = documentUnit.Title; documentUnit.Status = DocumentUnitStatus.Active; #endregion #region [ Navigation Properties ] Category category = await _webApiClient.GetCategoryAsync(udsBuildModel.Category.IdCategory.Value); if (category.UniqueId != Guid.Empty && documentUnit.Category.UniqueId != udsBuildModel.Category.UniqueId) { documentUnit.Category = category; } Container container = await _webApiClient.GetContainerAsync(udsBuildModel.Container.IdContainer.Value); if (container.UniqueId != Guid.Empty && documentUnit.Container.UniqueId != udsBuildModel.Container.UniqueId) { documentUnit.Container = container; } documentUnit.Fascicle = await _webApiClient.GetFascicleAsync(udsBuildModel.UniqueId); if (udsBuildModel.Roles == null || !udsBuildModel.Roles.Any()) { documentUnit.DocumentUnitRoles.Clear(); } if (udsBuildModel.Roles != null) { IList <Role> roles = new List <Role>(); foreach (RoleModel item in udsBuildModel.Roles) { roles.Add(await _webApiClient.GetRoleAsync(item)); } foreach (Role item in roles.Where(t => !documentUnit.DocumentUnitRoles.Any(x => x.UniqueIdRole == t.UniqueId))) { documentUnit.DocumentUnitRoles.Add(new DocumentUnitRole() { UniqueIdRole = item.UniqueId, RoleLabel = udsBuildModel.Roles.SingleOrDefault(r => r.UniqueId.HasValue ? r.UniqueId.Value.Equals(item.UniqueId) : r.IdRole.Equals(item.EntityShortId))?.RoleLabel, RegistrationDate = DateTimeOffset.UtcNow, RegistrationUser = identity.User, AuthorizationRoleType = GetRoleType(string.Empty) }); } foreach (DocumentUnitRole item in documentUnit.DocumentUnitRoles.Where(t => !roles.Any(x => x.UniqueId == t.UniqueIdRole)).ToList()) { documentUnit.DocumentUnitRoles.Remove(item); } } if (udsBuildModel.Users == null || !udsBuildModel.Users.Any()) { documentUnit.DocumentUnitUsers.Clear(); } if (udsBuildModel.Users != null) { IList <DocumentUnitUser> users = new List <DocumentUnitUser>(); foreach (UserModel item in udsBuildModel.Users) { if (item.Account != null && !documentUnit.DocumentUnitUsers.Where(x => x.Account != item.Account).Any()) { users.Add(new DocumentUnitUser() { Account = item.Account, RegistrationDate = DateTimeOffset.UtcNow, RegistrationUser = identity.User, AuthorizationType = AuthorizationRoleType.Accounted }); } } foreach (DocumentUnitUser item in users.Where(t => !documentUnit.DocumentUnitUsers.Any(x => x.Account == t.Account))) { documentUnit.DocumentUnitUsers.Add(new DocumentUnitUser() { Account = item.Account, RegistrationDate = DateTimeOffset.UtcNow, RegistrationUser = identity.User, AuthorizationType = AuthorizationRoleType.Accounted }); } foreach (DocumentUnitUser item in documentUnit.DocumentUnitUsers.Where(t => !users.Any(x => x.Account == t.Account)).ToList()) { documentUnit.DocumentUnitUsers.Remove(item); } } if (udsBuildModel.Documents.Count == 0) { documentUnit.DocumentUnitChains.Clear(); } if (udsBuildModel.Documents.Count > 0) { //Elimino le chain che non esistono più foreach (DocumentUnitChain item in documentUnit.DocumentUnitChains.Where(t => !udsBuildModel.Documents.Any(x => x.IdChain == t.IdArchiveChain)).ToList()) { documentUnit.DocumentUnitChains.Remove(item); } foreach (UDSDocumentModel document in udsBuildModel.Documents) { switch (document.DocumentType) { case UDSDocumentType.Document: { DocumentUnitChain mainDocument = documentUnit.DocumentUnitChains.Where(t => t.ChainType == ChainType.MainChain).FirstOrDefault(); if (mainDocument != null) { if (document.IdChain != Guid.Empty) { if (mainDocument.IdArchiveChain != document.IdChain || (mainDocument.ChainType == ChainType.MainChain && !mainDocument.DocumentName.Equals(document.DocumentName))) { documentUnit.DocumentUnitChains.Remove(mainDocument); AddUDSDocumentUnitChain(documentUnit, document, ChainType.MainChain, identity); } } else { documentUnit.DocumentUnitChains.Remove(mainDocument); } } else { AddUDSDocumentUnitChain(documentUnit, document, ChainType.MainChain, identity); } break; } case UDSDocumentType.DocumentAttachment: { DocumentUnitChain attachment = documentUnit.DocumentUnitChains.Where(t => t.ChainType == ChainType.AttachmentsChain).FirstOrDefault(); if (attachment != null) { if (document.IdChain != Guid.Empty) { if (attachment.IdArchiveChain != document.IdChain) { documentUnit.DocumentUnitChains.Remove(attachment); AddUDSDocumentUnitChain(documentUnit, document, ChainType.AttachmentsChain, identity); } } else { documentUnit.DocumentUnitChains.Remove(attachment); } } else { AddUDSDocumentUnitChain(documentUnit, document, ChainType.AttachmentsChain, identity); } break; } case UDSDocumentType.DocumentAnnexed: { DocumentUnitChain annexed = documentUnit.DocumentUnitChains.Where(t => t.ChainType == ChainType.AnnexedChain).FirstOrDefault(); if (annexed != null) { if (document.IdChain != Guid.Empty) { if (annexed.IdArchiveChain != document.IdChain) { documentUnit.DocumentUnitChains.Remove(annexed); AddUDSDocumentUnitChain(documentUnit, document, ChainType.AnnexedChain, identity); } } else { documentUnit.DocumentUnitChains.Remove(annexed); } } else { AddUDSDocumentUnitChain(documentUnit, document, ChainType.AnnexedChain, identity); } break; } case UDSDocumentType.DocumentDematerialisation: { DocumentUnitChain dematerialisation = documentUnit.DocumentUnitChains.Where(t => t.ChainType == ChainType.DematerialisationChain).FirstOrDefault(); if (dematerialisation != null) { if (document.IdChain != Guid.Empty) { if (dematerialisation.IdArchiveChain != document.IdChain) { documentUnit.DocumentUnitChains.Remove(dematerialisation); AddUDSDocumentUnitChain(documentUnit, document, ChainType.DematerialisationChain, identity); } } else { documentUnit.DocumentUnitChains.Remove(dematerialisation); } } else { AddUDSDocumentUnitChain(documentUnit, document, ChainType.DematerialisationChain, identity); } break; } } } } #endregion } catch (Exception ex) { _logger.WriteError(new LogMessage("UDS, MappingUpdateAsync Error: "), ex, LogCategories); throw ex; } return(documentUnit); }
private static void SetPropertyValue(IContentBase content, XmlNode uploadFieldConfigNode, string propertyAlias, string propertyValue) { XmlNode propertyNode = uploadFieldConfigNode.SelectSingleNode(propertyAlias); if (propertyNode != null && string.IsNullOrEmpty(propertyNode.FirstChild.Value) == false && content.HasProperty(propertyNode.FirstChild.Value)) { content.SetValue(propertyNode.FirstChild.Value, propertyValue); } }
/// <summary> /// Returns all properties based on the editorAlias /// </summary> /// <param name="content"></param> /// <param name="editorAlias"></param> /// <returns></returns> public static IEnumerable <IProperty> GetPropertiesByEditor(this IContentBase content, string editorAlias) => content.Properties.Where(x => x.PropertyType.PropertyEditorAlias == editorAlias);