本文整理汇总了C#中Kooboo.CMS.Content.Models.TextContent类的典型用法代码示例。如果您正苦于以下问题:C# TextContent类的具体用法?C# TextContent怎么用?C# TextContent使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
TextContent类属于Kooboo.CMS.Content.Models命名空间,在下文中一共展示了TextContent类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: TestWritePerformance
public void TestWritePerformance()
{
int count = 100000;
Stopwatch classStopwatch = new Stopwatch();
classStopwatch.Start();
for (int i = 0; i < count; i++)
{
dynamic content = new ContentObject();
content.UUID = Guid.NewGuid().ToString();
content.UserKey = "userkey";
}
classStopwatch.Stop();
Stopwatch dynamicStopwatch = new Stopwatch();
dynamicStopwatch.Start();
for (int i = 0; i < count; i++)
{
dynamic content = new TextContent();
content.UUID = Guid.NewGuid().ToString();
content.UserKey = "userkey";
}
dynamicStopwatch.Stop();
Console.WriteLine("class write:{0}ms", classStopwatch.ElapsedMilliseconds);
Console.WriteLine("dynamic object write:{0}ms", dynamicStopwatch.ElapsedMilliseconds);
}
示例2: Execute
public override object Execute()
{
IEnumerable<TextContent> contents = new TextContent[0];
contents = TextContentQuery.Schema.GetContents();
if (TextContentQuery.Folder != null)
{
contents = contents.Where(it => it.FolderName.EqualsOrNullEmpty(TextContentQuery.Folder.FullName, StringComparison.CurrentCultureIgnoreCase));
}
QueryExpressionTranslator translator = new QueryExpressionTranslator();
var contentQueryable = translator.Translate(TextContentQuery.Expression, contents.AsQueryable());
foreach (var categoryQuery in translator.CategoryQueries)
{
var categories = (IEnumerable<TextContent>)ContentQueryExecutor.Execute(categoryQuery);
var categoryData = TextContentQuery.Repository.GetCategoryData()
.Where(it => categories.Any(c => it.CategoryUUID.EqualsOrNullEmpty(c.UUID, StringComparison.CurrentCultureIgnoreCase)));
contentQueryable = contentQueryable.Where(it => categoryData.Any(c => it.UUID.EqualsOrNullEmpty(c.ContentUUID, StringComparison.CurrentCultureIgnoreCase)));
}
return Execute(contentQueryable, translator.OrderExpressions, translator.CallType, translator.Skip, translator.Take);
}
示例3: TestReadPerformance
public void TestReadPerformance()
{
int count = 100000;
var contentObject = new ContentObject();
contentObject.UUID = Guid.NewGuid().ToString();
contentObject.UserKey = "userkey";
Stopwatch classStopwatch = new Stopwatch();
classStopwatch.Start();
for (int i = 0; i < count; i++)
{
var uuid = contentObject.UUID;
var userKey = contentObject.UserKey;
}
classStopwatch.Stop();
var dynamicContent = new TextContent();
dynamicContent.UUID = Guid.NewGuid().ToString();
dynamicContent.UserKey = "userkey";
Stopwatch dynamicStopwatch = new Stopwatch();
dynamicStopwatch.Start();
for (int i = 0; i < count; i++)
{
var uuid = dynamicContent.UUID;
var userKey = dynamicContent.UserKey;
}
dynamicStopwatch.Stop();
Console.WriteLine("class read:{0}ms", classStopwatch.ElapsedMilliseconds);
Console.WriteLine("dynamic object read:{0}ms", dynamicStopwatch.ElapsedMilliseconds);
}
示例4: Test1
public void Test1()
{
TextContent content = new TextContent();
content.Repository = "repository1";
content.FolderName = "news";
content.UtcCreationDate = DateTime.Now;
content.UtcLastModificationDate = DateTime.Now;
content["title"] = "title1";
VersionManager.LogVersion(content);
Assert.AreEqual(1, VersionManager.AllVersions(content).First());
var version1 = VersionManager.GetVersion(content, 1);
Assert.AreEqual(content["title"], version1.TextContent["title"]);
Assert.AreEqual(content.UtcLastModificationDate, version1.UtcCommitDate);
//content["title"] = "title2";
//content.UtcLastModificationDate = DateTime.Now;
//VersionManager.LogVersion(content);
//Assert.AreEqual(2, VersionManager.AllVersions(content).Last());
//var version2 = VersionManager.GetVersion(content, 2);
//Assert.AreEqual(content["title"], version2.TextContent["title"]);
//Assert.AreEqual(content.UtcLastModificationDate, version2.UtcCommitDate);
}
示例5: Execute
public override object Execute()
{
var contents = (IEnumerable<TextContent>)ContentQueryExecutor.Execute(CategoriesQuery.InnerQuery);
IQueryable<TextContent> categories = new TextContent[0].AsQueryable();
if (contents.Count() > 0)
{
categories = CategoriesQuery.CategoryFolder.GetSchema().GetContents().AsQueryable();
}
QueryExpressionTranslator translator = new QueryExpressionTranslator();
categories = translator.Translate(CategoriesQuery.Expression, categories);
var categoryData = CategoriesQuery.Repository.GetCategoryData()
.Where(it => it.CategoryFolder.EqualsOrNullEmpty(CategoriesQuery.CategoryFolder.FullName, StringComparison.CurrentCultureIgnoreCase))
.Where(it => contents.Any(c => it.ContentUUID.EqualsOrNullEmpty(c.UUID, StringComparison.CurrentCultureIgnoreCase)))
.ToArray();
categories = categories.Where(it => categoryData.Any(c => it.UUID.EqualsOrNullEmpty(c.CategoryUUID, StringComparison.CurrentCultureIgnoreCase)));
var result = Execute(categories, translator.OrderExpressions, translator.CallType, translator.Skip, translator.Take);
return result;
}
示例6: UpdateTextContent
public string UpdateTextContent(Site site, TextFolder textFolder, string uuid, System.Collections.Specialized.NameValueCollection values, [System.Runtime.InteropServices.OptionalAttribute][System.Runtime.InteropServices.DefaultParameterValueAttribute("")]string userid, string vendor)
{
var schema = textFolder.GetSchema();
var textContent = new TextContent(textFolder.Repository.Name, textFolder.SchemaName, textFolder.FullName);
textContent = _textContentBinder.Bind(schema, textContent, values);
IncomingQueue incomeQueue = new IncomingQueue()
{
Message = null,
Object = new Dictionary<string, object>(textContent),
ObjectUUID = textContent.IntegrateId,
ObjectTitle = textContent.GetSummary(),
Vendor = vendor,
PublishingObject = PublishingObject.TextContent,
Action = PublishingAction.Publish,
SiteName = site.FullName,
Status = QueueStatus.Pending,
UtcCreationDate = DateTime.UtcNow,
UtcProcessedTime = null,
UUID = Kooboo.UniqueIdGenerator.GetInstance().GetBase32UniqueId(10)
};
_incomeQueueProvider.Add(incomeQueue);
return textContent.IntegrateId;
}
示例7: TestAddCategory
public void TestAddCategory()
{
dynamic category1 = new TextContent(repository.Name, categorySchema.Name, categoryFolder.Name)
{
UserKey = "category1"
};
category1.Title = "category1";
textContentProvider.Add(category1);
dynamic category2 = new TextContent(repository.Name, categorySchema.Name, categoryFolder.Name)
{
UserKey = "category2"
};
category2.Title = "category2";
textContentProvider.Add(category2);
dynamic news1 = new TextContent(repository.Name, newsSchema.Name, newsFolder.Name)
{
UserKey = "news1"
};
news1.title = "news1";
textContentProvider.Add(news1);
textContentProvider.AddCategories(news1, new Category() { ContentUUID = news1.uuid, CategoryFolder = categoryFolder.FullName, CategoryUUID = (string)(category1.UUID) },
new Category() { ContentUUID = news1.uuid, CategoryFolder = categoryFolder.FullName, CategoryUUID = (string)(category2.UUID) });
textContentProvider.DeleteCategories(news1, new Category() { ContentUUID = news1.uuid, CategoryFolder = categoryFolder.FullName, CategoryUUID = (string)(category2.UUID) });
}
示例8: Insert
public void Insert()
{
TextContent news1 = new TextContent(repository.Name, newsSchema.Name, textFolder.FullName);
news1["Title"] = "title1";
news1["body"] = "body1";
provider.Add(news1);
}
示例9: QueryTests
public QueryTests()
{
EmptyUserKeyGenerator.DefaultGenerator = new EmptyUserKeyGenerator();
Providers.DefaultProviderFactory = new MongoDB.ProviderFactory();
repository = new Repository(Kooboo.UniqueIdGenerator.GetInstance().GetBase32UniqueId(10).ToString());
Providers.DefaultProviderFactory.GetProvider<IRepositoryProvider>().Add(repository);
categorySchema = new Schema(repository, "category") { IsDummy = false };
categorySchema.AddColumn(new Column() { Name = "Title" });
categoryFolder = new TextFolder(repository, "Category") { SchemaName = categorySchema.Name, IsDummy = false };
Providers.DefaultProviderFactory.GetProvider<ITextFolderProvider>().Add(categoryFolder);
newsSchema = new Schema(repository, "News") { IsDummy = false };
newsSchema.AddColumn(new Column() { Name = "title", DataType = Data.DataType.String });
newsSchema.AddColumn(new Column() { Name = "Body", DataType = Data.DataType.String });
newsSchema.AddColumn(new Column() { Name = "Comments", DataType = Data.DataType.Int });
Providers.DefaultProviderFactory.GetProvider<ISchemaProvider>().Add(newsSchema);
newsFolder = new TextFolder(repository, "News") { SchemaName = newsSchema.Name, Categories = new List<CategoryFolder>() { new CategoryFolder() { FolderName = categoryFolder.FullName, SingleChoice = false } }, OrderSetting = new OrderSetting() { FieldName = "Sequence", Direction = OrderDirection.Descending } };
Providers.DefaultProviderFactory.GetProvider<ITextFolderProvider>().Add(newsFolder);
commentSchema = new Schema(repository, "Comment") { IsDummy = false };
commentSchema.AddColumn(new Column() { Name = "Title" });
Providers.DefaultProviderFactory.GetProvider<ISchemaProvider>().Add(commentSchema);
category1 = new TextContent(repository.Name, categorySchema.Name, categoryFolder.FullName);
category1["title"] = "category1";
provider.Add(category1);
category2 = new TextContent(repository.Name, categorySchema.Name, categoryFolder.FullName);
category2["title"] = "category2";
provider.Add(category2);
newsContent = new TextContent(repository.Name, newsSchema.Name, newsFolder.FullName);
newsContent["title"] = "news1";
newsContent["body"] = "body";
newsContent["comments"] = 1;
provider.Add(newsContent);
news2 = new TextContent(repository.Name, newsSchema.Name, newsFolder.FullName);
news2["title"] = "news2";
news2["body"] = "body";
news2["comments"] = 0;
provider.Add(news2);
news3 = new TextContent(repository.Name, newsSchema.Name, newsFolder.FullName);
news3["title"] = "news2";
news3["body"] = "body";
news3["comments"] = 5;
provider.Add(news3);
provider.AddCategories(newsContent, new Category() { ContentUUID = newsContent.UUID, CategoryUUID = category1.UUID, CategoryFolder = category1.FolderName });
provider.AddCategories(newsContent, new Category() { ContentUUID = newsContent.UUID, CategoryUUID = category2.UUID, CategoryFolder = category2.FolderName });
commenContent = new TextContent(repository.Name, commentSchema.Name, "");
commenContent.ParentFolder = newsContent.FolderName;
commenContent.ParentUUID = newsContent.UUID;
commenContent["title"] = "comment1";
provider.Add(commenContent);
}
示例10: InitializeData
private static void InitializeData()
{
dynamic news1 = new TextContent(repository.Name, newsSchema.Name, newsFolder.Name)
{
UserKey = "news1"
};
news1.title = "news1";
textContentProvider.Add(news1);
dynamic comment1 = new TextContent(repository.Name, commentSchema.Name, null)
{
UserKey = "comment1",
ParentUUID = news1.UUID
};
comment1.Title = "comment1";
textContentProvider.Add(comment1);
dynamic comment2 = new TextContent(repository.Name, commentSchema.Name, null)
{
UserKey = "comment2",
ParentUUID = news1.UUID
};
comment2.Title = "comment2";
textContentProvider.Add(comment2);
}
示例11: ContentVersionPath
public ContentVersionPath(TextContent content)
{
var contentPath = new TextContentPath(content);
var basePath = Kooboo.CMS.Common.Runtime.EngineContext.Current.Resolve<Kooboo.CMS.Common.IBaseDir>();
var versionPath = Path.Combine(basePath.Cms_DataPhysicalPath, VersionPathName);
this.PhysicalPath = contentPath.PhysicalPath.Replace(basePath.Cms_DataPhysicalPath, versionPath);
}
示例12: Add
public string Add(string repositoryName, string folderName, string contentUUID, string fileName, byte[] binaryData)
{
var textContent = new TextContent(repositoryName, null, folderName) { UUID = contentUUID };
var ms = new MemoryStream(binaryData);
ms.Position = 0;
var contentFile = new ContentFile() { FileName = fileName, Stream = ms };
return FileUrlHelper.ResolveUrl(textContentFileProvider.Save(textContent, contentFile));
}
示例13: ContentVersionPath
public ContentVersionPath(TextContent content)
{
var contentPath = new TextContentPath(content);
var basePath = Path.Combine(Kooboo.Settings.BaseDirectory, RepositoryPath.Cms_Data);
var versionPath = Path.Combine(basePath, VersionPathName);
this.PhysicalPath = contentPath.PhysicalPath.Replace(basePath, versionPath);
// this.VirtualPath = UrlUtility.Combine(contentPath.VirtualPath, VersionPathName);
}
示例14: ClearCategoreis
public SqlCeCommand ClearCategoreis(TextContent textContent)
{
string sql = string.Format("DELETE FROM [{0}] WHERE [email protected]"
, textContent.GetRepository().GetCategoryTableName());
SqlCeCommand command = new SqlCeCommand();
command.CommandText = sql;
command.Parameters.Add(new SqlCeParameter("@UUID", textContent.UUID));
return command;
}
示例15: DeleteChildContents
private static void DeleteChildContents(TextContent textContent, TextFolder parentFolder, TextFolder childFolder)
{
var repository = textContent.GetRepository();
var childContents = childFolder.CreateQuery().WhereEquals("ParentFolder", parentFolder.FullName)
.WhereEquals("ParentUUID", textContent.UUID);
foreach (var content in childContents)
{
Services.ServiceFactory.TextContentManager.Delete(repository, childFolder, content.UUID);
}
}