Exemple #1
0
        public string Generate(Repository repository, Models.DataRuleSetting dataRule)
        {
            if (dataRule.DataRule is DataRuleBase)
            {
                var dataRuleBase = (DataRuleBase)dataRule.DataRule;
                var schema = dataRuleBase.GetSchema(repository).AsActual();

                string html = @"
            <h2><%: ViewBag.{0}.{1} ?? """" %></h2>
            <ul class=""detail {2}-detail"">
            {3}
            </ul>";
                string columnTp = @"
            <li>
            {0}:
            <p> <%: ViewBag.{1}.{0} ?? """" %> </p>
            </li>
            ";
                var titleField = schema.GetSummarizeColumn().Name;
                schema = schema.AsActual();
                StringBuilder sb = new StringBuilder();
                foreach (var column in schema.Columns)
                {
                    if (!column.Name.EqualsOrNullEmpty(titleField, StringComparison.CurrentCultureIgnoreCase))
                    {
                        sb.AppendFormat(columnTp, column.Name, dataRule.DataName);
                    }
                }

                return string.Format(html, dataRule.DataName, schema.GetSummarizeColumn().Name, schema.Name, sb.ToString());
            }
            return string.Empty;
        }
        public string Generate(Repository repository, Models.DataRuleSetting dataRule, bool inlineEdit)
        {
            if (dataRule.DataRule is DataRuleBase)
            {
                var dataRuleBase = (DataRuleBase)dataRule.DataRule;
                var schema = dataRuleBase.GetSchema(repository).AsActual();

                string html = @"
            <div>
            <h3 class=""title""{3}><%= ViewBag.{0}.{1}%></h3>
            <div class=""content"">
            {2}
            </div>
            </div>";
                string columnTp = @"
            <div{2}>
            <%= ViewBag.{1}.{0}%>
            </div>
            ";
                var titleField = schema.GetSummarizeColumn().Name;
                var editField = " <%:ViewHelper.Edit(ViewBag.{0},\"{1}\")%>";
                schema = schema.AsActual();
                StringBuilder sb = new StringBuilder();
                foreach (var column in schema.Columns)
                {
                    if (!column.Name.EqualsOrNullEmpty(titleField, StringComparison.CurrentCultureIgnoreCase))
                    {
                        sb.AppendFormat(columnTp, column.Name, dataRule.DataName, inlineEdit ? string.Format(editField, dataRule.DataName, column.Name) : "");
                    }
                }

                return string.Format(html, dataRule.DataName, schema.GetSummarizeColumn().Name, sb.ToString(), inlineEdit ? string.Format(editField, dataRule.DataName, titleField) : "");
            }
            return string.Empty;
        }
Exemple #3
0
        public static FolderType IdentifyFolderType(Kooboo.CMS.Content.Models.Repository repository, string folderId)
        {
            if (string.Compare(folderId, RootFolderName, true) == 0)
            {
                return(FolderType.Root);
            }
            if (string.Compare(folderId, Content_Folder_Root, true) == 0)
            {
                return(FolderType.Content_Folder_Root);
            }
            if (string.Compare(folderId, Media_Folder_Root, true) == 0)
            {
                return(FolderType.Media_Folder_Root);
            }
            var folder = Parse(repository, folderId);

            if (folder is TextFolder)
            {
                return(FolderType.Content_Folder);
            }
            else
            {
                return(FolderType.Media_Folder);
            }
        }
