Пример #1
0
        public ActionResult Categories()
        {
            var repository = Repository.Current;
            var categoryFolder = new TextFolder(repository, "Category");

            return View(categoryFolder.CreateQuery());
        }
Пример #2
0
        public virtual ActionResult Create(TextFolder model, string folderName)
        {
            //compatible with the Folder parameter changed to FolderName.
            folderName = folderName ?? this.ControllerContext.RequestContext.GetRequestValue("Folder");

            JsonResultEntry resultEntry = new JsonResultEntry() { Success = true };
            try
            {
                if (ModelState.IsValid)
                {
                    Folder parent = null;
                    if (!string.IsNullOrEmpty(folderName))
                    {
                        parent = FolderHelper.Parse<TextFolder>(Repository, folderName);
                    }
                    model.Parent = parent;
                    model.UtcCreationDate = DateTime.UtcNow;
                    Manager.Add(Repository, model);

                    resultEntry.Success = true;

                    return Json(resultEntry);
                }
            }
            catch (Exception e)
            {
                resultEntry.SetFailed().AddException(e);
            }
            resultEntry.AddModelState(ViewData.ModelState);
            return Json(resultEntry);
        }
Пример #3
0
        static SimpleQueryTests()
        {
            repository = new Repository("SimpleQueryTests");
            schema = new Schema(repository, "news");
            schema.AddColumn(new Column()
            {
                Name = "Title",
                DataType = DataType.String,
                Length = 256
            });
            schema.AddColumn(new Column()
            {
                Name = "Comments",
                DataType = DataType.Int
            });

            folder = new TextFolder(repository, "news");
            folder.SchemaName = schema.Name;

            ProviderFactory providerFactory = new ProviderFactory();
            Providers.DefaultProviderFactory = providerFactory;
            providerFactory.GetProvider<IRepositoryProvider>().Add(repository);
            providerFactory.GetProvider<ISchemaProvider>().Add(schema);
            providerFactory.GetProvider<ITextFolderProvider>().Add(folder);

            InitializeData();
        }
Пример #4
0
 public string UpdateTextContent(Site site, TextFolder textFolder, string integrateId, NameValueCollection values, string userid, string vendor)
 {
     var integrate = new ContentIntegrateId(integrateId);
     var files = values.GetFilesFromValues();
     var textContent = _textContentManager.Update(textFolder.Repository, textFolder, integrate.ContentUUID, values, files, DateTime.UtcNow, null, null, userid, true);
     return textContent.IntegrateId;
 }
Пример #5
0
 public string AddTextContent(Site site, TextFolder textFolder, NameValueCollection values, string userid, string vendor)
 {
     var files = values.GetFilesFromValues();
     var categories = values.GetCategories().Select(it => new TextContent(textFolder.Repository.Name, "", it.CategoryFolder) { UUID = it.CategoryUUID }).ToArray();
     var textContent = _textContentManager.Add(textFolder.Repository, textFolder, values, files, categories, userid);
     return textContent.IntegrateId;
 }
Пример #6
0
        static ParentQueryTests()
        {
            repository = new Repository("ParentQueryTests");

            commentSchema = new Schema(repository, "comments");
            commentSchema.AddColumn(new Column() { Name = "title", DataType = Kooboo.Data.DataType.String, Length = 256 });


            newsSchema = new Schema(repository, "news") { ChildSchemas = new[] { commentSchema.Name } };
            newsSchema.AddColumn(new Column()
            {
                Name = "Title",
                DataType = Kooboo.Data.DataType.String,
                Length = 256
            });
            newsSchema.AddColumn(new Column()
            {
                Name = "Comments",
                DataType = Kooboo.Data.DataType.Int
            });

            newsFolder = new TextFolder(repository, "news") { SchemaName = newsSchema.Name };

            ProviderFactory providerFactory = new ProviderFactory();
            Providers.DefaultProviderFactory = providerFactory;
            providerFactory.GetProvider<IRepositoryProvider>().Add(repository);
            providerFactory.GetProvider<ISchemaProvider>().Add(commentSchema);
            providerFactory.GetProvider<ISchemaProvider>().Add(newsSchema);
            providerFactory.GetProvider<ITextFolderProvider>().Add(newsFolder);
            InitializeData();
        }
