//================================================================= Constructors public FieldSettingContent(FieldSetting fieldSetting, ContentList contentList) : this(contentList ?? Repository.Root as Node, GetNodeTypeName(fieldSetting)) { this.FieldSetting = fieldSetting; this.ContentList = contentList; this.AddToDefaultView = false; this.Name = this.FieldSetting.Name; this._isNew = false; }
private void AddTileSource(PointCloudTileSource tileSource) { int index = ContentList.Items.Add(tileSource); ContentList.SelectedIndex = index; ContentList.ScrollIntoView(tileSource); UpdateSelection(tileSource); UpdateButtonStates(); }
protected override ContentView GetContentView(Content newContent) { if (!string.IsNullOrEmpty(ContentViewPath)) { return(base.GetContentView(newContent)); } var contentList = ContentList.GetContentListByParentWalk(GetContextNode()); if (contentList != null) { //try to find a content view at /Root/.../MyList/WorkflowTemplates/MyWorkflow.ascx var wfTemplatesPath = RepositoryPath.Combine(contentList.Path, "WorkflowTemplates"); var viewPath = RepositoryPath.Combine(wfTemplatesPath, newContent.Name + ".ascx"); if (Node.Exists(viewPath)) { return(ContentView.Create(newContent, Page, ViewMode.InlineNew, viewPath)); } //try to find it by type name, still locally viewPath = RepositoryPath.Combine(wfTemplatesPath, newContent.ContentType.Name + ".ascx"); if (Node.Exists(viewPath)) { return(ContentView.Create(newContent, Page, ViewMode.InlineNew, viewPath)); } //last attempt: global view for the workflow type return(ContentView.Create(newContent, Page, ViewMode.InlineNew, "StartWorkflow.ascx")); } else { var viewPath = string.Format("{0}/{1}/{2}", Repository.ContentViewFolderName, newContent.ContentType.Name, "StartWorkflow.ascx"); var resolvedPath = string.Empty; if (!SkinManager.TryResolve(viewPath, out resolvedPath)) { resolvedPath = RepositoryPath.Combine(Repository.SkinGlobalFolderPath, SkinManager.TrimSkinPrefix(viewPath)); if (!Node.Exists(resolvedPath)) { resolvedPath = string.Empty; } } if (!string.IsNullOrEmpty(resolvedPath)) { return(ContentView.Create(newContent, Page, ViewMode.InlineNew, resolvedPath)); } } return(base.GetContentView(newContent)); }
void TrimChoiceContent(ref ContentList content) { if (content != null) { content.TrimTrailingWhitespace(); if (content.content.Count == 0) { content = null; } } }
public void AddContentToContentList(ContentType type, string name) { RemoveContentFromContentLists(name); var newContent = new ContentIconAndName(ContentIconAndName.GetContentTypeIcon(type), name); DisplayContentList.Add(newContent); ContentList.Add(newContent); SubContentManager.AddSubContentAndRemoveDuplicateContent(DisplayContentList, service, newContent); RaisePropertyChanged("ContentList"); }
//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))); }); }
public ActionResult ContentItem(int id = 0) { var ContentList = contentListBLL.GetEntities(c => c.Id == id); if (id == 0) { ContentList = new ContentList[] { new Model.ContentList { Id = 0, Title = "", Author = "", Img = "AddImg.jpg", Label = "", Content = "", IsShow = true } }; } return(View(ContentList)); }
public static string GetColumnTitle(string fieldFullName, Node contextNode) { ContentList cl = null; if (contextNode != null) { cl = ContentList.GetContentListForNode(contextNode) ?? ContentList.GetContentListByParentWalk(contextNode); } return(GetColumnTitle(fieldFullName, cl != null ? cl.Path : string.Empty)); }
public ContentList GetContentList(Item contextItem, Rendering rendering) { Item datasource = GetDatasourceItem(contextItem, rendering); ContentList panel = new ContentList(); // Get panel title directly from datasource item panel.Title = datasource.Fields[Constants.FieldNames.PanelTitle].Value; panel.Items = GetFeaturePanelItems(datasource); return(panel); }
private void RemoveContentFromContentLists(string contentName) { for (int index = 0; index < DisplayContentList.Count; index++) { var content = DisplayContentList[index]; if (content.Name == contentName) { DisplayContentList.Remove(content); ContentList.Remove(content); } } }
private void DoRequest() { Plugin.IsLoading = true; //var bagResult = Plugin.CreatePoiTypeResult("BAG", Colors.CornflowerBlue); var result = Plugin.CreatePoiTypeResult("MGRS", Colors.CornflowerBlue); result.Style.InnerTextColor = Colors.Black; Plugin.SearchService.PoITypes.Add(result); ThreadPool.QueueUserWorkItem(delegate { try { string mgrsInput = Key; var pois = new ContentList(); double[] latLonResult = csCommon.Converters.MgrsConversion.convertMgrsToLatLon(mgrsInput); double lat = latLonResult[0]; double lon = latLonResult[1]; var p = new PoI { Service = Plugin.SearchService, InnerText = "1", Name = mgrsInput, Position = new Position(lon, lat), }; p.UpdateEffectiveStyle(); pois.Add(p); Application.Current.Dispatcher.Invoke( delegate { lock (Plugin.ServiceLock) { foreach (var q in pois) { Plugin.SearchService.PoIs.Add(q); } } Plugin.IsLoading = false; }); } catch (Exception e) { Logger.Log("MGRS search", "Error finding MGRS location", e.Message, Logger.Level.Error, true); Plugin.IsLoading = false; } }); }
private void ReportOrphans(XElement container, XElement notebooks) { // orphaned backup folders... progress.SetMessage("Orphans..."); progress.Increment(); var knowns = notebooks.Elements(ns + "Notebook") .Select(e => e.Attribute("name").Value) .ToList(); knowns.Add(Resx.AnalyzeCommand_OpenSections); knowns.Add(Resx.AnalyzeCommand_QuickNotes); var orphans = Directory.GetDirectories(backupPath) .Select(d => Path.GetFileNameWithoutExtension(d)) .Except(knowns); container.Add( new Paragraph("Orphans").SetQuickStyle(heading2Index), new Paragraph(Resx.AnalyzeCommand_OrphanSummary) ); if (!orphans.Any()) { container.Add( new Paragraph(string.Empty), new Paragraph(Resx.AnalyzeCommand_NoOrphans), new Paragraph(string.Empty) ); return; } var list = new ContentList(ns); container.Add( new Paragraph(ns, new XElement(ns + "T", new XCData(string.Empty)), list) ); foreach (var orphan in orphans) { var dir = new DirectoryInfo(Path.Combine(backupPath, orphan)); var size = dir.EnumerateFiles("*.*", SearchOption.AllDirectories).Sum(f => f.Length); list.Add(new Bullet($"{orphan} ({size.ToBytes(1)})")); } container.Add(new Paragraph(string.Empty)); }
private ContentList SearchContent(string bucketSlug, int offset) { ContentList response = _client.Content.SearchContent(new ContentSearchRequest { Buckets = new List <string> { bucketSlug }, Count = DEFAULT_COUNT, Offset = offset }); return(response); }
public void IterateTest() { ContentList contentList = new ContentList(); contentList.Add("0"); contentList.Add("1"); contentList.Add("2"); int expectedItem = 0; foreach (string actualValue in contentList) { Assert.Equal(expectedItem++.ToString(), actualValue); } }
public void ChangeContent(string target) { var item = ContentList.Find(x => x.DisplayName == target); if (item == null) { CurrentContent = ContentList; } else { CurrentContent = item.Content; } RaisePropertyChanged(nameof(CurrentContent)); }
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)); }
public ActionResult VideosByTopic() { //Try to get the slug objects object categorySlug = ControllerContext.RouteData.Values["categorySlug"]; if (categorySlug == null) { return(HttpNotFound("Sorry, the content was not found.")); } string categorySlugValue = categorySlug.ToString(); if (string.IsNullOrEmpty(categorySlugValue)) { return(HttpNotFound("Sorry, the content was not found.")); } //Select the appropriate category ContentCategoryList categoryList = ContentCategoryFactory.GetVideoLibraryCategories(); Category category = categoryList.Categories.Find(c => c.Slug == categorySlugValue); //Create the query string query = GetQueryStringFromServiceLines(category); ContentList videos = _client.Content.SearchContent(new ContentSearchRequest { Count = DEFAULT_COUNT, Buckets = new List <string> { "videos-v2" }, Languages = new List <string> { "en" }, Query = query }); //Convert to the view model. GroupedContentModel model = new GroupedContentModel(); model.Title = category.Names.Find(c => c.LanguageCode == "en").Value; model.Slug = category.Slug; ContentReferenceModelMapper mapper = new ContentReferenceModelMapper(); foreach (var item in videos.Items) { model.Items.Add(mapper.Map(item)); } return(View(model)); }
// // GET: /HowTo/SearchContent public ActionResult SearchContent(string searchString) { ContentList searchResults = new ContentList(); if (!string.IsNullOrEmpty(searchString)) { searchResults = _client.Content.SearchContent(new ContentSearchRequest { Count = DEFAULT_COUNT, Query = searchString }); } return(View(searchResults)); }
public async Task <ActionResult <ContentList> > DeleteContentList(int id) { ContentList contentList = ContentListService.GetEntity(s => s.Id == id).Result; if (contentList == null) { return(NotFound()); } await Task.Run(() => { ContentListService.Remov(contentList); }); return(contentList); }
public Media(XmlElement element) { Title = Util.ChildValue(element, "title"); Player = Util.ChildValue(element, "player"); Link = Util.ChildValue(element, "link"); Thumbnails = new ThumbnailList(); foreach (XmlElement child in element.GetElementsByTagName("thumbnail")) { Thumbnails.Add(new Thumbnail(child)); } Content = new ContentList(); foreach (XmlElement child in element.GetElementsByTagName("content")) { Content.Add(new Content(child)); } }
private IEnumerable <CollectionChange <ContentType, ContentType> > getCollectionChanges(IEnumerable <ContentType> items) { items = items ?? Enumerable.Empty <ContentType>(); //var cachedCollection = new List<TItem>(Collection); //var list = items.Take(5).ToList(); //items = list.ReturnInValue((x) => x.Shuffle()).Take(ThreadSafeRandom.Next(0, list.Count + 1)); var changes = ContentList.GetCollectionChanges(items, EqualityComparer) #if DEBUG .ToList() #endif ; return(changes); }
private void handleSaveFetchedLists(ListConfig listConfig, Dictionary <string, List <string> > lists) { foreach (KeyValuePair <string, List <string> > kvp in lists) { ContentList cl = new ContentList() { Name = kvp.Key, Version = listConfig.Version, IsSubList = (kvp.Key != Util.MAINLISTNAME), Elements = kvp.Value, }; ListRepository.Set(cl); } }
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); }
private ContentList GetAllContentForBuckets(ContentBucketList buckets) { ContentList allContent = new ContentList(); allContent.Items = new List <ContentResponse>(); foreach (ContentBucketResponse bucket in buckets.Items) { if (bucket.Type != ContentType.Image) { ContentList contentForBucket = GetAllContentForBucket(bucket.Slug); allContent.Items.AddRange(contentForBucket.Items); } } return(allContent); }
public override void OnListEmailChanged(ContentList list) { using (new SystemAccount()) { // remove current mail processor workflow RemoveWorkflow(list); var newEmail = list["ListEmail"] as string; // start new workflow + subscription if email is given if (!string.IsNullOrEmpty(newEmail)) { StartSubscription(list); } } }
protected override void OnModified(object sender, ContentRepository.Storage.Events.NodeEventArgs e) { base.OnModified(sender, e); var cdName = e.ChangedData.FirstOrDefault(cd => cd.Name == "Name"); if (cdName != null) { var cl = ContentList.GetContentListByParentWalk(this); if (cl != null && !string.IsNullOrEmpty(cl.DefaultView) && cl.DefaultView.CompareTo(cdName.Original) == 0) { cl.DefaultView = this.Name; cl.Save(SavingMode.KeepVersion); } } }
public bool AddList(string key, string value) { if (ContentList == null) { ContentList = new ObservableDictionary <string, string>(); } if (!string.IsNullOrEmpty(key) && !string.IsNullOrWhiteSpace(key) && !string.IsNullOrEmpty(value) && !string.IsNullOrWhiteSpace(value) && ContentList != null && !ContentList.ContainsKey(key)) { ContentList.Add(key, value); return(true); } return(false); }
public ExpressionIssue TryEvaluate(IContentNode input, out IContentNode result) { var list = new List <IContentNode>(); foreach (var e in Items) { var issue = e.Value.TryEvaluate(input, out IContentNode item); if (issue != null) { result = null; return(issue); } if (e is ListItem a) { list.Add(item); } else if (e is List l) { if (item is ContentList subList) { list.AddRange(subList); } else if (item is ContentNull) { // do nothing } else { result = null; return(new ExpressionIssue("Cannot merge a non-list into a list")); } } if (item is ContentList listItem) { list.AddRange(listItem); } else { list.Add(item); } } result = new ContentList(list, list, ContentFactory.Default); return(null); }
/// <summary> /// Execute a broker query to populate a list of teasers /// </summary> /// <param name="list">The list definition</param> public override void PopulateDynamicList(ContentList<Teaser> list) { BrokerQuery query = new BrokerQuery { Start = list.Start, PublicationId = Int32.Parse(WebRequestContext.Localization.LocalizationId), PageSize = list.PageSize, SchemaId = MapSchema(list.ContentType.Key), Sort = list.Sort.Key }; list.ItemListElements = query.ExecuteQuery(); foreach (var item in list.ItemListElements) { item.Link.Url = ContentResolver.ResolveLink(item.Link.Url); } list.HasMore = query.HasMore; }
private static void StartSubscription(ContentList list) { var subscribe = Settings.GetValue <MailProcessingMode>( MailHelper.MAILPROCESSOR_SETTINGS, MailHelper.SETTINGS_MODE, list.Path) == MailProcessingMode.ExchangePush; if (subscribe) { // subscribe to email after saving content. this is done separately from saving the content, // since subscriptionid must be persisted on the content and we use cyclic retrials for that ExchangeHelper.Subscribe(list); } var parent = GetMailProcessorWorkflowContainer(list); if (parent == null) { return; } // get the workflow to start var incomingEmailWorkflow = list.GetReference <Node>("IncomingEmailWorkflow"); if (incomingEmailWorkflow == null) { return; } // set the list as the related content var workflowC = Content.CreateNew(incomingEmailWorkflow.Name, parent, incomingEmailWorkflow.Name); workflowC["RelatedContent"] = list; try { workflowC.Save(); InstanceManager.Start(workflowC.ContentHandler as WorkflowHandlerBase); } catch (Exception ex) { SnLog.WriteException(ex, categories: ExchangeHelper.ExchangeLogCategory); } }
public List <ContentResponse> GetRelatedContent(string bucketSlug, string contentSlug, List <string> Languages) { //Start with an article that you want to get the related content for ContentArticleResponse article = _client.Content.GetContent(bucketSlug, contentSlug, new GetContentOptions()); ContentTaxonomyList meshTaxonomy = article.Taxonomies.Find(c => c.Slug == "mesh"); //If there aren't any mesh terms then we'll return no related documents if (meshTaxonomy == null) { return(new List <ContentResponse>()); } //Mesh terms exist, let's build a mesh basd query to get related articles. string query = "mesh: "; if (meshTaxonomy.Items.Count > 0) { query = "mesh: " + meshTaxonomy.Items[0].Value; } for (int i = 1; i < meshTaxonomy.Items.Count; i++) { query += " or mesh: " + meshTaxonomy.Items[i].Value; } //Search for content with an overlapping mesh code. ContentList relatedContent = _client.Content.SearchContent(new ContentSearchRequest { Query = query, Count = DEFAULT_COUNT, Languages = Languages }); //Fiter out the item that we started the related to search from. List <ContentResponse> contentResponses = new List <ContentResponse>(); foreach (ContentResponse response in relatedContent.Items) { if (response.Bucket.Slug != bucketSlug || response.Slug != contentSlug) { contentResponses.Add(response); } } return(contentResponses); }
protected virtual Node GetBindingRoot() { if (BindTarget != null) { var value = (SenseNet.Portal.UI.PortletFramework.BindTarget)Enum.Parse(typeof(SenseNet.Portal.UI.PortletFramework.BindTarget), BindTarget); switch (value) { case SenseNet.Portal.UI.PortletFramework.BindTarget.Unselected: return(Content.CreateNew("Folder", Repository.Root, "DummyNode").ContentHandler); case SenseNet.Portal.UI.PortletFramework.BindTarget.CurrentSite: //return PortalContext.Current.Site; return(SenseNet.Portal.Site.GetSiteByNode(PortalContext.Current.ContextNode)); case SenseNet.Portal.UI.PortletFramework.BindTarget.CurrentPage: return(PortalContext.Current.Page); case SenseNet.Portal.UI.PortletFramework.BindTarget.CurrentUser: return(HttpContext.Current.User.Identity as User); case SenseNet.Portal.UI.PortletFramework.BindTarget.CustomRoot: return(Node.LoadNode(this.CustomRootPath)); case SenseNet.Portal.UI.PortletFramework.BindTarget.CurrentStartPage: return(PortalContext.Current.Site.StartPage as Node ?? PortalContext.Current.Site as Node); case SenseNet.Portal.UI.PortletFramework.BindTarget.Breadcrumb: case SenseNet.Portal.UI.PortletFramework.BindTarget.CurrentContent: return(PortalContext.Current.ContextNode ?? Repository.Root); case SenseNet.Portal.UI.PortletFramework.BindTarget.CurrentWorkspace: return((Node)PortalContext.Current.ContextWorkspace ?? PortalContext.Current.Site); case SenseNet.Portal.UI.PortletFramework.BindTarget.CurrentList: return(ContentList.GetContentListByParentWalk(PortalContext.Current.ContextNode)); default: throw new NotImplementedException(BindTarget.ToString()); } } else { return(PortalContext.Current.ContextNode ?? Repository.Root); } }
public void RefreshContentList() { if (!IsLoggedInAlready()) { return; } DisplayContentList.Clear(); ContentList.Clear(); var foundContent = service.GetAllContentNames(); foreach (var contentName in foundContent) { AddNewContent(contentName); } FilterContentList(); RaisePropertyChanged("DisplayContentList"); isShowingStartContent = true; }
private List <ContentReferenceModel> ConvertToContentModel(ContentList contentList) { List <ContentReferenceModel> contentToDownload = new List <ContentReferenceModel>(); foreach (ContentResponse item in contentList.Items) { contentToDownload.Add(new ContentReferenceModel { BucketSlug = item.Bucket.Slug, Type = item.Type.ToString(), Slug = item.Slug, Title = item.Title, LegacyId = item.LegacyId }); } return(contentToDownload); }
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(); }
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); }
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")); }
private static ContentList ClonePoiTypes(PoiService source, string shapeIdLabel = null) { var clonedPoiTypes = new ContentList(); // Add all other PoI types. foreach (var baseContent in source.PoITypes) { var clone = new PoI(); // Important that this is a PoI! Otherwise we have a casting problem elsewhere. clone.FromXml(baseContent.ToXml()); // Deep clone. // Add a MetaInfo for the counter. if (clone.MetaInfo == null) { clone.MetaInfo = new List<MetaInfo>(); } clone.MetaInfo.Add(new MetaInfo() { Label = AggregationCountLabel, Description = "The number of features belonging to this aggregation", IsEditable = false, Type = MetaTypes.number }); if (shapeIdLabel != null) clone.MetaInfo.Add(new MetaInfo() { Label = "Shape_Name", IsEditable = false, Type = MetaTypes.text }); clonedPoiTypes.Add(clone); } return clonedPoiTypes; }
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"); }
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 }
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); }
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(); }
private void RemovePoIsFromViewModelCollection(ContentList pois) { foreach (var poi in pois) { if (!(poi is PoI)) continue; if (string.Equals(poi.PoiType.PoiTypeId, "threat", StringComparison.InvariantCultureIgnoreCase)) avm.Threats.Remove(poi as PoI); else if (string.Equals(poi.PoiType.PoiTypeId, "measure", StringComparison.InvariantCultureIgnoreCase)) avm.Measures.Remove(poi as PoI); } }
private void AddPoIsToViewModelCollection(ContentList pois) { foreach (var poi in pois) { if (!(poi is PoI)) continue; switch (poi.PoiType.PoiTypeId.ToLower()) { case "threat": if (!avm.Threats.Contains(poi)) avm.Threats.Add(poi as PoI); break; case "measure": if (!avm.Measures.Contains(poi)) avm.Measures.Add(poi as PoI); break; } } }
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); }
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 }
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"); }
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); }
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"); }
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++); }
public static ContentList Query(Query query, string[] groups, string[] permissions) { if (groups != null && groups.Length > 0 && permissions != null && permissions.Length > 0) { foreach (string permission in permissions) { BooleanClause bc = new BooleanClause(true, false); foreach (string role in groups) { bc.AddClause( new TermClause( string.Format("GroupWith{0}Permissions", permission), role, false, false) ); } query.Add(bc); } } if (query.OrderBy == null) query.OrderBy = "PublishDate DESC"; if (query.DefaultField == null) query.DefaultField = "Text"; ContentList results = new ContentList(); try { IndexDocument[] docs = Engine.Search(query); Dictionary<Guid, bool> usedResults = new Dictionary<Guid, bool>(docs.Length); results.StartIndex = query.StartResultIndex; results.EndIndex = query.EndResultIndex; results.TotalResults = query.TotalResults; for (int i = 0; i < docs.Length; i++) { Guid id = new Guid(docs[i].Get("ActiveObjectsID")); if (!usedResults.ContainsKey(id)) { usedResults.Add(id, true); results.Add(new Content(docs[i])); } else { LogDuplicate(id, docs[i].Get("Title")); } } usedResults.Clear(); } catch { } return results; }
public static void Merge(PoiService mainDataService, string mainKey, PoiService secondaryDataService, string secKey, bool includeSecondaryPois, bool excludeNonExistentSecondaryPois, bool includeSecondaryColumns, bool overwriteDuplicateLabels, bool stopOnFirstHit, bool includeMetaData, FileLocation destination = null, TextBox txtMergeDebugOutput = null) { if (txtMergeDebugOutput != null) txtMergeDebugOutput.Text = "Merging files on [" + mainKey + " = " + secKey + "]"; // Determine whether to use well-known text. var mainPoiType = mainDataService.PoITypes.FirstOrDefault(); if (mainPoiType == null) { mainPoiType = new PoI { Name = "Default", ContentId = "Default", Service = mainDataService, Style = new PoIStyle { Name = "default", FillColor = Colors.Transparent, StrokeColor = Color.FromArgb(255, 128, 128, 128), CallOutOrientation = CallOutOrientation.Right, FillOpacity = 0.3, TitleMode = TitleModes.Bottom, NameLabel = "Name", DrawingMode = DrawingModes.Image, StrokeWidth = 2, IconWidth = 24, IconHeight = 24, Icon = "images/missing.png", CallOutFillColor = Colors.White, CallOutForeground = Colors.Black, TapMode = TapMode.CallOut }, Id = Guid.NewGuid(), DrawingMode = DrawingModes.Image, MetaInfo = new List<MetaInfo>() }; mainDataService.PoITypes.Add(mainPoiType); } if (mainPoiType != null && string.IsNullOrEmpty(mainPoiType.ContentId)) mainPoiType.ContentId = "Default"; BaseContent secondaryPoiType = null; if (secondaryDataService.PoITypes != null && secondaryDataService.PoITypes.Any()) { secondaryPoiType = secondaryDataService.PoITypes.FirstOrDefault(); } ; bool useWKT = mainPoiType != null && mainPoiType.Style != null && mainPoiType.Style.Name == "WKT"; useWKT = (useWKT || secondaryPoiType != null && secondaryPoiType.Style != null) && secondaryPoiType.Style.Name == "WKT" && includeSecondaryColumns; if (useWKT) { if (mainPoiType != null) { mainPoiType.ContentId = "WKT"; // We directly set the main PoI's "PoiId" to WKT. } mainDataService.StaticService = true; // Make sure we save the file as static. if (txtMergeDebugOutput != null) txtMergeDebugOutput.AppendText( "\nOne of the files uses well-known text; the output will be a static layer."); } // Merge the meta info. if (txtMergeDebugOutput != null) txtMergeDebugOutput.AppendText("\nMerging meta info."); if (secondaryPoiType != null && secondaryPoiType.MetaInfo.Count == 0) { //if (txtMergeDebugOutput != null) txtMergeDebugOutput.AppendText("\nSecondary file has no meta info; nothing to merge."); } if (secondaryPoiType != null && includeSecondaryColumns) foreach (MetaInfo secMetaInfo in secondaryPoiType.MetaInfo) { string secMetaInfoLabel = secMetaInfo.Label; bool doAdd = true; if (secMetaInfoLabel == secKey) { //if (txtMergeDebugOutput != null) txtMergeDebugOutput.AppendText("\nLabel " + secMetaInfo.Label + " is the one we merge on, so we skip it."); doAdd = false; } if (doAdd) { if (mainPoiType != null) { if (mainPoiType.MetaInfo.Any(mainMetaInfo => mainMetaInfo.Label == secMetaInfoLabel)) { doAdd = false; // label already there. } } } if (!doAdd) continue; if (mainPoiType != null) mainPoiType.MetaInfo.Add(secMetaInfo); //if (txtMergeDebugOutput != null) txtMergeDebugOutput.AppendText("\nInserted meta-info from secondary file into main file: " + secMetaInfo.Label + "."); } // Merge the Style info. If the right file has WKT, set the drawing mode to MultiPolygon. // TODO For now we completely ignore some important aspects of poitypes: // 1. Multiple PoITypes. // 2. Different PoiId attributes. if (txtMergeDebugOutput != null) txtMergeDebugOutput.AppendText("\nMerging styles."); if ((secondaryPoiType != null && secondaryPoiType.Style != null && (mainPoiType.Style == null))) { // We need to overwrite, or the main does not have something yet. mainPoiType.Style = secondaryPoiType.Style; //if (txtMergeDebugOutput != null) txtMergeDebugOutput.AppendText("\nInserted style from secondary file into main file."); } else { //if (txtMergeDebugOutput != null) txtMergeDebugOutput.AppendText("\nMain file already has a style definition."); } if (useWKT) { mainPoiType.Style.DrawingMode = DrawingModes.MultiPolygon; // if (txtMergeDebugOutput != null) txtMergeDebugOutput.AppendText( // "\nEnsuring main file uses drawing mode 'multi polygon' given the fact that well-known text is used."); } // Remember which PoIs were found in the main as well as secondary file. HashSet<BaseContent> unvisitedMainPois = new HashSet<BaseContent>(); foreach (var poI in mainDataService.PoIs) { unvisitedMainPois.Add(poI); } // Merge data. if (txtMergeDebugOutput != null) txtMergeDebugOutput.AppendText("\n\nMerging data."); foreach (var secPoi in secondaryDataService.PoIs) { if (!secPoi.Labels.ContainsKey(secKey)) { // if (txtMergeDebugOutput != null) txtMergeDebugOutput.AppendText("\n" + secPoi.Id + " does not have label " + secKey + // " and will be skipped."); continue; } var mainPoiFound = false; //var mainPoi = mainDataService.PoIs.FirstOrDefault(p => p.Labels.ContainsKey(mainKey) // && string.Equals(p.Labels[mainKey], secPoi.Labels[secKey], StringComparison.InvariantCultureIgnoreCase)); foreach (var mainPoi in mainDataService.PoIs.Where(mainPoi => mainPoi.Labels.ContainsKey(mainKey) && string.Equals(mainPoi.Labels[mainKey], secPoi.Labels[secKey], StringComparison.InvariantCultureIgnoreCase))) if (mainPoi != null) { mainPoiFound = true; if (mainPoi.PoiType == null) { mainPoi.PoiType = mainPoiType; mainPoi.ContentId = mainPoiType.ContentId; } unvisitedMainPois.Remove(mainPoi); // We visited this PoI! :) if (!includeSecondaryColumns) continue; // Do not copy information from the secondary to the first. //if (txtMergeDebugOutput != null) txtMergeDebugOutput.AppendText("\nAdding new data to " + mainPoi.Labels[mainKey] + "."); //GetShortFriendlyName(mainPoi.Name) + "." + mainKey + " = " + GetShortFriendlyName(secPoi.Name) + "." + secKey + "] = " + ); // Merge the labels part. if (overwriteDuplicateLabels) { //if (txtMergeDebugOutput != null) txtMergeDebugOutput.AppendText("\nCopying label/values with overwrite: "); foreach (var label in secPoi.Labels) { if (label.Key != secKey) { //if (txtMergeDebugOutput != null) txtMergeDebugOutput.AppendText("\n->" + label.Key + "=" + label.Value + ", "); mainPoi.Labels[label.Key] = label.Value; } } } else { //if (txtMergeDebugOutput != null) txtMergeDebugOutput.AppendText("\nCopying label/values without overwrite: "); foreach (var label in secPoi.Labels.Where(l => l.Key != secKey)) { string value; if (mainPoi.Labels.TryGetValue(label.Key, out value)) { //if (txtMergeDebugOutput != null) txtMergeDebugOutput.AppendText("\n->" + label.Key + " skipped (value already set to " + value + "), "); continue; } //if (label.Key == secKey) //{ // //if (txtMergeDebugOutput != null) txtMergeDebugOutput.AppendText("\n->" + label.Key + " is the label on which we merge; skipped (value " + mainPoi.Labels[mainKey] + "), "); // continue; //} //if (txtMergeDebugOutput != null) txtMergeDebugOutput.AppendText("\n->Setting " + label.Key + " to " + label.Value); mainPoi.Labels[label.Key] = label.Value; } } // Also merge WKT information there may be. if (useWKT) { mainPoi.PoiTypeId = "WKT"; } if (!string.IsNullOrWhiteSpace(secPoi.WktText)) { if (overwriteDuplicateLabels || string.IsNullOrWhiteSpace(mainPoi.WktText)) { //if (txtMergeDebugOutput != null) txtMergeDebugOutput.AppendText("\nAlso merged well-known text elements."); mainPoi.WktText = secPoi.WktText; } } // Stop if needed. if (!stopOnFirstHit) continue; if (txtMergeDebugOutput != null) txtMergeDebugOutput.AppendText("\nStopping on first hit!"); break; // And that's it. //if (txtMergeDebugOutput != null) txtMergeDebugOutput.AppendText("\n"); } if (mainPoiFound) continue; if (includeSecondaryPois) { var copyPoI = new PoI(); copyPoI.FromXml(secPoi.ToXml()); if (useWKT) { copyPoI.PoiTypeId = "WKT"; } else { copyPoI.PoiType = mainPoiType; copyPoI.PoiTypeId = mainPoiType.PoiId; } copyPoI.Labels[mainKey] = copyPoI.Labels[secKey]; // Rename the merge label. copyPoI.Labels.Remove(secKey); mainDataService.PoIs.Add(copyPoI); if (txtMergeDebugOutput != null) txtMergeDebugOutput.AppendText("\nMain file does not have PoI with label " + mainKey + " set to " + secPoi.Labels[secKey] + ", including PoI from secondary file."); } else { if (txtMergeDebugOutput != null) txtMergeDebugOutput.AppendText("\nMain file does not have PoI with label " + mainKey + " set to " + secPoi.Labels[secKey] + " and will be skipped."); } } // Report on unvisited PoIs in main file. // Remove any PoIs in the main file that are not in the secondary file (if the user selected this option). if (txtMergeDebugOutput != null) { if (unvisitedMainPois.Any()) { if (txtMergeDebugOutput != null) txtMergeDebugOutput.AppendText( "\nSome PoIs in the main file were not matched with a PoI in the secondary file."); if (excludeNonExistentSecondaryPois && txtMergeDebugOutput != null) txtMergeDebugOutput.AppendText(" These PoIs will be removed from the main file."); } foreach (BaseContent unvisitedMainPoi in unvisitedMainPois) { if (txtMergeDebugOutput != null) { string unvisitedMainPoiValue; bool found = unvisitedMainPoi.Labels.TryGetValue(mainKey, out unvisitedMainPoiValue); if (!found) { unvisitedMainPoiValue = "UNDEFINED"; } txtMergeDebugOutput.AppendText("\n" + unvisitedMainPoi + ", " + mainKey + " = " + unvisitedMainPoiValue + "."); } } if (excludeNonExistentSecondaryPois) { // Annoyingly, calling "remove" on a ContentList throws an exception. // Therefore, we construct a new list of PoIs that should be kept, instead of removing the PoIs we should remove. ContentList newMainPoIs = new ContentList(); foreach (BaseContent poI in mainDataService.PoIs.Where(poI => !unvisitedMainPois.Contains(poI))) { newMainPoIs.Add(poI); } mainDataService.PoIs = newMainPoIs; } } // We are done. if (txtMergeDebugOutput != null) txtMergeDebugOutput.AppendText("\nMerge completed!"); if (destination == null) { mainDataService.SaveXml(); } else { PoiServiceExporters.Instance.Export(mainDataService, destination, includeMetaData); } }
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; }
private void PoICollectionChanged(object sender, NotifyCollectionChangedEventArgs e) { var cl = new ContentList(); switch (e.Action) { case NotifyCollectionChangedAction.Add: foreach (var item in e.NewItems.Cast<BaseContent>()) cl.Add(item); AddPoIsToViewModelCollection(cl); break; case NotifyCollectionChangedAction.Remove: foreach (var item in e.OldItems.Cast<BaseContent>()) cl.Add(item); RemovePoIsFromViewModelCollection(cl); break; } }
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(); }
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(); }
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)); }
public void InitRfisService() { InitPoiService(); Rfis = new ContentList {Service = this}; AllContent.Add(Rfis); }
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(); }
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(); }