Exemplo n.º 1
0
        public System.Web.Mvc.ActionResult HttpPost(Page_Context context, PagePositionContext positionContext)
        {
            HttpRequestBase request = context.ControllerContext.HttpContext.Request;
            Controller controller = (Controller)context.ControllerContext.Controller;
            string username = request.Form["username"];
            string email = request.Form["email"];
            try
            {
                if (string.IsNullOrEmpty(username) && string.IsNullOrEmpty(email))
                {
                    controller.ViewData.ModelState.AddModelError("", "Username or Email is required.".Localize());
                    return null;
                }
                else if (controller.ViewData.ModelState.IsValid)
                {
                    var repository = Repository.Current;
                    var textFolder = new TextFolder(repository, "Members");
                    TextContent content = null;
                    if (!string.IsNullOrEmpty(username))
                    {
                        content = textFolder.CreateQuery().WhereEquals("UserName", username).FirstOrDefault();
                        email = content.Get<string>("Email");
                    }
                    else
                    {
                        content = textFolder.CreateQuery().WhereEquals("Email", email).FirstOrDefault();
                        username = content.Get<string>("UserName");
                    }
                    if (content != null)
                    {
                        string randomValue = Kooboo.UniqueIdGenerator.GetInstance().GetBase32UniqueId(16);
                        ServiceFactory.TextContentManager.Update(textFolder, content.UUID, new string[] { "ForgotPWToken" }, new object[] { randomValue });

                        string link = new Uri(request.Url, string.Format("ResetPassword?UserName={0}&token={1}".RawLabel().ToString(), username, randomValue)).ToString();
                        string emailBody = "<b>{0}</b> <br/><br/> To change your password, click on the following link:<br/> <br/> <a href='{1}'>{1}</a> <br/>".RawLabel().ToString();
                        string subject = "Reset your password".RawLabel().ToString();
                        string body = string.Format(emailBody, username, link);
                        SendMail(email, subject, body, false);
                    }
                    else
                    {
                        controller.ViewData.ModelState.AddModelError("", "The user does not exists.".RawLabel().ToString());
                    }
                    controller.ViewBag.Message = "An email with instructions to choose a new password has been sent to you.".RawLabel().ToString();
                }
            }
            catch (Exception e)
            {
                controller.ViewData.ModelState.AddModelError("", e.Message);
            }

            return null;
        }
Exemplo n.º 2
0
        public ActionResult List(string userKey,int? pageIndex, int? pageSize)
        {
            var repository = Repository.Current;
            var categoryFolder = new TextFolder(repository, "Category");
            var articleFolder = new TextFolder(repository, "Article");

            var articleQuery = articleFolder.CreateQuery();

            //var userKey = Page_Context.Current.PageRequestContext.AllQueryString["UserKey"];

            if (!string.IsNullOrEmpty(userKey))
            {
                articleQuery = articleQuery.WhereCategory(categoryFolder.CreateQuery().WhereEquals("UserKey", userKey));
            }

            if (!pageIndex.HasValue)
            {
                pageIndex = 1;
            }
            if (!pageSize.HasValue)
            {
                pageSize = 2;
            }
            var pageData = articleQuery.Skip((pageIndex.Value - 1) * pageSize.Value).Take(pageSize.Value);

            DataRulePagedList pagedList = new DataRulePagedList(pageData,
                pageIndex.Value, pageSize.Value, articleQuery.Count());
            return View(pagedList);
        }
Exemplo n.º 3
0
        public ActionResult Categories()
        {
            var repository = Repository.Current;
            var categoryFolder = new TextFolder(repository, "Category");

            return View(categoryFolder.CreateQuery());
        }
Exemplo n.º 4
0
 public ActionResult Index(string repositoryName, string folder, string parentFolder, string parentUUID)
 {
     IContentQuery<TextContent> contentQuery = null;
     var repository = new Repository(repositoryName);
     var textFolder = new TextFolder(repository, folder);
     if (string.IsNullOrEmpty(parentFolder))
     {
         contentQuery = textFolder.CreateQuery()
             .Where(new OrElseExpression(new WhereEqualsExpression(null, "ParentUUID", null), new WhereEqualsExpression(null, "ParentUUID", "")));
     }
     else
     {
         contentQuery = textFolder.CreateQuery().WhereEquals("ParentFolder", parentFolder).WhereEquals("ParentUUID", parentUUID);
     }
     var data = contentQuery.ToDictionary(it => it.UUID, it => it.GetSummary());
     return Json(data, JsonRequestBehavior.AllowGet);
 }
