public void TestWritePerformance()
        {
            int count = 100000;
            Stopwatch classStopwatch = new Stopwatch();
            classStopwatch.Start();
            for (int i = 0; i < count; i++)
            {
                dynamic content = new ContentObject();
                content.UUID = Guid.NewGuid().ToString();
                content.UserKey = "userkey";
            }
            classStopwatch.Stop();

            Stopwatch dynamicStopwatch = new Stopwatch();
            dynamicStopwatch.Start();
            for (int i = 0; i < count; i++)
            {
                dynamic content = new TextContent();

                content.UUID = Guid.NewGuid().ToString();
                content.UserKey = "userkey";
            }

            dynamicStopwatch.Stop();

            Console.WriteLine("class write:{0}ms", classStopwatch.ElapsedMilliseconds);
            Console.WriteLine("dynamic object write:{0}ms", dynamicStopwatch.ElapsedMilliseconds);
        }
Esempio n. 2
0
        public override object Execute()
        {
            IEnumerable<TextContent> contents = new TextContent[0];

            contents = TextContentQuery.Schema.GetContents();

            if (TextContentQuery.Folder != null)
            {
                contents = contents.Where(it => it.FolderName.EqualsOrNullEmpty(TextContentQuery.Folder.FullName, StringComparison.CurrentCultureIgnoreCase));
            }

            QueryExpressionTranslator translator = new QueryExpressionTranslator();

            var contentQueryable = translator.Translate(TextContentQuery.Expression, contents.AsQueryable());

            foreach (var categoryQuery in translator.CategoryQueries)
            {
                var categories = (IEnumerable<TextContent>)ContentQueryExecutor.Execute(categoryQuery);


                var categoryData = TextContentQuery.Repository.GetCategoryData()
                    .Where(it => categories.Any(c => it.CategoryUUID.EqualsOrNullEmpty(c.UUID, StringComparison.CurrentCultureIgnoreCase)));

                contentQueryable = contentQueryable.Where(it => categoryData.Any(c => it.UUID.EqualsOrNullEmpty(c.ContentUUID, StringComparison.CurrentCultureIgnoreCase)));

            }

            return Execute(contentQueryable, translator.OrderExpressions, translator.CallType, translator.Skip, translator.Take);
        } 
        public void TestReadPerformance()
        {
            int count = 100000;
            var contentObject = new ContentObject();
            contentObject.UUID = Guid.NewGuid().ToString();
            contentObject.UserKey = "userkey";
            Stopwatch classStopwatch = new Stopwatch();
            classStopwatch.Start();
            for (int i = 0; i < count; i++)
            {
                var uuid = contentObject.UUID;
                var userKey = contentObject.UserKey;
            }
            classStopwatch.Stop();

            var dynamicContent = new TextContent();
            dynamicContent.UUID = Guid.NewGuid().ToString();
            dynamicContent.UserKey = "userkey";
            Stopwatch dynamicStopwatch = new Stopwatch();
            dynamicStopwatch.Start();
            for (int i = 0; i < count; i++)
            {
                var uuid = dynamicContent.UUID;
                var userKey = dynamicContent.UserKey;
            }
            dynamicStopwatch.Stop();

            Console.WriteLine("class read:{0}ms", classStopwatch.ElapsedMilliseconds);
            Console.WriteLine("dynamic object read:{0}ms", dynamicStopwatch.ElapsedMilliseconds);
        }
Esempio n. 4
0
        public override object Execute()
        {
            var contents = (IEnumerable<TextContent>)ContentQueryExecutor.Execute(CategoriesQuery.InnerQuery);
            IQueryable<TextContent> categories = new TextContent[0].AsQueryable();
            if (contents.Count() > 0)
            {
                categories = CategoriesQuery.CategoryFolder.GetSchema().GetContents().AsQueryable();
            }

            QueryExpressionTranslator translator = new QueryExpressionTranslator();


            categories = translator.Translate(CategoriesQuery.Expression, categories);


            var categoryData = CategoriesQuery.Repository.GetCategoryData()
                .Where(it => it.CategoryFolder.EqualsOrNullEmpty(CategoriesQuery.CategoryFolder.FullName, StringComparison.CurrentCultureIgnoreCase))
                .Where(it => contents.Any(c => it.ContentUUID.EqualsOrNullEmpty(c.UUID, StringComparison.CurrentCultureIgnoreCase)))
                .ToArray();

            categories = categories.Where(it => categoryData.Any(c => it.UUID.EqualsOrNullEmpty(c.CategoryUUID, StringComparison.CurrentCultureIgnoreCase)));

            var result = Execute(categories, translator.OrderExpressions, translator.CallType, translator.Skip, translator.Take);

            return result;
        } 