Exemple #4
0
        public RepositoryPath(Repository repository)
        {
            this.PhysicalPath = Path.Combine(BasePhysicalPath, repository.Name);
            this.VirtualPath = UrlUtility.Combine(BaseVirtualPath, repository.Name);
            this.SettingFile = Path.Combine(PhysicalPath, PathHelper.SettingFileName);

        }
        public virtual IDocumentStore GetStore(string repositoryName)
        {
            if (!stores.ContainsKey(repositoryName))
            {
                lock (stores)
                {
                    if (!stores.ContainsKey(repositoryName))
                    {
                        var store = CreateStore(repositoryName);
                        store.Initialize();

                        var repository = new Repository(repositoryName);
                        if (store.DatabaseCommands.GetIndex(repository.GetCategoryIndex()) == null)
                        {
                            IDictionary<string, string> analyzers = new Dictionary<string, string>();
                            analyzers.Add("ContentUUID", "Kooboo.CMS.Content.Persistence.RavenDB.Indexing.Analyzers.KeywordToLowerAnalyzer,Kooboo.CMS.Content.Persistence.RavenDB.Indexing");
                            analyzers.Add("CategoryFolder", "Kooboo.CMS.Content.Persistence.RavenDB.Indexing.Analyzers.KeywordToLowerAnalyzer,Kooboo.CMS.Content.Persistence.RavenDB.Indexing");
                            analyzers.Add("CategoryUUID", "Kooboo.CMS.Content.Persistence.RavenDB.Indexing.Analyzers.KeywordToLowerAnalyzer,Kooboo.CMS.Content.Persistence.RavenDB.Indexing");

                            store.DatabaseCommands.PutIndex(repository.GetCategoryIndex(), new IndexDefinition()
                            {
                                Map = @"from doc in docs where doc[""@metadata""][""Raven-Entity-Name""]==""Categories"" select new {doc.ContentUUID,doc.CategoryFolder,doc.CategoryUUID}"
                                //Analyzers = analyzers
                            }, true);
                        }

                        stores[repositoryName] = store;
                    }
                }
            }
            return stores[repositoryName];
        }
Exemple #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();
        }
        public int ResetSchema(Repository repository, Schema[] schemas)
        {
            var root = SchemaPath.GetBaseDir(repository);
            var paths = schemas.Select(it => Path.Combine(root, it.Name));

            return ResetSchema(repository, schemas, paths);
        }
Exemple #8
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();
        }
Exemple #9
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);
        }
Exemple #10
0
        public string CopyDocument(string repositoryId, string sourceId, NCMIS.ObjectModel.CmisProperties properties, string folderId)
        {
            string id;
            if (!TryPraseObjectId(sourceId, out id))
                throw new Exception("Invalid docuemnt id. parameter name \"sourceId\"");
            string contentUUID;
            Kooboo.CMS.Content.Models.Repository repository = new Repository(repositoryId);
            var sourceFolder = ParseDocumentId(repository, id, out contentUUID);

            IContentManager contentManager;
            IContentQuery<ContentBase> contentQuery;
            if (sourceFolder is TextFolder)
            {
                contentManager = ServiceFactory.TextContentManager;
                contentQuery = ((TextFolder)sourceFolder).CreateQuery().WhereEquals("UUID", contentUUID);
            }
            else
            {
                contentManager = ServiceFactory.MediaContentManager;
                contentQuery = ((MediaFolder)sourceFolder).CreateQuery().WhereEquals("UUID", contentUUID);
            }
            FolderObjectService folderObjectService = (FolderObjectService)ObjectService.GetService(typeof(Folder));
            string objectId = folderId;
            folderObjectService.TryPraseObjectId(folderId, out folderId);
            var targetFolder = CmisFolderHelper.Parse(repository, folderId);

            var content = contentManager.Copy(contentQuery.First(), targetFolder, null, properties.ToNameValueCollection());

            return GetObjectId(content);
        }
Exemple #11
0
        public virtual MediaContent Update(Repository repository, MediaFolder mediaFolder, string uuid, string fileName, Stream fileStream,
            string userid, MediaContentMetadata metadata)
        {
            IsAllowExtension(fileName, mediaFolder.AllowedExtensions);


            var binaryContent = mediaFolder.CreateQuery().WhereEquals("UUID", uuid).First();
            var old = new MediaContent(binaryContent);
            binaryContent.UserId = userid;
            binaryContent.UtcLastModificationDate = DateTime.UtcNow;

            binaryContent.FileName = fileName;
            binaryContent.UserKey = fileName;
            binaryContent.UUID = fileName;

            if (fileStream != null)
            {
                binaryContent.ContentFile = new ContentFile()
                {
                    Name = fileName,
                    FileName = fileName,
                    Stream = fileStream
                };
                Provider.SaveContentStream(old, fileStream);
            }

            binaryContent.Metadata = metadata;
            Provider.Update(binaryContent, old);

            return binaryContent;
        }