Пример #7
0
        public virtual ActionResult Create(TextFolder model, string folderName, string @return)
        {
            //compatible with the Folder parameter changed to FolderName.
            folderName = folderName ?? this.ControllerContext.RequestContext.GetRequestValue("Folder");

            var data = new JsonResultData(ModelState);
            if (ModelState.IsValid)
            {
                data.RunWithTry((resultData) =>
                {

                    Folder parent = null;
                    if (!string.IsNullOrEmpty(folderName))
                    {
                        parent = FolderHelper.Parse<TextFolder>(Repository, folderName);
                    }
                    model.Parent = parent;
                    model.UtcCreationDate = DateTime.UtcNow;
                    Manager.Add(Repository, model);

                    resultData.RedirectUrl = @return;
                });

            }

            return Json(data);
        }
Пример #8
0
        public QueryTests()
        {
            EmptyUserKeyGenerator.DefaultGenerator = new EmptyUserKeyGenerator();
            Providers.DefaultProviderFactory = new MongoDB.ProviderFactory();

            repository = new Repository(Kooboo.UniqueIdGenerator.GetInstance().GetBase32UniqueId(10).ToString());
            Providers.DefaultProviderFactory.GetProvider<IRepositoryProvider>().Add(repository);
            categorySchema = new Schema(repository, "category") { IsDummy = false };
            categorySchema.AddColumn(new Column() { Name = "Title" });
            categoryFolder = new TextFolder(repository, "Category") { SchemaName = categorySchema.Name, IsDummy = false };
            Providers.DefaultProviderFactory.GetProvider<ITextFolderProvider>().Add(categoryFolder);

            newsSchema = new Schema(repository, "News") { IsDummy = false };
            newsSchema.AddColumn(new Column() { Name = "title", DataType = Data.DataType.String });
            newsSchema.AddColumn(new Column() { Name = "Body", DataType = Data.DataType.String });
            newsSchema.AddColumn(new Column() { Name = "Comments", DataType = Data.DataType.Int });
            Providers.DefaultProviderFactory.GetProvider<ISchemaProvider>().Add(newsSchema);

            newsFolder = new TextFolder(repository, "News") { SchemaName = newsSchema.Name, Categories = new List<CategoryFolder>() { new CategoryFolder() { FolderName = categoryFolder.FullName, SingleChoice = false } }, OrderSetting = new OrderSetting() { FieldName = "Sequence", Direction = OrderDirection.Descending } };
            Providers.DefaultProviderFactory.GetProvider<ITextFolderProvider>().Add(newsFolder);

            commentSchema = new Schema(repository, "Comment") { IsDummy = false };
            commentSchema.AddColumn(new Column() { Name = "Title" });
            Providers.DefaultProviderFactory.GetProvider<ISchemaProvider>().Add(commentSchema);

            category1 = new TextContent(repository.Name, categorySchema.Name, categoryFolder.FullName);
            category1["title"] = "category1";
            provider.Add(category1);

            category2 = new TextContent(repository.Name, categorySchema.Name, categoryFolder.FullName);
            category2["title"] = "category2";
            provider.Add(category2);

            newsContent = new TextContent(repository.Name, newsSchema.Name, newsFolder.FullName);
            newsContent["title"] = "news1";
            newsContent["body"] = "body";
            newsContent["comments"] = 1;
            provider.Add(newsContent);

            news2 = new TextContent(repository.Name, newsSchema.Name, newsFolder.FullName);
            news2["title"] = "news2";
            news2["body"] = "body";
            news2["comments"] = 0;
            provider.Add(news2);

            news3 = new TextContent(repository.Name, newsSchema.Name, newsFolder.FullName);
            news3["title"] = "news2";
            news3["body"] = "body";
            news3["comments"] = 5;
            provider.Add(news3);

            provider.AddCategories(newsContent, new Category() { ContentUUID = newsContent.UUID, CategoryUUID = category1.UUID, CategoryFolder = category1.FolderName });
            provider.AddCategories(newsContent, new Category() { ContentUUID = newsContent.UUID, CategoryUUID = category2.UUID, CategoryFolder = category2.FolderName });

            commenContent = new TextContent(repository.Name, commentSchema.Name, "");
            commenContent.ParentFolder = newsContent.FolderName;
            commenContent.ParentUUID = newsContent.UUID;
            commenContent["title"] = "comment1";
            provider.Add(commenContent);
        }
