• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

C# media.Media类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了C#中umbraco.cms.businesslogic.media.Media的典型用法代码示例。如果您正苦于以下问题:C# Media类的具体用法?C# Media怎么用?C# Media使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



Media类属于umbraco.cms.businesslogic.media命名空间,在下文中一共展示了Media类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C#代码示例。

示例1: TryFindExistingMedia

        public bool TryFindExistingMedia(int parentNodeId, string fileName, out Media existingMedia)
        {
            var children = parentNodeId == -1 ? Media.GetRootMedias() : new Media(parentNodeId).Children;
            foreach (var childMedia in children)
            {
                if (childMedia.ContentType.Alias == MediaTypeAlias)
                {
                    var prop = childMedia.getProperty(Constants.Conventions.Media.File);
                    if (prop != null && prop.Value != null)
                    {
                        int subfolderId;
                        var currentValue = prop.Value.ToString();

                        var subfolder = UmbracoSettings.UploadAllowDirectories
                            ? currentValue.Replace(FileSystem.GetUrl("/"), "").Split('/')[0]
                            : currentValue.Substring(currentValue.LastIndexOf("/", StringComparison.Ordinal) + 1).Split('-')[0];
                        
                        if (int.TryParse(subfolder, out subfolderId))
                        {
                            var destFilePath = FileSystem.GetRelativePath(subfolderId, fileName);
                            var destFileUrl = FileSystem.GetUrl(destFilePath);

                            if (prop.Value.ToString() == destFileUrl)
                            {
                                existingMedia = childMedia;
                                return true;
                            }
                        }
                    }
                }
            }

            existingMedia = null;
            return false;
        }
开发者ID:ChrisNikkel,项目名称:Umbraco-CMS,代码行数:35,代码来源:UmbracoMediaFactory.cs


示例2: GetOriginalUrl

        /// <summary>
        ///   Gets the image property.
        /// </summary>
        /// <returns></returns>
        internal static string GetOriginalUrl(int nodeId, ImageResizerPrevalueEditor imagePrevalueEditor)
        {
            Property imageProperty;
            var node = new CMSNode(nodeId);
            if (node.nodeObjectType == Document._objectType)
            {
                imageProperty = new Document(nodeId).getProperty(imagePrevalueEditor.PropertyAlias);
            }
            else if (node.nodeObjectType == Media._objectType)
            {
                imageProperty = new Media(nodeId).getProperty(imagePrevalueEditor.PropertyAlias);
            }
            else
            {
                if (node.nodeObjectType != Member._objectType)
                {
                    throw new Exception("Unsupported Umbraco Node type for Image Resizer (only Document, Media and Members are supported.");
                }
                imageProperty = new Member(nodeId).getProperty(imagePrevalueEditor.PropertyAlias);
            }

            try
            {
                return imageProperty.Value.ToString();
            }
            catch
            {
                return string.Empty;
            }
        }
开发者ID:ZeeshanShafqat,项目名称:Aspose_Imaging_NET,代码行数:34,代码来源:ImageResizerHelper.cs


示例3: Run

        public void Run(IWorkflowInstance workflowInstance, IWorkflowRuntime runtime)
        {
            // Cast to Umbraco worklow instance.
            var umbracoWorkflowInstance = (UmbracoWorkflowInstance) workflowInstance;

            var count = 0;
            var newCmsNodes = new List<int>();

            foreach(var nodeId in umbracoWorkflowInstance.CmsNodes)
            {
                var n = new CMSNode(nodeId);
                if(!n.IsMedia()) continue;

                var d = new Media(nodeId);
                if (!MediaTypes.Contains(d.ContentType.Id)) continue;
                
                newCmsNodes.Add(nodeId);
                count++;
            }

            umbracoWorkflowInstance.CmsNodes = newCmsNodes;

            var transition = (count > 0) ? "contains_media" : "does_not_contain_media";
            runtime.Transition(workflowInstance, this, transition);
        }
开发者ID:OlivierAlbertini,项目名称:workflow-for-dot-net,代码行数:25,代码来源:FilterMediaWorkflowTask.cs