Exemple #12
0
        public void Import(Repository repository, MediaFolder folder, System.IO.Stream zipStream, bool @override)
        {
            using (ZipFile zipFile = ZipFile.Read(zipStream))
            {
                foreach (ZipEntry item in zipFile)
                {
                    if (item.IsDirectory)
                    {

                    }
                    else
                    {
                        var path = Path.GetDirectoryName(item.FileName);
                        var fileName = Path.GetFileName(item.FileName);
                        var currentFolder = CreateMediaFolderByPath(folder, path);
                        Add(currentFolder);
                        var stream = new MemoryStream();
                        item.Extract(stream);
                        stream.Position = 0;
                        ServiceFactory.MediaContentManager.Add(repository, currentFolder,
                            fileName, stream, true);
                    }
                }
            }
        }
Exemple #13
0
        public CmisObject CreateDocument(string repositoryId, NCMIS.ObjectModel.CmisProperties properties, string folderId, NCMIS.ObjectModel.ContentStream contentStream)
        {
            FolderObjectService folderObjectService = (FolderObjectService)ObjectService.GetService(typeof(Folder));
            if (folderObjectService.IsSystemFolder(folderId))
            {
                throw new Exception("Could not create document under system folder.");
            }
            Kooboo.CMS.Content.Models.Repository repository = new Repository(repositoryId);

            string objectId = folderId;
            folderObjectService.TryPraseObjectId(folderId, out folderId);
            var folder = CmisFolderHelper.Parse(repository, folderId);

            if (folder is TextFolder)
            {
                var textFolder = (TextFolder)folder.AsActual();

                var content = Services.ServiceFactory.TextContentManager.Add(repository, textFolder, UserId, properties.ToNameValueCollection(), contentStream.ToFileCollection(), null);

                return ObjectConvertor.ToCmis(content, false);
            }
            else if (folder is MediaFolder)
            {
                var mediaFolder = (MediaFolder)folder.AsActual();
                if (contentStream != null)
                {
                    var content = Services.ServiceFactory.MediaContentManager.Add(repository, mediaFolder, UserId, contentStream.Filename, new MemoryStream(contentStream.Stream));
                    return ObjectConvertor.ToCmis(content, false);
                }
            }
            return ObjectConvertor.EmptyCmisObject();
        }