Пример #9
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);
        }
Пример #10
0
        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;
        }
Пример #11
0
        static CategoriesQueryTests()
        {
            repository = new Repository("CategoriesQueryTests");

            categorySchema = new Schema(repository, "category");
            categorySchema.AddColumn(new Column() { Name = "title", DataType = DataType.String, Length = 256 });

            categoryFolder = new TextFolder(repository, "category") { SchemaName = categorySchema.Name };

            newsSchema = new Schema(repository, "news");
            newsSchema.AddColumn(new Column()
            {
                Name = "Title",
                DataType = DataType.String,
                Length = 256
            });
            newsSchema.AddColumn(new Column()
            {
                Name = "Comments",
                DataType = DataType.Int
            });

            newsFolder = new TextFolder(repository, "news") { SchemaName = newsSchema.Name, CategoryFolders = new[] { categoryFolder.Name } };

            ProviderFactory providerFactory = new ProviderFactory();
            Providers.DefaultProviderFactory = providerFactory;
            providerFactory.GetProvider<IRepositoryProvider>().Add(repository);
            providerFactory.GetProvider<ISchemaProvider>().Add(categorySchema);
            providerFactory.GetProvider<ISchemaProvider>().Add(newsSchema);
            providerFactory.GetProvider<ITextFolderProvider>().Add(newsFolder);
            providerFactory.GetProvider<ITextFolderProvider>().Add(categoryFolder);
            InitializeData();
        }
        public void Receive(IEventContext context)
        {
            if (context is ContentEventContext)
            {
                var contentEventContext = (ContentEventContext)context;
                if (contentEventContext.ContentAction == Models.ContentAction.Delete)
                {
                    Task.Factory.StartNew(() =>
                    {
                        try
                        {
                            var textFolder = contentEventContext.Content.GetFolder().AsActual();

                            // Delete the child contents in this folder.
                            DeleteChildContents(contentEventContext.Content, textFolder, textFolder);

                            if (textFolder.EmbeddedFolders != null)
                            {
                                foreach (var folderName in textFolder.EmbeddedFolders)
                                {
                                    var childFolder = new TextFolder(textFolder.Repository, folderName);
                                    DeleteChildContents(contentEventContext.Content, textFolder, childFolder);
                                }
                            }
                        }
                        catch (Exception e)
                        {
                            Kooboo.HealthMonitoring.Log.LogException(e);
                        }

                    });
                }
            }
        }
Пример #13
0
        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);
        }
Пример #14
0
        public virtual ActionResult WorkflowHistory(string UUID, string folderName)
        {
            var textContent = new TextFolder(Repository, folderName).CreateQuery().WhereEquals("UUID", UUID).FirstOrDefault();

            var history = Manager.GetWorkflowHistory(Repository, textContent);

            return View(history);
        }
Пример #15
0
 private void EnsureFolder(Repository orginalRepository, TextFolder folder)
 {
     Folder parentFolder = folder.Parent;
     while (parentFolder != null)
     {
         parentFolder.Repository = orginalRepository;
         parentFolder = parentFolder.Parent;
     }
 }
 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);
     }
 }
Пример #17
0
        public override void Add(Repository orginalRepository, TextFolder folder)
        {
            _textFolderManager.Add(orginalRepository, folder);

            Sync(Site.Current, orginalRepository, (Repository targetRepository) =>
            {
                EnsureFolder(targetRepository, folder);
                _textFolderManager.Add(targetRepository, folder);
            });
        }
        public static IDocumentQuery<TextContent> CreateQuery(this DocumentSession session, Schema schema, TextFolder textFolder)
        {
            var documentQuery = session.LuceneQuery<TextContent>(schema.GetIndexName()).WaitForNonStaleResultsAsOfNow(TextContentProvider.WaitTimeout);

            if (textFolder != null)
            {
                documentQuery = documentQuery.WhereEquals("FolderName", textFolder.FullName.ToLower());
            }
            return documentQuery;
        }