示例4: DoHandleMedia

        public override void DoHandleMedia(Media media, PostedMediaFile uploadedFile, User user)
        {
            // Get umbracoFile property
            var propertyId = media.getProperty("umbracoFile").Id;

            // Get paths
            var destFilePath = FileSystem.GetRelativePath(propertyId, uploadedFile.FileName);
            var ext = Path.GetExtension(destFilePath).Substring(1);

            //var absoluteDestPath = HttpContext.Current.Server.MapPath(destPath);
            //var absoluteDestFilePath = HttpContext.Current.Server.MapPath(destFilePath);

            // Set media properties
            media.getProperty("umbracoFile").Value = FileSystem.GetUrl(destFilePath);
            media.getProperty("umbracoBytes").Value = uploadedFile.ContentLength;

            if (media.getProperty("umbracoExtension") != null)
                media.getProperty("umbracoExtension").Value = ext;

            if (media.getProperty("umbracoExtensio") != null)
                media.getProperty("umbracoExtensio").Value = ext;

            FileSystem.AddFile(destFilePath, uploadedFile.InputStream, uploadedFile.ReplaceExisting);

            // Save media
            media.Save();
        }
开发者ID:elrute,项目名称:Triphulcas,代码行数:27,代码来源:UmbracoFileMediaFactory.cs


示例5: update

        public void update(mediaCarrier carrier, string username, string password)
        {

            Authenticate(username, password);

            if (carrier == null) throw new Exception("No carrier specified");

            Media m = new Media(carrier.Id);

            if (carrier.MediaProperties != null)
            {
                foreach (mediaProperty updatedproperty in carrier.MediaProperties)
                {
                    if (!(updatedproperty.Key.ToLower().Equals("umbracofile")))
                    {
                        Property property = m.getProperty(updatedproperty.Key);
                        if (property == null)
                            throw new Exception("property " + updatedproperty.Key + " was not found");
                        property.Value = updatedproperty.PropertyValue;
                    }
                }
            }

            m.Save();
        }
开发者ID:elrute,项目名称:Triphulcas,代码行数:25,代码来源:mediaService.cs


示例6: TryFindExistingMedia

        public bool TryFindExistingMedia(int parentNodeId, string fileName, out Media existingMedia)
        {
            var children = parentNodeId == -1 ? Media.GetRootMedias() : new Media(parentNodeId).Children;
            foreach (var childMedia in children)
            {
                if (childMedia.ContentType.Alias == MediaTypeAlias)
                {
                    var prop = childMedia.getProperty("umbracoFile");
                    if (prop != null)
                    {
                        var destFilePath = FileSystem.GetRelativePath(prop.Id, fileName);
                        var destFileUrl = FileSystem.GetUrl(destFilePath);

                        if (prop.Value.ToString() == destFileUrl)
                        {
                            existingMedia = childMedia;
                            return true;
                        }
                    }
                }
            }

            existingMedia = null;
            return false;
        }
开发者ID:elrute,项目名称:Triphulcas,代码行数:25,代码来源:UmbracoMediaFactory.cs


示例7: DoHandleMedia

        public override void DoHandleMedia(Media media, PostedMediaFile uploadedFile, User user)
        {
            // Get umbracoFile property
            var propertyId = media.getProperty(Constants.Conventions.Media.File).Id;

            // Get paths
            var destFilePath = FileSystem.GetRelativePath(propertyId, uploadedFile.FileName);
            var ext = Path.GetExtension(destFilePath).Substring(1);

            //var absoluteDestPath = HttpContext.Current.Server.MapPath(destPath);
            //var absoluteDestFilePath = HttpContext.Current.Server.MapPath(destFilePath);

            // Set media properties
            media.getProperty(Constants.Conventions.Media.File).Value = FileSystem.GetUrl(destFilePath);
            media.getProperty(Constants.Conventions.Media.Bytes).Value = uploadedFile.ContentLength;

            if (media.getProperty(Constants.Conventions.Media.Extension) != null)
                media.getProperty(Constants.Conventions.Media.Extension).Value = ext;

            // Legacy: The 'extensio' typo applied to MySQL (bug in install script, prior to v4.6.x)
            if (media.getProperty("umbracoExtensio") != null)
                media.getProperty("umbracoExtensio").Value = ext;

            FileSystem.AddFile(destFilePath, uploadedFile.InputStream, uploadedFile.ReplaceExisting);

            // Save media
            media.Save();
        }
开发者ID:CarlSargunar,项目名称:Umbraco-CMS,代码行数:28,代码来源:UmbracoFileMediaFactory.cs


示例8: Delete

        public bool Delete()
        {
            cms.businesslogic.media.Media d = new cms.businesslogic.media.Media(ParentID);

            // Log
            BusinessLogic.Log.Add(BusinessLogic.LogTypes.Delete, User.GetCurrent(), d.Id, "");

            d.delete();
            return true;

        }
