本文整理汇总了C#中Kooboo.CMS.Content.Models.TextFolder.AsActual方法的典型用法代码示例。如果您正苦于以下问题:C# TextFolder.AsActual方法的具体用法?C# TextFolder.AsActual怎么用?C# TextFolder.AsActual使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Kooboo.CMS.Content.Models.TextFolder
的用法示例。
在下文中一共展示了TextFolder.AsActual方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Import
public void Import(TextFolder textFolder, System.IO.Stream inputStream)
{
textFolder = textFolder.AsActual();
if (textFolder != null)
{
XDocument xDoc = XDocument.Load(inputStream);
var xiffNode = xDoc.Element("xliff");
if (xiffNode != null)
{
var fileNodes = xiffNode.Elements();
var textContents = fileNodes.Select(it => ToTextContent(it)).Where(it => it != null);
foreach (var item in textContents)
{
InsertOrUpdate(textFolder, item);
}
}
}
}
示例2: OnExcluded
public void OnExcluded(ModuleContext moduleContext)
{
var repository = moduleContext.Site.AsActual().GetRepository();
if (repository != null)
{
TextFolder productFolder = new TextFolder(repository, "Product");
if (productFolder.AsActual() != null)
{
_textFolderManager.Remove(repository, productFolder);
}
Schema productSchema = new Schema(repository, "Product");
if (productSchema.AsActual() != null)
{
_schemaManager.Remove(repository, productSchema);
}
}
}
示例3: Update
public virtual ContentBase Update(Repository repository, TextFolder folder, string uuid, NameValueCollection values, HttpFileCollectionBase files,
DateTime modificationDate, IEnumerable<TextContent> addedCateogries, IEnumerable<TextContent> removedCategories, string userid = "", bool enableVersion = true)
{
var textFolder = (TextFolder)folder.AsActual();
var schema = new Schema(repository, textFolder.SchemaName);
var textContent = textFolder.CreateQuery().WhereEquals("UUID", uuid).First();
var old = new TextContent(textContent);
textContent = Binder.Update(schema, textContent, values);
textContent.Repository = repository.Name;
textContent.UserId = userid;
textContent.UtcLastModificationDate = modificationDate;
var parentFolder = values["ParentFolder"];
if (!string.IsNullOrEmpty(parentFolder))
{
textContent.ParentFolder = parentFolder;
}
var parentUUID = values["ParentUUID"];
if (!string.IsNullOrEmpty(parentUUID))
{
textContent.ParentUUID = parentUUID;
}
if (files != null)
{
textContent.ContentFiles = GetPostFiles(files);
}
textContent.___EnableVersion___ = enableVersion;
//SaveFiles(textContent, schema, files);
EventBus.Content.ContentEvent.Fire(ContentAction.PreUpdate, textContent);
TextContentProvider.Update(textContent, old);
if (addedCateogries != null)
{
AddCategories(repository, textContent, addedCateogries.ToArray());
}
if (removedCategories != null)
{
RemoveCategories(repository, textContent, removedCategories.ToArray());
}
EventBus.Content.ContentEvent.Fire(ContentAction.Update, textContent);
return textContent;
}
示例4: Copy
public virtual ContentBase Copy(TextContent originalContent, TextFolder textFolder, bool keepStatus, bool keepUUID, NameValueCollection values)
{
textFolder = textFolder.AsActual();
var repository = textFolder.Repository;
var schema = new Schema(repository, textFolder.SchemaName);
var copyedContent = new TextContent(originalContent);
copyedContent.Id = "";
copyedContent.UUID = "";
if (keepUUID)
{
copyedContent.UUID = originalContent.UUID;
}
copyedContent.UtcCreationDate = DateTime.Now.ToUniversalTime();
copyedContent.Repository = textFolder.Repository.Name;
copyedContent.FolderName = textFolder.FullName;
copyedContent.SchemaName = textFolder.SchemaName;
copyedContent.OriginalUUID = originalContent.UUID;
copyedContent.OriginalRepository = originalContent.Repository;
copyedContent.OriginalFolder = originalContent.FolderName;
copyedContent.IsLocalized = false;
copyedContent.Sequence = 0;
copyedContent.UserId = originalContent.UserId;
var versions = Kooboo.CMS.Content.Versioning.VersionManager.AllVersionInfos(originalContent);
if (versions.Count() > 0)
{
copyedContent.OriginalLastestVisitedVersionId = versions.Max(it => it.Version);
}
if (values != null)
{
originalContent = Binder.Bind(schema, copyedContent, values);
}
if (!keepStatus)
{
copyedContent.Published = false;
}
//如果没有Content event,那么在发送设置的“转发”功能就会失效。
EventBus.Content.ContentEvent.Fire(ContentAction.PreAdd, copyedContent);
TextContentProvider.Add(copyedContent);
if (textFolder.Categories != null && textFolder.Categories.Count > 0)
{
var originalRepository = originalContent.GetRepository();
var originalFolder = originalContent.GetFolder().AsActual();
var originalCategories = QueryCategories(originalRepository, originalFolder.FullName, originalContent.UUID);
List<TextContent> categories = new List<TextContent>();
foreach (var category in originalCategories)
{
foreach (var originalCategoryContent in category.Contents)
{
foreach (var categoryFolder in textFolder.Categories)
{
var categoryContent = (new TextFolder(textFolder.Repository, categoryFolder.FolderName)).CreateQuery()
.WhereEquals("UUID", originalCategoryContent.UUID).FirstOrDefault();
if (categoryContent != null)
{
categories.Add(categoryContent);
break;
}
}
}
}
AddCategories(repository, copyedContent, categories.ToArray());
}
EventBus.Content.ContentEvent.Fire(ContentAction.Add, copyedContent);
return copyedContent;
}
示例5: Add
public virtual ContentBase Add(Repository repository, TextFolder folder, string parentFolder, string parentUUID, NameValueCollection values
, HttpFileCollectionBase files, IEnumerable<TextContent> categories, string userid = "")
{
var textFolder = (TextFolder)folder.AsActual();
var schema = new Schema(repository, textFolder.SchemaName);
var textContent = new TextContent(repository.Name, schema.Name, textFolder.FullName);
textContent = Binder.Bind(schema, textContent, values);
textContent.ParentFolder = parentFolder;
textContent.ParentUUID = parentUUID;
textContent.UserId = userid;
textContent.UtcLastModificationDate = textContent.UtcCreationDate = DateTime.Now;
textContent.ContentFiles = GetPostFiles(files);
EventBus.Content.ContentEvent.Fire(ContentAction.PreAdd, textContent);
TextContentProvider.Add(textContent);
if (categories != null)
{
AddCategories(repository, textContent, categories.ToArray());
}
EventBus.Content.ContentEvent.Fire(ContentAction.Add, textContent);
return textContent;
}
示例6: GetFolderCategories
private IEnumerable<TextContent> GetFolderCategories(TextFolder folder)
{
folder = folder.AsActual();
IEnumerable<TextContent> categories = new TextContent[0];
if (folder.Categories != null)
{
foreach (var categoryFolderName in folder.Categories)
{
var categoryFolder = (TextFolder)(FolderHelper.Parse<TextFolder>(Repository, categoryFolderName.FolderName).AsActual());
var contents = categoryFolder.CreateQuery();
categories = categories.Concat(contents).ToArray();
}
}
return categories;
}
示例7: GetCategories
private string[] GetCategories(TextFolder textFolder, TextContent content)
{
var folder = textFolder.AsActual();
IEnumerable<string> categories = new string[0];
if (folder.Categories != null)
{
foreach (var categoryFolderName in folder.Categories)
{
var categoryFolder = (TextFolder)(FolderHelper.Parse<TextFolder>(Repository, categoryFolderName.FolderName).AsActual());
categories = categories.Concat(textFolder.CreateQuery().WhereEquals("UUID", content.UUID).Categories(categoryFolder).ToArray()
.Select(it => it.GetSummary()));
}
}
return categories.ToArray();
}
示例8: TranslatedCategoriesQuery
public TranslatedCategoriesQuery(Repository repository, TextFolder categoryFolder)
: base(repository, new Schema(repository, categoryFolder.AsActual().SchemaName), categoryFolder)
{
this.CategoryFolder = categoryFolder;
}
示例9: OnIncluded
public void OnIncluded(ModuleContext moduleContext)
{
var repository = moduleContext.Site.AsActual().GetRepository();
if (repository != null)
{
//import the content types. the zip file contains "Category" content type.
//var contentTypePath = new ModulePathHelper(ModuleAreaRegistration.ModuleName).GetModuleInstallationFilePath("ContentType.zip");
//if (File.Exists(contentTypePath.PhysicalPath))
//{
// using (FileStream fs = new FileStream(contentTypePath.PhysicalPath, FileMode.Open, FileAccess.Read, FileShare.Read))
// {
// _schemaManager.Import(repository, fs, true);
// }
//}
Schema productSchema = new Schema(repository, "Product");
productSchema.AddColumn("ProductName", "TextBox", DataType.String, "", true, true);
productSchema.AddColumn("ProductDetail", "Tinymce", DataType.String, "", false, true);
if (productSchema.AsActual() == null)
{
_schemaManager.Add(repository, productSchema);
}
TextFolder productFolder = new TextFolder(repository, "Product")
{
SchemaName = "Product"
};
if (productFolder.AsActual() == null)
{
_textFolderManager.Add(repository, productFolder);
}
}
}