Пример #19
0
        public InsertUpdateDeleteTests()
        {
            repository = new Repository("InsertUpdateDeleteTests");
            newsSchema = new Schema(repository, "News");
            newsSchema.AddColumn(new Column() { Name = "title", DataType = Data.DataType.String });
            newsSchema.AddColumn(new Column() { Name = "Body", DataType = Data.DataType.String });
            textFolder = new TextFolder(repository, "News") { SchemaName = newsSchema.Name };

            EmptyUserKeyGenerator.DefaultGenerator = new EmptyUserKeyGenerator();
        }
Пример #20
0
        public static Kooboo.CMS.Content.Models.TextFolder GetTextFolder(string repositoryId, string folderId)
        {
            var repository = GetRepository(repositoryId);
            var textFolder = new Kooboo.CMS.Content.Models.TextFolder(repository, folderId).AsActual();

            if (textFolder == null)
            {
                throw new FaultException <cmisFaultType>(CreateFault(enumServiceException.objectNotFound, string.Format("No such folder:{0}.".Localize(), folderId)));
            }
            return(textFolder);
        }
Пример #21
0
        public static Kooboo.CMS.Content.Models.TextFolder GetTextFolder(string repositoryId, string folderId)
        {
            var repository = GetRepository(repositoryId);
            var textFolder = new Kooboo.CMS.Content.Models.TextFolder(repository, folderId).AsActual();

            if (textFolder == null)
            {
                throw new FaultException(string.Format("No such folder:{0}.".Localize(), folderId));
            }
            return(textFolder);
        }
Пример #22
0
 /// <summary>
 /// Gets the folder form template.
 /// </summary>
 /// <param name="textFolder">The text folder.</param>
 /// <param name="type">The type.</param>
 /// <returns></returns>
 private static string GetFolderFormTemplate(TextFolder textFolder, FormType type)
 {
     string fileVirtualPath = "";
     var folderPath = new FolderPath(textFolder);
     string filePhysicalPath = Path.Combine(folderPath.PhysicalPath, SchemaExtensions.CUSTOM_TEMPLATES, string.Format("{0}.cshtml", type));
     if (File.Exists(filePhysicalPath))
     {
         fileVirtualPath = UrlUtility.Combine(folderPath.VirtualPath, SchemaExtensions.CUSTOM_TEMPLATES, string.Format("{0}.cshtml", type));
     }
     return fileVirtualPath;
 }
        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);
                _textFolderManager.Update(targetRepository, newFolder, oldFolder);
            });
        }
Пример #24
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;
        }
Пример #25
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;
        }