Exemple #14
0
        public virtual MediaContent Add(Repository repository, MediaFolder mediaFolder, string fileName, Stream fileStream, bool @overrided,
            string userId, MediaContentMetadata metadata)
        {
            fileName = UrlUtility.ToUrlString(Path.GetFileNameWithoutExtension(fileName)) + Path.GetExtension(fileName);
            IsAllowExtension(fileName, mediaFolder.AllowedExtensions);

            var mediaContent = new MediaContent(repository.Name, mediaFolder.FullName);

            mediaContent.UserId = userId;
            mediaContent.Published = true;

            mediaContent.FileName = fileName;

            mediaContent.UserKey = fileName;
            mediaContent.UUID = fileName;

            mediaContent.ContentFile = new ContentFile()
            {
                Name = fileName,
                FileName = fileName,
                Stream = fileStream
            };

            mediaContent.UtcLastModificationDate = mediaContent.UtcCreationDate = DateTime.UtcNow;
            mediaContent.Metadata = metadata;
            Provider.Add(mediaContent, @overrided);

            return mediaContent;
        }
        public void Export(Repository repository, string baseFolder, string[] folders, string[] docs, Stream outputStream)
        {
            ZipFile zipFile = new ZipFile();
            var basePrefix = StorageNamesEncoder.EncodeContainerName(repository.Name) + "/" + MediaBlobHelper.MediaDirectoryName + "/";
            if (!string.IsNullOrEmpty(baseFolder))
            {
                var baseMediaFolder = ServiceFactory.MediaFolderManager.Get(repository, baseFolder);
                basePrefix = baseMediaFolder.GetMediaFolderItemPath(null) + "/";
            }

            var blobClient = CloudStorageAccountHelper.GetStorageAccount().CreateCloudBlobClient();

            //add file
            if (docs != null)
            {
                foreach (var doc in docs)
                {
                    var blob = blobClient.GetBlockBlobReference(basePrefix + StorageNamesEncoder.EncodeBlobName(doc));

                    var bytes = blob.DownloadByteArray();
                    zipFile.AddEntry(doc, bytes);
                }
            }
            //add folders
            if (folders != null)
            {
                foreach (var folder in folders)
                {
                    var folderName = folder.Split('~').LastOrDefault();
                    zipFolder(blobClient, basePrefix, folderName, "", ref zipFile);
                }
            }
            zipFile.Save(outputStream);
        }
Exemple #16
0
        public string Generate(Repository repository, Models.DataRuleSetting dataRule)
        {
            if (dataRule.DataRule is DataRuleBase)
            {
                var dataRuleBase = (DataRuleBase)dataRule.DataRule;
                var schema = dataRuleBase.GetSchema(repository).AsActual();

                string html = @"
            <ul>
            <%foreach (var item in ViewBag.{0})
              {{%>
            <li>
            <%: Html.FrontHtml().PageLink(item.{1}, ""{2}/detail"", new {{ UserKey = item.UserKey}}) %>
            </li>
            <%}}%>
            </ul>";

                var snippet = string.Format(html, dataRule.DataName, schema.GetSummarizeColumn().Name, schema.Name);
                if (dataRule.DataRule.EnablePaging())
                {
                    snippet += Environment.NewLine + string.Format("<%: Html.FrontHtml().Pager(ViewBag.{0}) %>", dataRule.DataName);
                }
                return snippet;
            }
            return string.Empty;
        }
Exemple #17
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();
        }
Exemple #18
0
        public static void InitializeDatabase(Repository repository)
        {
            //if (!SqlServerSettings.Instance.SharingDatabase)
            //{
            //    if (SqlServerSettings.Instance.GetConnection(repository.Name) == null)
            //    {
            //        lock (locker)
            //        {
            //            if (SqlServerSettings.Instance.GetConnection(repository.Name) == null)
            //            {
            //                var dataFile = GetDatabaseFile(repository);

            //                var connectionString = GetIndividualDatabaseConnectionString(SqlServerSettings.Instance.CreateDatabaseSetting, repository);
            //                if (!File.Exists(dataFile))
            //                {
            //                    CreateDatabase(repository, SqlServerSettings.Instance.CreateDatabaseSetting);
            //                }

            //                SqlServerSettings.Instance.AddConnection(new ConnectionSetting() { Name = repository.Name, ConnectionString = connectionString });

            //                SqlServerSettings.Instance.Save();
            //            }
            //        }
            //    }
            //}
            SchemaManager.InitializeRepositoryDatabase(repository);
        }
Exemple #19
0
 public void InitializeMediaContents(Repository repository)
 {
     Kooboo.CMS.Content.Persistence.Default.MediaFolderProvider fileMediaFolderProvider = new Default.MediaFolderProvider();
     foreach (var item in fileMediaFolderProvider.All(repository))
     {
         ImportMediaFolderDataCascading(fileMediaFolderProvider.Get(item));
     }
 }
Exemple #20
0
        public static void DeleteRepositoryContainer(Repository repository)
        {
            var blobClient = CloudStorageAccountHelper.GetStorageAccount().CreateCloudBlobClient();

            var container = blobClient.GetContainerReference(repository.Name.ToLower());

            container.Delete();
        }
