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; }
public virtual ActionResult BatchPublish(string folderName, string parentFolder, string[] docArr) { JsonResultEntry entry = new JsonResultEntry(); try { TextFolder textFolder = new TextFolder(Repository, folderName).AsActual(); var schema = textFolder.GetSchema().AsActual(); if (docArr != null) { foreach (var doc in docArr) { if (string.IsNullOrEmpty(doc)) continue; ServiceFactory.TextContentManager.Update(Repository, schema, doc, new string[] { "Published" }, new object[] { true }, User.Identity.Name); } } entry.SetSuccess(); } catch (Exception e) { entry.AddException(e); } return Json(entry); }
public string AddTextContent(Site site, TextFolder textFolder, 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(); foreach (string key in values) { textContent[key] = values[key]; } textContent.Repository = textFolder.Repository.Name; textContent.SchemaName = textFolder.SchemaName; textContent.FolderName = textFolder.FullName; if (!string.IsNullOrEmpty(values["UUID"])) { textContent.UUID = values["UUID"]; } textContent = _textContentBinder.Bind(schema, textContent, values, true, false); IncomingQueue incomeQueue = new IncomingQueue(site, Kooboo.UniqueIdGenerator.GetInstance().GetBase32UniqueId(10)) { Message = null, Object = new Dictionary<string, object>(textContent), ObjectUUID = textContent.IntegrateId, ObjectTitle = textContent.GetSummary(), Vendor = vendor, PublishingObject = PublishingObject.TextContent, Action = PublishingAction.Publish, Status = QueueStatus.Pending, UtcCreationDate = DateTime.UtcNow, UtcProcessedTime = null }; _incomeQueueProvider.Add(incomeQueue); return textContent.IntegrateId; }
public virtual ActionResult Delete(string folderName, string parentFolder, string[] docArr, string[] folderArr) { JsonResultEntry entry = new JsonResultEntry(); try { TextFolder textFolder = new TextFolder(Repository, folderName).AsActual(); var schema = textFolder.GetSchema().AsActual(); if (docArr != null) { foreach (var doc in docArr) { if (string.IsNullOrEmpty(doc)) continue; ServiceFactory.TextContentManager.Delete(Repository, textFolder, doc); } } if (folderArr != null) { foreach (var f in folderArr) { if (string.IsNullOrEmpty(f)) continue; var folderPathArr = FolderHelper.SplitFullName(f); ServiceFactory.TextFolderManager.Remove(Repository, new TextFolder(Repository, folderPathArr)); } } entry.SetSuccess(); } catch (Exception e) { entry.AddException(e); } return Json(entry); }
public virtual ActionResult Diff(string folderName, string parentFolder, string uuid, int v1, int v2) { TextFolder textFolder = new TextFolder(Repository, folderName).AsActual(); var schema = textFolder.GetSchema().AsActual(); var textContent = schema.CreateQuery().WhereEquals("UUID", uuid).FirstOrDefault(); var version1 = VersionManager.GetVersion(textContent, v1); var version1Content = new TextContent(version1.TextContent); var version2 = VersionManager.GetVersion(textContent, v2); var version2Content = new TextContent(version2.TextContent); var sideBySideDiffBuilder = new SideBySideDiffBuilder(new Differ()); var model = new TextContentDiffModel() { UUID = uuid, Version1Name = v1, Version2Name = v2 }; foreach (var k in textContent.Keys) { var version1Text = version1Content[k] != null ? version1Content[k].ToString() : ""; var version2Text = version2Content[k] != null ? version2Content[k].ToString() : ""; var diffModel = sideBySideDiffBuilder.BuildDiffModel(version1Text, version2Text); model.Version1.Add(k, diffModel.OldText); model.Version2.Add(k, diffModel.NewText); } return View(model); }
public virtual ActionResult Create(string folderName, string parentFolder) { TextFolder textFolder = new TextFolder(Repository, folderName).AsActual(); var schema = textFolder.GetSchema().AsActual(); SchemaPath schemaPath = new SchemaPath(schema); ViewData["Folder"] = textFolder; ViewData["Schema"] = schema; ViewData["Template"] = textFolder.GetFormTemplate(FormType.Create); SetPermissionData(textFolder); var content = schema.DefaultContent(); content = Kooboo.CMS.Content.Models.Binder.TextContentBinder.DefaultBinder.Bind(schema, content, Request.QueryString, true, false); return View(content); }
public virtual ActionResult Create(string folderName, string parentFolder, string parentUUID, FormCollection form) { JsonResultEntry resultEntry = new JsonResultEntry() { Success = true }; try { if (ModelState.IsValid) { TextFolder textFolder = new TextFolder(Repository, folderName).AsActual(); var schema = textFolder.GetSchema().AsActual(); SchemaPath schemaPath = new SchemaPath(schema); IEnumerable<TextContent> addedCategories; IEnumerable<TextContent> removedCategories; ParseCategories(form, out addedCategories, out removedCategories); ContentBase content; content = ServiceFactory.TextContentManager.Add(Repository, textFolder, parentFolder, parentUUID, form, Request.Files, addedCategories, User.Identity.Name); resultEntry.ReloadPage = true; resultEntry.Success = true; } } catch (RuleViolationException ruleEx) { foreach (var item in ruleEx.Issues) { resultEntry.AddFieldError(item.PropertyName, item.ErrorMessage); } } catch (Exception e) { resultEntry.SetFailed().AddException(e); } resultEntry.AddModelState(ViewData.ModelState); return Json(resultEntry); }
public virtual ActionResult ReconfigContent(IEnumerable<ContentSorter> list, string folderName, string uuid, string parentUUID) { JsonResultEntry entry = new JsonResultEntry(); try { TextFolder textFolder = new TextFolder(Repository, folderName).AsActual(); if (!string.IsNullOrEmpty(uuid) && string.Compare(uuid, parentUUID, true) != 0) { ServiceFactory.TextContentManager.Update(textFolder, uuid, new[] { "ParentUUID", "ParentFolder" }, new[] { parentUUID, folderName }, User.Identity.Name); } var schema = textFolder.GetSchema().AsActual(); foreach (var c in list) { ServiceFactory.TextContentManager.Update(Repository, schema, c.UUID, new string[] { "Sequence" }, new object[] { c.Sequence }, User.Identity.Name); } } catch (Exception e) { entry.AddException(e); } return Json(entry); }
public virtual void Localize(TextFolder textFolder, string uuid) { Update(textFolder.Repository, textFolder.GetSchema(), uuid, new string[] { "IsLocalized" }, new object[] { true }); }
public virtual ActionResult Publish(string folderName, string uuid) { var data = new JsonResultData(ModelState); data.RunWithTry((resultData) => { TextFolder textFolder = new TextFolder(Repository, folderName).AsActual(); var schema = textFolder.GetSchema().AsActual(); TextContent textContent = schema.CreateQuery().WhereEquals("UUID", uuid).FirstOrDefault(); var published = (bool?)textContent["Published"]; if (published.HasValue && published.Value == true) { TextContentManager.Update(Repository, schema, uuid, new string[] { "Published" }, new object[] { false }, User.Identity.Name); } else { TextContentManager.Update(Repository, schema, uuid, new string[] { "Published" }, new object[] { true }, User.Identity.Name); } }); return Json(data); }
public virtual ActionResult Index(string folderName, string parentUUID, string parentFolder, string search , IEnumerable<WhereClause> whereClause, int? page, int? pageSize, string orderField = null, string direction = 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["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 = ServiceFactory.TextFolderManager.ChildFolders(textFolder, search).Select(it => it.AsActual()); } } IContentQuery<TextContent> query = textFolder.CreateQuery(); if (string.IsNullOrEmpty(orderField)) { query = query.DefaultOrder(); } else { if (!string.IsNullOrEmpty(direction) && direction.ToLower() == "desc") { query = query.OrderByDescending(orderField); } else { query = query.OrderBy(orderField); } } 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.VisibleOnSidebarMenu == null || it.VisibleOnSidebarMenu.Value == true) .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 = ServiceFactory.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.ToArray(), ContentQuery = query, PageIndex = page.Value, PageSize = pageSize.Value, ShowTreeStyle = showTreeStyle }); }
public virtual ActionResult Delete(string folderName, string parentFolder, string[] folders, string[] docs) { var data = new JsonResultData(ModelState); data.RunWithTry((resultData) => { TextFolder textFolder = new TextFolder(Repository, folderName).AsActual(); var schema = textFolder.GetSchema().AsActual(); if (docs != null) { foreach (var doc in docs) { if (string.IsNullOrEmpty(doc)) continue; TextContentManager.Delete(Repository, textFolder, doc); } } if (folders != null) { foreach (var f in folders) { if (string.IsNullOrEmpty(f)) continue; var folderPathArr = FolderHelper.SplitFullName(f); TextFolderManager.Remove(Repository, new TextFolder(Repository, folderPathArr)); } } resultData.ReloadPage = true; }); return Json(data); }
public virtual ActionResult Edit(string folderName, string uuid, FormCollection form, string @return, bool localize = false) { var data = new JsonResultData(); try { if (ModelState.IsValid) { TextFolder textFolder = new TextFolder(Repository, folderName).AsActual(); var schema = textFolder.GetSchema().AsActual(); SchemaPath schemaPath = new SchemaPath(schema); IEnumerable<TextContent> addedCategories; IEnumerable<TextContent> removedCategories; ParseCategories(form, out addedCategories, out removedCategories); ContentBase content; content = TextContentManager.Update(Repository, textFolder, uuid, form, Request.Files, DateTime.UtcNow, addedCategories, removedCategories, User.Identity.Name); if (localize == true) { TextContentManager.Localize(textFolder, uuid); } data.RedirectToOpener = true; data.RedirectUrl = @return; } } catch (RuleViolationException violationException) { foreach (var item in violationException.Issues) { ModelState.AddModelError(item.PropertyName, item.ErrorMessage); } data.Success = false; } catch (Exception e) { data.AddException(e); } data.AddModelState(ModelState); return Json(data); }
public virtual ActionResult Create(string folderName, string parentFolder, string parentUUID, FormCollection form, string @return) { var data = new JsonResultData(); try { if (ModelState.IsValid) { TextFolder textFolder = new TextFolder(Repository, folderName).AsActual(); var schema = textFolder.GetSchema().AsActual(); SchemaPath schemaPath = new SchemaPath(schema); IEnumerable<TextContent> addedCategories; IEnumerable<TextContent> removedCategories; ParseCategories(form, out addedCategories, out removedCategories); ContentBase content; content = TextContentManager.Add(Repository, textFolder, parentFolder, parentUUID, form, Request.Files, addedCategories, User.Identity.Name); data.RedirectUrl = @return; } } catch (RuleViolationException ruleEx) { foreach (var item in ruleEx.Issues) { data.AddFieldError(item.PropertyName, item.ErrorMessage); } } catch (Exception e) { data.AddException(e); } data.AddModelState(ModelState); return Json(data); }
public virtual ActionResult Copy(string folderName, string parentFolder, string[] docs) { var data = new JsonResultData(ModelState); data.RunWithTry((resultData) => { TextFolder textFolder = new TextFolder(Repository, folderName).AsActual(); var schema = textFolder.GetSchema().AsActual(); if (docs != null) { foreach (var doc in docs) { if (string.IsNullOrEmpty(doc)) continue; TextContentManager.Copy(textFolder.GetSchema(), doc); } } data.ReloadPage = true; }); return Json(data); }
public virtual ActionResult BatchUnpublish(string folderName, string[] docs) { var data = new JsonResultData(ModelState); data.RunWithTry((resultData) => { TextFolder textFolder = new TextFolder(Repository, folderName).AsActual(); var schema = textFolder.GetSchema().AsActual(); if (docs != null) { foreach (var doc in docs) { if (string.IsNullOrEmpty(doc)) continue; TextContentManager.Update(Repository, schema, doc, new string[] { "Published" }, new object[] { false }, User.Identity.Name); } } resultData.ReloadPage = true; }); return Json(data); }
public virtual ActionResult Edit(string folderName, string parentFolder, string uuid) { TextFolder textFolder = new TextFolder(Repository, folderName).AsActual(); var schema = textFolder.GetSchema().AsActual(); SchemaPath schemaPath = new SchemaPath(schema); ViewData["Folder"] = textFolder; ViewData["Schema"] = schema; ViewData["Template"] = textFolder.GetFormTemplate(FormType.Update); SetPermissionData(textFolder); var content = schema.CreateQuery().WhereEquals("UUID", uuid).FirstOrDefault(); if (content != null) { content = ServiceFactory.WorkflowManager.GetPendWorkflowItemForContent(Repository, content, User.Identity.Name); } return View(content); }
/// <summary> /// /// </summary> /// <param name="OriginalRepository"></param> /// <param name="OriginalFolder"></param> /// <param name="OriginalUUID"></param> /// <param name="startVersionId"></param> /// <returns></returns> public virtual ActionResult ShowOriginalVersions(string OriginalRepository, string OriginalFolder, string OriginalUUID, int startVersionId = 0) { TextFolder textFolder = new TextFolder(new Repository(OriginalRepository), OriginalFolder).AsActual(); var schema = textFolder.GetSchema().AsActual(); var textContent = schema.CreateQuery().WhereEquals("UUID", OriginalUUID).FirstOrDefault(); var versions = VersionManager.AllVersionInfos(textContent).Where(it => it.Version > startVersionId); return View(versions); }
public virtual ActionResult Edit(string folderName, string parentFolder, string uuid, FormCollection form, bool? localize) { JsonResultEntry resultEntry = new JsonResultEntry() { Success = true }; try { if (ModelState.IsValid) { TextFolder textFolder = new TextFolder(Repository, folderName).AsActual(); var schema = textFolder.GetSchema().AsActual(); SchemaPath schemaPath = new SchemaPath(schema); IEnumerable<TextContent> addedCategories; IEnumerable<TextContent> removedCategories; ParseCategories(form, out addedCategories, out removedCategories); ContentBase content; //if (textFolder != null) //{ content = ServiceFactory.TextContentManager.Update(Repository, textFolder, uuid, form, Request.Files, DateTime.UtcNow, addedCategories, removedCategories, User.Identity.Name); if (localize.HasValue && localize.Value == true) { ServiceFactory.TextContentManager.Localize(textFolder, uuid); } //} //else //{ // content = ServiceFactory.TextContentManager.Update(Repository, schema, uuid, form, // Request.Files, User.Identity.Name); //} resultEntry.Success = true; } } catch (RuleViolationException violationException) { foreach (var item in violationException.Issues) { ModelState.AddModelError(item.PropertyName, item.ErrorMessage); } resultEntry.Success = false; } catch (Exception e) { resultEntry.SetFailed().AddException(e); } resultEntry.AddModelState(ViewData.ModelState); return Json(resultEntry); }
public virtual ActionResult Sort(IEnumerable<ContentSorter> list, string folderName) { var entry = new JsonResultEntry(); try { TextFolder textFolder = new TextFolder(Repository, folderName).AsActual(); var schema = textFolder.GetSchema().AsActual(); foreach (var c in list) { ServiceFactory.TextContentManager.Update(Repository, schema, c.UUID, new string[] { "Sequence" }, new object[] { c.Sequence }, User.Identity.Name); } } catch (Exception e) { } return Json(entry); }
public virtual ActionResult Publish(string folderName, string parentFolder, string uuid) { var entry = new JsonResultEntry(); try { TextFolder textFolder = new TextFolder(Repository, folderName).AsActual(); var schema = textFolder.GetSchema().AsActual(); TextContent textContent = schema.CreateQuery().WhereEquals("UUID", uuid).FirstOrDefault(); var published = (bool?)textContent["Published"]; if (published.HasValue && published.Value == true) { ServiceFactory.TextContentManager.Update(Repository, schema, uuid, new string[] { "Published" }, new object[] { false }, User.Identity.Name); } else { ServiceFactory.TextContentManager.Update(Repository, schema, uuid, new string[] { "Published" }, new object[] { true }, User.Identity.Name); } } catch (Exception e) { entry.AddException(e); } return Json(entry); }
public virtual ActionResult Create(string folderName, string parentFolder, string LikeUUID) { 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.Create_Menu); ViewData["Template"] = textFolder.GetFormTemplate(FormType.Create); SetPermissionData(textFolder); var content = Binder.Default(schema); content = Binder.Bind(schema, content, Request.QueryString, true, false); // copy categories and parentUUID - TODO if (!String.IsNullOrEmpty(LikeUUID)) { // želimo kategorije iz zadanog itema var contentLike = schema.CreateQuery().WhereEquals("UUID", LikeUUID).FirstOrDefault(); // sve kategorije za ovaj folder List<TextContent> addedCategories = new List<TextContent>(); foreach (CategoryFolder cf in textFolder.Categories) { addedCategories.AddRange(contentLike.Categories(cf.FolderName)); } // copy parentUUID content.ParentUUID = contentLike.ParentUUID; var cb = TextContentManager.Add(Repository, textFolder, content.ParentFolder, content.ParentUUID, content.ToNameValueCollection(), Request.Files, addedCategories, User.Identity.Name); content = new TextContent(cb); } return View(content); }
public virtual ActionResult Sort(ContentSorter[] list, string folderName) { var data = new JsonResultData(ModelState); data.RunWithTry((resultData) => { TextFolder textFolder = new TextFolder(Repository, folderName).AsActual(); var schema = textFolder.GetSchema().AsActual(); foreach (var c in list) { TextContentManager.Update(Repository, schema, c.UUID, new string[] { "Sequence" }, new object[] { c.Sequence }, User.Identity.Name); } resultData.ReloadPage = true; }); return Json(data); }
public JsonResult JSONForUUIDs(string folderName, FormCollection form) { string[] uuids = form["uuids"].Split(','); TextFolder textFolder = new TextFolder(Repository, folderName).AsActual(); var schema = textFolder.GetSchema().AsActual(); var img_column = schema.Columns.Find(i => i.ControlType == "ImageCrop");//|| i.ControlType == "File" string img_column_key = img_column != null ? img_column.Name : ""; var related_items = schema.CreateQuery().WhereIn("UUID", uuids); // keep order List<Object> items = new List<object>(); foreach(string uuid in uuids) { var item = related_items.SingleOrDefault(i => i.UUID == uuid); if (item != null) { object image; string thumb = ""; item.TryGetValue(img_column_key, out image); if (img_column!=null && !String.IsNullOrEmpty((string)image) ) { image = UrlUtility.resizeImage((string)image,60,60); thumb = image.ToString(); } items.Add(new { Text = item.GetSummary(), UUID = item.UUID, thumb = thumb }); } } return Json(items, JsonRequestBehavior.AllowGet); }
public virtual ActionResult Versions(string folderName, string parentFolder, string uuid) { TextFolder textFolder = new TextFolder(Repository, folderName).AsActual(); var schema = textFolder.GetSchema().AsActual(); var textContent = schema.CreateQuery().WhereEquals("UUID", uuid).FirstOrDefault(); var versions = VersionManager.AllVersionInfos(textContent); return View(versions); }
public virtual ActionResult Copy(string folderName, string parentFolder, string[] docArr, string[] folderArr) { JsonResultEntry entry = new JsonResultEntry(); try { TextFolder textFolder = new TextFolder(Repository, folderName).AsActual(); var schema = textFolder.GetSchema().AsActual(); if (docArr != null) { foreach (var doc in docArr) { if (string.IsNullOrEmpty(doc)) continue; ServiceFactory.TextContentManager.Copy(textFolder.GetSchema(), doc); } } entry.ReloadPage = true; entry.SetSuccess(); } catch (Exception e) { entry.AddException(e); } return Json(entry); }