当前位置: 首页>>代码示例>>C#>>正文


C# Models.MediaFolder类代码示例

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


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

示例1: Add

        public virtual MediaContent Add(Repository repository, MediaFolder mediaFolder, string fileName, Stream fileStream, bool @overrided,
            string userId, MediaContentMetadata metadata)
        {
            fileName = UrlUtility.ToUrlString(Path.GetFileNameWithoutExtension(fileName)) + Path.GetExtension(fileName);
            IsAllowExtension(fileName, mediaFolder.AllowedExtensions);

            var mediaContent = new MediaContent(repository.Name, mediaFolder.FullName);

            mediaContent.UserId = userId;
            mediaContent.Published = true;

            mediaContent.FileName = fileName;

            mediaContent.UserKey = fileName;
            mediaContent.UUID = fileName;

            mediaContent.ContentFile = new ContentFile()
            {
                Name = fileName,
                FileName = fileName,
                Stream = fileStream
            };

            mediaContent.UtcLastModificationDate = mediaContent.UtcCreationDate = DateTime.UtcNow;
            mediaContent.Metadata = metadata;
            Provider.Add(mediaContent, @overrided);

            return mediaContent;
        }
开发者ID:Godoy,项目名称:CMS,代码行数:29,代码来源:MediaContentManager.cs

示例2: Test_Add_Folder

 public void Test_Add_Folder()
 {
     MediaFolder mediaFolder = new MediaFolder(repository, "Test_Add_Folder");
     mediaFolder.DisplayName = "Test Add Folder";
     mediaFolder.UserId = "admin";
     provider.Add(mediaFolder);
 }
开发者ID:Godoy,项目名称:CMS,代码行数:7,代码来源:MediaFolderProviderTest.cs

示例3: RemoveFolder

        public static void RemoveFolder(MediaFolder folder)
        {
            locker.EnterWriteLock();
            try
            {
                var storeList = GetList(folder.Repository);
                var mediaFolders = ToMediaFolders(folder.Repository, storeList);
                if (storeList.ContainsKey(folder.FullName))
                {
                    storeList.Remove(folder.FullName);

                    foreach (var item in mediaFolders)
                    {
                        if (item.Parent == folder)
                        {
                            if (storeList.ContainsKey(item.FullName))
                            {
                                storeList.Remove(item.FullName);
                            }
                        }
                    }
                }
                SaveList(folder.Repository, storeList);
            }
            finally
            {
                locker.ExitWriteLock();
            }

        }
开发者ID:Godoy,项目名称:CMS,代码行数:30,代码来源:MediaFolderProvider.cs

示例4: Create

        public virtual ActionResult Create(MediaFolder model, string folderName)
        {
            var entry = new JsonResultEntry();
            if (ModelState.IsValid)
            {
                try
                {
                    MediaFolder parent = null;
                    if (!string.IsNullOrEmpty(folderName))
                    {
                        parent = FolderHelper.Parse<MediaFolder>(Repository, folderName).AsActual();
                    }
                    model.Parent = parent;

                    FolderManager.Add(Repository, model);

                }
                catch (Exception e)
                {
                    entry.AddException(e);
                }

            }
            else
            {
                entry.AddModelState(ModelState);
            }

            return Json(entry);
        }
开发者ID:Epitomy,项目名称:CMS,代码行数:30,代码来源:MediaFolderController.cs

示例5: Import

        public void Import(Repository repository, MediaFolder folder, System.IO.Stream zipStream, bool @override)
        {
            using (ZipFile zipFile = ZipFile.Read(zipStream))
            {
                foreach (ZipEntry item in zipFile)
                {
                    if (item.IsDirectory)
                    {

                    }
                    else
                    {
                        var path = Path.GetDirectoryName(item.FileName);
                        var fileName = Path.GetFileName(item.FileName);
                        var currentFolder = CreateMediaFolderByPath(folder, path);
                        Add(currentFolder);
                        var stream = new MemoryStream();
                        item.Extract(stream);
                        stream.Position = 0;
                        ServiceFactory.MediaContentManager.Add(repository, currentFolder,
                            fileName, stream, true);
                    }
                }
            }
        }
开发者ID:Epitomy,项目名称:CMS,代码行数:25,代码来源:MediaFolderProvider.cs

示例6: Update

        public virtual MediaContent Update(Repository repository, MediaFolder mediaFolder, string uuid, string fileName, Stream fileStream,
            string userid, MediaContentMetadata metadata)
        {
            IsAllowExtension(fileName, mediaFolder.AllowedExtensions);


            var binaryContent = mediaFolder.CreateQuery().WhereEquals("UUID", uuid).First();
            var old = new MediaContent(binaryContent);
            binaryContent.UserId = userid;
            binaryContent.UtcLastModificationDate = DateTime.UtcNow;

            binaryContent.FileName = fileName;
            binaryContent.UserKey = fileName;
            binaryContent.UUID = fileName;

            if (fileStream != null)
            {
                binaryContent.ContentFile = new ContentFile()
                {
                    Name = fileName,
                    FileName = fileName,
                    Stream = fileStream
                };
                Provider.SaveContentStream(old, fileStream);
            }

            binaryContent.Metadata = metadata;
            Provider.Update(binaryContent, old);

            return binaryContent;
        }