Exemplo n.º 5
0
        public void Test1()
        {
            Repository repository = new Repository("TextTranslatorTests");

            MediaFolder binaryFolder = new MediaFolder(repository, "image");

            var binaryQuery = binaryFolder.CreateQuery().WhereEquals("Title", "title1");

            Assert.AreEqual("[MediaContent] SELECT * FROM [TextTranslatorTests.image] WHERE Title = title1 ORDER  | OP:Unspecified PageSize:0 TOP:0 Skip:0 ", TextTranslator.Translate(binaryQuery));

            Schema schema = new Schema(repository, "news") { IsDummy = false };

            TextFolder textFolder = new TextFolder(repository, "news") { SchemaName = "news", IsDummy = false };

            var textQuery = textFolder.CreateQuery().WhereEquals("Title", "title1").WhereCategory(textFolder.CreateQuery());

            Assert.AreEqual("[TextContent] SELECT * FROM [TextTranslatorTests.news$news] WHERE Title = title1 Category:([TextContent] SELECT * FROM [TextTranslatorTests.news$news] WHERE  Category:() ORDER  | OP:Unspecified PageSize:0 TOP:0 Skip:0 ) ORDER  | OP:Unspecified PageSize:0 TOP:0 Skip:0 ", TextTranslator.Translate(textQuery));
        }
 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);
     }
 }
Exemplo n.º 7
0
        public System.Web.Mvc.ActionResult HttpPost(Page_Context context, PagePositionContext positionContext)
        {
            HttpRequestBase request = context.ControllerContext.HttpContext.Request;
            Controller controller = (Controller)context.ControllerContext.Controller;
            string username = request.Params["UserName"];
            string token = request.Params["token"];
            if (!ValidateMemberPasswordToken(username, token))
            {
                context.ControllerContext.Controller.ViewData.ModelState.AddModelError("", "The password token is invalid.".Localize());
                return null;
            }
            AntiForgery.Validate();

            var newPassword = request.Form["newpassword"];
            var confirmPassword = request.Form["confirmPassword"];
            if (newPassword != confirmPassword)
            {
                context.ControllerContext.Controller.ViewData.ModelState.AddModelError("", "The passwords do not match.".RawLabel().ToString());
                return null;
            }
            try
            {
                var httpContext = context.ControllerContext.HttpContext;
                var repository = Repository.Current;
                var textFolder = new TextFolder(repository, "Members");
                var content = textFolder.CreateQuery().WhereEquals("UserName", username).FirstOrDefault();

                var passwordSalt = "";
                if (content["PasswordSalt"] == null)
                {
                    passwordSalt = MemberAuth.GenerateSalt();
                }
                else
                {
                    passwordSalt = content["PasswordSalt"].ToString();
                }

                newPassword = MemberAuth.EncryptPassword(newPassword, passwordSalt);

                ServiceFactory.TextContentManager.Update(textFolder, content.UUID,
                    new string[] { "Password", "ForgotPWToken", "PasswordSalt" }, new object[] { newPassword, "", passwordSalt });
                context.ControllerContext.Controller.ViewBag.Message = "The password has been changed.".Label();

                MemberAuth.SetAuthCookie(username, false);
                return new RedirectResult(context.Url.FrontUrl().PageUrl("Dashboard").ToString());
            }
            catch (Exception e)
            {
                context.ControllerContext.Controller.ViewData.ModelState.AddModelError("", e.Message);
                Kooboo.HealthMonitoring.Log.LogException(e);
            }
            return null;
        }
Exemplo n.º 8
0
        public virtual void Export(string formatter, string folderName, string[] docs)
        {
            var exporter = Kooboo.CMS.Common.Runtime.EngineContext.Current.Resolve<ITextContentFormater>((formatter ?? ""));
            var fileName = folderName + exporter.FileExtension;
            Response.AttachmentHeader(fileName);

            var textFolder = new TextFolder(Repository, folderName);

            var contentQuery = textFolder.CreateQuery();
            foreach (var item in docs)
            {
                contentQuery = contentQuery.Or(new WhereEqualsExpression(null, "UUID", item));
            }
            exporter.Export(contentQuery, Response.OutputStream);
        }
