Exemplo n.º 1
0
        public void ContentList_SaveFieldSetting()
        {
            string listDef = @"<?xml version='1.0' encoding='utf-8'?>
<ContentListDefinition xmlns='http://schemas.com/ContentRepository/ContentListDefinition'>
	<DisplayName>Cars title</DisplayName>
	<Description>Cars description</Description>
	<Icon>automobile.gif</Icon>
	<Fields>
		<ContentListField name='#ListField1' type='ShortText'>
			<DisplayName>ContentListField1</DisplayName>
			<Description>ContentListField1 Description</Description>
			<Icon>icon.gif</Icon>
			<Configuration>
				<MaxLength>100</MaxLength>
			</Configuration>
		</ContentListField>
		<ContentListField name='#ListField2' type='WhoAndWhen'>
			<DisplayName>ContentListField2</DisplayName>
			<Description>ContentListField2 Description</Description>
			<Icon>icon.gif</Icon>
			<Configuration>
			</Configuration>
		</ContentListField>
		<ContentListField name='#ListField3' type='ShortText'>
			<DisplayName>ContentListField3</DisplayName>
			<Description>ContentListField3 Description</Description>
			<Icon>icon.gif</Icon>
			<Configuration>
				<MaxLength>200</MaxLength>
			</Configuration>
		</ContentListField>
	</Fields>
</ContentListDefinition>
";
            string path    = RepositoryPath.Combine(this.TestRoot.Path, "Cars");

            if (Node.Exists(path))
            {
                Node.ForceDelete(path);
            }

            var list = new ContentList(this.TestRoot)
            {
                Name = "Cars",
                ContentListDefinition = listDef,
                AllowedChildTypes     = new[] { ContentType.GetByName("Car") }
            };

            list.Save();

            var fsNodes = new List <Node>(list.FieldSettingContents);
            var fs      = fsNodes[0] as FieldSettingContent;
            var fsc     = Content.Create(fsNodes[0]);
            var title   = "New field title";

            fsc["DisplayName"] = title;
            fsc.Save();

            Assert.IsTrue(fs.FieldSetting.DisplayName.CompareTo(title) == 0);
        }
Exemplo n.º 2
0
        public void ContentList_1()
        {
            string listDef = @"<?xml version='1.0' encoding='utf-8'?>
<ContentListDefinition xmlns='http://schemas.com/ContentRepository/ContentListDefinition'>
	<DisplayName>Cars title</DisplayName>
	<Description>Cars description</Description>
	<Icon>automobile.gif</Icon>
	<Fields>
		<ContentListField name='#ListField1' type='ShortText'>
			<DisplayName>ContentListField1</DisplayName>
			<Description>ContentListField1 Description</Description>
			<Icon>icon.gif</Icon>
			<Configuration>
				<MaxLength>100</MaxLength>
			</Configuration>
		</ContentListField>
		<ContentListField name='#ListField2' type='WhoAndWhen'>
			<DisplayName>ContentListField2</DisplayName>
			<Description>ContentListField2 Description</Description>
			<Icon>icon.gif</Icon>
			<Configuration>
			</Configuration>
		</ContentListField>
		<ContentListField name='#ListField3' type='ShortText'>
			<DisplayName>ContentListField3</DisplayName>
			<Description>ContentListField3 Description</Description>
			<Icon>icon.gif</Icon>
			<Configuration>
				<MaxLength>200</MaxLength>
			</Configuration>
		</ContentListField>
	</Fields>
</ContentListDefinition>
";
            string path    = RepositoryPath.Combine(this.TestRoot.Path, "Cars");

            if (Node.Exists(path))
            {
                Node.ForceDelete(path);
            }

            ContentList list = new ContentList(this.TestRoot);

            list.Name = "Cars";
            list.ContentListDefinition = listDef;
            list.AllowedChildTypes     = new ContentType[] { ContentType.GetByName("Car") };

            list.Save();

            Node car = new GenericContent(list, "Car");

            car.Name         = "Kispolszki";
            car["#String_0"] = "ABC 34-78";
            car.Save();

            Content content = Content.Create(car);

            //-- Sikeres, ha nem dob hibat
        }
Exemplo n.º 3
0
        public void ContentList_Concurrent_AddStringField()
        {
            string listDef0 = @"<?xml version='1.0' encoding='utf-8'?>
                <ContentListDefinition xmlns='http://schemas.com/ContentRepository/ContentListDefinition'>
	                <Fields>
		                <ContentListField name='#StringField1' type='ShortText' />
	                </Fields>
                </ContentListDefinition>
                ";

            string path = RepositoryPath.Combine(this.TestRoot.Path, "Cars");

            if (Node.Exists(path))
            {
                Node.ForceDelete(path);
            }

            var list = new ContentList(this.TestRoot);

            list.Name = "Cars";
            list.ContentListDefinition = listDef0;
            list.AllowedChildTypes     = new ContentType[] { ContentType.GetByName("Car") };

            list.Save();
            var listId = list.Id;

            Node car = new GenericContent(list, "Car");

            car.Name         = "Trabant Tramp";
            car["#String_0"] = "ABC 34-78";
            car.Save();

            var t1 = new System.Threading.Thread(ContentList_Concurrent_AddStringField_Thread);
            var t2 = new System.Threading.Thread(ContentList_Concurrent_AddStringField_Thread);

            t1.Start();
            t2.Start();

            var startingTime = DateTime.UtcNow;

            while (counter < 2)
            {
                System.Threading.Thread.Sleep(1000);
                if ((DateTime.UtcNow - startingTime).TotalSeconds > 10)
                {
                    break;
                }
            }
            if (t1.ThreadState == System.Threading.ThreadState.Running)
            {
                t1.Abort();
            }
            if (t2.IsAlive)
            {
                t2.Abort();
            }

            Assert.IsTrue(counter == 2);
        }
Exemplo n.º 4
0
        public void ContentList_DeleteAndUnregister_Bug1648()
        {
            string listDef1 = @"<?xml version='1.0' encoding='utf-8'?>
<ContentListDefinition xmlns='http://schemas.com/ContentRepository/ContentListDefinition'>
	<Fields>
		<ContentListField name='#CDU_ListField' type='Integer' />
	</Fields>
</ContentListDefinition>
";
            string listDef2 = @"<?xml version='1.0' encoding='utf-8'?>
<ContentListDefinition xmlns='http://schemas.com/ContentRepository/ContentListDefinition'>
	<Fields>
		<ContentListField name='#CDU_ListField' type='ShortText' />
	</Fields>
</ContentListDefinition>
";

            ContentList list;
            Content     content;
            var         listName = "ContentList_DeleteAndUnregister";
            var         path     = RepositoryPath.Combine(this.TestRoot.Path, listName);

            //----------------

            if (Node.Exists(path))
            {
                Node.ForceDelete(path);
            }

            list      = new ContentList(this.TestRoot);
            list.Name = listName;
            list.ContentListDefinition = listDef1;
            list.AllowedChildTypes     = new ContentType[] { ContentType.GetByName("Car") };
            list.Save();

            content = Content.CreateNew("Car", list, "TestCar");
            content["#CDU_ListField"] = 123;
            content.Save();

            //----------------

            if (Node.Exists(path))
            {
                Node.ForceDelete(path);
            }

            list      = new ContentList(this.TestRoot);
            list.Name = listName;
            list.ContentListDefinition = listDef2;
            list.AllowedChildTypes     = new ContentType[] { ContentType.GetByName("Car") };
            list.Save();

            content = Content.CreateNew("Car", list, "TestCar");
            content["#CDU_ListField"] = "Sample data";
            content.Save();
        }
Exemplo n.º 5
0
        private void CreateContentList(string parentPath, string name, string listDef)
        {
            Node        parent      = Node.LoadNode(parentPath);
            ContentList contentlist = new ContentList(parent);

            contentlist.Name = name;
            contentlist.ContentListDefinition = listDef;
            contentlist.AllowChildTypes(new[] { "Folder", "Car" });
            contentlist.Save();
        }
Exemplo n.º 6
0
        //TODO: Remove inconclusive test result and implement this test.
        //[TestMethod]
        public void OData_Getting_ContentList_NoProjection()
        {
            Assert.Inconclusive("InMemorySchemaWriter.CreatePropertyType is partially implemented.");

            Test(() =>
            {
                CreateTestSite();

                var testRoot = CreateTestRoot("ODataTestRoot");

                string listDef = @"<?xml version='1.0' encoding='utf-8'?>
<ContentListDefinition xmlns='http://schemas.sensenet.com/SenseNet/ContentRepository/ContentListDefinition'>
	<Fields>
		<ContentListField name='#ListField1' type='ShortText'/>
		<ContentListField name='#ListField2' type='Integer'/>
		<ContentListField name='#ListField3' type='Reference'/>
	</Fields>
</ContentListDefinition>
";
                string path    = RepositoryPath.Combine(testRoot.Path, "Cars");
                if (Node.Exists(path))
                {
                    Node.ForceDelete(path);
                }
                ContentList list           = new ContentList(testRoot);
                list.Name                  = "Cars";
                list.ContentListDefinition = listDef;
                list.AllowedChildTypes     = new ContentType[] { ContentType.GetByName("Car") };
                list.Save();

                var car = Content.CreateNew("Car", list, "Car1");
                car.Save();
                car = Content.CreateNew("Car", list, "Car2");
                car.Save();

                var entities = ODataGET <ODataEntities>("/OData.svc" + list.Path, "");

                var entity          = entities.First();
                var entityPropNames = entity.AllProperties.Select(y => y.Key).ToArray();

                var allowedFieldNames = new List <string>();
                allowedFieldNames.AddRange(ContentType.GetByName("Car").FieldSettings.Select(f => f.Name));
                allowedFieldNames.AddRange(ContentType.GetByName("File").FieldSettings.Select(f => f.Name));
                allowedFieldNames.AddRange(list.ListFieldNames);
                allowedFieldNames.AddRange(new[] { "__metadata", "IsFile", "Actions", "IsFolder" });
                allowedFieldNames = allowedFieldNames.Distinct().ToList();

                var a = entityPropNames.Except(allowedFieldNames).ToArray();
                var b = allowedFieldNames.Except(entityPropNames).ToArray();

                Assert.IsTrue(a.Length == 0, String.Format("Expected empty but contains: '{0}'", string.Join("', '", a)));
                Assert.IsTrue(b.Length == 0, String.Format("Expected empty but contains: '{0}'", string.Join("', '", b)));
            });
        }