Esempio n. 5
0
 public void Insert()
 {
     TextContent news1 = new TextContent(repository.Name, newsSchema.Name, textFolder.FullName);
     news1["Title"] = "title1";
     news1["body"] = "body1";
     provider.Add(news1);
 }
Esempio n. 6
0
        public void TestAddCategory()
        {
            dynamic category1 = new TextContent(repository.Name, categorySchema.Name, categoryFolder.Name)
            {
                UserKey = "category1"
            };
            category1.Title = "category1";

            textContentProvider.Add(category1);

            dynamic category2 = new TextContent(repository.Name, categorySchema.Name, categoryFolder.Name)
            {
                UserKey = "category2"
            };
            category2.Title = "category2";

            textContentProvider.Add(category2);

            dynamic news1 = new TextContent(repository.Name, newsSchema.Name, newsFolder.Name)
            {
                UserKey = "news1"
            };
            news1.title = "news1";
            textContentProvider.Add(news1);

            textContentProvider.AddCategories(news1, new Category() { ContentUUID = news1.uuid, CategoryFolder = categoryFolder.FullName, CategoryUUID = (string)(category1.UUID) },
                 new Category() { ContentUUID = news1.uuid, CategoryFolder = categoryFolder.FullName, CategoryUUID = (string)(category2.UUID) });

            textContentProvider.DeleteCategories(news1, new Category() { ContentUUID = news1.uuid, CategoryFolder = categoryFolder.FullName, CategoryUUID = (string)(category2.UUID) });
        }
Esempio n. 7
0
        public void Test1()
        {
            TextContent content = new TextContent();
            content.Repository = "repository1";
            content.FolderName = "news";
            content.UtcCreationDate = DateTime.Now;
            content.UtcLastModificationDate = DateTime.Now;
            content["title"] = "title1";

            VersionManager.LogVersion(content);

            Assert.AreEqual(1, VersionManager.AllVersions(content).First());

            var version1 = VersionManager.GetVersion(content, 1);

            Assert.AreEqual(content["title"], version1.TextContent["title"]);
            Assert.AreEqual(content.UtcLastModificationDate, version1.UtcCommitDate);

            //content["title"] = "title2";
            //content.UtcLastModificationDate = DateTime.Now;

            //VersionManager.LogVersion(content);

            //Assert.AreEqual(2, VersionManager.AllVersions(content).Last());

            //var version2 = VersionManager.GetVersion(content, 2);

            //Assert.AreEqual(content["title"], version2.TextContent["title"]);
            //Assert.AreEqual(content.UtcLastModificationDate, version2.UtcCommitDate);
        }
Esempio n. 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);
        }
Esempio n. 9
0
        private static void InitializeData()
        {
            dynamic news1 = new TextContent(repository.Name, newsSchema.Name, newsFolder.Name)
            {
                UserKey = "news1"
            };
            news1.title = "news1";
            textContentProvider.Add(news1);


            dynamic comment1 = new TextContent(repository.Name, commentSchema.Name, null)
            {
                UserKey = "comment1",
                ParentUUID = news1.UUID
            };
            comment1.Title = "comment1";

            textContentProvider.Add(comment1);

            dynamic comment2 = new TextContent(repository.Name, commentSchema.Name, null)
            {
                UserKey = "comment2",
                ParentUUID = news1.UUID
            };
            comment2.Title = "comment2";

            textContentProvider.Add(comment2);
        }
Esempio n. 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;
        }
Esempio n. 11
0
 public ContentVersionPath(TextContent content)
 {
     var contentPath = new TextContentPath(content);
     var basePath = Kooboo.CMS.Common.Runtime.EngineContext.Current.Resolve<Kooboo.CMS.Common.IBaseDir>();
     var versionPath = Path.Combine(basePath.Cms_DataPhysicalPath, VersionPathName);
     this.PhysicalPath = contentPath.PhysicalPath.Replace(basePath.Cms_DataPhysicalPath, versionPath);            
 }