开发者ID:elrute,项目名称:Triphulcas,代码行数:11,代码来源:mediaTasks.cs


示例9: Delete

        public bool Delete()
        {
            cms.businesslogic.media.Media d = new cms.businesslogic.media.Media(ParentID);

            // Log
            LogHelper.Debug<mediaTasks>(string.Format("Delete media item {0} by user {1}", d.Id, User.GetCurrent().Id));

            d.delete();
            return true;

        }
开发者ID:phaniarveti,项目名称:Experiments,代码行数:11,代码来源:mediaTasks.cs


示例10: GetAncestorMedia

		/// <summary>
		/// Functionally similar to the XPath axis 'ancestor'
		/// </summary>
		/// <param name="media">an umbraco.cms.businesslogic.media.Media object</param>
		/// <returns>Media nodes as IEnumerable</returns>
		public static IEnumerable<Media> GetAncestorMedia(this Media media)
		{
			var ancestor = new Media(media.Parent.Id);

			while (ancestor != null)
			{
				yield return ancestor;

				ancestor = new Media(ancestor.Parent.Id);
			}
		}
开发者ID:phaniarveti,项目名称:Experiments,代码行数:16,代码来源:MediaExtensions.cs


示例11: GetSiblingMedia

		/// <summary>
		/// Gets all sibling Media
		/// </summary>
		/// <param name="media">an umbraco.cms.businesslogic.media.Media object</param>
		/// <returns>Media nodes as IEnumerable</returns>
		public static IEnumerable<Media> GetSiblingMedia(this Media media)
		{
			if (media.Parent != null)
			{
				var parentMedia = new Media(media.Parent.Id);

				foreach (var siblingMedia in parentMedia.GetChildMedia().Where(childMedia => childMedia.Id != media.Id))
				{
					yield return siblingMedia;
				}
			}
		}
开发者ID:phaniarveti,项目名称:Experiments,代码行数:17,代码来源:MediaExtensions.cs


示例12: DoHandleMedia

        public override void DoHandleMedia(Media media, PostedMediaFile postedFile, BusinessLogic.User user)
        {
            // Get Image object, width and height
            var image = System.Drawing.Image.FromStream(postedFile.InputStream);
            var fileWidth = image.Width;
            var fileHeight = image.Height;

            // Get umbracoFile property
            var propertyId = media.getProperty("umbracoFile").Id;

            // Get paths
            var destFileName = ConstructDestFileName(propertyId, postedFile.FileName);
            var destPath = ConstructDestPath(propertyId);
            var destFilePath = VirtualPathUtility.Combine(destPath, destFileName);
            var ext = VirtualPathUtility.GetExtension(destFileName).Substring(1);

            var absoluteDestPath = HttpContext.Current.Server.MapPath(destPath);
            var absoluteDestFilePath = HttpContext.Current.Server.MapPath(destFilePath);

            // Set media properties
            media.getProperty("umbracoFile").Value = destFilePath;
            media.getProperty("umbracoWidth").Value = fileWidth;
            media.getProperty("umbracoHeight").Value = fileHeight;
            media.getProperty("umbracoBytes").Value = postedFile.ContentLength;

            if (media.getProperty("umbracoExtension") != null)
                media.getProperty("umbracoExtension").Value = ext;

            if (media.getProperty("umbracoExtensio") != null)
                media.getProperty("umbracoExtensio").Value = ext;

            // Create directory
            if (UmbracoSettings.UploadAllowDirectories)
                Directory.CreateDirectory(absoluteDestPath);

            // Generate thumbnail
            var thumbDestFilePath = Path.Combine(absoluteDestPath, Path.GetFileNameWithoutExtension(destFileName) + "_thumb");
            GenerateThumbnail(image, 100, fileWidth, fileHeight, thumbDestFilePath + ".jpg");

            // Generate additional thumbnails based on PreValues set in DataTypeDefinition uploadField
            GenerateAdditionalThumbnails(image, fileWidth, fileHeight, thumbDestFilePath);

            image.Dispose();

            // Save file
            postedFile.SaveAs(absoluteDestFilePath);

            // Close stream
            postedFile.InputStream.Close();

            // Save media
            media.Save();
        }
开发者ID:jracabado,项目名称:justEdit-,代码行数:53,代码来源:UmbracoImageMediaFactory.cs