Exemplo n.º 7
0
        public void ContentList_DeleteAndUnregister_InTree()
        {
            var listDefs = new [] { @"<?xml version='1.0' encoding='utf-8'?>
<ContentListDefinition xmlns='http://schemas.com/ContentRepository/ContentListDefinition'>
	<Fields>
		<ContentListField name='#CDUInTree_ListField1' type='Integer' />
	</Fields>
</ContentListDefinition>
",
                                    @"<?xml version='1.0' encoding='utf-8'?>
<ContentListDefinition xmlns='http://schemas.com/ContentRepository/ContentListDefinition'>
	<Fields>
		<ContentListField name='#CDUInTree_ListField2' type='Integer' />
	</Fields>
</ContentListDefinition>
" };
            var c = Content.CreateNew("Folder", TestRoot, Guid.NewGuid().ToString());

            c.Save();
            var rootFolder = c.ContentHandler;

            var listTypes = new List <ContentListType>();

            foreach (var listDef in listDefs)
            {
                var list = new ContentList(rootFolder);
                list.Name = Guid.NewGuid().ToString();
                list.ContentListDefinition = listDef;
                list.Save();
                if (list.ContentListType == null)
                {
                    Assert.Inconclusive();
                }
                listTypes.Add(list.ContentListType);
            }

            rootFolder.ForceDelete();

            var count = 0;

            foreach (var listType in listTypes)
            {
                if (ActiveSchema.ContentListTypes[listType.Name] != null)
                {
                    count++;
                }
            }

            Assert.IsTrue(count == 0, String.Format("There is/are {0} ContentListType. Expected: 0", count));
        }
Exemplo n.º 8
0
        public void ContentList_CreateListUnderList()
        {
            string path = RepositoryPath.Combine(this.TestRoot.Path, "Cars");

            if (Node.Exists(path))
            {
                Node.ForceDelete(path);
            }

            ContentList list = new ContentList(this.TestRoot);

            list.Name = "Cars";
            list.Save();

            list = new ContentList(list);
        }
Exemplo n.º 9
0
        public void ContentList_WithoutDefinition()
        {
            string path = RepositoryPath.Combine(this.TestRoot.Path, "Cars");

            if (Node.Exists(path))
            {
                Node.ForceDelete(path);
            }

            ContentList list = new ContentList(this.TestRoot);

            list.Name = "Cars";
            list.AllowedChildTypes = new ContentType[] { ContentType.GetByName("Car") };

            list.Save();

            Node car = new GenericContent(list, "Car");

            car.Name = "Kispolszki";
            car.Save();

            //-- Sikeres, ha nem dob hibat
        }
Exemplo n.º 10
0
        public void ContentList_DeleteField()
        {
            string listDef = @"<?xml version='1.0' encoding='utf-8'?>
<ContentListDefinition xmlns='http://schemas.com/ContentRepository/ContentListDefinition'>
	<DisplayName>Cars title</DisplayName>
	<Description>Cars description</Description>
	<Icon>automobile.gif</Icon>
	<Fields>
		<ContentListField name='#ListField1' type='ShortText'>
			<DisplayName>ContentListField1</DisplayName>
			<Description>ContentListField1 Description</Description>
			<Icon>icon.gif</Icon>
			<Configuration>
				<MaxLength>100</MaxLength>
			</Configuration>
		</ContentListField>
		<ContentListField name='#ListField2' type='WhoAndWhen'>
			<DisplayName>ContentListField2</DisplayName>
			<Description>ContentListField2 Description</Description>
			<Icon>icon.gif</Icon>
			<Configuration>
			</Configuration>
		</ContentListField>
		<ContentListField name='#ListField3' type='ShortText'>
			<DisplayName>ContentListField3</DisplayName>
			<Description>ContentListField3 Description</Description>
			<Icon>icon.gif</Icon>
			<Configuration>
				<MaxLength>200</MaxLength>
			</Configuration>
		</ContentListField>
	</Fields>
</ContentListDefinition>
";
            string path    = RepositoryPath.Combine(this.TestRoot.Path, "Cars");

            if (Node.Exists(path))
            {
                Node.ForceDelete(path);
            }

            var list = new ContentList(this.TestRoot)
            {
                Name = "Cars",
                ContentListDefinition = listDef,
                AllowedChildTypes     = new ContentType[] { ContentType.GetByName("Car") }
            };

            list.Save();

            Node car = new GenericContent(list, "Car");

            car.Name         = "Kispolszki";
            car["#String_0"] = "ABC 34-78";
            car.Save();

            list = Node.Load <ContentList>(list.Path);
            var fs = Content.Create(car).Fields["#ListField3"].FieldSetting;

            list.DeleteField(fs);

            var cc = Content.Load(car.Path);

            Assert.IsTrue(!cc.Fields.ContainsKey("#ListField3"));
        }
Exemplo n.º 11
0
        public void ContentList_AvailableFields()
        {
            ContentType c = ContentType.GetByName("CT_Root");

            if (c != null)
            {
                ContentTypeInstaller.RemoveContentType(c);
            }
            ContentTypeManager.Reset();

            ContentTypeInstaller installer = ContentTypeInstaller.CreateBatchContentTypeInstaller();

            installer.AddContentType(@"<?xml version='1.0' encoding='utf-8'?>
				<ContentType name='CT_Root' parentType='GenericContent' handler='ContentRepository.GenericContent' xmlns='http://schemas.com/ContentRepository/ContentTypeDefinition'>
					<Fields>
						<Field name='InheritanceTest' type='Integer'>
							<Configuration><MinValue>-5</MinValue><MaxValue>7</MaxValue></Configuration>
						</Field>
					</Fields>
				</ContentType>"                );

            installer.AddContentType("<ContentType name='CT_A' parentType='CT_Root' handler='ContentRepository.GenericContent' xmlns='http://schemas.com/ContentRepository/ContentTypeDefinition'><Fields><Field name='InheritanceTest' type='Integer'><Configuration><MinValue>0</MinValue><MaxValue>10</MaxValue></Configuration></Field></Fields></ContentType>");
            installer.AddContentType("<ContentType name='CT_A_A' parentType='CT_A' handler='ContentRepository.GenericContent' xmlns='http://schemas.com/ContentRepository/ContentTypeDefinition'><Fields><Field name='InheritanceTest' type='Integer'><Configuration><MinValue>1</MinValue><MaxValue>20</MaxValue></Configuration></Field></Fields></ContentType>");
            installer.AddContentType("<ContentType name='CT_B' parentType='CT_Root' handler='ContentRepository.GenericContent' xmlns='http://schemas.com/ContentRepository/ContentTypeDefinition'><Fields><Field name='InheritanceTest' type='Integer'><Configuration><MinValue>2</MinValue><MaxValue>30</MaxValue></Configuration></Field></Fields></ContentType>");
            installer.AddContentType("<ContentType name='CT_B_B' parentType='CT_B' handler='ContentRepository.GenericContent' xmlns='http://schemas.com/ContentRepository/ContentTypeDefinition'><Fields><Field name='InheritanceTest' type='Integer'><Configuration><MinValue>3</MinValue><MaxValue>40</MaxValue></Configuration></Field></Fields></ContentType>");

            installer.ExecuteBatch();

            string listDef = @"<?xml version='1.0' encoding='utf-8'?>
<ContentListDefinition xmlns='http://schemas.com/ContentRepository/ContentListDefinition'>
	<DisplayName>Cars title</DisplayName>
	<Description>Cars description</Description>
	<Icon>automobile.gif</Icon>
	<Fields>
		<ContentListField name='#ListField1' type='ShortText'>
			<DisplayName>ContentListField1</DisplayName>
			<Description>ContentListField1 Description</Description>
			<Icon>icon.gif</Icon>
			<Configuration>
				<MaxLength>100</MaxLength>
			</Configuration>
		</ContentListField>
		<ContentListField name='#ListField2' type='WhoAndWhen'>
			<DisplayName>ContentListField2</DisplayName>
			<Description>ContentListField2 Description</Description>
			<Icon>icon.gif</Icon>
			<Configuration>
			</Configuration>
		</ContentListField>
		<ContentListField name='#ListField3' type='ShortText'>
			<DisplayName>ContentListField3</DisplayName>
			<Description>ContentListField3 Description</Description>
			<Icon>icon.gif</Icon>
			<Configuration>
				<MaxLength>200</MaxLength>
			</Configuration>
		</ContentListField>
	</Fields>
</ContentListDefinition>
";

            var b = new bool[21];

            ContentType  CT_Root = ContentType.GetByName("CT_Root");
            FieldSetting FS_Root = CT_Root.FieldSettings[0];

            ContentType  CT_A   = ContentType.GetByName("CT_A");
            ContentType  CT_B   = ContentType.GetByName("CT_B");
            FieldSetting FS_A   = CT_A.FieldSettings[0];
            ContentType  CT_A_A = ContentType.GetByName("CT_A_A");
            FieldSetting FS_A_A = CT_A_A.FieldSettings[0];

            string path = RepositoryPath.Combine(this.TestRoot.Path, "Cars");

            if (Node.Exists(path))
            {
                Node.ForceDelete(path);
            }

            var list = new ContentList(this.TestRoot);

            list.Name = "Cars";
            list.ContentListDefinition = listDef;
            list.AllowedChildTypes     = new[] { CT_A, CT_B };

            list.Save();

            b[0] = FS_Root.ParentFieldSetting == null;
            b[1] = FS_A.ParentFieldSetting == FS_Root;
            b[2] = FS_A_A.ParentFieldSetting == FS_A;

            var fields = list.GetAvailableFields();
        }
Exemplo n.º 12
0
        public void ContentList_AvailableFields()
        {
            ContentType c = ContentType.GetByName("CT_Root");
            if (c != null)
                ContentTypeInstaller.RemoveContentType(c);
            ContentTypeManager.Reset();

            ContentTypeInstaller installer = ContentTypeInstaller.CreateBatchContentTypeInstaller();

            installer.AddContentType(@"<?xml version='1.0' encoding='utf-8'?>
				<ContentType name='CT_Root' parentType='GenericContent' handler='SenseNet.ContentRepository.GenericContent' xmlns='http://schemas.sensenet.com/SenseNet/ContentRepository/ContentTypeDefinition'>
					<Fields>
						<Field name='InheritanceTest' type='Integer'>
							<Configuration><MinValue>-5</MinValue><MaxValue>7</MaxValue></Configuration>
						</Field>
					</Fields>
				</ContentType>");

            installer.AddContentType("<ContentType name='CT_A' parentType='CT_Root' handler='SenseNet.ContentRepository.GenericContent' xmlns='http://schemas.sensenet.com/SenseNet/ContentRepository/ContentTypeDefinition'><Fields><Field name='InheritanceTest' type='Integer'><Configuration><MinValue>0</MinValue><MaxValue>10</MaxValue></Configuration></Field></Fields></ContentType>");
            installer.AddContentType("<ContentType name='CT_A_A' parentType='CT_A' handler='SenseNet.ContentRepository.GenericContent' xmlns='http://schemas.sensenet.com/SenseNet/ContentRepository/ContentTypeDefinition'><Fields><Field name='InheritanceTest' type='Integer'><Configuration><MinValue>1</MinValue><MaxValue>20</MaxValue></Configuration></Field></Fields></ContentType>");
            installer.AddContentType("<ContentType name='CT_B' parentType='CT_Root' handler='SenseNet.ContentRepository.GenericContent' xmlns='http://schemas.sensenet.com/SenseNet/ContentRepository/ContentTypeDefinition'><Fields><Field name='InheritanceTest' type='Integer'><Configuration><MinValue>2</MinValue><MaxValue>30</MaxValue></Configuration></Field></Fields></ContentType>");
            installer.AddContentType("<ContentType name='CT_B_B' parentType='CT_B' handler='SenseNet.ContentRepository.GenericContent' xmlns='http://schemas.sensenet.com/SenseNet/ContentRepository/ContentTypeDefinition'><Fields><Field name='InheritanceTest' type='Integer'><Configuration><MinValue>3</MinValue><MaxValue>40</MaxValue></Configuration></Field></Fields></ContentType>");

            installer.ExecuteBatch();

            string listDef = @"<?xml version='1.0' encoding='utf-8'?>
<ContentListDefinition xmlns='http://schemas.sensenet.com/SenseNet/ContentRepository/ContentListDefinition'>
	<DisplayName>Cars title</DisplayName>
	<Description>Cars description</Description>
	<Icon>automobile.gif</Icon>
	<Fields>
		<ContentListField name='#ListField1' type='ShortText'>
			<DisplayName>ContentListField1</DisplayName>
			<Description>ContentListField1 Description</Description>
			<Icon>icon.gif</Icon>
			<Configuration>
				<MaxLength>100</MaxLength>
			</Configuration>
		</ContentListField>
		<ContentListField name='#ListField2' type='WhoAndWhen'>
			<DisplayName>ContentListField2</DisplayName>
			<Description>ContentListField2 Description</Description>
			<Icon>icon.gif</Icon>
			<Configuration>
			</Configuration>
		</ContentListField>
		<ContentListField name='#ListField3' type='ShortText'>
			<DisplayName>ContentListField3</DisplayName>
			<Description>ContentListField3 Description</Description>
			<Icon>icon.gif</Icon>
			<Configuration>
				<MaxLength>200</MaxLength>
			</Configuration>
		</ContentListField>
	</Fields>
</ContentListDefinition>
";

            var b = new bool[21];

            ContentType CT_Root = ContentType.GetByName("CT_Root");
            FieldSetting FS_Root = CT_Root.FieldSettings[0];

            ContentType CT_A = ContentType.GetByName("CT_A");
            ContentType CT_B = ContentType.GetByName("CT_B");
            FieldSetting FS_A = CT_A.FieldSettings[0];
            ContentType CT_A_A = ContentType.GetByName("CT_A_A");
            FieldSetting FS_A_A = CT_A_A.FieldSettings[0];

            string path = RepositoryPath.Combine(this.TestRoot.Path, "Cars");
            if (Node.Exists(path))
                Node.ForceDelete(path);

            var list = new ContentList(this.TestRoot);
            list.Name = "Cars";
            list.ContentListDefinition = listDef;
            list.AllowedChildTypes = new[] { CT_A, CT_B };

            list.Save();

            b[0] = FS_Root.ParentFieldSetting == null;
            b[1] = FS_A.ParentFieldSetting == FS_Root;
            b[2] = FS_A_A.ParentFieldSetting == FS_A;

            var fields = list.GetAvailableFields();
        }
Exemplo n.º 13
0
        public void ContentList_Concurrent_AddStringField()
        {
            string listDef0 = @"<?xml version='1.0' encoding='utf-8'?>
                <ContentListDefinition xmlns='http://schemas.sensenet.com/SenseNet/ContentRepository/ContentListDefinition'>
	                <Fields>
		                <ContentListField name='#StringField1' type='ShortText' />
	                </Fields>
                </ContentListDefinition>
                ";

            string path = RepositoryPath.Combine(this.TestRoot.Path, "Cars");
            if (Node.Exists(path))
                Node.ForceDelete(path);

            var list = new ContentList(this.TestRoot);
            list.Name = "Cars";
            list.ContentListDefinition = listDef0;
            list.AllowedChildTypes = new ContentType[] { ContentType.GetByName("Car") };

            list.Save();
            var listId = list.Id;

            Node car = new GenericContent(list, "Car");
            car.Name = "Trabant Tramp";
            car["#String_0"] = "ABC 34-78";
            car.Save();

            var t1 = new System.Threading.Thread(ContentList_Concurrent_AddStringField_Thread);
            var t2 = new System.Threading.Thread(ContentList_Concurrent_AddStringField_Thread);
            t1.Start();
            t2.Start();

            var startingTime = DateTime.Now;
            while (counter < 2)
            {
                System.Threading.Thread.Sleep(1000);
                if ((DateTime.Now - startingTime).TotalSeconds > 10)
                    break;
            }
            if (t1.ThreadState == System.Threading.ThreadState.Running)
                t1.Abort();
            if (t2.IsAlive)
                t2.Abort();

            Assert.IsTrue(counter == 2);
        }
Exemplo n.º 14
0
        public void Field_OuterField_OnTheContentList()
        {
            ContentTypeInstaller.InstallContentType(@"<?xml version='1.0' encoding='utf-8'?>
                <ContentType name='OuterFieldTestContentType' parentType='GenericContent' handler='SenseNet.ContentRepository.GenericContent' xmlns='http://schemas.sensenet.com/SenseNet/ContentRepository/ContentTypeDefinition'>
                </ContentType>
                ");
            string ltd = @"<?xml version='1.0' encoding='utf-8'?>
				<ContentListDefinition xmlns='http://schemas.sensenet.com/SenseNet/ContentRepository/ContentListDefinition'>
					<Fields><ContentListField name='#OuterField1' type='OuterField' /></Fields></ContentListDefinition>";

            ContentList list = new ContentList(_testRoot);
            list.ContentListDefinition = ltd;
            list.Save();

            var content = Content.CreateNew("OuterFieldTestContentType", list, new Guid().ToString());

            content["#OuterField1"] = "asdf";
            content.ContentHandler.Index = 123;
            content.Save();
            var id = content.Id;

            content = Content.Load(id);
            var fieldValue = content["#OuterField1"];
            var indexValue = content.ContentHandler.Index;

            Assert.IsTrue(content.ContentHandler.PropertyTypes["#OuterField1"] == null, "#1");
            Assert.IsTrue(content.ContentHandler.Index == 124, "#2");
        }
Exemplo n.º 15
0
        public void Field_NamingConvention_BadContentListField()
        {
            //-- Sikeres, ha hibat dob

            string ltd = @"<?xml version='1.0' encoding='utf-8'?>
				<ContentListDefinition name='FieldNamingTest' xmlns='http://schemas.sensenet.com/SenseNet/ContentRepository/ContentTypeDefinition'>
					<Fields><ContentListField name='ContentListField1' type='ShortText' /></Fields></ContentListDefinition>";

            if (Node.Exists("/Root/ContentList1"))
                Node.ForceDelete("/Root/ContentList1");

            ContentList list = new ContentList(Repository.Root);
            list.Name = "ContentList1";
            list.ContentListDefinition = ltd;
            list.Save();

            if (Node.Exists("/Root/ContentList1"))
                Node.ForceDelete("/Root/ContentList1");

        }
Exemplo n.º 16
0
        public void ContentList_SaveFieldSetting()
        {
            string listDef = @"<?xml version='1.0' encoding='utf-8'?>
<ContentListDefinition xmlns='http://schemas.sensenet.com/SenseNet/ContentRepository/ContentListDefinition'>
	<DisplayName>Cars title</DisplayName>
	<Description>Cars description</Description>
	<Icon>automobile.gif</Icon>
	<Fields>
		<ContentListField name='#ListField1' type='ShortText'>
			<DisplayName>ContentListField1</DisplayName>
			<Description>ContentListField1 Description</Description>
			<Icon>icon.gif</Icon>
			<Configuration>
				<MaxLength>100</MaxLength>
			</Configuration>
		</ContentListField>
		<ContentListField name='#ListField2' type='WhoAndWhen'>
			<DisplayName>ContentListField2</DisplayName>
			<Description>ContentListField2 Description</Description>
			<Icon>icon.gif</Icon>
			<Configuration>
			</Configuration>
		</ContentListField>
		<ContentListField name='#ListField3' type='ShortText'>
			<DisplayName>ContentListField3</DisplayName>
			<Description>ContentListField3 Description</Description>
			<Icon>icon.gif</Icon>
			<Configuration>
				<MaxLength>200</MaxLength>
			</Configuration>
		</ContentListField>
	</Fields>
</ContentListDefinition>
";
            string path = RepositoryPath.Combine(this.TestRoot.Path, "Cars");
            if (Node.Exists(path))
                Node.ForceDelete(path);

            var list = new ContentList(this.TestRoot)
            {
                Name = "Cars",
                ContentListDefinition = listDef,
                AllowedChildTypes = new[] { ContentType.GetByName("Car") }
            };

            list.Save();

            var fsNodes = new List<Node>(list.FieldSettingContents);
            var fs = fsNodes[0] as FieldSettingContent;
            var fsc = Content.Create(fsNodes[0]);
            var title = "New field title";

            fsc["DisplayName"] = title;
            fsc.Save();

            Assert.IsTrue(fs.FieldSetting.DisplayName.CompareTo(title) == 0);
        }
Exemplo n.º 17
0
        public void ContentList_CreateListUnderList()
		{
			string path = RepositoryPath.Combine(this.TestRoot.Path, "Cars");
			if (Node.Exists(path))
                Node.ForceDelete(path);

            ContentList list = new ContentList(this.TestRoot);
            list.Name = "Cars";
            list.Save();

            list = new ContentList(list);
		}
Exemplo n.º 18
0
        public void ContentList_DeleteAndUnregister_Bug1648()
        {
            string listDef1 = @"<?xml version='1.0' encoding='utf-8'?>
<ContentListDefinition xmlns='http://schemas.sensenet.com/SenseNet/ContentRepository/ContentListDefinition'>
	<Fields>
		<ContentListField name='#CDU_ListField' type='Integer' />
	</Fields>
</ContentListDefinition>
";
            string listDef2 = @"<?xml version='1.0' encoding='utf-8'?>
<ContentListDefinition xmlns='http://schemas.sensenet.com/SenseNet/ContentRepository/ContentListDefinition'>
	<Fields>
		<ContentListField name='#CDU_ListField' type='ShortText' />
	</Fields>
</ContentListDefinition>
";

            ContentList list;
            Content content;
            var listName = "ContentList_DeleteAndUnregister";
            var path = RepositoryPath.Combine(this.TestRoot.Path, listName);

            //----------------

            if (Node.Exists(path))
                Node.ForceDelete(path);

            list = new ContentList(this.TestRoot);
            list.Name = listName;
            list.ContentListDefinition = listDef1;
            list.AllowedChildTypes = new ContentType[] { ContentType.GetByName("Car") };
            list.Save();

            content = Content.CreateNew("Car", list, "TestCar");
            content["#CDU_ListField"] = 123;
            content.Save();

            //----------------

            if (Node.Exists(path))
                Node.ForceDelete(path);

            list = new ContentList(this.TestRoot);
            list.Name = listName;
            list.ContentListDefinition = listDef2;
            list.AllowedChildTypes = new ContentType[] { ContentType.GetByName("Car") };
            list.Save();

            content = Content.CreateNew("Car", list, "TestCar");
            content["#CDU_ListField"] = "Sample data";
            content.Save();
        }
Exemplo n.º 19
0
        public void ContentList_DeleteAndUnregister_InTree()
        {
            var listDefs = new [] { @"<?xml version='1.0' encoding='utf-8'?>
<ContentListDefinition xmlns='http://schemas.sensenet.com/SenseNet/ContentRepository/ContentListDefinition'>
	<Fields>
		<ContentListField name='#CDUInTree_ListField1' type='Integer' />
	</Fields>
</ContentListDefinition>
",
@"<?xml version='1.0' encoding='utf-8'?>
<ContentListDefinition xmlns='http://schemas.sensenet.com/SenseNet/ContentRepository/ContentListDefinition'>
	<Fields>
		<ContentListField name='#CDUInTree_ListField2' type='Integer' />
	</Fields>
</ContentListDefinition>
"};
            var c = Content.CreateNew("Folder", TestRoot, Guid.NewGuid().ToString());
            c.Save();
            var rootFolder = c.ContentHandler;

            var listTypes = new List<ContentListType>();
            foreach (var listDef in listDefs)
            {
                var list = new ContentList(rootFolder);
                list.Name = Guid.NewGuid().ToString();
                list.ContentListDefinition = listDef;
                list.Save();
                if(list.ContentListType == null)
                    Assert.Inconclusive();
                listTypes.Add(list.ContentListType);
            }

            rootFolder.ForceDelete();

            var count = 0;
            foreach (var listType in listTypes)
                if (ActiveSchema.ContentListTypes[listType.Name] != null)
                    count++;

            Assert.IsTrue(count == 0, String.Format("There is/are {0} ContentListType. Expected: 0", count));
        }
Exemplo n.º 20
0
        private string CheckListTypeXmlNamespaceCompatibility(string xmlNamespace, string namespaceName, bool featureEnabled)
        {
            var compat = RepositoryConfiguration.BackwardCompatibilityXmlNamespaces;
            SetBackwardCompatibilityXmlNamespaces(featureEnabled);

            var fieldName = "#ListField1";
            string listDef = String.Format(@"<ContentListDefinition xmlns='{0}'><Fields>
                <ContentListField name='{1}' type='ShortText' /></Fields></ContentListDefinition>", xmlNamespace, fieldName);

            string listPath = RepositoryPath.Combine(this.TestRoot.Path, "Cars");
            if (Node.Exists(listPath))
                Node.ForceDelete(listPath);

            ContentList list;
            int listId = 0;

            try
            {
                list = new ContentList(this.TestRoot);
                list.Name = "Cars";
                list.ContentListDefinition = listDef;
                list.Save();
                listId = list.Id;
                list = Node.Load<ContentList>(listId);
            }
            catch (Exception e)
            {
                SetBackwardCompatibilityXmlNamespaces(compat);
                return String.Concat("Cannot create List (", namespaceName, "): ", e.Message);
            }

            var fieldValue = Guid.NewGuid().ToString();
            var content = Content.CreateNew("Car", list, "XmlNamespaceCompatibilityContent");

            if (!content.Fields.ContainsKey(fieldName))
            {
                SetBackwardCompatibilityXmlNamespaces(compat);
                return String.Concat("Missing field (", namespaceName, ")");
            }

            content[fieldName] = fieldValue;

            try
            {
                content.Save();
            }
            catch (Exception e)
            {
                SetBackwardCompatibilityXmlNamespaces(compat);
                var msg = String.Concat("Cannot save a ListItem (", namespaceName, "): ", e.Message, e.StackTrace.Replace("\r", " ").Replace("\n", " "));
Debug.WriteLine(msg);
                return msg;
            }

            var id = content.Id;
            try
            {
                content = Content.Load(id);
            }
            catch (Exception e)
            {
                SetBackwardCompatibilityXmlNamespaces(compat);
                return String.Concat("Cannot load back a ListItem (", namespaceName, "): ", e.Message);
            }

            var loadedValue = (string)content[fieldName];

            //content.Delete();
            Node.ForceDelete(id);

            SetBackwardCompatibilityXmlNamespaces(compat);

            if (loadedValue != fieldValue)
                return String.Concat("Inconsistent field value (", namespaceName, ")");

            if(list.ContentListDefinition != listDef)
                return String.Concat("List definition xml is modified (", namespaceName, ")");

            return null;
        }
Exemplo n.º 21
0
        public void ContentList_FieldInitialize_Bug2943()
        {
            string listDef = @"<?xml version='1.0' encoding='utf-8'?>
<ContentListDefinition xmlns='http://schemas.sensenet.com/SenseNet/ContentRepository/ContentListDefinition'>
	<Fields>
		<ContentListField name='#ListField1' type='Integer'>
			<Configuration>
				<MinValue>-100</MinValue>
				<MaxValue>100</MaxValue>
			</Configuration>
		</ContentListField>
	</Fields>
</ContentListDefinition>
";
            string path = RepositoryPath.Combine(this.TestRoot.Path, "Cars");
            if (Node.Exists(path))
                Node.ForceDelete(path);

            ContentList list;
            Content content;
            var bb = new List<bool>();

            list = new ContentList(this.TestRoot);
            list.Name = "Cars";
            list.ContentListDefinition = listDef;
            list.AllowedChildTypes = new ContentType[] { ContentType.GetByName("Car") };
            list.Save();

            content = Content.CreateNew("Car", list, "TestCar");

            content["#ListField1"] = 0;
            bb.Add(content.IsValid);
            content["#ListField1"] = 10;
            bb.Add(content.IsValid);
            content["#ListField1"] = 0;
            bb.Add(content.IsValid);
            content["#ListField1"] = -10;
            bb.Add(content.IsValid);
            content["#ListField1"] = -100;
            bb.Add(content.IsValid);
            content["#ListField1"] = 100;
            bb.Add(content.IsValid);
            content["#ListField1"] = -101;
            bb.Add(!content.IsValid);
            content["#ListField1"] = 101;
            bb.Add(!content.IsValid);

            content = Content.CreateNew("Car", list, "TestCar1");

            content["#ListField1"] = 0;
            bb.Add(content.IsValid);
            content["#ListField1"] = 10;
            bb.Add(content.IsValid);
            content["#ListField1"] = 0;
            bb.Add(content.IsValid);
            content["#ListField1"] = -10;
            bb.Add(content.IsValid);
            content["#ListField1"] = -101;
            bb.Add(!content.IsValid);
            content["#ListField1"] = 101;
            bb.Add(!content.IsValid);

            var i = 0;
            foreach (var b in bb)
                Assert.IsTrue(b, "#" + i++);
        }
Exemplo n.º 22
0
        public void ContentList_Modify()
		{
			List<string> listDefs = new List<string>();
            listDefs.Add(@"<?xml version='1.0' encoding='utf-8'?>
<ContentListDefinition xmlns='http://schemas.sensenet.com/SenseNet/ContentRepository/ContentListDefinition'>
	<Fields>
	</Fields>
</ContentListDefinition>
");
            listDefs.Add(@"<?xml version='1.0' encoding='utf-8'?>
<ContentListDefinition xmlns='http://schemas.sensenet.com/SenseNet/ContentRepository/ContentListDefinition'>
	<Fields>
		<ContentListField name='#LF0' type='ShortText' />
		<ContentListField name='#LF1' type='ShortText' />
	</Fields>
</ContentListDefinition>
");
            listDefs.Add(@"<?xml version='1.0' encoding='utf-8'?>
<ContentListDefinition xmlns='http://schemas.sensenet.com/SenseNet/ContentRepository/ContentListDefinition'>
	<Fields>
		<ContentListField name='#LF0' type='ShortText' />
	</Fields>
</ContentListDefinition>
");
            listDefs.Add(@"<?xml version='1.0' encoding='utf-8'?>
<ContentListDefinition xmlns='http://schemas.sensenet.com/SenseNet/ContentRepository/ContentListDefinition'>
	<Fields>
	</Fields>
</ContentListDefinition>
");
            listDefs.Add(@"<?xml version='1.0' encoding='utf-8'?>
<ContentListDefinition xmlns='http://schemas.sensenet.com/SenseNet/ContentRepository/ContentListDefinition'>
	<Fields>
		<ContentListField name='#LF0' type='ShortText' />
		<ContentListField name='#LF1' type='ShortText' />
		<ContentListField name='#LF2' type='ShortText' />
	</Fields>
</ContentListDefinition>
");
            listDefs.Add(@"<?xml version='1.0' encoding='utf-8'?>
<ContentListDefinition xmlns='http://schemas.sensenet.com/SenseNet/ContentRepository/ContentListDefinition'>
	<Fields>
		<ContentListField name='#LF0' type='ShortText' />
		<ContentListField name='#LF2' type='ShortText' />
	</Fields>
</ContentListDefinition>
");
            listDefs.Add(@"<?xml version='1.0' encoding='utf-8'?>
<ContentListDefinition xmlns='http://schemas.sensenet.com/SenseNet/ContentRepository/ContentListDefinition'>
	<Fields>
		<ContentListField name='#LF0' type='ShortText' />
		<ContentListField name='#LF1' type='ShortText' />
		<ContentListField name='#LF2' type='ShortText' />
	</Fields>
</ContentListDefinition>
");
            listDefs.Add(@"<?xml version='1.0' encoding='utf-8'?>
<ContentListDefinition xmlns='http://schemas.sensenet.com/SenseNet/ContentRepository/ContentListDefinition'>
	<Fields>
		<ContentListField name='#LF2' type='ShortText' />
	</Fields>
</ContentListDefinition>
");
            listDefs.Add(@"<?xml version='1.0' encoding='utf-8'?>
<ContentListDefinition xmlns='http://schemas.sensenet.com/SenseNet/ContentRepository/ContentListDefinition'>
	<Fields>
		<ContentListField name='#LF0' type='ShortText' />
		<ContentListField name='#LF3' type='ShortText' />
		<ContentListField name='#LF2' type='ShortText' />
	</Fields>
</ContentListDefinition>
");
            listDefs.Add(@"<?xml version='1.0' encoding='utf-8'?>
<ContentListDefinition xmlns='http://schemas.sensenet.com/SenseNet/ContentRepository/ContentListDefinition'>
	<Fields>
		<ContentListField name='#LF0' type='ShortText' />
		<ContentListField name='#LF1' type='ShortText' />
		<ContentListField name='#LF2' type='ShortText' />
	</Fields>
</ContentListDefinition>
");

			string listName = "List1";
            string listPath = RepositoryPath.Combine(this.TestRoot.Path, listName);
            if (Node.Exists(listPath))
                Node.ForceDelete(listPath);

			ContentList list = new ContentList(this.TestRoot);
            list.Name = listName;
            list.AllowedChildTypes = new ContentType[] { ContentType.GetByName("Car") };

            list.Save();

            Node car = new GenericContent(list, "Car");
			car.Name = "Kispolszki";
			car.Save();
			int carId = car.Id;

			StringBuilder log = new StringBuilder();
            for (int def = 0; def < listDefs.Count; def++)
			{
                Exception ex = null;
                for (var i = 0; i < 10; i++)
                {
                    try
                    {
                        ex = null;
                        list = Node.Load<ContentList>(listPath);
                        list.ContentListDefinition = listDefs[def];
                        list.Save();
                        break;
                    }
                    catch(Exception e)
                    {
                        ex = e;
                        System.Threading.Thread.Sleep(200);
Debug.WriteLine("@> {0}. {1} / {2}", i, def, listDefs.Count);
                    }
                }
                if (ex != null)
                    throw new ApplicationException("Exception after 10 iteration: " + ex.Message, ex);


				car = Node.LoadNode(carId);
				log.Append("Def_").Append(def).Append(": ");
				for (int i = 0; i < 4; i++)
				{
					var propName = "#String_" + i;
					if(car.HasProperty(propName))
						log.Append("[").Append(propName).Append(" = ").Append(car.PropertyTypes[propName].Mapping).Append("]");
				}
				log.Append("\r\n");
			}

			string realLog = log.Replace("\r\n", "").Replace(" ", "").Replace("\t", "").ToString();
			string expectedLog = @"
				Def_0: 
				Def_1: [#String_0 = 800000000][#String_1 = 800000001]
				Def_2: [#String_0 = 800000000]
				Def_3: 
				Def_4: [#String_0 = 800000000][#String_1 = 800000001][#String_2 = 800000002]
				Def_5: [#String_0 = 800000000][#String_2 = 800000002]
				Def_6: [#String_0 = 800000000][#String_1 = 800000001][#String_2 = 800000002]
				Def_7: [#String_2 = 800000002]
				Def_8: [#String_0 = 800000000][#String_1 = 800000001][#String_2 = 800000002]
				Def_9: [#String_0 = 800000000][#String_2 = 800000002][#String_3 = 800000003]
				".Replace("\r\n", "").Replace(" ", "").Replace("\t", "");

			Assert.IsTrue(realLog == expectedLog);
		}
Exemplo n.º 23
0
        private static void CreatePlayGround()
        {
            DestroyPlayground();

            // /Root
            //      |
            //      +-ContentTemplates
            //      |   |
            //      |   +-File
            //      |   |   |
            //      |   |   +-file1.txt
            //      |   |
            //      |   +-ContentList
            //      |       |
            //      |       +-list1
            //      |
            //      +-CTemplateTests
            //          |
            //          +-CtSite
            //          |   |
            //          |   +-ContentTemplates
            //          |   |   |
            //          |   |   +-File
            //          |   |       |
            //          |   |       +-file1.txt
            //          |   |
            //          |   +-CtWorkspace1
            //          |   |   |
            //          |   |   +-ContentTemplates
            //          |   |   |   |
            //          |   |   |   +-ContentList
            //          |   |   |       |
            //          |   |   |       +-list1
            //          |   |   +-CtList1
            //          |   |   |   |
            //          |   |   |   +-ContentTemplates
            //          |   |   |       |
            //          |   |   |       +-File
            //          |   |   |           |
            //          |   |   |           +-file1.txt
            //          |   |   +-CtList2
            //          |   | 
            //          |   +-CtWorkspace2
            //          | 
            //          +-CtWorkspace3

            //global template folder
            var ctfGlobal = Node.LoadNode(Repository.ContentTemplateFolderPath);
            if (ctfGlobal == null)
            {
                ctfGlobal = new SystemFolder(Node.LoadNode("/Root")) {Name = Repository.ContentTemplatesFolderName};
                ctfGlobal.Save();
            }

            //create GLOBAL content template type folders
            var folderGlobalCtFile1 = Node.Load<Folder>(RepositoryPath.Combine(ctfGlobal.Path, "File"));
            if (folderGlobalCtFile1 == null)
            {
                folderGlobalCtFile1 = new Folder(ctfGlobal) { Name = "File" };
                folderGlobalCtFile1.Save();
            }
            var folderGlobalCtList1 = Node.Load<Folder>(RepositoryPath.Combine(ctfGlobal.Path, "ContentList"));
            if (folderGlobalCtList1 == null)
            {
                folderGlobalCtList1 = new Folder(ctfGlobal) { Name = "ContentList" };
                folderGlobalCtList1.Save();
            }

            //create GLOBAL content templates
            _fileGlobalTemplate1 = Node.Load<File>(RepositoryPath.Combine(folderGlobalCtFile1.Path, _testFileName));
            if (_fileGlobalTemplate1 == null)
            {
                _fileGlobalTemplate1 = new File(folderGlobalCtFile1) { Name = _testFileName, Index = 30 };
                _fileGlobalTemplate1.Save();
            }
            _listGlobalTemplate1 = Node.Load<ContentList>(RepositoryPath.Combine(folderGlobalCtList1.Path, _testListTemplateName));
            if (_listGlobalTemplate1 == null)
            {
                _listGlobalTemplate1 = new ContentList(folderGlobalCtList1) { Name = _testListTemplateName, Index = 30 };
                _listGlobalTemplate1.Save();
            }

            //create site, workspace and list
            var site = new Site(TestRoot) {Name = "CtSite"};
            site.UrlList.Add("mytemplatetestinterneturl", "Forms");
            site.Save();

            var ws = new Workspace(site) { Name = "CtWorkspace2", AllowedChildTypes = new List<ContentType> { ContentType.GetByName("ContentList"), ContentType.GetByName("Workspace"), ContentType.GetByName("File") } };
            ws.Save();

            ws = new Workspace(TestRoot) { Name = "CtWorkspace3", AllowedChildTypes = new List<ContentType> { ContentType.GetByName("ContentList"), ContentType.GetByName("Workspace"), ContentType.GetByName("File") } };
            ws.Save();

            ws = new Workspace(site) { Name = "CtWorkspace1", AllowedChildTypes = new List<ContentType> { ContentType.GetByName("ContentList"), ContentType.GetByName("Workspace") } };
            ws.Save();

            _list1 = new ContentList(TestWorkspace) { Name = "CtList1", AllowedChildTypes = new List<ContentType> { ContentType.GetByName("File") } };
            _list1.Save();
            _list2 = new ContentList(TestWorkspace) { Name = "CtList2", AllowedChildTypes = new List<ContentType> { ContentType.GetByName("File") } };
            _list2.Save();

            //create content template folders
            var ctfSite = new SystemFolder(site) {Name = Repository.ContentTemplatesFolderName};
            ctfSite.Save();
            var ctfWs = new SystemFolder(TestWorkspace) { Name = Repository.ContentTemplatesFolderName };
            ctfWs.Save();
            var ctfList = new SystemFolder(_list1) { Name = Repository.ContentTemplatesFolderName };
            ctfList.Save();

            //create content template type folders
            var folderCtFile1 = new Folder(ctfSite) {Name = "File"};
            folderCtFile1.Save();

            var folderCtL1 = new Folder(ctfWs) { Name = "ContentList" };
            folderCtL1.Save();

            var folderCtFile2 = new Folder(ctfList) { Name = "File" };
            folderCtFile2.Save();

            //create content templates
            _fileTemplate1 = new File(folderCtFile1) {Name = _testFileName, Index = 10 };
            _fileTemplate1.Save();

            _fileTemplate2 = new File(folderCtFile2) { Name = _testFileName, Index = 20 };
            _fileTemplate2.Save();

            _listTemplate1 = new ContentList(folderCtL1) { Name = _testListTemplateName, Index = 10 };
            _listTemplate1.Save();
        }
Exemplo n.º 24
0
        public void ContentList_FieldInitialize_Bug2943()
        {
            string listDef = @"<?xml version='1.0' encoding='utf-8'?>
<ContentListDefinition xmlns='http://schemas.com/ContentRepository/ContentListDefinition'>
	<Fields>
		<ContentListField name='#ListField1' type='Integer'>
			<Configuration>
				<MinValue>-100</MinValue>
				<MaxValue>100</MaxValue>
			</Configuration>
		</ContentListField>
	</Fields>
</ContentListDefinition>
";
            string path    = RepositoryPath.Combine(this.TestRoot.Path, "Cars");

            if (Node.Exists(path))
            {
                Node.ForceDelete(path);
            }

            ContentList list;
            Content     content;
            var         bb = new List <bool>();

            list      = new ContentList(this.TestRoot);
            list.Name = "Cars";
            list.ContentListDefinition = listDef;
            list.AllowedChildTypes     = new ContentType[] { ContentType.GetByName("Car") };
            list.Save();

            content = Content.CreateNew("Car", list, "TestCar");

            content["#ListField1"] = 0;
            bb.Add(content.IsValid);
            content["#ListField1"] = 10;
            bb.Add(content.IsValid);
            content["#ListField1"] = 0;
            bb.Add(content.IsValid);
            content["#ListField1"] = -10;
            bb.Add(content.IsValid);
            content["#ListField1"] = -100;
            bb.Add(content.IsValid);
            content["#ListField1"] = 100;
            bb.Add(content.IsValid);
            content["#ListField1"] = -101;
            bb.Add(!content.IsValid);
            content["#ListField1"] = 101;
            bb.Add(!content.IsValid);

            content = Content.CreateNew("Car", list, "TestCar1");

            content["#ListField1"] = 0;
            bb.Add(content.IsValid);
            content["#ListField1"] = 10;
            bb.Add(content.IsValid);
            content["#ListField1"] = 0;
            bb.Add(content.IsValid);
            content["#ListField1"] = -10;
            bb.Add(content.IsValid);
            content["#ListField1"] = -101;
            bb.Add(!content.IsValid);
            content["#ListField1"] = 101;
            bb.Add(!content.IsValid);

            var i = 0;

            foreach (var b in bb)
            {
                Assert.IsTrue(b, "#" + i++);
            }
        }
Exemplo n.º 25
0
        //TODO: Remove inconclusive test result and implement this test.
        /*//[TestMethod]*/
        public async Task OD_GET_Filter_SubstringOfEqListField()
        {
            //Assert.Inconclusive("InMemorySchemaWriter.CreatePropertyType is partially implemented.");

            await ODataTestAsync(async() =>
            {
                var testRoot = CreateTestRoot("ODataTestRoot");

                var listDef    = @"<?xml version='1.0' encoding='utf-8'?>
        <ContentListDefinition xmlns='http://schemas.sensenet.com/SenseNet/ContentRepository/ContentListDefinition'>
            <DisplayName>[DisplayName]</DisplayName>
            <Description>[Description]</Description>
            <Icon>[icon.gif]</Icon>
            <Fields>
                <ContentListField name='#CustomField' type='ShortText'>
                    <DisplayName>CustomField</DisplayName>
                    <Description>CustomField Description</Description>
                    <Icon>icon.gif</Icon>
                    <Configuration>
                        <MaxLength>100</MaxLength>
                    </Configuration>
                </ContentListField>
            </Fields>
        </ContentListDefinition>
        ";
                var itemType   = "HTMLContent";
                var fieldValue = "qwer asdf yxcv";

                // create list
                var list = new ContentList(testRoot)
                {
                    Name = Guid.NewGuid().ToString()
                };
                list.ContentListDefinition = listDef;
                list.AllowedChildTypes     = new ContentType[] { ContentType.GetByName(itemType) };
                list.Save();

                // create item
                var item             = Content.CreateNew(itemType, list, Guid.NewGuid().ToString());
                item["#CustomField"] = fieldValue;
                item.Save();

                // check expando field accessibility
                item = Content.Load(item.Id);
                Assert.AreEqual(fieldValue, (string)item["#CustomField"]);

                // get base count
                var countByCQ = ContentQuery.Query("#CustomField:*asdf* .AUTOFILTERS:OFF").Count;

                // get ids by SnLinq
                var origIds = Content.All
                              .DisableAutofilters()
                              .Where(x => ((string)x["#CustomField"]).Contains("asdf"))
                              .AsEnumerable()
                              .Select(f => f.Id)
                              .ToArray();
                Assert.IsTrue(origIds.Length > 0);

                // get ids by filter
                var response1 = await ODataGetAsync(
                    "/OData.svc" + list.Path,
                    "enableautofilters=false&$filter=substringof('asdf', #CustomField) eq true")
                                .ConfigureAwait(false);
                var entities1 = GetEntities(response1);
                var ids1      = entities1.Select(e => e.Id).ToArray();
                Assert.AreEqual(0, origIds.Except(ids1).Count());
                Assert.AreEqual(0, ids1.Except(origIds).Count());

                // get ids by filter URLencoded
                var response2 = await ODataGetAsync(
                    "/OData.svc" + list.Path,
                    "enableautofilters=false&$filter=substringof('asdf', %23CustomField) eq true")
                                .ConfigureAwait(false);
                var entities2 = GetEntities(response1);
                var ids2      = entities2.Select(e => e.Id).ToArray();
                Assert.AreEqual(0, origIds.Except(ids2).Count());
                Assert.AreEqual(0, ids2.Except(origIds).Count());
            }).ConfigureAwait(false);
        }
Exemplo n.º 26
0
        public void ContentList_WithoutDefinition()
		{
			string path = RepositoryPath.Combine(this.TestRoot.Path, "Cars");
			if (Node.Exists(path))
                Node.ForceDelete(path);

            ContentList list = new ContentList(this.TestRoot);
            list.Name = "Cars";
            list.AllowedChildTypes = new ContentType[] { ContentType.GetByName("Car") };

            list.Save();

            Node car = new GenericContent(list, "Car");
			car.Name = "Kispolszki";
			car.Save();

			//-- Sikeres, ha nem dob hibat
		}
Exemplo n.º 27
0
        public void ContentList_Modify()
        {
            List <string> listDefs = new List <string>();

            listDefs.Add(@"<?xml version='1.0' encoding='utf-8'?>
<ContentListDefinition xmlns='http://schemas.com/ContentRepository/ContentListDefinition'>
	<Fields>
	</Fields>
</ContentListDefinition>
");
            listDefs.Add(@"<?xml version='1.0' encoding='utf-8'?>
<ContentListDefinition xmlns='http://schemas.com/ContentRepository/ContentListDefinition'>
	<Fields>
		<ContentListField name='#LF0' type='ShortText' />
		<ContentListField name='#LF1' type='ShortText' />
	</Fields>
</ContentListDefinition>
");
            listDefs.Add(@"<?xml version='1.0' encoding='utf-8'?>
<ContentListDefinition xmlns='http://schemas.com/ContentRepository/ContentListDefinition'>
	<Fields>
		<ContentListField name='#LF0' type='ShortText' />
	</Fields>
</ContentListDefinition>
");
            listDefs.Add(@"<?xml version='1.0' encoding='utf-8'?>
<ContentListDefinition xmlns='http://schemas.com/ContentRepository/ContentListDefinition'>
	<Fields>
	</Fields>
</ContentListDefinition>
");
            listDefs.Add(@"<?xml version='1.0' encoding='utf-8'?>
<ContentListDefinition xmlns='http://schemas.com/ContentRepository/ContentListDefinition'>
	<Fields>
		<ContentListField name='#LF0' type='ShortText' />
		<ContentListField name='#LF1' type='ShortText' />
		<ContentListField name='#LF2' type='ShortText' />
	</Fields>
</ContentListDefinition>
");
            listDefs.Add(@"<?xml version='1.0' encoding='utf-8'?>
<ContentListDefinition xmlns='http://schemas.com/ContentRepository/ContentListDefinition'>
	<Fields>
		<ContentListField name='#LF0' type='ShortText' />
		<ContentListField name='#LF2' type='ShortText' />
	</Fields>
</ContentListDefinition>
");
            listDefs.Add(@"<?xml version='1.0' encoding='utf-8'?>
<ContentListDefinition xmlns='http://schemas.com/ContentRepository/ContentListDefinition'>
	<Fields>
		<ContentListField name='#LF0' type='ShortText' />
		<ContentListField name='#LF1' type='ShortText' />
		<ContentListField name='#LF2' type='ShortText' />
	</Fields>
</ContentListDefinition>
");
            listDefs.Add(@"<?xml version='1.0' encoding='utf-8'?>
<ContentListDefinition xmlns='http://schemas.com/ContentRepository/ContentListDefinition'>
	<Fields>
		<ContentListField name='#LF2' type='ShortText' />
	</Fields>
</ContentListDefinition>
");
            listDefs.Add(@"<?xml version='1.0' encoding='utf-8'?>
<ContentListDefinition xmlns='http://schemas.com/ContentRepository/ContentListDefinition'>
	<Fields>
		<ContentListField name='#LF0' type='ShortText' />
		<ContentListField name='#LF3' type='ShortText' />
		<ContentListField name='#LF2' type='ShortText' />
	</Fields>
</ContentListDefinition>
");
            listDefs.Add(@"<?xml version='1.0' encoding='utf-8'?>
<ContentListDefinition xmlns='http://schemas.com/ContentRepository/ContentListDefinition'>
	<Fields>
		<ContentListField name='#LF0' type='ShortText' />
		<ContentListField name='#LF1' type='ShortText' />
		<ContentListField name='#LF2' type='ShortText' />
	</Fields>
</ContentListDefinition>
");

            string listName = "List1";
            string listPath = RepositoryPath.Combine(this.TestRoot.Path, listName);

            if (Node.Exists(listPath))
            {
                Node.ForceDelete(listPath);
            }

            ContentList list = new ContentList(this.TestRoot);

            list.Name = listName;
            list.AllowedChildTypes = new ContentType[] { ContentType.GetByName("Car") };

            list.Save();

            Node car = new GenericContent(list, "Car");

            car.Name = "Kispolszki";
            car.Save();
            int carId = car.Id;

            StringBuilder log = new StringBuilder();

            for (int def = 0; def < listDefs.Count; def++)
            {
                Exception ex = null;
                for (var i = 0; i < 10; i++)
                {
                    try
                    {
                        ex   = null;
                        list = Node.Load <ContentList>(listPath);
                        list.ContentListDefinition = listDefs[def];
                        list.Save();
                        break;
                    }
                    catch (Exception e)
                    {
                        ex = e;
                        System.Threading.Thread.Sleep(200);
                        Debug.WriteLine("@> {0}. {1} / {2}", i, def, listDefs.Count);
                    }
                }
                if (ex != null)
                {
                    throw new ApplicationException("Exception after 10 iteration: " + ex.Message, ex);
                }


                car = Node.LoadNode(carId);
                log.Append("Def_").Append(def).Append(": ");
                for (int i = 0; i < 4; i++)
                {
                    var propName = "#String_" + i;
                    if (car.HasProperty(propName))
                    {
                        log.Append("[").Append(propName).Append(" = ").Append(car.PropertyTypes[propName].Mapping).Append("]");
                    }
                }
                log.Append("\r\n");
            }

            string realLog     = log.Replace("\r\n", "").Replace(" ", "").Replace("\t", "").ToString();
            string expectedLog = @"
				Def_0: 
				Def_1: [#String_0 = 800000000][#String_1 = 800000001]
				Def_2: [#String_0 = 800000000]
				Def_3: 
				Def_4: [#String_0 = 800000000][#String_1 = 800000001][#String_2 = 800000002]
				Def_5: [#String_0 = 800000000][#String_2 = 800000002]
				Def_6: [#String_0 = 800000000][#String_1 = 800000001][#String_2 = 800000002]
				Def_7: [#String_2 = 800000002]
				Def_8: [#String_0 = 800000000][#String_1 = 800000001][#String_2 = 800000002]
				Def_9: [#String_0 = 800000000][#String_2 = 800000002][#String_3 = 800000003]
				"                .Replace("\r\n", "").Replace(" ", "").Replace("\t", "");

            Assert.IsTrue(realLog == expectedLog);
        }
Exemplo n.º 28
0
        public static void CreateSandbox(TestContext testContext)
        {

            var site = new Site(Repository.Root);
            site.Name = "TestSiteForActionFramework";
                var urlList = new Dictionary<string, string>();
                urlList.Add("newtesthost", "Windows");
                site.UrlList = urlList;
                site.Save();
            

            //---- Appmodel
            //-------------

                //Root/TestRoot/(apps)
            var siteAppsFolder = new SystemFolder(site);
                siteAppsFolder.Name = "(apps)";
                siteAppsFolder.Save();
            
            //---- Folder
            //-----------

                // /TestRoot/(apps)/Folder
            var siteAppsFolderFolder = new SystemFolder(siteAppsFolder);
                siteAppsFolderFolder.Name = "Folder";
                siteAppsFolderFolder.Save();

                // /TestRoot/(apps)/Folder/App1
            var siteAppsApp1 = new Application(siteAppsFolderFolder);
                siteAppsApp1.Name = "App1";
                siteAppsApp1.Scenario = "sc1,sc4,sc5";
                siteAppsApp1.Save();

                // /TestRoot/(apps)/Folder/App2
            var siteAppsApp2 = new Application(siteAppsFolderFolder);
                siteAppsApp2.Name = "App2";
                siteAppsApp2.Scenario = "sc1,Settings";
                siteAppsApp2.Save();

                // TestRoot/(apps)/Folder/App3
            var siteAppsApp3 = new Application(siteAppsFolderFolder);
                siteAppsApp3.Name = "App3";
                siteAppsApp3.Scenario = "sc1,sc2,sc7,sc10";
                siteAppsApp3.RequiredPermissions = "5";
                siteAppsApp3.Save();

                // TestRoot/(apps)/Folder/App4
            var siteAppsApp4 = new Application(siteAppsFolderFolder);
                siteAppsApp4.Name = "App4";
                siteAppsApp4.Scenario = "sc2,sc6,sc10";
                siteAppsApp4.RequiredPermissions = "5";
                siteAppsApp4.Save();

                //Root/TestRoot/(apps)/Folder/App5
            var siteAppsApp5 = new Application(siteAppsFolderFolder);
                siteAppsApp5.Name = "App5";
                siteAppsApp5.Scenario = "sc11";
                siteAppsApp5.RequiredPermissions = "5;10;11";
                siteAppsApp5.Save();

                //Root/TestRoot/(apps)/Folder/App6
            var siteAppsApp6 = new Application(siteAppsFolderFolder);
                siteAppsApp6.Name = "App6";
                siteAppsApp6.Scenario = "sc12";
                siteAppsApp6.Save();

                //Root/TestRoot/(apps)/Folder/App12
            var siteSampleAppsApp12 = new Application(siteAppsFolderFolder);
                siteSampleAppsApp12.Name = "App12";
                siteSampleAppsApp12.Scenario = "sc20";
                siteSampleAppsApp12.Save();

                //Root/TestRoot/(apps)/Folder/App21
            var siteSampleAppsApp21 = new Application(siteAppsFolderFolder);
                siteSampleAppsApp21.Name = "App21";
                siteSampleAppsApp21.Scenario = "sc21";
                siteSampleAppsApp21.Save();

                //Root/TestRoot/(apps)/Folder/App22
            var siteSampleAppsApp22 = new Application(siteAppsFolderFolder);
                siteSampleAppsApp22.Name = "App22";
                siteSampleAppsApp22.Scenario = "sc22";
                siteSampleAppsApp22.Save();

                //Root/TestRoot/(apps)/Folder/App23
                var siteSampleAppsApp23 = new Application(siteAppsFolderFolder);
                siteSampleAppsApp23.Name = "App23";
                siteSampleAppsApp23.Scenario = "sc23";
                siteSampleAppsApp23.Disabled = true;
                siteSampleAppsApp23.Save();

                //Root/TestRoot/(apps)/Folder/App24
                var siteSampleAppsApp24 = new Application(siteAppsFolderFolder);
                siteSampleAppsApp24.Name = "App24";
                siteSampleAppsApp24.Scenario = "sc24";
                siteSampleAppsApp24.Disabled = true;
                siteSampleAppsApp24.Clear = true;
                siteSampleAppsApp24.Save();

                //Root/TestRoot/(apps)/Folder/App25
                var siteSampleAppsApp25 = new Application(siteAppsFolderFolder);
                siteSampleAppsApp25.Name = "App25";
                siteSampleAppsApp25.Scenario = "sc25";
                siteSampleAppsApp25.Save();

                //Root/TestRoot/Sample
            var siteSample = new SystemFolder(site);
                siteSample.Name = "Sample";
                siteSample.Save();
           
            //---- ContentList
            //----------------

                //Root/TestRoot/(apps)/ContentList
            var siteAppsFolderContentList = new SystemFolder(siteAppsFolder);
                siteAppsFolderContentList.Name = "ContentList";
                siteAppsFolderContentList.Save();

                //Root/TestRoot/Sample2
            var siteSample2 = new ContentList(site);
                siteSample2.Name = "Sample2";
                siteSample2.Save();

                //Root/TestRoot/(apps)/ContentList/App1
            var siteAppsContentListOverrideApp1 = new Application(siteAppsFolderContentList);
                siteAppsContentListOverrideApp1.Name = "App1";
                siteAppsContentListOverrideApp1.Scenario = "sc4,sc5";
                siteAppsContentListOverrideApp1.Save();


                //Root/TestRoot/(apps)/ContentList/ContentListApp1
            var siteAppsContentListApp1 = new Application(siteAppsFolderContentList);
                siteAppsContentListApp1.Name = "ContentListApp1";
                siteAppsContentListApp1.Scenario = "sc2,sc10";
                siteAppsContentListApp1.Save();

                //Root/TestRoot/Apps/ContentList/ContentListApp2
            var siteAppsContentListApp2 = new Application(siteAppsFolderContentList);
                siteAppsContentListApp2.Name = "ContentListApp2";
                siteAppsContentListApp2.Scenario = "sc1";
                siteAppsContentListApp2.Save();

                //Root/TestRoot/(apps)/ContentList/ContentListApp3
            var siteAppsContentListApp3 = new Application(siteAppsFolderContentList);
                siteAppsContentListApp3.Name = "ContentListApp3";
                siteAppsContentListApp3.Scenario = "sc1,sc2,sc3,mySettings";
                siteAppsContentListApp3.Save();

                //Root/TestRoot/(apps)/ContentList/App6
            var siteAppsContentListOverrideApp6 = new Application(siteAppsFolderContentList);
                siteAppsContentListOverrideApp6.Name = "App6";
                siteAppsContentListOverrideApp6.Scenario = "sc12";
                siteAppsContentListOverrideApp6.RequiredPermissions = "11";
                siteAppsContentListOverrideApp6.Save();
            
            //---- This structure under Sample
            //--------------------------------

                //Root/TestRoot/Sample/(apps)
            var siteSampleApps = new SystemFolder(siteSample);
                siteSampleApps.Name = "(apps)";
                siteSampleApps.Save();

                //Root/TestRoot/Sample/(apps)/This
            var siteSampleAppsThis = new SystemFolder(siteSampleApps);
                siteSampleAppsThis.Name = "This";
                siteSampleAppsThis.Save();

                //Root/TestRoot/Sample/(apps)/This/App12
            var siteSampleAppsThisApp12 = new Application(siteSampleAppsThis);
                siteSampleAppsThisApp12.Name = "App12";
                siteSampleAppsThisApp12.Scenario = "sc20";
                siteSampleAppsThisApp12.Save();

                //Root/TestRoot/Sample/(apps)/Folder
            var siteSampleAppsFolder = new SystemFolder(siteSampleApps);
                siteSampleAppsFolder.Name = "Folder";
                siteSampleAppsFolder.Save();

                //Root/TestRoot/Sample/(apps)/Folder/App21
            var siteSampleAppsFolderApp21 = new Application(siteSampleAppsFolder);
                siteSampleAppsFolderApp21.Name = "App21";
                siteSampleAppsFolderApp21.Scenario = "sc21";
                siteSampleAppsFolderApp21.Save();

                //Root/TestRoot/Sample/(apps)/Folder/App22
                var siteSampleAppsFolderApp22 = new Application(siteSampleAppsFolder);
                siteSampleAppsFolderApp22.Name = "App22";
                siteSampleAppsFolderApp22.Scenario = "sc22";
                siteSampleAppsFolderApp22.Disabled = true;
                siteSampleAppsFolderApp22.Save();

                //Root/TestRoot/Sample/(apps)/Folder/App23
                var siteSampleAppsFolderApp23 = new Application(siteSampleAppsFolder);
                siteSampleAppsFolderApp23.Name = "App23";
                siteSampleAppsFolderApp23.Scenario = "sc23";
                siteSampleAppsFolderApp23.Disabled = true;
                siteSampleAppsFolderApp23.Save();

                //Root/TestRoot/Sample/(apps)/Folder/App24
                var siteSampleAppsFolderApp24 = new Application(siteSampleAppsFolder);
                siteSampleAppsFolderApp24.Name = "App24";
                siteSampleAppsFolderApp24.Scenario = "sc24";
                siteSampleAppsFolderApp24.RequiredPermissions = "5";
                siteSampleAppsFolderApp24.Save();

                //Root/TestRoot/Sample/(apps)/Folder/App25
                var siteSampleAppsFolderApp25 = new Application(siteSampleAppsFolder);
                siteSampleAppsFolderApp25.Name = "App25";
                siteSampleAppsFolderApp25.Scenario = "sc25";
                siteSampleAppsFolderApp25.Clear = true;
                siteSampleAppsFolderApp25.Save();



            
            // ---- Subfolder
            // --------------

                //Root/TestRoot/Sample/SubFolder
            var siteSampleSubFolder = new SystemFolder(siteSample);
                siteSampleSubFolder.Name = "SubFolder";
                siteSampleSubFolder.Save();

                //Root/TestRoot/Sample/SubFolder/(apps)
            var siteSampleSubFolderApps = new SystemFolder(siteSampleSubFolder);
            siteSampleSubFolderApps.Name = "(apps)";
            siteSampleSubFolderApps.Save();

            //Root/TestRoot/Sample/SubFolder/(apps)/This
            var siteSampleSubFolderAppsThis = new SystemFolder(siteSampleSubFolderApps);
            siteSampleSubFolderAppsThis.Name = "This";
            siteSampleSubFolderAppsThis.Save();

            //Root/TestRoot/Sample/SubFolder/(apps)/This/App24
            var siteSampleSubFolderAppsThisApp24 = new Application(siteSampleSubFolderAppsThis);
            siteSampleSubFolderAppsThisApp24.Name = "App24";
            siteSampleSubFolderAppsThisApp24.Scenario = "sc24";
            siteSampleSubFolderAppsThisApp24.Disabled = true;
            siteSampleSubFolderAppsThisApp24.Save();


        }
Exemplo n.º 29
0
        private string CheckListTypeXmlNamespaceCompatibility(string xmlNamespace, string namespaceName, bool featureEnabled)
        {
            var compat = RepositoryConfiguration.BackwardCompatibilityXmlNamespaces;

            SetBackwardCompatibilityXmlNamespaces(featureEnabled);

            var    fieldName = "#ListField1";
            string listDef   = String.Format(@"<ContentListDefinition xmlns='{0}'><Fields>
                <ContentListField name='{1}' type='ShortText' /></Fields></ContentListDefinition>", xmlNamespace, fieldName);

            string listPath = RepositoryPath.Combine(this.TestRoot.Path, "Cars");

            if (Node.Exists(listPath))
            {
                Node.ForceDelete(listPath);
            }

            ContentList list;
            int         listId = 0;

            try
            {
                list      = new ContentList(this.TestRoot);
                list.Name = "Cars";
                list.ContentListDefinition = listDef;
                list.Save();
                listId = list.Id;
                list   = Node.Load <ContentList>(listId);
            }
            catch (Exception e)
            {
                SetBackwardCompatibilityXmlNamespaces(compat);
                return(String.Concat("Cannot create List (", namespaceName, "): ", e.Message));
            }

            var fieldValue = Guid.NewGuid().ToString();
            var content    = Content.CreateNew("Car", list, "XmlNamespaceCompatibilityContent");

            if (!content.Fields.ContainsKey(fieldName))
            {
                SetBackwardCompatibilityXmlNamespaces(compat);
                return(String.Concat("Missing field (", namespaceName, ")"));
            }

            content[fieldName] = fieldValue;

            try
            {
                content.Save();
            }
            catch (Exception e)
            {
                SetBackwardCompatibilityXmlNamespaces(compat);
                var msg = String.Concat("Cannot save a ListItem (", namespaceName, "): ", e.Message, e.StackTrace.Replace("\r", " ").Replace("\n", " "));
                Debug.WriteLine(msg);
                return(msg);
            }

            var id = content.Id;

            try
            {
                content = Content.Load(id);
            }
            catch (Exception e)
            {
                SetBackwardCompatibilityXmlNamespaces(compat);
                return(String.Concat("Cannot load back a ListItem (", namespaceName, "): ", e.Message));
            }

            var loadedValue = (string)content[fieldName];

            //content.Delete();
            Node.ForceDelete(id);

            SetBackwardCompatibilityXmlNamespaces(compat);

            if (loadedValue != fieldValue)
            {
                return(String.Concat("Inconsistent field value (", namespaceName, ")"));
            }

            if (list.ContentListDefinition != listDef)
            {
                return(String.Concat("List definition xml is modified (", namespaceName, ")"));
            }

            return(null);
        }
Exemplo n.º 30
0
		private void CreateContentList(string parentPath, string name, string listDef)
		{
			Node parent = Node.LoadNode(parentPath);
			ContentList contentlist = new ContentList(parent);
			contentlist.Name = name;
			contentlist.ContentListDefinition = listDef;
			contentlist.Save();
		}
Exemplo n.º 31
0
        public void Field_NamingConvention_Correct()
        {
            //-- Sikeres, ha nem dob hibat
            string ctd = @"<?xml version='1.0' encoding='utf-8'?>
				<ContentType name='FieldNamingTest' parentType='GenericContent' handler='SenseNet.ContentRepository.GenericContent' xmlns='http://schemas.sensenet.com/SenseNet/ContentRepository/ContentTypeDefinition'>
					<Fields><Field name='ShortText' type='ShortText' /></Fields></ContentType>";

            string ltd = @"<?xml version='1.0' encoding='utf-8'?>
				<ContentListDefinition xmlns='http://schemas.sensenet.com/SenseNet/ContentRepository/ContentListDefinition'>
					<Fields><ContentListField name='#ContentListField1' type='ShortText' /></Fields></ContentListDefinition>";

            if (ContentTypeManager.Current.GetContentTypeByName("FieldNamingTest") != null)
                ContentTypeInstaller.RemoveContentType("FieldNamingTest");
            if (Node.Exists("/Root/ContentList1"))
                Node.ForceDelete("/Root/ContentList1");

            ContentTypeInstaller.InstallContentType(ctd);

            ContentList list = new ContentList(Repository.Root);
            list.Name = "ContentList1";
            list.ContentListDefinition = ltd;
            list.Save();

            if (ContentTypeManager.Current.GetContentTypeByName("FieldNamingTest") != null)
                ContentTypeInstaller.RemoveContentType("FieldNamingTest");
            if (Node.Exists("/Root/ContentList1"))
                Node.ForceDelete("/Root/ContentList1");
        }
Exemplo n.º 32
0
		public void ContentList_1()
		{
			string listDef = @"<?xml version='1.0' encoding='utf-8'?>
<ContentListDefinition xmlns='http://schemas.sensenet.com/SenseNet/ContentRepository/ContentListDefinition'>
	<DisplayName>Cars title</DisplayName>
	<Description>Cars description</Description>
	<Icon>automobile.gif</Icon>
	<Fields>
		<ContentListField name='#ListField1' type='ShortText'>
			<DisplayName>ContentListField1</DisplayName>
			<Description>ContentListField1 Description</Description>
			<Icon>icon.gif</Icon>
			<Configuration>
				<MaxLength>100</MaxLength>
			</Configuration>
		</ContentListField>
		<ContentListField name='#ListField2' type='WhoAndWhen'>
			<DisplayName>ContentListField2</DisplayName>
			<Description>ContentListField2 Description</Description>
			<Icon>icon.gif</Icon>
			<Configuration>
			</Configuration>
		</ContentListField>
		<ContentListField name='#ListField3' type='ShortText'>
			<DisplayName>ContentListField3</DisplayName>
			<Description>ContentListField3 Description</Description>
			<Icon>icon.gif</Icon>
			<Configuration>
				<MaxLength>200</MaxLength>
			</Configuration>
		</ContentListField>
	</Fields>
</ContentListDefinition>
";
			string path = RepositoryPath.Combine(this.TestRoot.Path, "Cars");
			if (Node.Exists(path))
                Node.ForceDelete(path);

			ContentList list = new ContentList(this.TestRoot);
            list.Name = "Cars";
            list.ContentListDefinition = listDef;
            list.AllowedChildTypes = new ContentType[] { ContentType.GetByName("Car") };

            list.Save();

            Node car = new GenericContent(list, "Car");
			car.Name = "Kispolszki";
			car["#String_0"] = "ABC 34-78";
			car.Save();

			Content content = Content.Create(car);

			//-- Sikeres, ha nem dob hibat
		}
Exemplo n.º 33
0
        public static void CreateSandbox(TestContext testContext)
        {
            var site = new Site(Repository.Root);

            site.Name = "TestSiteForActionFramework";
            var urlList = new Dictionary <string, string>();

            urlList.Add("newtesthost", "Windows");
            site.UrlList = urlList;
            site.Save();


            //---- Appmodel
            //-------------

            //Root/TestRoot/(apps)
            var siteAppsFolder = new SystemFolder(site);

            siteAppsFolder.Name = "(apps)";
            siteAppsFolder.Save();

            //---- Folder
            //-----------

            // /TestRoot/(apps)/Folder
            var siteAppsFolderFolder = new SystemFolder(siteAppsFolder);

            siteAppsFolderFolder.Name = "Folder";
            siteAppsFolderFolder.Save();

            // /TestRoot/(apps)/Folder/App1
            var siteAppsApp1 = new Application(siteAppsFolderFolder);

            siteAppsApp1.Name     = "App1";
            siteAppsApp1.Scenario = "sc1,sc4,sc5";
            siteAppsApp1.Save();

            // /TestRoot/(apps)/Folder/App2
            var siteAppsApp2 = new Application(siteAppsFolderFolder);

            siteAppsApp2.Name     = "App2";
            siteAppsApp2.Scenario = "sc1,Settings";
            siteAppsApp2.Save();

            // TestRoot/(apps)/Folder/App3
            var siteAppsApp3 = new Application(siteAppsFolderFolder);

            siteAppsApp3.Name                = "App3";
            siteAppsApp3.Scenario            = "sc1,sc2,sc7,sc10";
            siteAppsApp3.RequiredPermissions = "5";
            siteAppsApp3.Save();

            // TestRoot/(apps)/Folder/App4
            var siteAppsApp4 = new Application(siteAppsFolderFolder);

            siteAppsApp4.Name                = "App4";
            siteAppsApp4.Scenario            = "sc2,sc6,sc10";
            siteAppsApp4.RequiredPermissions = "5";
            siteAppsApp4.Save();

            //Root/TestRoot/(apps)/Folder/App5
            var siteAppsApp5 = new Application(siteAppsFolderFolder);

            siteAppsApp5.Name                = "App5";
            siteAppsApp5.Scenario            = "sc11";
            siteAppsApp5.RequiredPermissions = "5;10;11";
            siteAppsApp5.Save();

            //Root/TestRoot/(apps)/Folder/App6
            var siteAppsApp6 = new Application(siteAppsFolderFolder);

            siteAppsApp6.Name     = "App6";
            siteAppsApp6.Scenario = "sc12";
            siteAppsApp6.Save();

            //Root/TestRoot/(apps)/Folder/App12
            var siteSampleAppsApp12 = new Application(siteAppsFolderFolder);

            siteSampleAppsApp12.Name     = "App12";
            siteSampleAppsApp12.Scenario = "sc20";
            siteSampleAppsApp12.Save();

            //Root/TestRoot/(apps)/Folder/App21
            var siteSampleAppsApp21 = new Application(siteAppsFolderFolder);

            siteSampleAppsApp21.Name     = "App21";
            siteSampleAppsApp21.Scenario = "sc21";
            siteSampleAppsApp21.Save();

            //Root/TestRoot/(apps)/Folder/App22
            var siteSampleAppsApp22 = new Application(siteAppsFolderFolder);

            siteSampleAppsApp22.Name     = "App22";
            siteSampleAppsApp22.Scenario = "sc22";
            siteSampleAppsApp22.Save();

            //Root/TestRoot/(apps)/Folder/App23
            var siteSampleAppsApp23 = new Application(siteAppsFolderFolder);

            siteSampleAppsApp23.Name     = "App23";
            siteSampleAppsApp23.Scenario = "sc23";
            siteSampleAppsApp23.Disabled = true;
            siteSampleAppsApp23.Save();

            //Root/TestRoot/(apps)/Folder/App24
            var siteSampleAppsApp24 = new Application(siteAppsFolderFolder);

            siteSampleAppsApp24.Name     = "App24";
            siteSampleAppsApp24.Scenario = "sc24";
            siteSampleAppsApp24.Disabled = true;
            siteSampleAppsApp24.Clear    = true;
            siteSampleAppsApp24.Save();

            //Root/TestRoot/(apps)/Folder/App25
            var siteSampleAppsApp25 = new Application(siteAppsFolderFolder);

            siteSampleAppsApp25.Name     = "App25";
            siteSampleAppsApp25.Scenario = "sc25";
            siteSampleAppsApp25.Save();



            //Root/TestRoot/Sample
            var siteSample = new SystemFolder(site);

            siteSample.Name = "Sample";
            siteSample.Save();

            //---- ContentList
            //----------------

            //Root/TestRoot/(apps)/ContentList
            var siteAppsFolderContentList = new SystemFolder(siteAppsFolder);

            siteAppsFolderContentList.Name = "ContentList";
            siteAppsFolderContentList.Save();

            //Root/TestRoot/Sample2
            var siteSample2 = new ContentList(site);

            siteSample2.Name = "Sample2";
            siteSample2.Save();

            //Root/TestRoot/(apps)/ContentList/App1
            var siteAppsContentListOverrideApp1 = new Application(siteAppsFolderContentList);

            siteAppsContentListOverrideApp1.Name     = "App1";
            siteAppsContentListOverrideApp1.Scenario = "sc4,sc5";
            siteAppsContentListOverrideApp1.Save();


            //Root/TestRoot/(apps)/ContentList/ContentListApp1
            var siteAppsContentListApp1 = new Application(siteAppsFolderContentList);

            siteAppsContentListApp1.Name     = "ContentListApp1";
            siteAppsContentListApp1.Scenario = "sc2,sc10";
            siteAppsContentListApp1.Save();

            //Root/TestRoot/Apps/ContentList/ContentListApp2
            var siteAppsContentListApp2 = new Application(siteAppsFolderContentList);

            siteAppsContentListApp2.Name     = "ContentListApp2";
            siteAppsContentListApp2.Scenario = "sc1";
            siteAppsContentListApp2.Save();

            //Root/TestRoot/(apps)/ContentList/ContentListApp3
            var siteAppsContentListApp3 = new Application(siteAppsFolderContentList);

            siteAppsContentListApp3.Name     = "ContentListApp3";
            siteAppsContentListApp3.Scenario = "sc1,sc2,sc3,mySettings";
            siteAppsContentListApp3.Save();

            //Root/TestRoot/(apps)/ContentList/App6
            var siteAppsContentListOverrideApp6 = new Application(siteAppsFolderContentList);

            siteAppsContentListOverrideApp6.Name                = "App6";
            siteAppsContentListOverrideApp6.Scenario            = "sc12";
            siteAppsContentListOverrideApp6.RequiredPermissions = "11";
            siteAppsContentListOverrideApp6.Save();


            //Root/TestRoot/(apps)/GenericContent
            var siteAppsGenericContent = new SystemFolder(siteAppsFolder)
            {
                Name = "GenericContent"
            };

            siteAppsGenericContent.Save();
            //Root/TestRoot/(apps)/GenericContent/AppOvr
            var siteAppsGenericContentAppOvr = new Application(siteAppsGenericContent)
            {
                Name = "AppOvr", DisplayName = "ASDF", Icon = "ABC"
            };

            siteAppsGenericContentAppOvr.Save();

            //Root/TestRoot/(apps)/WebContent
            var siteAppsWebContent = new SystemFolder(siteAppsFolder)
            {
                Name = "WebContent"
            };

            siteAppsWebContent.Save();
            //Root/TestRoot/(apps)/WebContent/AppOvr
            var siteAppsWebContentAppOvr = new Application(siteAppsWebContent, "ApplicationOverride")
            {
                Name = "AppOvr", DisplayName = "QWER", Icon = "DEF"
            };

            siteAppsWebContentAppOvr.Save();

            //Root/TestRoot/(apps)/WebContentDemo
            var siteAppsWebContentDemo = new SystemFolder(siteAppsFolder)
            {
                Name = "WebContentDemo"
            };

            siteAppsWebContentDemo.Save();
            //Root/TestRoot/(apps)/WebContentDemo/AppOvr
            var siteAppsWebContentDemoAppOvr = new Application(siteAppsWebContentDemo, "ApplicationOverride")
            {
                Name = "AppOvr", DisplayName = "YXCV", Icon = "GHI"
            };

            siteAppsWebContentDemoAppOvr.Save();

            //---- This structure under Sample
            //--------------------------------

            //Root/TestRoot/Sample/(apps)
            var siteSampleApps = new SystemFolder(siteSample);

            siteSampleApps.Name = "(apps)";
            siteSampleApps.Save();

            //Root/TestRoot/Sample/(apps)/This
            var siteSampleAppsThis = new SystemFolder(siteSampleApps);

            siteSampleAppsThis.Name = "This";
            siteSampleAppsThis.Save();

            //Root/TestRoot/Sample/(apps)/This/App12
            var siteSampleAppsThisApp12 = new Application(siteSampleAppsThis);

            siteSampleAppsThisApp12.Name     = "App12";
            siteSampleAppsThisApp12.Scenario = "sc20";
            siteSampleAppsThisApp12.Save();

            //Root/TestRoot/Sample/(apps)/Folder
            var siteSampleAppsFolder = new SystemFolder(siteSampleApps);

            siteSampleAppsFolder.Name = "Folder";
            siteSampleAppsFolder.Save();

            //Root/TestRoot/Sample/(apps)/Folder/App21
            var siteSampleAppsFolderApp21 = new Application(siteSampleAppsFolder);

            siteSampleAppsFolderApp21.Name     = "App21";
            siteSampleAppsFolderApp21.Scenario = "sc21";
            siteSampleAppsFolderApp21.Save();

            //Root/TestRoot/Sample/(apps)/Folder/App22
            var siteSampleAppsFolderApp22 = new Application(siteSampleAppsFolder);

            siteSampleAppsFolderApp22.Name     = "App22";
            siteSampleAppsFolderApp22.Scenario = "sc22";
            siteSampleAppsFolderApp22.Disabled = true;
            siteSampleAppsFolderApp22.Save();

            //Root/TestRoot/Sample/(apps)/Folder/App23
            var siteSampleAppsFolderApp23 = new Application(siteSampleAppsFolder);

            siteSampleAppsFolderApp23.Name     = "App23";
            siteSampleAppsFolderApp23.Scenario = "sc23";
            siteSampleAppsFolderApp23.Disabled = true;
            siteSampleAppsFolderApp23.Save();

            //Root/TestRoot/Sample/(apps)/Folder/App24
            var siteSampleAppsFolderApp24 = new Application(siteSampleAppsFolder);

            siteSampleAppsFolderApp24.Name                = "App24";
            siteSampleAppsFolderApp24.Scenario            = "sc24";
            siteSampleAppsFolderApp24.RequiredPermissions = "5";
            siteSampleAppsFolderApp24.Save();

            //Root/TestRoot/Sample/(apps)/Folder/App25
            var siteSampleAppsFolderApp25 = new Application(siteSampleAppsFolder);

            siteSampleAppsFolderApp25.Name     = "App25";
            siteSampleAppsFolderApp25.Scenario = "sc25";
            siteSampleAppsFolderApp25.Clear    = true;
            siteSampleAppsFolderApp25.Save();

            // ---- Subfolder
            // --------------

            //Root/TestRoot/Sample/SubFolder
            var siteSampleSubFolder = new SystemFolder(siteSample);

            siteSampleSubFolder.Name = "SubFolder";
            siteSampleSubFolder.Save();

            //Root/TestRoot/Sample/SubFolder/(apps)
            var siteSampleSubFolderApps = new SystemFolder(siteSampleSubFolder);

            siteSampleSubFolderApps.Name = "(apps)";
            siteSampleSubFolderApps.Save();

            //Root/TestRoot/Sample/SubFolder/(apps)/This
            var siteSampleSubFolderAppsThis = new SystemFolder(siteSampleSubFolderApps);

            siteSampleSubFolderAppsThis.Name = "This";
            siteSampleSubFolderAppsThis.Save();

            //Root/TestRoot/Sample/SubFolder/(apps)/This/App24
            var siteSampleSubFolderAppsThisApp24 = new Application(siteSampleSubFolderAppsThis);

            siteSampleSubFolderAppsThisApp24.Name     = "App24";
            siteSampleSubFolderAppsThisApp24.Scenario = "sc24";
            siteSampleSubFolderAppsThisApp24.Disabled = true;
            siteSampleSubFolderAppsThisApp24.Save();
        }
Exemplo n.º 34
0
        public void ContentList_DeleteField()
        {
            string listDef = @"<?xml version='1.0' encoding='utf-8'?>
<ContentListDefinition xmlns='http://schemas.sensenet.com/SenseNet/ContentRepository/ContentListDefinition'>
	<DisplayName>Cars title</DisplayName>
	<Description>Cars description</Description>
	<Icon>automobile.gif</Icon>
	<Fields>
		<ContentListField name='#ListField1' type='ShortText'>
			<DisplayName>ContentListField1</DisplayName>
			<Description>ContentListField1 Description</Description>
			<Icon>icon.gif</Icon>
			<Configuration>
				<MaxLength>100</MaxLength>
			</Configuration>
		</ContentListField>
		<ContentListField name='#ListField2' type='WhoAndWhen'>
			<DisplayName>ContentListField2</DisplayName>
			<Description>ContentListField2 Description</Description>
			<Icon>icon.gif</Icon>
			<Configuration>
			</Configuration>
		</ContentListField>
		<ContentListField name='#ListField3' type='ShortText'>
			<DisplayName>ContentListField3</DisplayName>
			<Description>ContentListField3 Description</Description>
			<Icon>icon.gif</Icon>
			<Configuration>
				<MaxLength>200</MaxLength>
			</Configuration>
		</ContentListField>
	</Fields>
</ContentListDefinition>
";
            string path = RepositoryPath.Combine(this.TestRoot.Path, "Cars");
            if (Node.Exists(path))
                Node.ForceDelete(path);

            var list = new ContentList(this.TestRoot)
            {
                Name = "Cars",
                ContentListDefinition = listDef,
                AllowedChildTypes = new ContentType[] { ContentType.GetByName("Car") }
            };

            list.Save();

            Node car = new GenericContent(list, "Car");
            car.Name = "Kispolszki";
            car["#String_0"] = "ABC 34-78";
            car.Save();

            list = Node.Load<ContentList>(list.Path);
            var fs = Content.Create(car).Fields["#ListField3"].FieldSetting;

            list.DeleteField(fs);

            var cc = Content.Load(car.Path);

            Assert.IsTrue(!cc.Fields.ContainsKey("#ListField3"));
        }
Exemplo n.º 35
0
        private static void CreatePlayGround()
        {
            DestroyPlayground();

            // /Root
            //      |
            //      +-ContentTemplates
            //      |   |
            //      |   +-File
            //      |   |   |
            //      |   |   +-file1.txt
            //      |   |
            //      |   +-ContentList
            //      |       |
            //      |       +-list1
            //      |
            //      +-CTemplateTests
            //          |
            //          +-CtSite
            //          |   |
            //          |   +-ContentTemplates
            //          |   |   |
            //          |   |   +-File
            //          |   |       |
            //          |   |       +-file1.txt
            //          |   |
            //          |   +-CtWorkspace1
            //          |   |   |
            //          |   |   +-ContentTemplates
            //          |   |   |   |
            //          |   |   |   +-ContentList
            //          |   |   |       |
            //          |   |   |       +-list1
            //          |   |   +-CtList1
            //          |   |   |   |
            //          |   |   |   +-ContentTemplates
            //          |   |   |       |
            //          |   |   |       +-File
            //          |   |   |           |
            //          |   |   |           +-file1.txt
            //          |   |   +-CtList2
            //          |   |
            //          |   +-CtWorkspace2
            //          |
            //          +-CtWorkspace3

            //global template folder
            var ctfGlobal = Node.LoadNode(Repository.ContentTemplateFolderPath);

            if (ctfGlobal == null)
            {
                ctfGlobal = new SystemFolder(Node.LoadNode("/Root"))
                {
                    Name = Repository.ContentTemplatesFolderName
                };
                ctfGlobal.Save();
            }

            //create GLOBAL content template type folders
            var folderGlobalCtFile1 = Node.Load <Folder>(RepositoryPath.Combine(ctfGlobal.Path, "File"));

            if (folderGlobalCtFile1 == null)
            {
                folderGlobalCtFile1 = new Folder(ctfGlobal)
                {
                    Name = "File"
                };
                folderGlobalCtFile1.Save();
            }
            var folderGlobalCtList1 = Node.Load <Folder>(RepositoryPath.Combine(ctfGlobal.Path, "ContentList"));

            if (folderGlobalCtList1 == null)
            {
                folderGlobalCtList1 = new Folder(ctfGlobal)
                {
                    Name = "ContentList"
                };
                folderGlobalCtList1.Save();
            }

            //create GLOBAL content templates
            _fileGlobalTemplate1 = Node.Load <File>(RepositoryPath.Combine(folderGlobalCtFile1.Path, _testFileName));
            if (_fileGlobalTemplate1 == null)
            {
                _fileGlobalTemplate1 = new File(folderGlobalCtFile1)
                {
                    Name = _testFileName, Index = 30
                };
                _fileGlobalTemplate1.Save();
            }
            _listGlobalTemplate1 = Node.Load <ContentList>(RepositoryPath.Combine(folderGlobalCtList1.Path, _testListTemplateName));
            if (_listGlobalTemplate1 == null)
            {
                _listGlobalTemplate1 = new ContentList(folderGlobalCtList1)
                {
                    Name = _testListTemplateName, Index = 30
                };
                _listGlobalTemplate1.Save();
            }

            //create site, workspace and list
            var site = new Site(TestRoot)
            {
                Name = "CtSite"
            };

            site.UrlList.Add("mytemplatetestinterneturl", "Forms");
            site.Save();

            var ws = new Workspace(site)
            {
                Name = "CtWorkspace2", AllowedChildTypes = new List <ContentType> {
                    ContentType.GetByName("ContentList"), ContentType.GetByName("Workspace"), ContentType.GetByName("File")
                }
            };

            ws.Save();

            ws = new Workspace(TestRoot)
            {
                Name = "CtWorkspace3", AllowedChildTypes = new List <ContentType> {
                    ContentType.GetByName("ContentList"), ContentType.GetByName("Workspace"), ContentType.GetByName("File")
                }
            };
            ws.Save();

            ws = new Workspace(site)
            {
                Name = "CtWorkspace1", AllowedChildTypes = new List <ContentType> {
                    ContentType.GetByName("ContentList"), ContentType.GetByName("Workspace")
                }
            };
            ws.Save();

            _list1 = new ContentList(TestWorkspace)
            {
                Name = "CtList1", AllowedChildTypes = new List <ContentType> {
                    ContentType.GetByName("File")
                }
            };
            _list1.Save();
            _list2 = new ContentList(TestWorkspace)
            {
                Name = "CtList2", AllowedChildTypes = new List <ContentType> {
                    ContentType.GetByName("File")
                }
            };
            _list2.Save();

            //create content template folders
            var ctfSite = new SystemFolder(site)
            {
                Name = Repository.ContentTemplatesFolderName
            };

            ctfSite.Save();
            var ctfWs = new SystemFolder(TestWorkspace)
            {
                Name = Repository.ContentTemplatesFolderName
            };

            ctfWs.Save();
            var ctfList = new SystemFolder(_list1)
            {
                Name = Repository.ContentTemplatesFolderName
            };

            ctfList.Save();

            //create content template type folders
            var folderCtFile1 = new Folder(ctfSite)
            {
                Name = "File"
            };

            folderCtFile1.Save();

            var folderCtL1 = new Folder(ctfWs)
            {
                Name = "ContentList"
            };

            folderCtL1.Save();

            var folderCtFile2 = new Folder(ctfList)
            {
                Name = "File"
            };

            folderCtFile2.Save();

            //create content templates
            _fileTemplate1 = new File(folderCtFile1)
            {
                Name = _testFileName, Index = 10
            };
            _fileTemplate1.Save();

            _fileTemplate2 = new File(folderCtFile2)
            {
                Name = _testFileName, Index = 20
            };
            _fileTemplate2.Save();

            _listTemplate1 = new ContentList(folderCtL1)
            {
                Name = _testListTemplateName, Index = 10
            };
            _listTemplate1.Save();
        }
Exemplo n.º 36
0
 private static void CreateContentList(string parentPath, string name, string listDef)
 {
     var parent = Node.LoadNode(parentPath);
     var contentlist = new ContentList(parent)
                           {
                               Name = name,
                               ContentListDefinition = listDef
                           };
     
     contentlist.Save();
 }