本文整理汇总了C#中Kooboo.CMS.Content.Models.MediaFolder.CreateQuery方法的典型用法代码示例。如果您正苦于以下问题:C# MediaFolder.CreateQuery方法的具体用法?C# MediaFolder.CreateQuery怎么用?C# MediaFolder.CreateQuery使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Kooboo.CMS.Content.Models.MediaFolder
的用法示例。
在下文中一共展示了MediaFolder.CreateQuery方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: 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;
}
示例2: 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; });
}
示例3: 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);
}
}
示例4: 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;
}
示例5: SaveBytes
public void SaveBytes(MediaContentParameter content)
{
var mediaContent = content.MediaContent;
var mediaFolder = new MediaFolder(new Repository(mediaContent.Repository), mediaContent.FolderName);
mediaContent = mediaFolder.CreateQuery().WhereEquals("FileName", mediaContent.FileName)
.FirstOrDefault();
using (FileStream file = new FileStream(mediaContent.PhysicalPath, FileMode.Create, System.IO.FileAccess.Write))
{
using (MemoryStream stream = new MemoryStream(content.FileData))
{
stream.WriteTo(file);
}
}
}
示例6: GetBytes
public byte[] GetBytes(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)
{
return null;
}
using (var fs = File.Open(content.PhysicalPath, FileMode.Open, FileAccess.Read, FileShare.Read))
{
return fs.ReadData();
}
}
示例7: Test1
public void Test1()
{
Repository repository = new Repository("TextTranslatorTests");
MediaFolder binaryFolder = new MediaFolder(repository, "image");
var binaryQuery = binaryFolder.CreateQuery().WhereEquals("Title", "title1");
Assert.AreEqual("[MediaContent] SELECT * FROM [TextTranslatorTests.image] WHERE Title = title1 ORDER | OP:Unspecified PageSize:0 TOP:0 Skip:0 ", TextTranslator.Translate(binaryQuery));
Schema schema = new Schema(repository, "news") { IsDummy = false };
TextFolder textFolder = new TextFolder(repository, "news") { SchemaName = "news", IsDummy = false };
var textQuery = textFolder.CreateQuery().WhereEquals("Title", "title1").WhereCategory(textFolder.CreateQuery());
Assert.AreEqual("[TextContent] SELECT * FROM [TextTranslatorTests.news$news] WHERE Title = title1 Category:([TextContent] SELECT * FROM [TextTranslatorTests.news$news] WHERE Category:() ORDER | OP:Unspecified PageSize:0 TOP:0 Skip:0 ) ORDER | OP:Unspecified PageSize:0 TOP:0 Skip:0 ", TextTranslator.Translate(textQuery));
}
示例8: ParseMediaContent
public static MediaContent ParseMediaContent(Repository repository, string virtualPath)
{
if (repository == null)
{
throw new ArgumentNullException("repository");
}
if (Uri.IsWellFormedUriString(virtualPath, UriKind.Absolute))
{
throw new NotSupportedException("Not support to parse absolute url path.".Localize());
}
var mediaBaseVirtualPath = UrlUtility.Combine(new RepositoryPath(repository).VirtualPath, FolderPath.GetRootPath(typeof(MediaFolder)));
var mediaFolderVirtualPath = UrlUtility.ResolveUrl(mediaBaseVirtualPath);
if (virtualPath.Length > mediaFolderVirtualPath.Length)
{
var mediaContentPath = virtualPath.Substring(mediaBaseVirtualPath.Length - 1);
var paths = mediaContentPath.Split(new[] { "/" }, StringSplitOptions.RemoveEmptyEntries);
var mediaFolder = new MediaFolder(repository, paths.Take(paths.Length - 1));
var fileName = paths.Last();
return mediaFolder.CreateQuery().WhereEquals("UUID", fileName).FirstOrDefault();
}
return null;
}
示例9: Count
public int Count(string repositoryName, string folderName, string prefix)
{
var mediaFolder = new MediaFolder(new Repository(repositoryName), folderName);
return mediaFolder.CreateQuery().WhereContains("FileName", prefix)
.Count();
}
示例10: IfUserKeyExists
protected virtual bool IfUserKeyExists(ContentBase content, string userKey)
{
var repository = new Repository(content.Repository);
if (content is TextContent)
{
var textContent = (TextContent)content;
var schema = new Schema(repository, textContent.SchemaName);
var contentExists = schema.CreateQuery().WhereEquals("UserKey", userKey).FirstOrDefault();
if (contentExists != null)
{
return contentExists.UUID != content.UUID;
}
return false;
}
else if (content is MediaContent)
{
var mediaContent = (MediaContent)content;
var folder = new MediaFolder(repository, mediaContent.FolderName);
var contentExists = folder.CreateQuery().WhereEquals("UserKey", userKey).FirstOrDefault();
if (contentExists != null)
{
return contentExists.UUID != content.UUID;
}
return false;
}
return false;
}
示例11: Delete
public virtual void Delete(Repository repository, MediaFolder mediaFolder, string uuid)
{
var mediaContent = mediaFolder.CreateQuery().WhereEquals("UUID", uuid).First();
Provider.Delete(mediaContent);
}