本文整理汇总了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;
}
示例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);
}
示例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();
}
}
示例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);
}
示例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);
}
}
}
}
示例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;
}
示例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);
}
示例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);
}
示例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);
}
示例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;
}
示例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);
}
}
示例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; });
}
示例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;
}
示例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);
}
示例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);
}