Exemple #21
0
        public int ResetSchema(Repository repository)
        {
            var root = SchemaPath.GetBaseDir(repository);

            var paths = Directory.GetDirectories(root);
            var schemas = Kooboo.CMS.Content.Services.ServiceFactory.SchemaManager.All(repository, "").ToArray();

            return ResetSchema(repository, schemas, paths);
        }
 public virtual ActionResult Delete(string repositoryName)
 {
     if (!string.IsNullOrEmpty(repositoryName))
     {
         var repository = new Repository(repositoryName);
         Manager.Remove(repository);
     }
     return RedirectToAction("Index", "Home");
 }
        public MediaContentProviderTest()
        {
            Kooboo.CMS.Content.Persistence.AzureBlobService.AssemblyInitializer.ResetProviders();

            repository = new Repository(Kooboo.UniqueIdGenerator.GetInstance().GetBase32UniqueId(5));
            mediaFolder = new MediaFolder(repository, "MediaFolder1/MediaFolder2");

            Kooboo.CMS.Content.Persistence.Providers.DefaultProviderFactory.GetProvider<IRepositoryProvider>().Initialize(repository);
        }
 private void EnsureFolder(Repository orginalRepository, TextFolder folder)
 {
     Folder parentFolder = folder.Parent;
     while (parentFolder != null)
     {
         parentFolder.Repository = orginalRepository;
         parentFolder = parentFolder.Parent;
     }
 }
 public static string GenerateCodeSnippet(Repository repository, DataRuleSetting dataRule)
 {
     var codeSnippet = (IDataRuleCodeSnippet)hashtable[dataRule.TakeOperation];
     if (codeSnippet == null)
     {
         return "";
     }
     return codeSnippet.Generate(repository, dataRule);
 }
Exemple #26
0
 public DatabaseHelperTest()
 {
     cf = DatabaseHelper.GetCouchbaseClientConfiguration();
     if (!DatabaseHelper.ExistBucket(cf.Bucket))
     {
         CreateBucket();
     }
     repository = new Repository(cf.Bucket);
     repository.CreateDefaultViews();
 }
Exemple #27
0
        public IEnumerable<SelectListItem> GetSelectListItems(RequestContext requestContext, string filter)
        {
            IEnumerable<Repository> repositories = new Repository[] { Repository.Current };
            if (ServiceFactory.UserManager.IsAdministrator(requestContext.HttpContext.User.Identity.Name))
            {
                repositories = Kooboo.CMS.Content.Services.ServiceFactory.RepositoryManager.All();
            }

            return repositories.Select(it => it.AsActual()).Select(it => new SelectListItem() { Text = string.IsNullOrEmpty(it.DisplayName) ? it.Name : it.DisplayName, Value = it.Name }).EmptyItem("");
        }
        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 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();
        }
Exemple #30
0
        private void CopyRepository(Kooboo.CMS.Content.Models.Repository sourceRepository, string name)
        {
            var repositoryManager = Kooboo.CMS.Content.Services.ServiceFactory.RepositoryManager;
            var repository        = repositoryManager.Get(name);

            if (repository == null)
            {
                repositoryManager.Copy(sourceRepository, name);
            }
        }
Exemple #31
0
 public virtual IEnumerable<FolderIndexInfo> GetFolderIndexInfoes(Repository repository)
 {
     List<FolderIndexInfo> list = new List<FolderIndexInfo>();
     var searchSettings = SearchSettingProvider.All(repository).ToArray();
     foreach (var folder in Kooboo.CMS.Content.Services.ServiceFactory.TextFolderManager.All(repository, ""))
     {
         GetFolderIndexInfoes(folder, ref list, searchSettings);
     }
     return list;
 }
