public override void Update(Repository orginalRepository, TextFolder newFolder, TextFolder oldFolder) { _textFolderManager.Update(orginalRepository, newFolder, oldFolder); Sync(Site.Current, orginalRepository, (Repository targetRepository) => { EnsureFolder(targetRepository, newFolder); EnsureFolder(targetRepository, oldFolder); //create folder when not exists if (_textFolderManager.Get(targetRepository, oldFolder.FullName) == null) { _textFolderManager.Add(targetRepository, oldFolder); } _textFolderManager.Update(targetRepository, newFolder, oldFolder); }); }
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; 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 virtual void Update(TextFolder textFolder, string uuid, string fieldName, object value, string userName = "", bool enableVersion = true) { Update(textFolder, uuid, new[] { fieldName }, new[] { value }, userName, enableVersion); }
protected override void ByFolder(Page_Context pageContext, View.PagePositionContext positionContext, Repository repository, TextFolder folder) { string uuid = pageContext.ControllerContext.RequestContext.GetRequestValue("uuid"); try { Content.Services.ServiceFactory.TextContentManager.Delete(repository, folder, uuid); } catch (RuleViolationException violationException) { violationException.FillIssues(positionContext == null ? pageContext.ControllerContext.Controller.ViewData.ModelState : positionContext.ViewData.ModelState); } }
public virtual ContentBase Add(Repository repository, TextFolder folder, NameValueCollection values, HttpFileCollectionBase files, IEnumerable <TextContent> categories, string userid = "") { return(Add(repository, folder, null, null, values, files, categories, userid)); }
public virtual ActionResult SelectTextContent(string siteName, string folderName, string selected, int?page, int?pageSize, string search, string sortField = null, string sortDir = null) { var site = SiteHelper.Parse(siteName); var repository = site.GetRepository(); var textFolder = (TextFolder)(FolderHelper.Parse <TextFolder>(repository, folderName).AsActual()); var singleChoice = string.Equals("True", Request.RequestContext.GetRequestValue("SingleChoice"), StringComparison.OrdinalIgnoreCase); Schema schema = new Schema(repository, textFolder.SchemaName).AsActual(); SchemaPath schemaPath = new SchemaPath(schema); ViewData["Folder"] = textFolder; ViewData["Schema"] = schema; ViewData["Template"] = textFolder.GetFormTemplate(FormType.Selectable); //ViewData["WhereClause"] = whereClause; IEnumerable <TextFolder> childFolders = new TextFolder[0]; //Skip the child folders on the embedded folder grid. if (!page.HasValue || page.Value <= 1) { childFolders = ServiceFactory.TextFolderManager.ChildFoldersWithSameSchema(textFolder).Select(it => it.AsActual()); } var query = textFolder.CreateQuery(); if (!string.IsNullOrEmpty(sortField)) { query = query.SortBy(sortField, sortDir); } else { query = query.DefaultOrder(); } bool showTreeStyle = schema.IsTreeStyle; if (showTreeStyle) { query = query.Where(new OrElseExpression(new WhereEqualsExpression(null, "ParentUUID", null), new WhereEqualsExpression(null, "ParentUUID", ""))); } if (!string.IsNullOrEmpty(search)) { IWhereExpression exp = new FalseExpression(); foreach (var item in schema.Columns.Where(it => it.ShowInGrid)) { exp = new OrElseExpression(exp, (new WhereContainsExpression(null, item.Name, search))); } if (exp != null) { query = query.Where(exp); } showTreeStyle = false; } var contents = query.ToPageList(page ?? 1, pageSize ?? textFolder.PageSize, textFolder.EnablePaging.HasValue ? textFolder.EnablePaging.Value : true); SelectableViewModel viewModel = new SelectableViewModel() { ShowTreeStyle = showTreeStyle, ChildFolders = childFolders, Contents = contents, SingleChoice = singleChoice }; if (Request.IsAjaxRequest()) { return(PartialView("", viewModel)); } else { IEnumerable <TextContent> selectedContents = new TextContent[0]; if (!string.IsNullOrEmpty(selected)) { string[] selectedArr = selected.Split(','); IContentQuery <TextContent> selectedQuery = textFolder.CreateQuery().DefaultOrder(); foreach (var userKey in selectedArr) { selectedQuery = selectedQuery.Or((IWhereExpression)textFolder.CreateQuery().DefaultOrder().WhereEquals("UUID", userKey).Expression); } selectedContents = selectedQuery; } viewModel.Selected = selectedContents; } return(View(viewModel)); }
protected abstract void ByFolder(Page_Context pageContext, View.PagePositionContext positionContext, Repository repository, TextFolder folder);
protected virtual bool IsRebuilding(TextFolder textFolder) { var key = GetIndexThreadKey(textFolder); return(indexThreads.ContainsKey(key)); }
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, TextContent previous = null) { var textFolder = (TextFolder)folder.AsActual(); var schema = new Schema(repository, textFolder.SchemaName); var textContent = previous ?? 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); //TODO:FS Update only dirty entity // /* * if (previous != null) * { * var _old = new TextContent(old); * _old["Id"] = previous["Id"]; * * if (!previous.OrderBy(c => c.Key).SequenceEqual(_old.OrderBy(c => c.Key))) * { * TextContentProvider.Update(textContent, old); * } * } * else */ { TextContentProvider.Update(textContent, old); } if (removedCategories != null) { RemoveCategories(repository, textContent, removedCategories.ToArray()); } if (addedCateogries != null) { AddCategories(repository, textContent, addedCateogries.ToArray()); } EventBus.Content.ContentEvent.Fire(ContentAction.Update, textContent); return(textContent); }
private void RemotePublish(ref PublishingQueue queueItem, PublishingAction action) { var site = new Site(queueItem.SiteName).AsActual(); if (site != null) { switch (queueItem.PublishingObject) { case PublishingObject.Page: if (queueItem.RemoteEndpoints != null) { var page = new Page(site, queueItem.ObjectUUID).AsActual(); if (page != null) { foreach (var remote in queueItem.RemoteEndpoints) { var outgoingQueue = new OutgoingQueue(); outgoingQueue.SiteName = queueItem.SiteName; outgoingQueue.PublishingObject = queueItem.PublishingObject; outgoingQueue.ObjectUUID = queueItem.ObjectUUID; outgoingQueue.RemoteEndpoint = remote; outgoingQueue.UtcCreationDate = DateTime.UtcNow; outgoingQueue.Status = QueueStatus.Pending; outgoingQueue.RetryTimes = 0; outgoingQueue.Action = action; outgoingQueue.PublishDraft = queueItem.PublishDraft; _outgoingQueueProvider.Add(outgoingQueue); } } else { NoSuchObjectMessage(ref queueItem); } } NoAnyEndPoint(ref queueItem); break; case PublishingObject.TextContent: if (queueItem.PublishingMappings != null) { var contentIntegrateId = new ContentIntegrateId(queueItem.ObjectUUID); var repository = new Repository(contentIntegrateId.Repository).AsActual();; if (repository != null) { var textFolder = new TextFolder(repository, contentIntegrateId.FolderName).AsActual(); if (textFolder != null) { var contentUUID = contentIntegrateId.ContentUUID; foreach (var mappingName in queueItem.PublishingMappings) { var mapping = new RemoteTextFolderMapping(); //todo:AsActual if (mapping != null) { var outgoingQueue = new OutgoingQueue(); outgoingQueue.SiteName = queueItem.SiteName; outgoingQueue.PublishingObject = queueItem.PublishingObject; outgoingQueue.ObjectUUID = queueItem.ObjectUUID; outgoingQueue.RemoteEndpoint = mapping.RemoteEndpoint; outgoingQueue.RemoteFolderId = mapping.RemoteFolderId; outgoingQueue.UtcCreationDate = DateTime.UtcNow; outgoingQueue.Status = QueueStatus.Pending; outgoingQueue.RetryTimes = 0; outgoingQueue.Action = action; outgoingQueue.PublishDraft = queueItem.PublishDraft; _outgoingQueueProvider.Add(outgoingQueue); } } } else { NoSuchObjectMessage(ref queueItem); } } else { NoSuchObjectMessage(ref queueItem); } } NoAnyEndPoint(ref queueItem); break; default: NoSuchPublishingObject(ref queueItem); break; } } }
private string GetIndexThreadKey(TextFolder textFolder) { return(string.Format("Repository:{0};FullName:{1}", textFolder.Repository.Name, textFolder.FullName)); }
protected virtual void LocalPublish(ref PublishingQueue queueItem, PublishingAction action) { var site = new Site(queueItem.SiteName).AsActual(); if (site != null) { switch (queueItem.PublishingObject) { case PublishingObject.Page: var page = new Page(site, queueItem.ObjectUUID).AsActual(); if (page != null) { if (action == PublishingAction.Publish) { _pageManager.Publish(page, queueItem.PublishDraft, queueItem.UserId); } else if (action == PublishingAction.Unbpulish) { _pageManager.Unpublish(page, queueItem.UserId); } } else { NoSuchObjectMessage(ref queueItem); } break; case PublishingObject.TextContent: var contentIntegrateId = new ContentIntegrateId(queueItem.ObjectUUID); var repository = new Repository(contentIntegrateId.Repository).AsActual();; if (repository != null) { var textFolder = new TextFolder(repository, contentIntegrateId.FolderName).AsActual(); if (textFolder != null) { var contentUUID = contentIntegrateId.ContentUUID; if (action == PublishingAction.Publish) { _textContentManager.Publish(textFolder, contentUUID, queueItem.UserId); } else if (action == PublishingAction.Unbpulish) { _textContentManager.Unpublish(textFolder, contentUUID, queueItem.UserId); } } else { NoSuchObjectMessage(ref queueItem); } } else { NoSuchObjectMessage(ref queueItem); } break; default: NoSuchPublishingObject(ref queueItem); break; } } queueItem.UtcProcessedTime = DateTime.UtcNow; }
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 ActionResult Index() { var productFolder = new TextFolder(Repository.Current, "Product"); return(View(productFolder.CreateQuery())); }
public void DeleteTextContent(Site site, TextFolder textFolder, string integrateId, string vendor) { var integrate = new ContentIntegrateId(integrateId); _textContentManager.Delete(textFolder.Repository, textFolder, integrate.ContentUUID); }
public void Unpublish(TextFolder textFolder, string contentUUID, string userName = "") { this.Update(textFolder, contentUUID, "Published", false, userName); }
public ActionResult PublishTextContent(CreateTextContentPublishingQueueViewModel model, string @return) { if (model.TextFolderMappings == null || model.TextFolderMappings.Length == 0) { ModelState.AddModelError("TextFolderMappings", "Required".Localize()); } var resultEntry = new JsonResultData(ModelState); if (ModelState.IsValid) { if (model.Schedule && !model.UtcTimeToPublish.HasValue && !model.UtcTimeToUnpublish.HasValue) { resultEntry.AddErrorMessage("UtcTimeToPublish and UtcTimeToUnpublish can not be both empty."); } else { TextFolder textFolder = new TextFolder(Repository.Current, model.LocalFolderId).AsActual(); for (int i = 0, j = model.TextContents.Length; i < j; i++) { var content = textFolder.CreateQuery().WhereEquals("UUID", model.TextContents[i]).FirstOrDefault(); if (content != null) { foreach (string mapping in model.TextFolderMappings) { var queue = new RemotePublishingQueue(Site, Kooboo.UniqueIdGenerator.GetInstance().GetBase32UniqueId(10)) { PublishingObject = PublishingObject.TextContent, UserId = User.Identity.Name, UtcCreationDate = DateTime.UtcNow, TextFolderMapping = mapping, ObjectUUID = content.IntegrateId, ObjectTitle = model.ObjectTitles[i], Status = QueueStatus.Pending }; if (model.Schedule) { if (model.UtcTimeToPublish.HasValue) { queue.UtcTimeToPublish = model.UtcTimeToPublish.Value.ToUniversalTime(); } if (model.UtcTimeToUnpublish.HasValue) { queue.UtcTimeToUnpublish = model.UtcTimeToUnpublish.Value.ToUniversalTime(); } } else { queue.UtcTimeToPublish = DateTime.UtcNow; } resultEntry.RunWithTry((data) => { _manager.Add(queue); }); } } } resultEntry.RedirectUrl = @return; } } return(Json(resultEntry)); }
public virtual void UpdateAction(Repository repository, TextContent originalContent, TextFolder targetFolder, bool keepStatus) { var contents = BroadcastingContentHelper.GetContentsByOriginalUUID(targetFolder, originalContent.UUID).ToArray(); var categoriesOfOriginalContent = GetAllCategories(originalContent).ToArray(); if (originalContent.Published.HasValue && originalContent.Published.Value == true && contents.Length == 0) { Services.ServiceFactory.TextContentManager.Copy(originalContent, targetFolder, keepStatus, true, null); } else { foreach (var drivedContent in contents) { if (drivedContent.IsLocalized != null && drivedContent.IsLocalized.Value == false) { var values = BroadcastingContentHelper.ExcludeBasicFields(originalContent); if (keepStatus) { if (originalContent.Published.HasValue) { values["Published"] = originalContent.Published.Value.ToString(); } } drivedContent.OriginalLastestVisitedVersionId = Kooboo.CMS.Content.Versioning.VersionManager.AllVersionInfos(originalContent).Max(it => it.Version); var categoriesOfDrivedContent = GetAllCategories(drivedContent); Services.ServiceFactory.TextContentManager.Update(repository, targetFolder, drivedContent.UUID, values, null, DateTime.UtcNow, categoriesOfOriginalContent, categoriesOfDrivedContent); } else { drivedContent.OriginalUpdateTimes = drivedContent.OriginalUpdateTimes + 1; _textContentProvider.Update(drivedContent, drivedContent); } } } }
/// <summary> /// <example> /// <div> // <div> // <form method="post"> // <input type="hidden" name="FolderName" value="news" /> // <input type="hidden" name="Published" value="true" /> // <input type="hidden" name="Categories[0].FolderName" value="<%: ViewBag.category.FolderName %>" /> // <input type="hidden" name="Categories[0].UUID" value="<%: ViewBag.category.UUID %>" /> // <table> // <tr> // <td> // title: // </td> // <td> // <input type="text" name="title" data-val-required="title is required" data-val="true" /> // <%: Html.ValidationMessageForInput("title") %> // </td> // </tr> // <tr> // <td> // body: // </td> // <td> // <textarea name="body" cols="20" rows="10"></textarea> // </td> // </tr> // </table> // <input type="submit" name="submit" value="submit" /> // </form> //</div> /// </example> /// </summary> /// <param name="pageContext"></param> /// <param name="repository"></param> /// <param name="folder"></param> protected override void ByFolder(Page_Context pageContext, View.PagePositionContext positionContext, Repository repository, TextFolder folder) { var httpContext = pageContext.ControllerContext.RequestContext.HttpContext; var categories = GetCategories("Categories", pageContext.ControllerContext); try { var parentFolder = httpContext.Request.Form["ParentFolder"]; var parentUUID = httpContext.Request.Form["ParentUUID"]; Content.Services.ServiceFactory.TextContentManager.Add(repository, folder, parentFolder, parentUUID, httpContext.Request.Form, httpContext.Request.Files, categories, httpContext.User.Identity.Name); } catch (RuleViolationException violationException) { violationException.FillIssues(positionContext == null ? pageContext.ControllerContext.Controller.ViewData.ModelState : positionContext.ViewData.ModelState); } }
public virtual void DeleteAction(Repository repository, TextContent originalContent, TextFolder targetFolder) { foreach (var drivedContent in BroadcastingContentHelper.GetContentsByOriginalUUID(targetFolder, originalContent.UUID)) { if (drivedContent.IsLocalized != null && drivedContent.IsLocalized.Value == false) { Services.ServiceFactory.TextContentManager.Delete(repository, targetFolder, drivedContent.UUID); } } }
protected override void ByFolder(Page_Context pageContext, View.PagePositionContext positionContext, Repository repository, TextFolder folder) { var httpContext = pageContext.ControllerContext.RequestContext.HttpContext; string uuid = pageContext.ControllerContext.RequestContext.GetRequestValue("uuid"); var addCategories = GetCategories("AddCategories", pageContext.ControllerContext); var removeCategories = GetCategories("RemoveCategories", pageContext.ControllerContext); try { Content.Services.ServiceFactory.TextContentManager.Update(repository, folder, uuid, httpContext.Request.Form , httpContext.Request.Files, DateTime.UtcNow, addCategories, removeCategories, httpContext.User.Identity.Name); } catch (RuleViolationException violationException) { violationException.FillIssues(positionContext == null ? pageContext.ControllerContext.Controller.ViewData.ModelState : positionContext.ViewData.ModelState); } }
protected abstract object DoPost(Repository repository, TextFolder folder, ControllerContext controllerContext, NameValueCollection formValues);
public QueryTests() { EmptyUserKeyGenerator.DefaultGenerator = new EmptyUserKeyGenerator(); Providers.DefaultProviderFactory = new SqlServer.ProviderFactory(); repository = new Repository(Guid.NewGuid().ToString()); Providers.DefaultProviderFactory.GetProvider <IRepositoryProvider>().Add(repository); categorySchema = new Schema(repository, "category") { IsDummy = false }; categorySchema.AddColumn(new Column() { Name = "Title" }); Providers.DefaultProviderFactory.GetProvider <ISchemaProvider>().Add(categorySchema); 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 = DataType.String }); newsSchema.AddColumn(new Column() { Name = "Body", DataType = DataType.String }); newsSchema.AddColumn(new Column() { Name = "Comments", DataType = 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); categoryContent = new TextContent(repository.Name, categorySchema.Name, categoryFolder.FullName); categoryContent["title"] = "category1"; provider.Add(categoryContent); 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 = categoryContent.UUID, CategoryFolder = categoryContent.FolderName }); commenContent = new TextContent(repository.Name, commentSchema.Name, ""); commenContent.ParentUUID = newsContent.UUID; commenContent["title"] = "comment1"; provider.Add(commenContent); }
private IEnumerable <TextContent> GetCategories(TextFolder textFolder, IEnumerable <string> categories) { return(GetFolderCategories(textFolder).Where(it => categories.Any(c => string.Compare(c, it.GetSummary(), true) == 0))); }
public virtual ContentBase Update(Repository repository, TextFolder folder, string uuid, NameValueCollection values, string userid = "") { return(Update(repository, folder, uuid, values, null, DateTime.Now, null, null)); }
public virtual ActionResult Index(string folderName, string parentUUID, string parentFolder, string search , IEnumerable <WhereClause> whereClause, int?page, int?pageSize, string sortField = null, string sortDir = null) { //compatible with the Folder parameter changed to FolderName. folderName = folderName ?? this.ControllerContext.RequestContext.GetRequestValue("Folder"); TextFolder textFolder = new TextFolder(Repository, folderName).AsActual(); var schema = textFolder.GetSchema().AsActual(); SchemaPath schemaPath = new SchemaPath(schema); ViewData["Folder"] = textFolder; ViewData["Schema"] = schema; ViewData["Menu"] = textFolder.GetFormTemplate(FormType.Grid_Menu); ViewData["Template"] = textFolder.GetFormTemplate(FormType.Grid); ViewData["WhereClause"] = whereClause; SetPermissionData(textFolder); IEnumerable <TextFolder> childFolders = new TextFolder[0]; //Skip the child folders on the embedded folder grid. if (string.IsNullOrEmpty(parentFolder)) { if (!page.HasValue || page.Value <= 1) { childFolders = TextFolderManager.ChildFolders(textFolder, search).Select(it => it.AsActual()); } } IContentQuery <TextContent> query = textFolder.CreateQuery(); query = SortByField(sortField, sortDir, query); bool showTreeStyle = schema.IsTreeStyle; //如果有带搜索条件,则不输出树形结构 if (!string.IsNullOrEmpty(search)) { IWhereExpression exp = new FalseExpression(); foreach (var item in schema.Columns.Where(it => it.ShowInGrid)) { exp = new OrElseExpression(exp, (new WhereContainsExpression(null, item.Name, search))); } if (exp != null) { query = query.Where(exp); } showTreeStyle = false; } if (whereClause != null && whereClause.Count() > 0) { var expression = WhereClauseToContentQueryHelper.Parse(whereClause, schema, new MVCValueProviderWrapper(ValueProvider)); query = query.Where(expression); showTreeStyle = false; } if (!string.IsNullOrWhiteSpace(parentUUID)) { query = query.WhereEquals("ParentUUID", parentUUID); } else { //有两种情况需要考虑要不要查询所有的数据(ParentUUID=null) //1.树形结构数据,第一次查询需要过滤ParentUUID==null //2.自嵌套的目前结构,也需要过滤ParentUUID==null var selfEmbedded = textFolder.EmbeddedFolders != null && textFolder.EmbeddedFolders.Contains(textFolder.FullName, StringComparer.OrdinalIgnoreCase); if (showTreeStyle || selfEmbedded) { query = query.Where(new OrElseExpression(new WhereEqualsExpression(null, "ParentUUID", null), new WhereEqualsExpression(null, "ParentUUID", ""))); } } if (childFolders != null) { childFolders = childFolders .Select(it => it.AsActual()) .Where(it => it.Visible) .Where(it => Kooboo.CMS.Content.Services.ServiceFactory.WorkflowManager.AvailableViewContent(it, User.Identity.Name)); } page = page ?? 1; pageSize = pageSize ?? textFolder.PageSize; //var pagedList = query.ToPageList(page.Value, pageSize.Value); //IEnumerable<TextContent> contents = pagedList.ToArray(); //if (Repository.EnableWorkflow == true) //{ // contents =WorkflowManager.GetPendWorkflowItemForContents(Repository, contents.ToArray(), User.Identity.Name); //} //var workflowContentPagedList = new PagedList<TextContent>(contents, page.Value, pageSize.Value, pagedList.TotalItemCount); //ViewData["ContentPagedList"] = workflowContentPagedList; return(View(new TextContentGrid() { ChildFolders = childFolders.OrderBy(it => it.FriendlyText).ToArray(), ContentQuery = query, PageIndex = page.Value, PageSize = pageSize.Value, ShowTreeStyle = showTreeStyle })); }
public virtual void Localize(TextFolder textFolder, string uuid) { Update(textFolder.Repository, textFolder.GetSchema(), uuid, new string[] { "IsLocalized" }, new object[] { true }); }
public string AddTextContent(Site site, TextFolder textFolder, NameValueCollection values, HttpFileCollectionBase files, IEnumerable <TextContent> categories, string userid, string vendor) { var textContent = _textContentManager.Add(textFolder.Repository, textFolder, values, files, categories, ""); return(textContent.IntegrateId); }
public WorkflowHistoryPath(WorkflowHistory history) { var folder = new TextFolder(history.Repository, history.ContentFolder); var content = folder.CreateQuery().WhereEquals("UUID", history.ContentUUID).FirstOrDefault(); ContentPath = new TextContentPath(content); PhysicalPath = SettingFile = Path.Combine(ContentPath.PhysicalPath, PATH_NAME, GetFile(history)); VirtualPath = UrlUtility.Combine(ContentPath.VirtualPath, PATH_NAME, GetFile(history)); }
public static IContentQuery <TextContent> DefaultOrder(this IContentQuery <TextContent> textContents, TextFolder textFolder) { if (textContents is TextContentQueryBase) { string orderField = SystemFieldNames.UtcCreationDate; OrderDirection orderDirection = OrderDirection.Descending; if (textFolder.Sortable.HasValue && textFolder.Sortable.Value) { orderField = "Sequence"; orderDirection = OrderDirection.Descending; } if (orderDirection == OrderDirection.Ascending) { return(textContents.OrderBy(orderField)); } else { return(textContents.OrderByDescending(orderField)); } } return(textContents); }