示例13: CanHandleMedia

        public virtual bool CanHandleMedia(int parentNodeId, PostedMediaFile postedFile, User user)
        {
            try
            {
                var parentNode = new Media(parentNodeId);

                return parentNodeId <= -1 || user.Applications.Any(app => app.alias.ToLower() == Constants.Applications.Media) && (user.StartMediaId <= 0 || ("," + parentNode.Path + ",").Contains("," + user.StartMediaId + ",")) && parentNode.ContentType.AllowedChildContentTypeIDs.Contains(MediaType.GetByAlias(MediaTypeAlias).Id);
            }
            catch
            {
                return false;
            }
        }
开发者ID:ChrisNikkel,项目名称:Umbraco-CMS,代码行数:13,代码来源:UmbracoMediaFactory.cs


示例14: GetLinkValue

 /// <summary>
 /// Returns the value for a link in WYSIWYG mode, by default only media items that have a 
 /// DataTypeUploadField are linkable, however, a custom tree can be created which overrides
 /// this method, or another GUID for a custom data type can be added to the LinkableMediaDataTypes
 /// list on application startup.
 /// </summary>
 /// <param name="dd"></param>
 /// <param name="nodeLink"></param>
 /// <returns></returns>
 public virtual string GetLinkValue(Media dd, string nodeLink)
 {
     var props = dd.getProperties;
     foreach (Property p in props)
     {
         Guid currId = p.PropertyType.DataTypeDefinition.DataType.Id;
         if (LinkableMediaDataTypes.Contains(currId) &&  !String.IsNullOrEmpty(p.Value.ToString()))
         {
             return p.Value.ToString();
         }
     }
     return "";
 }
开发者ID:jracabado,项目名称:justEdit-,代码行数:22,代码来源:BaseMediaTree.cs


示例15: GetProperty

        public System.Xml.Linq.XElement GetProperty(umbraco.cms.businesslogic.property.Property prop)
        {
            //get access to media item based on some path.
            try
            {
                var mediaItem = new Media(int.Parse(prop.Value.ToString()));

                return new XElement(prop.PropertyType.Alias, mediaItem.ConfigPath());
            }
            catch { }

            return  new XElement(prop.PropertyType.Alias, "");
        }
开发者ID:tocsoft,项目名称:Umbraco-DeveloperFriendly,代码行数:13,代码来源:MediaPickerConverter.cs


示例16: GetMedia

        public static Media GetMedia(int mediaId)
        {
            Media media = null;

            try
            {
                media = new Media(mediaId);
                if (media.nodeObjectType != Media._objectType)
                {
                    media = null;
                }
            }
            catch { }
            return media;
        }
开发者ID:1508,项目名称:upac-for-umbraco,代码行数:15,代码来源:UmbracoUtil.cs


示例17: MakeNew

        /// <summary>
        /// Creates a new Media
        /// </summary>
        /// <param name="Name">The name of the media</param>
        /// <param name="dct">The type of the media</param>
        /// <param name="u">The user creating the media</param>
        /// <param name="ParentId">The id of the folder under which the media is created</param>
        /// <returns></returns>
        public static Media MakeNew(string Name, MediaType dct, BusinessLogic.User u, int ParentId)
        {
            Guid newId = Guid.NewGuid();
            // Updated to match level from base node
            CMSNode n = new CMSNode(ParentId);
            int newLevel = n.Level;
            newLevel++;
            CMSNode.MakeNew(ParentId, _objectType, u.Id, newLevel, Name, newId);
            Media tmp = new Media(newId);
            tmp.CreateContent(dct);

            NewEventArgs e = new NewEventArgs();
            tmp.OnNew(e);

            return tmp;
        }
开发者ID:elrute,项目名称:Triphulcas,代码行数:24,代码来源:Media.cs