Пример #26
0
        public override void Remove(Repository orginalRepository, TextFolder folder)
        {
            _textFolderManager.Remove(orginalRepository, folder);

            Sync(Site.Current, orginalRepository, (Repository targetRepository) =>
            {
                TextFolder targetFolder = _textFolderManager.Get(targetRepository, folder.FullName);
                if (targetFolder != null)
                {
                    EnsureFolder(targetRepository, folder);
                    _textFolderManager.Remove(targetRepository, folder);
                }
            });
        }
        public QueryTests()
        {
            EmptyUserKeyGenerator.DefaultGenerator = new EmptyUserKeyGenerator();
            Providers.DefaultProviderFactory = new RavenDB.ProviderFactory();
            Database.Current = new EmbeddedDatabase();

            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 = Data.DataType.String });
            newsSchema.AddColumn(new Column() { Name = "Body", DataType = Data.DataType.String });
            newsSchema.AddColumn(new Column() { Name = "Comments", DataType = Data.DataType.Int });
            Providers.DefaultProviderFactory.GetProvider<ISchemaProvider>().Add(newsSchema);
            newsFolder = new TextFolder(repository, "News") { SchemaName = newsSchema.Name, CategoryFolders = new[] { categoryFolder.FullName }, IsDummy = false };
            Providers.DefaultProviderFactory.GetProvider<ITextFolderProvider>().Add(newsFolder);

            commentSchema = new Schema(repository, "Comment") { IsDummy = false };
            commentSchema.AddColumn(new Column() { Name = "Title" });
            Providers.DefaultProviderFactory.GetProvider<ISchemaProvider>().Add(commentSchema);

            category1 = new TextContent(repository.Name, categorySchema.Name, categoryFolder.FullName);
            category1["title"] = "category1";
            provider.Add(category1);

            category2 = new TextContent(repository.Name, categorySchema.Name, categoryFolder.FullName);
            category2["title"] = "category2";
            provider.Add(category2);

            newsContent = new TextContent(repository.Name, newsSchema.Name, newsFolder.FullName);
            newsContent["title"] = "news1";
            newsContent["body"] = "body";
            newsContent["comments"] = 10;
            provider.Add(newsContent);

            provider.AddCategories(newsContent, new Category() { ContentUUID = newsContent.UUID, CategoryUUID = category1.UUID, CategoryFolder = category1.FolderName });
            provider.AddCategories(newsContent, new Category() { ContentUUID = newsContent.UUID, CategoryUUID = category2.UUID, CategoryFolder = category2.FolderName });

            commenContent = new TextContent(repository.Name, commentSchema.Name, "");
            commenContent.ParentUUID = newsContent.UUID;
            commenContent["title"] = "comment1";
            provider.Add(commenContent);
        }
Пример #28
0
 public virtual ActionResult Rebuild(string folderName)
 {
     var entry = new JsonResultEntry();
     try
     {
         var textFolder = new TextFolder(Repository, folderName);
         IndexSummaryService.Instance.Rebuild(textFolder);
         entry.RedirectUrl = Url.Action("Index", Request.RequestContext.AllRouteValues());
     }
     catch (Exception e)
     {
         entry.AddException(e);
     }
     return Json(entry);
 }
Пример #29
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);
        }
        public InsertUpdateDeleteTests()
        {
            EmptyUserKeyGenerator.DefaultGenerator = new EmptyUserKeyGenerator();
            Providers.DefaultProviderFactory = new RavenDB.ProviderFactory();

            repository = new Repository("InsertUpdateDeleteTests");
            Providers.DefaultProviderFactory.GetProvider<IRepositoryProvider>().Add(repository);

            newsSchema = new Schema(repository, "News");
            newsSchema.AddColumn(new Column() { Name = "title", DataType = Data.DataType.String });
            newsSchema.AddColumn(new Column() { Name = "Body", DataType = Data.DataType.String });
            Providers.DefaultProviderFactory.GetProvider<ISchemaProvider>().Add(newsSchema);

            textFolder = new TextFolder(repository, "News") { SchemaName = newsSchema.Name };
            Providers.DefaultProviderFactory.GetProvider<ITextFolderProvider>().Add(textFolder);
        }
Пример #31
0
        public override IEnumerable<RelationModel> Relations(TextFolder textFolder)
        {
            var relations = base.Relations(textFolder);
            var site = Site.Current;
            if (site != null)
            {
                var viewDataRules = _viewManager.All(site, null).Select(it => it.AsActual()).Where(it => it.DataRules != null)
                .SelectMany(it => FindDataRuleRelations("View:" + it.Name, it.DataRules, textFolder));

                var pageDataRules = _pageManager.AllPagesFlattened(site).Select(it => it.AsActual()).Where(it => it.DataRules != null)
                .SelectMany(it => FindDataRuleRelations("Page:" + it.FullName, it.DataRules, textFolder));

                relations = relations.Concat(viewDataRules).Concat(pageDataRules);
            }
            return relations;
        }
Пример #32
0
        public virtual ActionResult Rebuild(FolderIndexInfo[] model, string @return)
        {
            var data = new JsonResultData(ModelState);

            data.RunWithTry((resultData) =>
            {
                foreach (var item in model)
                {
                    var textFolder = new TextFolder(Repository, item.FolderName);
                    IndexSummaryService.Rebuild(textFolder);
                }
                data.RedirectUrl = @return;
            });

            return Json(data);
        }