public static void LogVersion(TextContent content) { if (content.GetRepository().AsActual().EnableVersioning.Value == true) { VersionLogger.LogVersion(content); } }
public void LogVersion(TextContent content) { VersionInfo versionInfo = new VersionInfo() { CommitUser = content.UserId, UtcCommitDate = content.UtcLastModificationDate, TextContent = new Dictionary <string, object>(content) }; if (!string.IsNullOrEmpty(content.FolderName)) { versionInfo.Categories = ServiceFactory.TextContentManager .QueryCategories(content.GetRepository(), content.FolderName, content.UUID) .Select(it => new Category() { FolderName = it.CategoryFolder.FullName, Contents = it.Contents.Select(c => new CategoryContent() { UUID = c.UUID, DisplayName = c.GetSummary() }).ToArray() }) .ToArray(); } DataContractSerializationHelper.Serialize(versionInfo, GetNextVersionFile(content)); }
public IEnumerable <Category> QueryCategories(TextContent content) { List <Category> list = new List <Category>(); SqlCeConnection connection; using (var dataReader = SQLCeHelper.ExecuteReader(content.GetRepository().GetConnectionString(), dbCommands.QueryCategories(content), out connection)) { try { while (dataReader.Read()) { Category category = new Category() { CategoryFolder = dataReader.GetString(dataReader.GetOrdinal("CategoryFolder")), CategoryUUID = dataReader.GetString(dataReader.GetOrdinal("CategoryUUID")), ContentUUID = dataReader.GetString(dataReader.GetOrdinal("UUID")), }; list.Add(category); } } finally { dataReader.Close(); connection.Close(); } } return(list); }
public virtual bool AvailableToEditContent(TextContent content, string userName) { var repository = content.GetRepository().AsActual(); var folder = content.GetFolder(); var available = AvailableViewContent(folder, userName); if (available == true && repository.EnableWorkflow == true) { available = AvailableToPublish(folder, userName); if (!available) { var workflowItem = GetPendWorkflowItemForContent(content.GetRepository(), content, userName); available = workflowItem["_WorkflowItem_"] != null; } } return(available); }
public SqlCommand QueryCategories(TextContent textContent) { string sql = string.Format("SELECT * FROM [{0}] WHERE UUID = @UUID" , textContent.GetRepository().GetCategoryTableName()); SqlCommand command = new SqlCommand(); command.CommandText = sql; command.Parameters.Add(new SqlParameter("@UUID", textContent.UUID)); return(command); }
public SqlCeCommand ClearCategoreis(TextContent textContent) { string sql = string.Format("DELETE FROM [{0}] WHERE UUID=@UUID" , textContent.GetRepository().GetCategoryTableName()); SqlCeCommand command = new SqlCeCommand(); command.CommandText = sql; command.Parameters.Add(new SqlCeParameter("@UUID", textContent.UUID)); return(command); }
public MySqlCommand ClearCategories(TextContent textContent) { string sql = string.Format("DELETE FROM `{0}` WHERE UUID=?UUID " , textContent.GetRepository().GetCategoryTableName()); MySqlCommand command = new MySqlCommand(); command.CommandText = sql; command.Parameters.Add(new MySqlParameter("?UUID", textContent.UUID)); return(command); }
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); } }
public IEnumerable <Category> QueryCategories(TextContent content) { MongoCollection <BsonDocument> collection = content.GetRepository().GetCategoriesCollection(); var query = MongoDBHelper.EQIgnoreCase("ContentUUID", content.UUID); var documents = collection.Find(query); List <Category> list = new List <Category>(); foreach (var doc in documents) { Category category = new Category() { CategoryFolder = doc["CategoryFolder"].AsString, CategoryUUID = doc["CategoryUUID"].AsString, ContentUUID = doc["ContentUUID"].AsString }; list.Add(category); } return(list); }
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); }
public void ClearCategories(TextContent content) { SQLCeHelper.ExecuteNonQuery(content.GetRepository().GetConnectionString(), dbCommands.ClearCategoreis(content)); }
public static IContentQuery <TextContent> Categories(this TextContent content, string categoryFolder) { var repository = content.GetRepository(); return(Categories(content, new TextFolder(repository, categoryFolder))); }
public void ClearCategories(TextContent content) { SQLServerHelper.BatchExecuteNonQuery(content.GetRepository(), dbCommands.ClearCategories(content)); }
public virtual IndexObject GetIndexObject(object o) { IndexObject indexObject = null; TextContent textContent = (TextContent)o; NameValueCollection storeFields = new NameValueCollection(); NameValueCollection sysFields = new NameValueCollection(); var repository = textContent.GetRepository(); var schema = textContent.GetSchema().AsActual(); var folder = textContent.FolderName; var folderSearchSetting = SearchSettingProvider.Get(new SearchSetting(repository, folder)); if (folderSearchSetting != null) { string title = textContent.GetSummary(); StringBuilder bodyBuilder = new StringBuilder(); foreach (var key in textContent.Keys) { var column = schema[key]; // If column == null, then it could be a system field. var isSystemField = column == null || column.IsSystemField; var index = !isSystemField; var value = textContent[key]; string strValue = ""; string indexValue = ""; if (value != null) { if (value is DateTime) { var rawValue = (DateTime)value; strValue = rawValue.Ticks.ToString(); indexValue = rawValue.ToString(); } else { indexValue = strValue = value.ToString(); } } if (index && !column.Summarize) { bodyBuilder.AppendFormat(" {0} ", Kooboo.StringExtensions.StripAllTags(indexValue.ToString())); } if (isSystemField) { sysFields[key] = strValue; } else { storeFields[key] = strValue; } } indexObject = new IndexObject() { Title = title, Body = bodyBuilder.ToString(), StoreFields = storeFields, SystemFields = sysFields, NativeType = typeof(TextContent).AssemblyQualifiedNameWithoutVersion() }; } return(indexObject); }
public CmisObject ToCmis(object o, bool includeRelationships) { CmisObject cmisObject = new CmisObject(); TextContent content = (TextContent)o; cmisObject.Id = ObjectService.GetObjectId(content); cmisObject.Properties = new CmisProperties() { Items = content.Keys.Select(key => CmisPropertyHelper.CreateProperty(key, content[key])).ToArray() }; cmisObject.Properties.Items = cmisObject.Properties.Items.Concat(new CmisProperty[] { CmisPropertyHelper.CreateCmisPropertyCreatedBy(new [] { content.UserId }), CmisPropertyHelper.CreateCmisPropertyCreationDate(new [] { content.UtcCreationDate }), CmisPropertyHelper.CreateCmisPropertyLastModificationDate(new [] { content.UtcLastModificationDate }), CmisPropertyHelper.CreateCmisPropertyName(new [] { content.GetSummarize() }), CmisPropertyHelper.CreateCmisPropertyObjectId(new [] { cmisObject.Id }), CmisPropertyHelper.CreateCmisPropertyBaseTypeId(new [] { "cmis:document" }), CmisPropertyHelper.CreateCmisPropertyObjectTypeId(new [] { content.SchemaName }), }).ToArray(); if (includeRelationships) { var categories = Services.ServiceFactory.TextContentManager.QueryCategories(content.GetRepository(), content.FolderName, content.UUID); cmisObject.Relationship = categories.Select(it => it.Contents).SelectMany(it => it.Select(c => ObjectConvertor.ToCmis(c, includeRelationships))).ToArray(); } return(cmisObject); }
public IEnumerable <Category> QueryCategories(TextContent content) { return(content.GetRepository().GetCategoryData() .Where(it => it.ContentUUID == content.UUID) .ToArray()); }