Esempio n. 12
0
 public ContentVersionPath(TextContent content)
 {
     var contentPath = new TextContentPath(content);
     var basePath = Path.Combine(Kooboo.Settings.BaseDirectory, RepositoryPath.Cms_Data);
     var versionPath = Path.Combine(basePath, VersionPathName);
     this.PhysicalPath = contentPath.PhysicalPath.Replace(basePath, versionPath);
     //  this.VirtualPath = UrlUtility.Combine(contentPath.VirtualPath, VersionPathName);
 }
Esempio n. 13
0
 public string Add(string repositoryName, string folderName, string contentUUID, string fileName, byte[] binaryData)
 {
     var textContent = new TextContent(repositoryName, null, folderName) { UUID = contentUUID };
     var ms = new MemoryStream(binaryData);
     ms.Position = 0;
     var contentFile = new ContentFile() { FileName = fileName, Stream = ms };
     return FileUrlHelper.ResolveUrl(textContentFileProvider.Save(textContent, contentFile));
 }
Esempio n. 14
0
 public SqlCeCommand ClearCategoreis(TextContent textContent)
 {
     string sql = string.Format("DELETE FROM [{0}] WHERE UUID=@UUID"
          , textContent.GetRepository().GetCategoryTableName());
     SqlCeCommand command = new SqlCeCommand();
     command.CommandText = sql;
     command.Parameters.Add(new SqlCeParameter("@UUID", textContent.UUID));
     return command;
 }
Esempio n. 15
0
        public string Save(TextContent content, ContentFile file)
        {
            var extension = Path.GetExtension(file.FileName);
            var fileName = Kooboo.Extensions.StringExtensions.NormalizeUrl(Path.GetFileNameWithoutExtension(file.FileName)) + extension;
            TextContentPath contentPath = new TextContentPath(content);
            string filePath = Path.Combine(contentPath.PhysicalPath, fileName);
            file.Stream.SaveAs(filePath, true);

            return UrlUtility.Combine(contentPath.VirtualPath, fileName);
        }
 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);
     }
 }
Esempio n. 17
0
        public MySqlCommand ClearCategories(TextContent textContent)
        {
            string sql = string.Format("DELETE FROM `{0}` WHERE UUID=?UUID "
                 , textContent.GetRepository().GetCategoryTableName());
            MySqlCommand command = new MySqlCommand();
            command.CommandText = sql;
            command.Parameters.Add(new MySqlParameter("?UUID", textContent.UUID));

            return command;
        }
Esempio n. 18
0
 public VersionInfo GetVersion(TextContent content, int version)
 {
     string versionFile = GetVersionFile(content, version);
     if (File.Exists(versionFile))
     {
         var versionInfo = DataContractSerializationHelper.Deserialize<VersionInfo>(versionFile);
         versionInfo.Version = version;
         return versionInfo;
     }
     return null;
 }
Esempio n. 19
0
 public static IHtmlString EditFieldAttributes(TextContent data, string fieldName, FieldDataType dataType)
 {
     if (dataType == FieldDataType.Auto)
     {
         dataType = QueryFieldDataType(data, fieldName);
     }
     if (data == null || !Page_Context.Current.EnabledInlineEditing(EditingType.Content)
         || !Kooboo.CMS.Content.Services.ServiceFactory.WorkflowManager.AvailableToEditContent(data, Page_Context.Current.ControllerContext.HttpContext.User.Identity.Name))
     {
         return new HtmlString("");
     }
     return new HtmlString(string.Format("editType=\"field\" dataType=\"{0}\" schema=\"{1}\" folder=\"{2}\" uuid=\"{3}\" fieldName=\"{4}\"", dataType.ToString(), data.SchemaName, data.FolderName, data.UUID, fieldName));
 }
Esempio n. 20
0
 private IDbDataParameter CreateParameter(Column column, TextContent textContent)
 {
     string name = "@" + column.Name;
     object value = textContent[column.Name];
     if (value is DateTime)
     {
         if ((DateTime)value < MinSQLServerDate)
         {
             value = MinSQLServerDate;
         }
     }
     SqlParameter parameter = new SqlParameter(name, value);
     return parameter;
 }
Esempio n. 21
0
 public static IHtmlString EditField(TextContent data, string fieldName, FieldDataType dataType)
 {
     if (dataType == FieldDataType.Auto)
     {
         dataType = QueryFieldDataType(data, fieldName);
     }
     if (data == null || !Page_Context.Current.EnabledInlineEditing(EditingType.Content)
         || !Kooboo.CMS.Content.Services.ServiceFactory.WorkflowManager.AvailableToEditContent(data, Page_Context.Current.ControllerContext.HttpContext.User.Identity.Name))
     {
         return new HtmlString(data[fieldName] == null ? "" : data[fieldName].ToString());
     }
     var format = "<var start=\"true\" editType=\"field\" dataType=\"{0}\" schema=\"{1}\" folder=\"{2}\" uuid=\"{3}\" fieldName=\"{4}\" style=\"display:none;\"></var>{5}<var end=\"true\" style=\"display:none;\"></var>";
     return new HtmlString(string.Format(format, dataType.ToString(), data.SchemaName, data.FolderName, data.UUID, fieldName, data[fieldName]));
 }
        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);
        }
Esempio n. 23
0
 public void DeleteFiles(TextContent content)
 {
     var contentPath = new TextContentPath(content);
     try
     {
         if (Directory.Exists(contentPath.PhysicalPath))
         {
             IOUtility.DeleteDirectory(contentPath.PhysicalPath, true);
         }
     }
     catch (Exception e)
     {
         Kooboo.HealthMonitoring.Log.LogException(e);
     }
 }
Esempio n. 24
0
 public static TextContent ToContent(this BsonDocument doc)
 {
     if (doc == null)
     {
         return null;
     }
     TextContent content = new TextContent();
     foreach (var item in doc)
     {
         if (item.Name != "_id")
         {
             content[item.Name] = BsonHelper.GetValue(doc[item.Name]);
         }
     }
     return content;
 }
Esempio n. 25
0
 public IEnumerable<int> AllVersions(TextContent content)
 {
     ContentVersionPath versionPath = new ContentVersionPath(content);
     if (Directory.Exists(versionPath.PhysicalPath))
     {
         foreach (var file in Directory.EnumerateFiles(versionPath.PhysicalPath))
         {
             string fileName = Path.GetFileNameWithoutExtension(file);
             int version;
             if (int.TryParse(fileName, out version))
             {
                 yield return version;
             }
         }
     }
 }
Esempio n. 26
0
 protected virtual SendingSetting AllowSending(TextContent content, Repository repository, ContentEventContext eventContext)
 {
     if (!repository.EnableBroadcasting)
     {
         return null;
     }
     var list = Providers.DefaultProviderFactory.GetProvider<ISendingSettingProvider>().All(repository).Select(o => Providers.DefaultProviderFactory.GetProvider<ISendingSettingProvider>().Get(o));
     foreach (var item in list)
     {
         if (AllowSendingSetting(content, item, eventContext))
         {
             return item;
         }
     }
     return null;
 }
Esempio n. 27
0
 public static TextContent ToContent(this BsonDocument doc)
 {
     if (doc == null)
     {
         return null;
     }
     TextContent content = new TextContent();
     foreach (var item in doc)
     {
         if (item.Name != "_id" && !IsCaseInsensitiveFieldName(item.Name))
         {
             content[item.Name] = BsonHelper.GetValue(doc[item.Name]);
         }
     }
     return content.ConvertToLocalTime();
 }
Esempio n. 28
0
        public SqlCommand Add(TextContent textContent)
        {
            textContent = textContent.ConvertToUTCTime();

            var schema = textContent.GetSchema().AsActual();
            if (schema == null)
            {
                return null;
            }
            List<string> fields = new List<string>() { 
            "UUID", "Repository", "FolderName", "UserKey", "UtcCreationDate", "UtcLastModificationDate", "Published", "OriginalUUID",
            "SchemaName","ParentFolder", "ParentUUID","UserId","OriginalRepository","OriginalFolder",
            "IsLocalized","Sequence"
            };

            SqlCommand command = new SqlCommand();

            command.Parameters.Add(new SqlParameter("@UUID", textContent.UUID));
            command.Parameters.Add(new SqlParameter("@Repository", textContent.Repository));
            command.Parameters.Add(new SqlParameter("@FolderName", textContent.FolderName));
            command.Parameters.Add(new SqlParameter("@UserKey", textContent.UserKey));
            command.Parameters.Add(new SqlParameter("@UtcCreationDate", textContent.UtcCreationDate));
            command.Parameters.Add(new SqlParameter("@UtcLastModificationDate", textContent.UtcLastModificationDate));
            command.Parameters.Add(new SqlParameter("@Published", textContent.Published));
            command.Parameters.Add(new SqlParameter("@OriginalUUID", textContent.OriginalUUID));
            command.Parameters.Add(new SqlParameter("@SchemaName", textContent.SchemaName));
            command.Parameters.Add(new SqlParameter("@ParentFolder", textContent.ParentFolder));
            command.Parameters.Add(new SqlParameter("@ParentUUID", textContent.ParentUUID));
            command.Parameters.Add(new SqlParameter("@UserId", textContent.UserId));
            command.Parameters.Add(new SqlParameter("@OriginalRepository", textContent.OriginalRepository));
            command.Parameters.Add(new SqlParameter("@OriginalFolder", textContent.OriginalFolder));
            command.Parameters.Add(new SqlParameter("@IsLocalized", textContent.IsLocalized));
            command.Parameters.Add(new SqlParameter("@Sequence", textContent.Sequence));

            foreach (var column in schema.Columns.Where(it => !it.IsSystemField))
            {
                fields.Add(string.Format("{0}", column.Name));
                command.Parameters.Add(CreateParameter(column, textContent));
            }
            string sql = string.Format("INSERT INTO [{0}] ({1}) VALUES({2})", schema.GetTableName(),
                string.Join(",", fields.Select(it => "[" + it + "]").ToArray()),
                string.Join(",", fields.Select(it => "@" + it).ToArray()));
            command.CommandText = sql;

            return command;
        }
Esempio n. 29
0
        public void Test1()
        {
            NameValueCollection values = new NameValueCollection();
            values["title"] = "title1";
            values["body"] = "body1";
            values["comments"] = "0";
            var postdate = DateTime.Now;
            values["Postdate"] = postdate.ToString();

            TextContent textContent = new TextContent();
            textContent = binder.Bind(schema, textContent, values);

            Assert.AreEqual(values["title"], textContent["title"].ToString());
            Assert.AreEqual(values["body"], textContent["body"].ToString());
            Assert.AreEqual(0, (int)textContent["comments"]);
            Assert.AreEqual(postdate.ToUniversalTime().ToString(), ((DateTime)textContent["postdate"]).ToString());
        }
Esempio n. 30
0
        public void Export_Categories_Data()
        {
            TextContent news1 = new TextContent(repository.Name, newsSchema.Name, textFolder.FullName);
            news1["Title"] = "title1";
            news1["body"] = "body1";
            provider.Add(news1);

            TextContent category1 = new TextContent(repository.Name, "category", "category");
            category1["Title"] = "category1";
            provider.Add(category1);

            var categories = new Category[] { new Category() { ContentUUID = news1.UUID, CategoryFolder = category1.FolderName, CategoryUUID = category1.UUID } };

            provider.AddCategories(news1, categories);

            var exportedCategories = provider.ExportCategoryData(repository);

            Assert.IsTrue(exportedCategories.Count() > 1);
        }
Esempio n. 31
0
 /// <summary>
 /// Gets the folder.
 /// </summary>
 /// <param name="content">The content.</param>
 /// <returns></returns>
 public static TextFolder GetFolder(this TextContent content)
 {
     return(new TextFolder(content.GetRepository(), FolderHelper.SplitFullName(content.FolderName)));
 }
Esempio n. 32
0
 /// <summary>
 /// Gets the schema.
 /// </summary>
 /// <param name="textContent">Content of the text.</param>
 /// <returns></returns>
 public static Schema GetSchema(this TextContent textContent)
 {
     return(new Schema(textContent.GetRepository(), textContent.SchemaName));
 }