Exemple #32
0
        public override bool IsValid(Kooboo.CMS.Content.Models.Repository repository)
        {
            var valid = base.IsValid(repository);

            if (valid && !string.IsNullOrEmpty(CategoryFolderName))
            {
                var folder = FolderHelper.Parse <TextFolder>(repository, CategoryFolderName);
                return(folder.AsActual() != null);
            }
            return(valid);
        }
        static BinaryContentProviderTests()
        {
            repository = new Repository("SimpleQueryTests");

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

            ProviderFactory providerFactory = new ProviderFactory();
            Providers.DefaultProviderFactory = providerFactory;
            providerFactory.GetProvider<IRepositoryProvider>().Add(repository);
            providerFactory.GetProvider<IMediaFolderProvider>().Add(binaryFolder);
        }
Exemple #34
0
 public static Folder Parse(Kooboo.CMS.Content.Models.Repository repository, string folderId)
 {
     string[] id = folderId.Split('$');
     if (string.Compare(id[0], Content_Folder_Root, true) == 0)
     {
         return(FolderHelper.Parse <TextFolder>(repository, id[1]));
     }
     else if (string.Compare(id[0], Media_Folder_Root, true) == 0)
     {
         return(FolderHelper.Parse <MediaFolder>(repository, id[1]));
     }
     throw new Exception("Unknow folder type");
 }
Exemple #35
0
        public virtual ActionResult Import(ImportRepositoryModel model, string @return)
        {
            var data = new JsonResultData(ModelState);

            data.RunWithTry((resultData) =>
            {
                Kooboo.CMS.Content.Models.Repository repository = null;
                if (Request.Files.Count > 0)
                {
                    repository = Kooboo.CMS.Content.Services.ServiceFactory.RepositoryManager.Create(model.Name, Request.Files[0].InputStream);
                }
                else
                {
                    repository = Kooboo.CMS.Content.Services.ServiceFactory.RepositoryManager.Create(model.Name, model.File);
                }

                resultData.RedirectUrl = @return;
            });

            return(Json(data, "text/plain", System.Text.Encoding.UTF8));
        }
        private static CmisObject AddContentFolder(Kooboo.CMS.Content.Models.Repository repository, Folder parent, System.Collections.Specialized.NameValueCollection values)
        {
            var textFolder = new TextFolder(repository, values["name"], parent);

            textFolder.DisplayName = values["DisplayName"];
            textFolder.SchemaName  = values["schemaName"];
            var categories = values["CategoryFolders"];

            if (!string.IsNullOrEmpty(categories))
            {
                textFolder.CategoryFolders = categories.Split(new string[] { "," }, StringSplitOptions.RemoveEmptyEntries);
            }
            var creationDate = values["UtcCreationDate"];

            if (!string.IsNullOrEmpty(creationDate))
            {
                textFolder.UtcCreationDate = DateTime.Parse(creationDate).ToUniversalTime();
            }

            ServiceFactory.TextFolderManager.Add(repository, textFolder);

            return(ObjectConvertor.ToCmis(textFolder, false));
        }
        private static CmisObject AddMediaFolder(Kooboo.CMS.Content.Models.Repository repository, Folder parent, System.Collections.Specialized.NameValueCollection values)
        {
            var mediaFolder = new MediaFolder(repository, values["name"], parent);

            mediaFolder.DisplayName = values["DisplayName"];
            var allowedExtensions = values["AllowedExtensions"];

            if (!string.IsNullOrEmpty(allowedExtensions))
            {
                mediaFolder.AllowedExtensions = allowedExtensions.Split(new[] { ',' }, StringSplitOptions.RemoveEmptyEntries);
            }

            var creationDate = values["UtcCreationDate"];

            if (!string.IsNullOrEmpty(creationDate))
            {
                mediaFolder.UtcCreationDate = DateTime.Parse(creationDate).ToUniversalTime();
            }

            ServiceFactory.MediaFolderManager.Add(repository, mediaFolder);

            return(ObjectConvertor.ToCmis(mediaFolder, false));
        }