开发者ID:Godoy,项目名称:CMS,代码行数:31,代码来源:MediaContentManager.cs

示例7: MediaContentProviderTest

        public MediaContentProviderTest()
        {
            Kooboo.CMS.Content.Persistence.AzureBlobService.AssemblyInitializer.ResetProviders();

            repository = new Repository(Kooboo.UniqueIdGenerator.GetInstance().GetBase32UniqueId(5));
            mediaFolder = new MediaFolder(repository, "MediaFolder1/MediaFolder2");

            Kooboo.CMS.Content.Persistence.Providers.DefaultProviderFactory.GetProvider<IRepositoryProvider>().Initialize(repository);
        }
开发者ID:Epitomy,项目名称:CMS,代码行数:9,代码来源:MediaContentProviderTest.cs

示例8: Test_Delete_Folder

        public void Test_Delete_Folder()
        {
            MediaFolder mediaFolder = new MediaFolder(repository, "Test_Delete_Folder");
            mediaFolder.DisplayName = "Test delete Folder";
            mediaFolder.UserId = "admin";
            provider.Add(mediaFolder);

            provider.Remove(mediaFolder);
        }
开发者ID:Godoy,项目名称:CMS,代码行数:9,代码来源:MediaFolderProviderTest.cs

示例9: Test_Update_Folder

        public void Test_Update_Folder()
        {
            MediaFolder mediaFolder = new MediaFolder(repository, "Test_Update_Folder");
            mediaFolder.DisplayName = "Test Update Folder";
            mediaFolder.UserId = "admin";
            provider.Add(mediaFolder);

            mediaFolder.DisplayName = "Updated Folder";
            provider.Update(mediaFolder, mediaFolder);
        }
开发者ID:Godoy,项目名称:CMS,代码行数:10,代码来源:MediaFolderProviderTest.cs

示例10: Get

 public MediaFolder Get(MediaFolder dummy)
 {
     var folder = RemoteServiceFactory.CreateService<IMediaFolderService>()
     .Get(dummy.Repository.Name, dummy.FullName);
     if (folder != null)
     {
         ((IPersistable)folder).Init(dummy);
     }
     return folder;
 }
开发者ID:Epitomy,项目名称:CMS,代码行数:10,代码来源:MediaFolderProvider.cs

示例11: Delete

 public void Delete(string repositoryName, string folderName, string fileName)
 {
     var mediaFolder = new MediaFolder(new Repository(repositoryName), folderName);
     var content = mediaFolder.CreateQuery().WhereEquals("FileName", fileName)
         .FirstOrDefault();
     if (content != null)
     {
         mediaContentProvider.Delete(content);
     }
 }
开发者ID:kooboo-jifeng,项目名称:CMS,代码行数:10,代码来源:MediaContentService.cs

示例12: All

 public IEnumerable<MediaContent> All(string repositoryName, string folderName
     , int skip, int maxResult, string prefix)
 {
     var mediaFolder = new MediaFolder(new Repository(repositoryName), folderName);
     return mediaFolder.CreateQuery().WhereContains("FileName", prefix)
         .Skip(skip)
         .Take(maxResult)
         .ToArray()
         .Select(it => { it.VirtualPath = FileUrlHelper.ResolveUrl(it.VirtualPath); return it; });
 }
开发者ID:Godoy,项目名称:CMS,代码行数:10,代码来源:MediaContentService.cs

示例13: Get

 public MediaContent Get(string repositoryName, string folderName, string fileName)
 {
     var mediaFolder = new MediaFolder(new Repository(repositoryName), folderName);
     var content = mediaFolder.CreateQuery().WhereEquals("FileName", fileName)
         .FirstOrDefault();
     if (content != null)
     {
         content.VirtualPath = FileUrlHelper.ResolveUrl(content.VirtualPath);
     }
     return content;
 }
开发者ID:Godoy,项目名称:CMS,代码行数:11,代码来源:MediaContentService.cs

示例14: BinaryContentProviderTests

        static BinaryContentProviderTests()
        {
            repository = new Repository("SimpleQueryTests");

            binaryFolder = new MediaFolder(repository, "image");

            ProviderFactory providerFactory = new ProviderFactory();
            Providers.DefaultProviderFactory = providerFactory;
            providerFactory.GetProvider<IRepositoryProvider>().Add(repository);
            providerFactory.GetProvider<IMediaFolderProvider>().Add(binaryFolder);
        }
开发者ID:Epitomy,项目名称:CMS,代码行数:11,代码来源:BinaryContentProviderTests.cs

示例15: Test_Get_Folder

        public void Test_Get_Folder()
        {
            MediaFolder mediaFolder = new MediaFolder(repository, "Test_Get_Folder");
            mediaFolder.DisplayName = "Test get Folder";
            mediaFolder.UserId = "admin";
            provider.Add(mediaFolder);

            var gotFolder = provider.Get(mediaFolder);
            Assert.IsNotNull(gotFolder);
            Assert.AreEqual(mediaFolder.DisplayName, gotFolder.DisplayName);
            Assert.AreEqual(mediaFolder.UserId, gotFolder.UserId);
        }
开发者ID:Godoy,项目名称:CMS,代码行数:12,代码来源:MediaFolderProviderTest.cs


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