Exemplo n.º 9
0
        public System.Web.Mvc.ActionResult HttpPost(Page_Context context, PagePositionContext positionContext)
        {
            AntiForgery.Validate();

            try
            {
                var httpContext = context.ControllerContext.HttpContext;
                var repository = Repository.Current;
                var textFolder = new TextFolder(repository, "Members");

                string username = httpContext.Request.Form["username"];
                string password = httpContext.Request.Form["password"];

                var member = textFolder.CreateQuery().WhereEquals("UserName", username).FirstOrDefault();

                if (member != null)
                {
                    var encryptedPassword = password;
                    if (member["PasswordSalt"] != null)
                    {
                        var passwordSalt = member["PasswordSalt"].ToString();
                        encryptedPassword = MemberAuth.EncryptPassword(password, passwordSalt);
                    }
                    if (encryptedPassword == member["Password"].ToString())
                    {
                        var rememberme = httpContext.Request.Form["rememberMe"].Contains("true");
                        var returnUrl = httpContext.Request.QueryString["returnUrl"];
                        if (string.IsNullOrEmpty(returnUrl))
                        {
                            returnUrl = context.Url.FrontUrl().PageUrl("Dashboard").ToString();
                        }
                        MemberAuth.SetAuthCookie(username, rememberme);
                        return new RedirectResult(returnUrl);
                    }
                }
                context.ControllerContext.Controller.ViewData.ModelState.AddModelError("", "Username or password is invalid".RawLabel().ToString());
                return null;

            }
            catch (Exception e)
            {
                context.ControllerContext.Controller.ViewData.ModelState.AddModelError("", e);
                Kooboo.HealthMonitoring.Log.LogException(e);
            }
            return null;
        }
Exemplo n.º 10
0
 public virtual void Rebuild(TextFolder textFolder)
 {
     var isBuilding = IsRebuilding(textFolder);
     if (!isBuilding)
     {
         var key = GetIndexThreadKey(textFolder);
         Thread thread = new Thread(delegate()
         {
             var searchService = SearchHelper.OpenService(textFolder.Repository);
             searchService.BatchDelete(textFolder.FullName);
             var folderQuery = textFolder.CreateQuery().WhereEquals("Published", true);
             searchService.BatchAdd(folderQuery);
             indexThreads.Remove(key);
         });
         indexThreads.Add(key, thread);
         thread.Start();
     }
 }
Exemplo n.º 11
0
        public System.Web.Mvc.ActionResult HttpPost(Page_Context context, PagePositionContext positionContext)
        {
            AntiForgery.Validate();

            try
            {
                var httpContext = context.ControllerContext.HttpContext;
                var repository = Repository.Current;
                var textFolder = new TextFolder(repository, "Members");
                var values = new NameValueCollection(httpContext.Request.Form);
                values["Published"] = true.ToString();

                var member = textFolder.CreateQuery().WhereEquals("UserName", values["username"]).FirstOrDefault();
                if (member != null)
                {
                    context.ControllerContext.Controller.ViewData.ModelState.AddModelError("UserName", "The user already exists.".RawLabel().ToString());
                }
                else
                {
                    values["PasswordSalt"] = MemberAuth.GenerateSalt();
                    values["Password"] = MemberAuth.EncryptPassword(values["Password"], values["PasswordSalt"]);

                    var textContext = ServiceFactory.TextContentManager.Add(repository, textFolder, null, null,
                       values, httpContext.Request.Files, null, httpContext.User.Identity.Name);

                    MemberAuth.SetAuthCookie(textContext["UserName"].ToString(), false);

                    return new RedirectResult(context.Url.FrontUrl().PageUrl("Dashboard").ToString());
                }

            }
            catch (Exception e)
            {
                context.ControllerContext.Controller.ViewData.ModelState.AddModelError("", e);
                Kooboo.HealthMonitoring.Log.LogException(e);
            }
            return null;
        }