示例18: TextImageParameters

 /// <summary>
 ///   Initializes a new instance of the <see cref = "TextImageParameters" /> class.
 /// </summary>
 /// <param name = "textString">The node property.</param>
 /// <param name = "outputFormat">The output format.</param>
 /// <param name = "customFontPath">The custom font path.</param>
 /// <param name = "fontName">Name of the font.</param>
 /// <param name = "fontSize">Size of the font.</param>
 /// <param name = "fontStyles">The font style.</param>
 /// <param name = "foreColor">Color of the fore.</param>
 /// <param name = "backColor">Color of the back.</param>
 /// <param name = "shadowColor">Color of the shadow.</param>
 /// <param name = "hAlign">The h align.</param>
 /// <param name = "vAlign">The v align.</param>
 /// <param name = "canvasHeight">Height of the canvas.</param>
 /// <param name = "canvasWidth">Width of the canvas.</param>
 /// <param name = "backgroundMedia">The background image.</param>
 public TextImageParameters(string textString, OutputFormat outputFormat, string customFontPath, string fontName,
                            int fontSize, FontStyle[] fontStyles, string foreColor, string backColor,
                            string shadowColor, HorizontalAlignment hAlign, VerticalAlignment vAlign,
                            int canvasHeight, int canvasWidth, Media backgroundMedia)
 {
     _text = textString;
     _outputFormat = outputFormat;
     _customFontPath = customFontPath;
     _fontName = fontName;
     _fontSize = fontSize;
     _fontStyles = fontStyles;
     _foreColor = foreColor;
     _backColor = backColor;
     _hAlign = hAlign;
     _vAlign = vAlign;
     _canvasHeight = canvasHeight;
     _canvasWidth = canvasWidth;
     _shadowColor = shadowColor;
     _backgroundMedia = backgroundMedia;
 }
开发者ID:bokmadsen,项目名称:uComponents,代码行数:37,代码来源:TextImageParameters.cs


示例19: Media_AfterSave

 void Media_AfterSave(Media sender, umbraco.cms.businesslogic.SaveEventArgs e)
 {
     try
     {
         if (Configuration.Settings.Enabled)
             if (Kraken.GetKrakStatus(sender) == EnmIsKrakable.Krakable)
             {
                 // In elkaar krakken
                 var result = Kraken.Compress(sender);
                 // Goed uitgekrakt?
                 if (result != null && result.success)
                     // Opslaan in Umbraco
                     result.Save(sender);
             }
     }
     catch
     {
         // Als de hel los breekt, ga dan in ieder geval door. Anders verpesten we (mogelijK) de media save event voor de gebruiker
     }
 }
开发者ID:PerplexInternetmarketing,项目名称:Perplex-Kraken,代码行数:20,代码来源:UmbracoEvents.cs


示例20: MediaType_Delete_Media_Type_With_Media_And_Children_Of_Diff_Media_Types

        public void MediaType_Delete_Media_Type_With_Media_And_Children_Of_Diff_Media_Types()
        {
            //System.Diagnostics.Debugger.Break();

            //create the doc types 
            var mt1 = CreateNewMediaType();
            var mt2 = CreateNewMediaType();
            var mt3 = CreateNewMediaType();

            //create the heirarchy
            mt1.AllowedChildContentTypeIDs = new int[] { mt2.Id, mt3.Id };
            mt1.Save();
            mt2.AllowedChildContentTypeIDs = new int[] { mt1.Id };
            mt2.Save();

            //create the content tree
            var node1 = Media.MakeNew("TEST" + Guid.NewGuid().ToString("N"), mt1, m_User, -1);
            var node2 = Media.MakeNew("TEST" + Guid.NewGuid().ToString("N"), mt2, m_User, node1.Id);
            var node3 = Media.MakeNew("TEST" + Guid.NewGuid().ToString("N"), mt1, m_User, node2.Id);
            var node4 = Media.MakeNew("TEST" + Guid.NewGuid().ToString("N"), mt3, m_User, node3.Id);

            //do the deletion of doc type #1
            DeleteMediaType(mt1);

            //do our checks
            Assert.IsFalse(Media.IsNode(node1.Id), "node1 is not deleted"); //this was of doc type 1, should be gone
            Assert.IsFalse(Media.IsNode(node3.Id), "node3 is not deleted"); //this was of doc type 1, should be gone

            Assert.IsTrue(Media.IsNode(node2.Id), "node2 is deleted");
            Assert.IsTrue(Media.IsNode(node4.Id), "node4 is deleted");

            node2 = new Media(node2.Id);//need to re-query the node
            Assert.IsTrue(node2.IsTrashed, "node2 is not in the trash");
            node4 = new Media(node4.Id); //need to re-query the node
            Assert.IsTrue(node4.IsTrashed, "node 4 is not in the trash");

            //remove the old data
            DeleteMediaType(mt2);
            DeleteMediaType(mt3);

        }
开发者ID:CarlSargunar,项目名称:Umbraco-CMS,代码行数:41,代码来源:MediaTypeTest.cs



注:本文中的umbraco.cms.businesslogic.media.Media类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C# member.Member类代码示例发布时间:2022-05-26
下一篇:
C# macro.MacroModel类代码示例发布时间:2022-05-26
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap