Exemple #1
0
        public void OnIncluded(Site site)
        {
            var repository = site.AsActual().GetRepository();

            if (repository != null)
            {
                //import the content types. the zip file contains "Category" content type.
                //var contentTypePath = new ModulePathHelper(ModuleAreaRegistration.ModuleName).GetModuleInstallationFilePath("ContentType.zip");
                //if (File.Exists(contentTypePath.PhysicalPath))
                //{
                //    using (FileStream fs = new FileStream(contentTypePath.PhysicalPath, FileMode.Open, FileAccess.Read, FileShare.Read))
                //    {
                //        _schemaManager.Import(repository, fs, true);
                //    }
                //}
                Schema productSchema = new Schema(repository, "Product");
                productSchema.AddColumn("ProductName", "TextBox", DataType.String, "", true, true);
                productSchema.AddColumn("ProductDetail", "Tinymce", DataType.String, "", false, true);
                if (productSchema.AsActual() == null)
                {
                    _schemaManager.Add(repository, productSchema);
                }

                TextFolder productFolder = new TextFolder(repository, "Product")
                {
                    SchemaName = "Product"
                };
                if (productFolder.AsActual() == null)
                {
                    _textFolderManager.Add(repository, productFolder);
                }
            }
        }
Exemple #2
0
        public void TestAdd()
        {
            Schema schema = new Schema(repository, "news")
            {
                IsDummy = false
            };

            schema.AddColumn(new Column()
            {
                Name     = "Title",
                DataType = DataType.String,
                Length   = 100
            });

            //add
            SchemaManager.Add(schema);

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

            newSchema.AddColumn(new Column()
            {
                Name     = "Title",
                DataType = DataType.String,
                Length   = 100
            });

            newSchema.AddColumn(new Column()
            {
                Name     = "Body",
                DataType = DataType.String,
                Length   = 256
            });
            newSchema.AddColumn(new Column()
            {
                Name     = "Comments",
                DataType = DataType.Int
            });
            //add column
            SchemaManager.Update(newSchema, schema);

            //remove column
            Schema lastSchema = new Schema(repository, "news")
            {
                IsDummy = false
            };

            lastSchema.AddColumn(new Column()
            {
                Name     = "Title",
                DataType = DataType.String,
                Length   = 100
            });

            lastSchema.AddColumn(new Column()
            {
                Name     = "Body",
                DataType = DataType.String,
                Length   = 256
            });

            //add column
            SchemaManager.Update(lastSchema, newSchema);

            SchemaManager.Delete(lastSchema);
        }