Exemplo n.º 12
0
        public object editPost(string postid, string username, string password, CookComputing.MetaWeblog.Post post, bool publish)
        {
            CheckUserPassword(username, password);
            string folderName;
            string userKey;
            string contentId = MetaWeblogHelper.ParsePostId(postid, out folderName, out userKey);
            var textFolder = new TextFolder(Repository, FolderHelper.SplitFullName(folderName));
            var content = textFolder.CreateQuery().WhereEquals("UUID", contentId).First();

            var values = new NameValueCollection();
            values["title"] = post.title;
            values["description"] = post.description;
            values["body"] = post.description;
            values["userKey"] = userKey;

            ServiceFactory.GetService<TextContentManager>().Update(Repository, textFolder, content.UUID, values);

            var old_categories = GetCategories(textFolder, content);

            var removedCategories = old_categories.Where(it => !post.categories.Any(c => string.Compare(c, it, true) == 0));
            var addedCategories = post.categories.Where(it => !old_categories.Any(c => string.Compare(c, it, true) == 0));

            var removed = GetCategories(textFolder, removedCategories).ToArray();
            if (removed.Length > 0)
            {
                ServiceFactory.GetService<TextContentManager>().RemoveCategories(Repository, (TextContent)content, removed);
            }

            var added = GetCategories(textFolder, addedCategories).ToArray();
            if (added.Length > 0)
            {
                ServiceFactory.GetService<TextContentManager>().AddCategories(Repository, (TextContent)content, added);
            }

            return MetaWeblogHelper.CompositePostId(content);
        }
 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()
                         {
                             PublishingObject = PublishingObject.TextContent,
                             SiteName = Site.Name,
                             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);
 }
Exemplo n.º 14
0
        public ActionResult PublishTextContent(CreateTextContentPublishingQueueViewModel model, string @return)
        {
            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".Localize());
                }
                else if (model.Schedule)
                {
                    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();
                        var queue = new LocalPublishingQueue(Site, Kooboo.UniqueIdGenerator.GetInstance().GetBase32UniqueId(10))
                        {
                            PublishingObject = PublishingObject.TextContent,
                            UserId = User.Identity.Name,
                            UtcCreationDate = DateTime.UtcNow,
                            ObjectUUID = content.IntegrateId,
                            ObjectTitle = model.ObjectTitles[i],
                            Status = QueueStatus.Pending
                        };
                        if (model.UtcTimeToPublish.HasValue)
                        {
                            queue.UtcTimeToPublish = model.UtcTimeToPublish.Value.ToUniversalTime();
                        }
                        if (model.UtcTimeToUnpublish.HasValue)
                        {
                            queue.UtcTimeToUnpublish = model.UtcTimeToUnpublish.Value.ToUniversalTime();
                        }

                        resultEntry.RunWithTry((data) =>
                        {
                            _manager.Add(queue);
                        });
                    }
                    resultEntry.RedirectUrl = @return;
                }
                else
                {
                    TextFolder textFolder = new TextFolder(Repository.Current, model.LocalFolderId).AsActual();
                    foreach (string uuid in model.TextContents)
                    {
                        Kooboo.CMS.Content.Services.ServiceFactory.TextContentManager.Update(textFolder, uuid, "Published", true, User.Identity.Name);
                    }
                    resultEntry.RedirectUrl = @return;
                }
            }
            return Json(resultEntry);
        }
 public void DeleteTextContent(Site site, TextFolder textFolder, string uuid, string vendor)
 {
     var integrateId = new ContentIntegrateId(uuid);
     var content = textFolder.CreateQuery().WhereEquals("UUID", integrateId.ContentUUID).FirstOrDefault();
     if (content != null)
     {
         IncomingQueue incomeQueue = new IncomingQueue()
         {
             Message = null,
             Object = null,
             ObjectUUID = uuid,
             ObjectTitle = content.GetSummary(),
             Vendor = vendor,
             PublishingObject = PublishingObject.TextContent,
             Action = PublishingAction.Unbpulish,
             SiteName = site.FullName,
             Status = QueueStatus.Pending,
             UtcCreationDate = DateTime.UtcNow,
             UtcProcessedTime = null,
             UUID = Kooboo.UniqueIdGenerator.GetInstance().GetBase32UniqueId(10)
         };
         _incomeQueueProvider.Add(incomeQueue);
     }
 }
Exemplo n.º 16
0
        public ActionResult QueryByParentUUID(string folderName, string parentUUID, string parentChain)
        {
            JsonResultEntry data = new JsonResultEntry();
            var textFolder = new TextFolder(Repository, folderName).AsActual();
            var contentQuery = textFolder.CreateQuery().WhereEquals("ParentUUID", parentUUID);
            var contents = contentQuery.DefaultOrder().ToArray();
            var requestContext = ControllerContext.RequestContext;

            List<TextFolder> embeddedFolders = new List<TextFolder>();
            if (textFolder.EmbeddedFolders != null)
            {
                foreach (var s in textFolder.EmbeddedFolders)
                {
                    embeddedFolders.Add(Kooboo.CMS.Content.Models.IPersistableExtensions.AsActual(new TextFolder(Repository.Current, s)));
                }
            }
            var url = requestContext.UrlHelper();
            parentChain = string.IsNullOrEmpty(parentChain) ? parentUUID : parentChain + "," + parentUUID;
            foreach (var item in contents)
            {
                item["_LocalCreationDate_"] = item.UtcCreationDate.ToLocalTime().ToShortDateString();
                item["_EditUrl_"] = url.Action("Edit", requestContext.AllRouteValues().Merge("UserKey", (object)(item.UserKey)).Merge("UUID", (object)(item.UUID)));
                item["_CreateUrl_"] = url.Action("Create", requestContext.AllRouteValues().Merge("UserKey", null).Merge("ParentUUID", (object)(item.UUID)));
                item["_VersionUrl_"] = url.Action("Versions", requestContext.AllRouteValues().Merge("UserKey", (object)(item.UserKey)).Merge("UUID", (object)(item.UUID)));
                item["_PublishUrl_"] = url.Action("Publish", requestContext.AllRouteValues().Merge("UserKey", (object)(item.UserKey)).Merge("UUID", (object)(item.UUID)));
                item["_ParentChain_"] = parentChain;
                item["_EmbeddedFolders_"] = embeddedFolders.Select(it => new
                {
                    Text = it.FriendlyText,
                    Link = url.Action("SubContent", new { SiteName = requestContext.GetRequestValue("SiteName"), RepositoryName = Repository.Name, ParentFolder = item.FolderName, FolderName = it.FullName, parentUUID = (object)(item.UUID) })
                });
            }
            data.Model = contents;

            return new Json_netResult() { Data = data, JsonRequestBehavior = JsonRequestBehavior.AllowGet };
        }
Exemplo n.º 17
0
        public virtual ActionResult UpdateToRead(string repositoryName, string folderName, string uuid, string originalRepository, string originalFolder, string originalUUID, string @return)
        {
            var data = new JsonResultData(ModelState);
            data.RunWithTry((resultData) =>
            {
                var repository = new Repository(repositoryName);
                var textFolder = new TextFolder(repository, folderName);
                var textContent = textFolder.CreateQuery().WhereEquals("UUID", uuid).FirstOrDefault();
                if (textContent != null)
                {
                    textContent.OriginalUpdateTimes = 0;
                    var originalTextFolder = new TextFolder(new Repository(originalRepository), originalFolder).AsActual();
                    if (originalTextFolder != null)
                    {
                        var originalContent = originalTextFolder.CreateQuery().WhereEquals("UUID", originalUUID).FirstOrDefault();
                        if (originalContent != null)
                        {
                            var maxVersion = VersionManager.AllVersionInfos(textContent).Max(it => it.Version);
                            textContent.OriginalLastestVisitedVersionId = maxVersion;
                        }
                    }

                    _textContentProvider.Update(textContent, textContent);
                }

                data.RedirectUrl = @return;
            });
            return Json(data);
        }
Exemplo n.º 18
0
        public ActionResult QueryByParentUUID(string folderName, string parentUUID, string parentChain, string @return)
        {
            var data = new JsonResultData(ModelState);
            var textFolder = new TextFolder(Repository, folderName).AsActual();
            var contentQuery = textFolder.CreateQuery().WhereEquals("ParentUUID", parentUUID).DefaultOrder();
            var contents = contentQuery.ToArray();
            var requestContext = ControllerContext.RequestContext;

            List<TextFolder> embeddedFolders = new List<TextFolder>();
            if (textFolder.EmbeddedFolders != null)
            {
                foreach (var s in textFolder.EmbeddedFolders)
                {
                    embeddedFolders.Add(Kooboo.CMS.Content.Models.IPersistableExtensions.AsActual(new TextFolder(Repository.Current, s)));
                }
            }
            var url = requestContext.UrlHelper();
            parentChain = string.IsNullOrEmpty(parentChain) ? parentUUID : parentChain + "," + parentUUID;
            foreach (var item in contents)
            {
                item["_LocalCreationDate_"] = item.UtcCreationDate.ToLocalTime().ToShortDateString();
                item["_EditUrl_"] = url.Action("Edit", requestContext.AllRouteValues().Merge("UserKey", (object)(item.UserKey)).Merge("UUID", (object)(item.UUID)).Merge("return", @return));
                item["_CreateUrl_"] = url.Action("Create", requestContext.AllRouteValues().Merge("UserKey", null).Merge("ParentFolder", folderName).Merge("ParentUUID", (object)(item.UUID)).Merge("return", @return));
                item["_VersionUrl_"] = url.Action("Versions", requestContext.AllRouteValues().Merge("UserKey", (object)(item.UserKey)).Merge("UUID", (object)(item.UUID)).Merge("return", @return));
                item["_PublishUrl_"] = url.Action("Publish", requestContext.AllRouteValues().Merge("UserKey", (object)(item.UserKey)).Merge("UUID", (object)(item.UUID)).Merge("return", @return));
                item["_ParentChain_"] = parentChain;
                item["_TRClass_"] = ("doctr" + (item.Published.HasValue && item.Published == true ? " published" : " unpublished") + ((item.IsLocalized != null && item.IsLocalized == false) ? " unlocalized" : " localized"));
                item["_EmbeddedFolders_"] = embeddedFolders.Select(it => new
                {
                    Text = it.FriendlyText,
                    Link = url.Action("SubContent", new { SiteName = requestContext.GetRequestValue("SiteName"), RepositoryName = Repository.Name, ParentFolder = item.FolderName, FolderName = it.FullName, parentUUID = (object)(item.UUID), @return = @return })
                });
                if (item.OriginalUpdateTimes > 0)
                {
                    item["_ViewOriginalContentChangesURL_"] = @Url.Action("ShowOriginalVersions", this.ControllerContext.RequestContext.AllRouteValues().Merge("UUID", (string)(item.UUID)).Merge("OriginalRepository", (string)(item.OriginalRepository))
                        .Merge("OriginalFolder", (string)(item.OriginalFolder)).Merge("OriginalUUID", (string)(item.OriginalUUID)).Merge("startVersionId", (int)(item.OriginalLastestVisitedVersionId))
                        .Merge("return", @return));
                }
            }
            data.Model = contents;

            return new Json_netResult() { Data = data, JsonRequestBehavior = JsonRequestBehavior.AllowGet };
        }
Exemplo n.º 19
0
        public virtual void Top(Repository repository, string folderName, string uuid)
        {
            var folder = new TextFolder(repository, folderName).AsActual();
            var content = folder.CreateQuery().WhereEquals("UUID", uuid).FirstOrDefault();
            if (content != null)
            {

            }
        }
Exemplo n.º 20
0
 /// <summary>
 /// 根据源内容查询广播的内容
 /// </summary>
 /// <param name="folder">The folder.</param>
 /// <param name="originalUUID">The original UUID.</param>
 /// <returns></returns>
 public static IEnumerable<TextContent> GetContentsByOriginalUUID(TextFolder folder, string originalUUID)
 {
     return folder.CreateQuery().WhereEquals("OriginalUUID", originalUUID);
 }
Exemplo n.º 21
0
        private void InsertOrUpdate(TextFolder textFolder, TextContent textContent)
        {
            var oldContent = textFolder.CreateQuery().WhereEquals("UUID", textContent.UUID).FirstOrDefault();
            textContent.Repository = textFolder.Repository.Name;
            textContent.FolderName = textFolder.FullName;
            textContent.SchemaName = textFolder.SchemaName;
            if (oldContent != null)
            {
                foreach (var key in textContent.Keys)
                {
                    oldContent[key] = textContent[key];
                }

                _textContentProvider.Update(oldContent, oldContent);
            }
            else
            {
                var nameValues = textContent.ToNameValueCollection();
                _textContentManager.Add(textFolder.Repository, textFolder, nameValues, null, null, System.Web.HttpContext.Current.User.Identity.Name);
            }

        }
Exemplo n.º 22
0
        public virtual bool ValidateMemberPasswordToken(string userName, string token)
        {
            var repository = Repository.Current;
            var textFolder = new TextFolder(repository, "Members");
            var member = textFolder.CreateQuery().WhereEquals("UserName", userName).FirstOrDefault();

            if (member == null)
            {
                return false;
            }
            string dbToken = member.Get<string>("ForgotPWToken");
            var passwordToken = dbToken == null ? "" : dbToken.ToString();
            if (string.IsNullOrEmpty(passwordToken) || !passwordToken.EqualsOrNullEmpty(token, StringComparison.OrdinalIgnoreCase))
            {
                return false;
            }
            return true;
        }
Exemplo n.º 23
0
        public virtual void Update(TextFolder textFolder, string uuid, IEnumerable<string> fieldNames, IEnumerable<object> fieldValues, string userName = "", bool enableVersion = true)
        {
            var content = textFolder.CreateQuery().WhereEquals("UUID", uuid).FirstOrDefault();
            if (content.IntegrateId != null)
            {
                var names = fieldNames.ToArray();
                var values = fieldValues.ToArray();
                for (int i = 0; i < names.Length; i++)
                {
                    content[names[i]] = values[i];
                }

                if (!string.IsNullOrEmpty(userName))
                {
                    content.UserId = userName;
                }
                content.___EnableVersion___ = enableVersion;
                content.UtcLastModificationDate = DateTime.UtcNow;

                EventBus.Content.ContentEvent.Fire(ContentAction.PreUpdate, content);

                TextContentProvider.Update(content, content);

                EventBus.Content.ContentEvent.Fire(ContentAction.Update, content);

            }
        }
Exemplo n.º 24
0
 public CookComputing.MetaWeblog.Post getPost(string postid, string username, string password)
 {
     string folderName;
     string userKey;
     string contentId = MetaWeblogHelper.ParsePostId(postid, out folderName, out userKey);
     var textFolder = new TextFolder(Repository, FolderHelper.SplitFullName(folderName));
     var content = textFolder.CreateQuery().WhereEquals("UUID", contentId).First();
     return new CookComputing.MetaWeblog.Post()
     {
         postid = postid,
         categories = GetCategories(textFolder, content),
         description = content["description"] == null ? content["body"] == null ? "" : content["body"].ToString() : content["description"].ToString(),
         title = content["title"] == null ? "" : content["title"].ToString(),
         userid = content.UserId
     };
 }
Exemplo n.º 25
0
        public virtual ActionResult Rebroadcast(string folderName, string parentFolder, string[] docs)
        {
            var data = new JsonResultData(ModelState);
            data.RunWithTry((resultData) =>
            {
                TextFolder textFolder = new TextFolder(Repository, folderName).AsActual();

                if (docs != null)
                {
                    foreach (var doc in docs.Reverse())
                    {
                        if (string.IsNullOrEmpty(doc)) continue;

                        var textContent = textFolder.CreateQuery().WhereEquals("UUID", doc).FirstOrDefault();
                        if (textContent != null)
                        {
                            Kooboo.CMS.Content.EventBus.Content.ContentEvent.Fire(ContentAction.Add, textContent);
                        }
                    }
                }
                resultData.ReloadPage = true;
            });
            return Json(data);
        }
Exemplo n.º 26
0
 public CookComputing.MetaWeblog.Post[] getRecentPosts(string blogid, string username, string password, int numberOfPosts)
 {
     CheckUserPassword(username, password);
     var folder = new TextFolder(Repository, FolderHelper.SplitFullName(blogid));
     return folder.CreateQuery().Take(numberOfPosts).ToArray().Select(it => new CookComputing.MetaWeblog.Post()
     {
         categories = GetCategories(folder, it),
         dateCreated = it.UtcCreationDate,
         description = it["description"] == null ? "" : it["description"].ToString(),
         postid = it.UUID,
         title = it["title"] == null ? "" : it["title"].ToString(),
         userid = it.UserId
     }).ToArray();
 }
