public GenericContent FetchContent() { if (_fetchContent == null && !_fetchError) { if (!string.IsNullOrEmpty(Query)) { var sf = SmartFolder.GetRuntimeQueryFolder(); sf.Query = this.Query; var c = Content.Create(sf); c.ChildrenDefinition.EnableAutofilters = this.EnableAutofilters; c.ChildrenDefinition.EnableLifespanFilter = this.EnableLifespanFilter; c.ChildrenDefinition.Skip = 0; //c.ChildrenDefinition.Sort = this.ChildrenDefinition.Sort; c.ChildrenDefinition.Top = 1; try { if (c.Children != null && c.Children.Any()) { _fetchContent = c.Children?.ToList()?.FirstOrDefault()?.ContentHandler as GenericContent; } } catch (Exception ex) { _fetchError = true; } } } return(_fetchContent); }
private static void DoBenchmarkSteps() { var root = Node.Load <Folder>("/Root/Timing_TestRoot/STU"); int id = 0; Node n = null; for (int i = 0; i < 5; i++) { n = new GenericContent(root, "Car"); n.Save(); } id = n.Id; Node node; for (var i = 0; i < 5; i++) { for (int j = 0; j < 100; j++) { node = Node.LoadNode(id); var sb = new StringBuilder(); foreach (var proptype in node.PropertyTypes) { sb.Append(node.GetProperty <object>(proptype)); } } node = Node.LoadNode(id); node.Index++; node.Save(); } }
public static TrashBag BagThis(GenericContent node) { var bin = TrashBin.Instance; if (bin == null) { return(null); } if (node == null) { throw new ArgumentNullException("node"); } //creating a bag has nothing to do with user permissions: Move will handle that TrashBag bag = null; var wsId = 0; var wsRelativePath = string.Empty; var ws = node.Workspace; if (ws != null) { wsId = ws.Id; wsRelativePath = node.Path.Substring(ws.Path.Length); } using (new SystemAccount()) { bag = new TrashBag(bin) { KeepUntil = DateTime.UtcNow.AddDays(bin.MinRetentionTime), OriginalPath = RepositoryPath.GetParentPath(node.Path), WorkspaceRelativePath = wsRelativePath, WorkspaceId = wsId, DisplayName = node.DisplayName, Link = node }; bag.Save(); CopyPermissions(node, bag); //add delete permission for the owner //bag.Security.SetPermission(User.Current, true, PermissionType.Delete, PermissionValue.Allow); } try { Node.Move(node.Path, bag.Path); } catch (Exception ex) { Logger.WriteException(ex); bag.Destroy(); throw new InvalidOperationException("Error moving item to the trash", ex); } return(bag); }
public static void ForceDelete(GenericContent n) { Logger.WriteVerbose("Trashbin: Finally deleting from Repository", null, new Dictionary <string, object> { { "NodePath", n.Path } }); n.ForceDelete(); }
private Tuple <List <GenericContent>, int, int> InitCarsForUnprocessedTests() { // init: create some cars var container = new Folder(TestRoot); container.Name = "unprocessedtest-" + Guid.NewGuid().ToString(); container.Save(); var lastActivityId = IndexingActivityManager.GetLastActivityId(); var carlist = new List <GenericContent>(); for (var i = 0; i < 10; i++) { var car = new GenericContent(container, "Car"); car.Name = "testcar" + i.ToString(); car.Save(); carlist.Add(car); } var expectedLastActivityId = IndexingActivityManager.GetLastActivityId(); // check1: cars can be found in the index for (var i = 0; i < carlist.Count; i++) { Assert.IsTrue(CheckCarInIndex(carlist[i].Id), "Car cannot be found in index after init."); } return(new Tuple <List <GenericContent>, int, int>(carlist, lastActivityId, expectedLastActivityId)); }
private void CreateTestSite() { // need to reset the pinned site list var action = new PortalContext.ReloadSiteListDistributedAction(); action.ExecuteAsync(CancellationToken.None).GetAwaiter().GetResult(); var sites = new GenericContent(Repository.Root, "Sites") { Name = "Sites" }; sites.Save(); var site = new Site(sites) { Name = "Fake Test Site", UrlList = new Dictionary <string, string> { { "localhost_forms", "Forms" }, { "localhost_windows", "Windows" }, { "localhost_none", "None" } } }; site.Save(); }
//====================================================================== GenericContent trash methods public static bool IsInTrash(GenericContent n) { //currently this is a simple path check, but //in the future, when local trash bins may exist, //it will be more complicated return(n != null && (n.Path + "/").StartsWith(TrashBinPath + "/")); }
public void AllowedChildTypes_Workspace_LocalItems_ODataActionRemove() { Test(() => { var ts = CreateTestStructure(); ts.Workspace1.AllowedChildTypes = new[] { "DocumentLibrary", "File", "Folder", "MemoList", "SystemFolder", "TaskList", "Workspace" } .Select(ContentType.GetByName).ToArray(); ts.Workspace1.Save(); var namesBefore = ts.Workspace1.GetAllowedChildTypeNames().OrderBy(x => x).ToArray(); var localNamesBefore = ts.Workspace1.AllowedChildTypes.Select(x => x.Name).OrderBy(x => x).ToArray(); var additionalNames = new[] { "Car", "TaskList", "Workspace" }; // ACTION var content = Content.Create(ts.Workspace1); GenericContent.RemoveAllowedChildTypes(content, additionalNames); // ASSERT ts.Workspace1 = Node.Load <Workspace>(ts.Workspace1.Id); var namesAfter = ts.Workspace1.GetAllowedChildTypeNames().OrderBy(x => x); var localNamesAfter = ts.Workspace1.AllowedChildTypes.Select(x => x.Name).OrderBy(x => x).ToArray(); var expected = namesBefore.Except(additionalNames).Distinct().OrderBy(x => x); Assert.AreEqual(string.Join(", ", expected), string.Join(", ", namesAfter)); }); }
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); }
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 }
public SocketTuningContent(GenericContent content, SocketTuner tuner, ILog log) { this.content = content; this.tuner = tuner; this.log = log; CopyHeaders(); }
public Toolbar() { ToolBarItems = new GenericContent <ToolBarItem>(Build, Refresh); this.Style = (Style)Application.Current.Resources["FormFloatLeft"]; this.HeightRequest = 25; this.BackgroundColor = (Color)Application.Current.Resources["barBackgroundColor"]; this.Padding = new Thickness(0); this.VerticalOptions = LayoutOptions.Start; }
public static IEnumerable <Node> GetNewItemNodes(GenericContent content) { if (content == null) { throw new ArgumentNullException("content"); } return(GetNewItemNodes(content, content.GetAllowedChildTypes().ToArray())); }
private static void AssertPropertyValues(GenericContent gc, bool trashValue, string descValue, string message) { if (gc == null) { throw new ArgumentNullException("gc"); } Assert.AreEqual(trashValue, gc.TrashDisabled, "Wrong TrashDisabled value " + message); Assert.AreEqual(descValue, gc.Description, "Wrong Description value " + message); }
protected string GetProperty(GenericContent content, string propertyName) { if (content == null) { return(string.Empty); } var value = content.GetProperty(propertyName); return(value == null ? string.Empty : value.ToString()); }
//===================================================================================== Overridden Properties protected override GenericContent ResolveLinkedContent() { GenericContent result = Link as GenericContent; if (!string.IsNullOrWhiteSpace(Query)) { result = FetchContent(); } return(result); }
public static bool HasUndoCheckOut(GenericContent node) { if (HasForceUndoCheckOutRight(node)) { return(false); } var s = SavingAction.Create(node); return(s.ValidateAction(StateAction.UndoCheckOut) == ActionValidationResult.Valid); }
public static string GetVersioningModeText(GenericContent node) { if (node == null) { return(string.Empty); } var modeString = HttpContext.GetGlobalResourceObject("Portal", node.VersioningMode.ToString()) as string; return(string.IsNullOrEmpty(modeString) ? node.VersioningMode.ToString() : modeString); }
/// <summary> /// Removes the given model from the cache. /// </summary> /// <param name="model">The model</param> private Task RemoveFromCacheAsync(GenericContent model) { return(Task.Run(() => { if (_cache != null) { _cache.Remove(model.Id.ToString()); _cache.Remove($"DynamicContent_{ model.Id.ToString() }"); } })); }
/// <summary> /// Checks if a content of the given ContentType is allowed under a given parent content /// </summary> /// <param name="parent"></param> /// <param name="child">child node whose NodeType will be checked</param> /// <returns></returns> public static bool CheckAllowedContentType(GenericContent parent, Node child) { if (child == null || parent == null) { return(true); } var nodetypeName = child.NodeType.Name; return(CheckAllowedContentType(parent, nodetypeName)); }
private bool CheckAllowedContentType(GenericContent parent, Node child, HttpContext context) { var result = UploadHelper.CheckAllowedContentType(parent, child); if (!result) { RedirectToErrorPage(String.Format("Cannot upload this type of content to {0}.", parent.Path), context); } return(result); }
public void AllowedChildTypes_Folder_NoLocalItems_ODataActionAdd() { Test(() => { var ts = CreateTestStructure(); var additionalNames = new[] { "Car", "File", "Memo" }; // ACTION var content = Content.Create(ts.Folder1); GenericContent.AddAllowedChildTypes(content, additionalNames); // An InvalidOperationException need to be thrown here }); }
/// <summary> /// Checks if a content of the given ContentType is allowed under a given parent content /// </summary> /// <param name="parent"></param> /// <param name="contentTypeName"></param> /// <returns></returns> public static bool CheckAllowedContentType(GenericContent parent, string contentTypeName) { // check allowed content types // true: allowed list is empty, but current user is administrator (if allowed types list is empty: only administrator should upload any type.) // true: if this type is allowed var cTypes = parent.GetAllowedChildTypes().ToList(); if ((cTypes.Count == 0 && PortalContext.Current.ArbitraryContentTypeCreationAllowed) || (cTypes.Any(ct => ct.Name == contentTypeName))) { return(true); } return(false); }
public static string GetProperty(GenericContent content, string propertyName) { if (content == null) { return(string.Empty); } if (string.IsNullOrEmpty(propertyName)) { return(content.Id.ToString()); } var value = content.GetProperty(propertyName); return(value == null ? string.Empty : value.ToString()); }
public void Versioning_LostVersions_AllNodesAreExist() { //-- Preparing //var gcontents = (from i in Enumerable.Repeat(typeof(int), 5) select (GenericContent)Content.CreateNew("Car", TestRoot, "car").ContentHandler).ToArray(); //var ids = gcontents.Select(i => //{ // var c = (GenericContent)Content.CreateNew("Car", TestRoot, "car").ContentHandler; // c.ApprovingMode = ApprovingType.False; // c.VersioningMode = VersioningType.None; // c.Save(); // return c; //}).Select(c => c.Id).ToArray(); //gcontents = Node.LoadNodes(ids).Cast<GenericContent>().ToArray(); //var versionids = gcontents.Select(c => c.VersionId).ToArray(); var gcontents = new GenericContent[5]; var ids = new int[5]; var versionids = new int[5]; for (int i = 0; i < gcontents.Length; i++) { var c = (GenericContent)Content.CreateNew("Car", TestRoot, "car").ContentHandler; c.ApprovingMode = ApprovingType.False; c.VersioningMode = VersioningType.None; c.Save(); gcontents[i] = c; ids[i] = c.Id; versionids[i] = c.VersionId; } //-- Thread #1 gcontents[1].CheckOut(); gcontents[3].CheckOut(); //-- Thread #2 var heads = DataBackingStore.GetNodeHeads(ids); //-- Thread #1 gcontents[1].CheckIn(); gcontents[3].CheckIn(); //-- Thread #2 var nodes = LoadNodes(heads, VersionNumber.LastAccessible); var v2 = nodes.Select(c => c.VersionId).ToArray(); Assert.IsTrue(versionids.Except(v2).Count() == 0); }
//public static ServiceAction GetServiceAction(Content context, string backUrl, string methodName, string title, string iconName, int index) //{ // var act = ActionFramework.GetAction("ServiceAction", context, backUrl, new { path = context.Path }) as ServiceAction; // if (act != null) // { // act.Name = methodName; // act.ServiceName = "ContentStore.mvc"; // act.MethodName = methodName; // act.Text = title; // act.Icon = iconName; // act.Index = index; // } // return act; //} public static IEnumerable <Node> GetNewItemNodes(GenericContent content) { if (content == null) { throw new ArgumentNullException("content"); } var types = content.GetAllowedChildTypes(); if (types is AllContentTypes) { return(new Node[0]); } return(GetNewItemNodes(content, types.ToArray())); }
protected string GetProperty(GenericContent content, string propertyName) { //TODO: handle recursive property definitions - e.g. @@Node.Reference.FieldName@@ if (content == null) { return(string.Empty); } if (string.IsNullOrEmpty(propertyName)) { return(content.Id.ToString()); } var value = content.GetProperty(propertyName); return(value == null ? string.Empty : value.ToString()); }
// ================================================================================================ Methods protected override void OnInit(EventArgs e) { base.OnInit(e); if (this.ContextNode == null) { return; } if (ShowExecutionTime) { Timer.Start(); } UITools.AddScript(UITools.ClientScriptConfigurations.SNWallPath); UITools.AddPickerCss(); UITools.AddScript(UITools.ClientScriptConfigurations.SNPickerPath); // get items for content types drowpdown in dropbox var gc = new GenericContent(this.ContextNode, "Folder"); var newItems = GenericScenario.GetNewItemNodes(gc, ContentType.GetContentTypes()); string jsonData; using (var s = new MemoryStream()) { var workData = newItems.Select(n => new ContentTypeItem { value = n.Name, label = n.DisplayName }).OrderBy(n => n.label); var serializer = new DataContractJsonSerializer(typeof(ContentTypeItem[])); serializer.WriteObject(s, workData.ToArray()); s.Flush(); s.Position = 0; using (var sr = new StreamReader(s)) { jsonData = sr.ReadToEnd(); } } UITools.RegisterStartupScript("initdropboxautocomplete", string.Format("SN.Wall.initDropBox({0})", jsonData), this.Page); if (ShowExecutionTime) { Timer.Stop(); } }
/// <summary> /// Processes the model after it has been loaded from /// the repository. /// </summary> /// <param name="model">The content model</param> private async Task OnLoadAsync(GenericContent model) { // Make sure we have a model if (model == null) { return; } // Initialize the model if (model is IDynamicContent dynamicModel) { await _factory.InitDynamicAsync(dynamicModel, App.ContentTypes.GetById(model.TypeId)).ConfigureAwait(false); } else { await _factory.InitAsync(model, App.ContentTypes.GetById(model.TypeId)).ConfigureAwait(false); } // Initialize primary image if (model.PrimaryImage == null) { model.PrimaryImage = new Extend.Fields.ImageField(); } if (model.PrimaryImage.Id.HasValue) { await _factory.InitFieldAsync(model.PrimaryImage).ConfigureAwait(false); } // Execute on load hook App.Hooks.OnLoad(model); // Update the cache if available if (_cache != null) { // Store the model if (model is IDynamicContent) { _cache.Set($"DynamicContent_{ model.Id.ToString() }", model); } else { _cache.Set(model.Id.ToString(), model); } } }
public static bool DeleteNode(GenericContent n) { if (Instance != null && Instance.IsActive && n.IsTrashable) { if (Instance.BagCapacity > 0 && n.NodesInTree > Instance.BagCapacity) { throw new ApplicationException("Node tree size exceeds trash bag limit, use ForceDelete to purge physically."); } TrashBag.BagThis(n); } else { ForceDelete(n); } return(true); }
public static void CreateSandbox(TestContext testContext) { var site = Node.Load<Site>("/Root/TestSiteForAppModelTest"); if (site == null) { site = new Site(Repository.Root); site.Name = "TestSiteForAppModelTest"; var urlList = new Dictionary<string, string>(); urlList.Add("testhost", "Windows"); site.UrlList = urlList; site.Save(); } var homePage = EnsureSiteStartPage(site); var webContent = Node.Load<GenericContent>("/Root/TestSiteForAppModelTest/Home/WebContent1"); if (webContent == null) { webContent = new GenericContent(homePage, "WebContent"); webContent.Name = "WebContent1"; webContent.Save(); } var file = Node.Load<File>("/Root/TestSiteForAppModelTest/Home/File1"); if (file == null) { file = new File(homePage); file.Name = "File1"; file.GetBinary("Binary").SetStream(Tools.GetStreamFromString("File1 content")); file.Save(); } //---- Appmodel var siteAppsFolder = Node.Load<SystemFolder>("/Root/TestSiteForAppModelTest/(apps)"); if (siteAppsFolder == null) { siteAppsFolder = new SystemFolder(site); siteAppsFolder.Name = "(apps)"; siteAppsFolder.Save(); } var siteAppsPageFolder = Node.Load<Folder>("/Root/TestSiteForAppModelTest/(apps)/Page"); if (siteAppsPageFolder == null) { siteAppsPageFolder = new SystemFolder(siteAppsFolder); siteAppsPageFolder.Name = "Page"; siteAppsPageFolder.Save(); } var siteAppsPageBrowsePage = Node.Load<Page>("/Root/TestSiteForAppModelTest/(apps)/Page/Browse"); if (siteAppsPageBrowsePage == null) { siteAppsPageBrowsePage = new Page(siteAppsPageFolder); siteAppsPageBrowsePage.Name = "Browse"; siteAppsPageBrowsePage.GetBinary("Binary").SetStream(Tools.GetStreamFromString("<html><body><h1>Page Browse App</h1></body></html>")); siteAppsPageBrowsePage.Save(); } var siteAppsPageEditPage = Node.Load<Page>("/Root/TestSiteForAppModelTest/(apps)/Page/Edit"); if (siteAppsPageEditPage == null) { siteAppsPageEditPage = new Page(siteAppsPageFolder); siteAppsPageEditPage.Name = "Edit"; siteAppsPageEditPage.GetBinary("Binary").SetStream(Tools.GetStreamFromString("<html><body><h1>Page EditPage</h1></body></html>")); siteAppsPageEditPage.Save(); } var siteAppsGenericContentFolder = Node.Load<Folder>("/Root/TestSiteForAppModelTest/(apps)/GenericContent"); if (siteAppsGenericContentFolder == null) { siteAppsGenericContentFolder = new SystemFolder(siteAppsFolder); siteAppsGenericContentFolder.Name = "GenericContent"; siteAppsGenericContentFolder.Save(); } var siteAppsGenericContentBrowsePage = Node.Load<Page>("/Root/TestSiteForAppModelTest/(apps)/GenericContent/Browse"); if (siteAppsGenericContentBrowsePage == null) { siteAppsGenericContentBrowsePage = new Page(siteAppsGenericContentFolder); siteAppsGenericContentBrowsePage.Name = "Browse"; siteAppsGenericContentBrowsePage.GetBinary("Binary").SetStream(Tools.GetStreamFromString("<html><body><h1>GenericContent Browse App</h1></body></html>")); siteAppsGenericContentBrowsePage.Save(); } var siteAppsGenericContentEditPage = Node.Load<Page>("/Root/TestSiteForAppModelTest/(apps)/GenericContent/Edit"); if (siteAppsGenericContentEditPage == null) { siteAppsGenericContentEditPage = new Page(siteAppsGenericContentFolder); siteAppsGenericContentEditPage.Name = "Edit"; siteAppsGenericContentEditPage.GetBinary("Binary").SetStream(Tools.GetStreamFromString("<html><body><h1>GenericContent EditPage</h1></body></html>")); siteAppsGenericContentEditPage.Save(); } //---- SelfDispatcher node var selfDispatcherContent = Node.Load<GenericContent>("/Root/TestSiteForAppModelTest/Home/SelfDispatcherContent1"); if (selfDispatcherContent == null) { selfDispatcherContent = new GenericContent(homePage, "WebContent"); selfDispatcherContent.Name = "SelfDispatcherContent1"; selfDispatcherContent.BrowseApplication = Node.LoadNode("/Root/TestSiteForAppModelTest/(apps)/GenericContent/Edit"); selfDispatcherContent.Save(); } }
public void Storage2_LoadLongText() { const string longPropertyName = "HTMLFragment"; var webContent = new GenericContent(TestRoot, "HTMLContent"); webContent[longPropertyName] = LONG_TEXT1; webContent.Save(); var reloadedText = webContent[longPropertyName] as string; Assert.IsTrue(!string.IsNullOrEmpty(reloadedText), "New node: Reloaded longtext property is null after save."); Assert.AreEqual(LONG_TEXT1, reloadedText, "New node: Reloaded longtext is not the same as the original."); webContent = Node.Load<GenericContent>(webContent.Id); reloadedText = webContent[longPropertyName] as string; Assert.AreEqual(LONG_TEXT1, reloadedText, "Existing node: Reloaded longtext is not the same as the original #1"); webContent[longPropertyName] = LONG_TEXT2; reloadedText = webContent[longPropertyName] as string; Assert.AreEqual(LONG_TEXT2, reloadedText, "Existing node: Reloaded longtext is not the same as the original #2"); webContent.Save(); webContent = Node.Load<GenericContent>(webContent.Id); reloadedText = webContent[longPropertyName] as string; Assert.AreEqual(LONG_TEXT2, reloadedText, "Existing node: Reloaded longtext is not the same as the original #3"); }
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 IndexingHistory_FixAddAddOverlap() { // add overlaps with add var fieldvalue1 = "IndexingHistoryFixAddAddOverlap"; var history = LuceneManager._history; var car = new GenericContent(TestRoot, "Car"); car.Name = Guid.NewGuid().ToString(); car.Save(); var id = car.Id; // init 1 & 2 var node1 = Node.LoadNode(id); node1["Description"] = fieldvalue1; node1.Save(); // delete changes from index DataRowTimestampTest.DeleteVersionFromIndex(node1.VersionId); DataRowTimestampTest.DeleteVersionIdFromIndexingHistory(node1.VersionId); var docInfo1 = IndexDocumentInfo.Create(node1); var docData1 = DataBackingStore.CreateIndexDocumentData(node1, docInfo1, null); var document1 = IndexDocumentInfo.CreateDocument(docInfo1, docData1); // 1 check indexing history var versionId1 = history.GetVersionId(document1); var timestamp1 = history.GetTimestamp(document1); var historyOk = LuceneManager._history.CheckForAdd(versionId1, timestamp1); // timestamp in indexing history should be the newest var actTimestamp1 = history.Get(versionId1); Assert.AreEqual(timestamp1, actTimestamp1, "Timestamp in indexing history did not change."); Assert.IsTrue(historyOk, "History indicates indexing should not be executed, but this is not true."); // 2 check indexing history var versionId2 = history.GetVersionId(document1); var timestamp2 = history.GetTimestamp(document1); historyOk = LuceneManager._history.CheckForAdd(versionId2, timestamp2); // timestamp in indexing history should not change var actTimestamp2 = history.Get(versionId2); Assert.AreEqual(timestamp2, actTimestamp2, "Timestamp in indexing history changed, although it should not have."); Assert.IsFalse(historyOk, "History indicates indexing can be executed, but this is not true."); // 2 does not continue, returns // 1 index var document = document1; LuceneManager._writer.AddDocument(document); var firstfound = ContentQuery.Query("Description:" + fieldvalue1, new QuerySettings { EnableAutofilters = false }).Count; // check indexing occured correctly // thread 1 adds values to index Assert.AreEqual(1, firstfound); // 1 detects no problem var detectChange1 = history.CheckHistoryChange(versionId1, timestamp1); Assert.IsFalse(detectChange1, "Thread 1 detected indexing overlapping although it should not have."); var node = Node.LoadNode(id); node.ForceDelete(); }
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")); }
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 IndexingHistory_FixDeleteUpdateOverlap() { // delete overlaps with update var fieldvalue1 = "IndexingHistoryFixDeleteAddOverlap"; var history = LuceneManager._history; var car = new GenericContent(TestRoot, "Car"); car.Name = Guid.NewGuid().ToString(); car.Save(); var id = car.Id; // init 2 var node2 = Node.LoadNode(id); node2["Description"] = fieldvalue1; node2.Save(); // delete changes from index DataRowTimestampTest.DeleteVersionFromIndex(node2.VersionId); DataRowTimestampTest.DeleteVersionIdFromIndexingHistory(node2.VersionId); var docInfo2 = IndexDocumentInfo.Create(node2); var docData2 = DataBackingStore.CreateIndexDocumentData(node2, docInfo2, null); var document2 = IndexDocumentInfo.CreateDocument(docInfo2, docData2); // init 1 var node1 = Node.LoadNode(id); node1.ForceDelete(); // delete changes from index DataRowTimestampTest.DeleteVersionFromIndex(node1.VersionId); DataRowTimestampTest.DeleteVersionIdFromIndexingHistory(node1.VersionId); // 1 check indexing history var versionId1 = node2.VersionId; var term = new Term(LucObject.FieldName.VersionId, Lucene.Net.Util.NumericUtils.IntToPrefixCoded(versionId1)); LuceneManager._history.ProcessDelete(new Term[] { term }); // timestamp in indexing history should change var actTimestamp1 = history.Get(versionId1); Assert.AreEqual(long.MaxValue, actTimestamp1, "Timestamp in indexing history did not change."); // 2 check indexing history var versionId2 = history.GetVersionId(document2); var timestamp2 = history.GetTimestamp(document2); var historyOk = LuceneManager._history.CheckForUpdate(versionId2, timestamp2); // timestamp in indexing history should not change var actTimestamp2 = history.Get(versionId2); Assert.AreNotEqual(timestamp2, actTimestamp2, "Timestamp in indexing history changed, although it should not have."); Assert.IsFalse(historyOk, "History indicates indexing can be executed, but this is not true."); // 2 does not continue, returns // 1 deletes index LuceneManager.SetFlagsForDelete(term); LuceneManager._writer.DeleteDocuments(term); var firstfound = ContentQuery.Query("Description:" + fieldvalue1, new QuerySettings { EnableAutofilters = false }).Count; // check indexing occured correctly // thread 1 deletes from index Assert.AreEqual(0, firstfound); }
public void IndexingHistory_FixAddUpdateOverlap() { // add overlaps with update var fieldvalue1 = "IndexingHistoryFixAddUpdateOverlapFirst"; var fieldvalue2 = "IndexingHistoryFixAddUpdateOverlapSecond"; var history = LuceneManager._history; var car = new GenericContent(TestRoot, "Car"); car.Name = Guid.NewGuid().ToString(); car.Save(); var id = car.Id; // init 1 var node1 = Node.LoadNode(id); node1["Description"] = fieldvalue1; node1.Save(); // delete changes from index DataRowTimestampTest.DeleteVersionFromIndex(node1.VersionId); DataRowTimestampTest.DeleteVersionIdFromIndexingHistory(node1.VersionId); var docInfo1 = IndexDocumentInfo.Create(node1); var docData1 = DataBackingStore.CreateIndexDocumentData(node1, docInfo1, null); var document1 = IndexDocumentInfo.CreateDocument(docInfo1, docData1); // init 2 var node2 = Node.LoadNode(id); node2["Description"] = fieldvalue2; node2.Save(); // delete changes from index DataRowTimestampTest.DeleteVersionFromIndex(node2.VersionId); DataRowTimestampTest.DeleteVersionIdFromIndexingHistory(node2.VersionId); var docInfo2 = IndexDocumentInfo.Create(node2); var docData2 = DataBackingStore.CreateIndexDocumentData(node2, docInfo2, null); var document2 = IndexDocumentInfo.CreateDocument(docInfo2, docData2); // 1 check indexing history var versionId1 = history.GetVersionId(document1); var timestamp1 = history.GetTimestamp(document1); var historyOk = LuceneManager._history.CheckForAdd(versionId1, timestamp1); // timestamp in indexing history should be the newest var actTimestamp1 = history.Get(versionId1); Assert.AreEqual(timestamp1, actTimestamp1, "Timestamp in indexing history did not change."); Assert.IsTrue(historyOk, "History indicates indexing should not be executed, but this is not true."); // 2 check indexing history var versionId2 = history.GetVersionId(document2); var timestamp2 = history.GetTimestamp(document2); historyOk = LuceneManager._history.CheckForUpdate(versionId2, timestamp2); // timestamp in indexing history should change var actTimestamp2 = history.Get(versionId2); Assert.AreEqual(timestamp2, actTimestamp2, "Timestamp in indexing history did not change."); Assert.IsTrue(historyOk, "History indicates indexing should not be executed, but this is not true."); // 2 index var document = document2; var updateTerm = UpdateDocumentActivity.GetIdTerm(document); LuceneManager.SetFlagsForUpdate(document); LuceneManager._writer.UpdateDocument(updateTerm, document); var firstfound = ContentQuery.Query("Description:" + fieldvalue1, new QuerySettings { EnableAutofilters = false }).Count; var secondfound = ContentQuery.Query("Description:" + fieldvalue2, new QuerySettings { EnableAutofilters = false }).Count; // check indexing occured correctly // thread 2 writes values in index Assert.AreEqual(0, firstfound); Assert.AreEqual(1, secondfound); // 1 index document = document1; LuceneManager._writer.AddDocument(document); firstfound = ContentQuery.Query("Description:" + fieldvalue1, new QuerySettings { EnableAutofilters = false }).Count; secondfound = ContentQuery.Query("Description:" + fieldvalue2, new QuerySettings { EnableAutofilters = false }).Count; // check indexing occured correctly // thread 1 adds values to index, duplication occurs Assert.AreEqual(1, firstfound); Assert.AreEqual(1, secondfound); // 1 detects problem var detectChange1 = history.CheckHistoryChange(versionId1, timestamp1); Assert.IsTrue(detectChange1, "Thread 1 did not detect indexing overlapping although it should have."); // 2 detects no problem var detectChange2 = history.CheckHistoryChange(versionId2, timestamp2); Assert.IsFalse(detectChange2, "Thread 2 detected indexing overlapping although it should not have."); // 1 fixes index LuceneManager.RefreshDocument(versionId1); firstfound = ContentQuery.Query("Description:" + fieldvalue1, new QuerySettings { EnableAutofilters = false }).Count; secondfound = ContentQuery.Query("Description:" + fieldvalue2, new QuerySettings { EnableAutofilters = false }).Count; Assert.AreEqual(0, firstfound); Assert.AreEqual(1, secondfound); var node = Node.LoadNode(id); node.ForceDelete(); }
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 IndexingHistory_FixUpdateDeleteOverlap() { // update overlaps with delete var fieldvalue1 = "IndexingHistoryFixUpdateDeleteOverlap"; var history = LuceneManager._history; var car = new GenericContent(TestRoot, "Car"); car.Name = Guid.NewGuid().ToString(); car.Save(); var id = car.Id; // init 1 var node1 = Node.LoadNode(id); node1["Description"] = fieldvalue1; node1.Save(); // delete changes from index DataRowTimestampTest.DeleteVersionFromIndex(node1.VersionId); DataRowTimestampTest.DeleteVersionIdFromIndexingHistory(node1.VersionId); var docInfo1 = IndexDocumentInfo.Create(node1); var docData1 = DataBackingStore.CreateIndexDocumentData(node1, docInfo1, null); var document1 = IndexDocumentInfo.CreateDocument(docInfo1, docData1); // init 2 var node2 = Node.LoadNode(id); node2.ForceDelete(); // delete changes from index DataRowTimestampTest.DeleteVersionFromIndex(node2.VersionId); DataRowTimestampTest.DeleteVersionIdFromIndexingHistory(node2.VersionId); // 1 check indexing history var versionId1 = history.GetVersionId(document1); var timestamp1 = history.GetTimestamp(document1); var historyOk = LuceneManager._history.CheckForUpdate(versionId1, timestamp1); // timestamp in indexing history should be the newest var actTimestamp1 = history.Get(versionId1); Assert.AreEqual(timestamp1, actTimestamp1, "Timestamp in indexing history did not change."); Assert.IsTrue(historyOk, "History indicates indexing should not be executed, but this is not true."); // 2 check indexing history var versionId2 = node2.VersionId; var term = new Term(LucObject.FieldName.VersionId, Lucene.Net.Util.NumericUtils.IntToPrefixCoded(versionId2)); LuceneManager._history.ProcessDelete(new Term[] { term }); // timestamp in indexing history should change var actTimestamp2 = history.Get(versionId2); Assert.AreEqual(long.MaxValue, actTimestamp2, "Timestamp in indexing history did not change."); // 2 index LuceneManager.SetFlagsForDelete(term); LuceneManager._writer.DeleteDocuments(term); var firstfound = ContentQuery.Query("Description:" + fieldvalue1, new QuerySettings { EnableAutofilters = false }).Count; // check indexing occured correctly // thread 2 deletes from index Assert.AreEqual(0, firstfound); // 1 index var document = document1; var updateTerm = UpdateDocumentActivity.GetIdTerm(document); LuceneManager.SetFlagsForUpdate(document); LuceneManager._writer.UpdateDocument(updateTerm, document); firstfound = ContentQuery.Query("Description:" + fieldvalue1, new QuerySettings { EnableAutofilters = false }).Count; // check indexing occured correctly // thread 1 updates (adds) values to index, ghost document is created Assert.AreEqual(1, firstfound); // 1 detects problem var detectChange1 = history.CheckHistoryChange(versionId1, timestamp1); Assert.IsTrue(detectChange1, "Thread 1 did not detect indexing overlapping although it should have."); // 1 fixes index LuceneManager.RefreshDocument(versionId1); firstfound = ContentQuery.Query("Description:" + fieldvalue1, new QuerySettings { EnableAutofilters = false }).Count; Assert.AreEqual(0, firstfound); }
public void Storage2_CreatePrivateDataOnlyOnDemand() { var node = new GenericContent(TestRoot, "Car"); var isShared = node.Data.IsShared; var hasShared = node.Data.SharedData != null; Assert.IsFalse(isShared, "#1"); Assert.IsFalse(hasShared, "#2"); node.Name = Guid.NewGuid().ToString(); node.Save(); var id = node.Id; //---------------------------------------------- node = Node.Load<GenericContent>(id); isShared = node.Data.IsShared; hasShared = node.Data.SharedData != null; Assert.IsTrue(isShared, "#3"); Assert.IsFalse(hasShared, "#4"); node.Index += 1; isShared = node.Data.IsShared; hasShared = node.Data.SharedData != null; Assert.IsFalse(isShared, "#5"); Assert.IsTrue(hasShared, "#6"); }
private static void AssertPropertyValues(GenericContent gc, bool trashValue, string descValue, string message) { if (gc == null) throw new ArgumentNullException("gc"); Assert.AreEqual(trashValue, gc.TrashDisabled, "Wrong TrashDisabled value " + message); Assert.AreEqual(descValue, gc.Description, "Wrong Description value " + message); }
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); }
private Tuple<List<GenericContent>, int, int> InitCarsForUnprocessedTests() { // init: create some cars var container = new Folder(TestRoot); container.Name = "unprocessedtest-" + Guid.NewGuid().ToString(); container.Save(); var lastActivityId = IndexingActivityManager.GetLastActivityId(); var carlist = new List<GenericContent>(); for (var i = 0; i < 10; i++) { var car = new GenericContent(container, "Car"); car.Name = "testcar" + i.ToString(); car.Save(); carlist.Add(car); } var expectedLastActivityId = IndexingActivityManager.GetLastActivityId(); // check1: cars can be found in the index for (var i = 0; i < carlist.Count; i++) { Assert.IsTrue(CheckCarInIndex(carlist[i].Id), "Car cannot be found in index after init."); } return new Tuple<List<GenericContent>, int, int>(carlist, lastActivityId, expectedLastActivityId); }
private static void DoBenchmarkSteps() { var root = Node.Load<Folder>("/Root/Timing_TestRoot/STU"); int id = 0; Node n = null; for (int i = 0; i < 5; i++) { n = new GenericContent(root, "Car"); n.Save(); } id = n.Id; Node node; for (var i = 0; i < 5; i++) { for (int j = 0; j < 100; j++) { node = Node.LoadNode(id); var sb = new StringBuilder(); foreach (var proptype in node.PropertyTypes) { sb.Append(node.GetProperty<object>(proptype)); } } node = Node.LoadNode(id); node.Index++; node.Save(); } }
protected void Page_Load(object sender, EventArgs e) { string qsContentIdString = Request.QueryString["content"]; string qsContentTypeIdString = Request.QueryString["type"]; string qsEditString = Request.QueryString["edit"]; string qsCreateString = Request.QueryString["create"]; bool isEdit = (!string.IsNullOrEmpty(qsEditString) && qsEditString == "1"); bool isCreate = (!string.IsNullOrEmpty(qsCreateString) && qsCreateString == "1"); qsContentIdString = string.IsNullOrEmpty(qsContentIdString) ? null : qsContentIdString; qsContentTypeIdString = string.IsNullOrEmpty(qsContentTypeIdString) ? null : qsContentTypeIdString; int contentId; int contentTypeId; GenericContent content = null; if (Int32.TryParse(qsContentIdString, out contentId)) // Display/Edit { content = GenericContent.GetContent(contentId); } else if (Int32.TryParse(qsContentTypeIdString, out contentTypeId)) // Create { content = new GenericContent(contentTypeId); } else { FailToLoad(); } if (content == null && contentId > 0) FailToLoad(); AddHTML("// START GENERIC CONTENT: "); for (int i = 0; i < content.InputElementTypeList.Count; i++) { Panel addedPanel = new Panel(); AbstractInputController myInput = getInputObject(content.InputElementTypeList[i], contentId); if (isEdit) { myInput.AddEdit(addedPanel, contentId, content.InputElementDataList[i]); SaveContentButton.Visible = true; } else if (isCreate) { myInput.AddCreate(addedPanel); SaveContentButton.Visible = true; } else { myInput.AddDisplay(addedPanel, contentId, content.InputElementDataList[i]); SaveContentButton.Visible = false; } GenericContentPanel.Controls.Add(addedPanel); } AddHTML("// END GENERIC CONTENT"); }