Exemplo n.º 27
0
        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
            });
        }
Exemplo n.º 28
0
 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();
 }
Exemplo n.º 29
0
        public virtual ActionResult Rebroadcast(string folderName, string parentFolder, string[] docArr, string[] folderArr)
        {
            JsonResultEntry entry = new JsonResultEntry();
            try
            {
                TextFolder textFolder = new TextFolder(Repository, folderName).AsActual();

                if (docArr != null)
                {
                    foreach (var doc in docArr)
                    {
                        if (string.IsNullOrEmpty(doc)) continue;

                        var textContent = textFolder.CreateQuery().WhereEquals("UUID", doc).FirstOrDefault();
                        if (textContent != null)
                        {
                            Kooboo.CMS.Content.EventBus.Content.ContentEvent.Fire(ContentAction.Add, textContent);
                        }
                    }
                }

                entry.SetSuccess();
            }
            catch (Exception e)
            {
                entry.AddException(e);
            }
            return Json(entry);
        }
Exemplo n.º 30
0
        public virtual void PublishTextContent(TextFolder textFolder, string[] docs, bool localPublish, bool remotePublish, bool publishSchedule, string[] publishingMappings, DateTime? publishDate, DateTime? unpublishDate, string userName)
        {
            foreach (string uuid in docs)
            {
                var content = textFolder.CreateQuery().WhereEquals("UUID", uuid).FirstOrDefault();
                if (content != null)
                {
                    if (localPublish)
                    {
                        if (publishSchedule)
                        {
                            var queue = new LocalPublishingQueue()
                            {
                                ObjectUUID = content.IntegrateId,
                                ObjectTitle=content.GetSummary(),
                                UserId = userName,
                                SiteName = Site.Current.Name,
                                UtcCreationDate = DateTime.UtcNow,
                                PublishingObject = PublishingObject.TextContent,
                                Status = QueueStatus.Pending
                            };
                            if (publishDate.HasValue)
                            {
                                queue.UtcTimeToPublish = publishDate.Value.ToUniversalTime();
                            }
                            if (unpublishDate.HasValue)
                            {
                                queue.UtcTimeToUnpublish = unpublishDate.Value.ToUniversalTime();
                            }
                            this._localPublishingQueueManager.Add(queue);
                        }
                        else
                        {
                            this._textContentManager.Publish(textFolder, uuid, userName);
                            _publishingLogProvider.Add(new PublishingLog()
                            {
                                QueueType = QueueType.Local,
                                SiteName = Site.Current.Name,
                                PublishingObject = PublishingObject.TextContent,
                                ObjectUUID = uuid,
                                ObjectTitle = uuid,
                                PublishingAction = PublishingAction.Publish,
                                UserId = userName,                                
                                Status = QueueStatus.OK,
                                UtcProcessedTime = DateTime.UtcNow
                            });

                        }
                    }
                    if (remotePublish)
                    {

                        foreach (string mapping in publishingMappings)
                        {
                            var queue = new RemotePublishingQueue()
                            {
                                ObjectUUID = content.IntegrateId,
                                ObjectTitle = content.GetSummary(),
                                PublishingObject = PublishingObject.TextContent,
                                SiteName = Site.Current.Name,
                                UserId = userName,
                                TextFolderMapping = mapping,
                                UtcCreationDate = DateTime.UtcNow,
                                Status = QueueStatus.Pending
                            };
                            if (publishSchedule)
                            {
                                if (publishDate.HasValue)
                                {
                                    queue.UtcTimeToPublish = publishDate.Value.ToUniversalTime();
                                }
                                if (unpublishDate.HasValue)
                                {
                                    queue.UtcTimeToUnpublish = unpublishDate.Value.ToUniversalTime();
                                }
                            }
                            else
                            {
                                queue.UtcTimeToPublish = DateTime.UtcNow;
                            }
                            this._remotePublishingQueueManager.Add(queue);
                        }
                    }

                }
            }
        }