public FromClause SetFromClause(HierarchyScope hierarchyScope, RevisionStatusType revisionStatus, IEnumerable <HiveId> excludeParentIds = null, IEnumerable <HiveId> excludeIds = null, params HiveId[] scopeStartIds) { excludeParentIds = excludeParentIds ?? Enumerable.Empty <HiveId>(); excludeIds = excludeIds ?? Enumerable.Empty <HiveId>(); From = new FromClause(scopeStartIds, excludeParentIds, excludeIds, hierarchyScope, revisionStatus); return(From); }
public FromClause SetFromClause(HierarchyScope hierarchyScope, RevisionStatusType revisionStatus, IEnumerable<HiveId> excludeParentIds = null, IEnumerable<HiveId> excludeIds = null, params HiveId[] scopeStartIds) { excludeParentIds = excludeParentIds ?? Enumerable.Empty<HiveId>(); excludeIds = excludeIds ?? Enumerable.Empty<HiveId>(); From = new FromClause(scopeStartIds, excludeParentIds, excludeIds, hierarchyScope, revisionStatus); return From; }
public string GetObjectId(string parentId, HierarchyScope scope, string objectName) { string xml; OneNote.GetHierarchy(parentId, scope, out xml); var doc = XDocument.Parse(xml); var nodeName = ""; switch (scope) { case (HierarchyScope.hsNotebooks): nodeName = "Notebook"; break; case (HierarchyScope.hsPages): nodeName = "Page"; break; case (HierarchyScope.hsSections): nodeName = "Section"; break; default: return(null); } var node = doc.Descendants(ns + nodeName).Where(n => n.Attribute("name").Value == objectName).FirstOrDefault(); return(node.Attribute("ID").Value); }
public FromClause(string startId, HierarchyScope hierarchyScope, RevisionStatusType revisionStatus, IEnumerable <HiveId> requiredEntityIds = null) { StartId = startId; HierarchyScope = hierarchyScope; RevisionStatusType = revisionStatus; RequiredEntityIds = requiredEntityIds ?? Enumerable.Empty <HiveId>(); }
public void Execute() { logger.WriteLine("SortCommand.Execute()"); var result = DialogResult.None; using (var dialog = new SortDialog()) { result = dialog.ShowDialog(owner); dialog.Focus(); result = dialog.DialogResult; scope = dialog.Scope; sorting = dialog.Soring; direction = dialog.Direction; pinNotes = dialog.PinNotes; } if (result == DialogResult.OK) { logger.WriteLine($"- sort scope [{scope}]"); logger.WriteLine($"- sort sorting[{sorting}]"); logger.WriteLine($"- sort direction [{direction}]"); using (var manager = new ApplicationManager()) { XElement root; if (scope == HierarchyScope.hsPages) { // get just the current section with all pages as child elements root = manager.CurrentSection(); root = SortPages(root, sorting, direction); } else { root = manager.GetHierarchy(scope); if (scope == HierarchyScope.hsNotebooks) { // notebooks is a simple flat list root = SortNotebooks(root, sorting, direction); } else { // sections will include all sections for the current notebook root = SortSections(root, sorting, direction, pinNotes); } } if (root != null) { manager.UpdateHierarchy(root); } } } }
public FromClause(IEnumerable <HiveId> startIds, IEnumerable <HiveId> excludeStartIds, IEnumerable <HiveId> excludeIds, HierarchyScope hierarchyScope, RevisionStatusType revisionStatus, string hierarchyType = null, IEnumerable <HiveId> requiredEntityIds = null) { ScopeStartIds = startIds; ExcludeEntityIds = excludeIds; ExcludeParentIds = excludeStartIds; HierarchyScope = hierarchyScope; RevisionStatusType = revisionStatus; RequiredEntityIds = requiredEntityIds ?? Enumerable.Empty <HiveId>(); HierarchyType = hierarchyType ?? string.Empty; }
public FromClause(IEnumerable<HiveId> startIds, IEnumerable<HiveId> excludeStartIds, IEnumerable<HiveId> excludeIds, HierarchyScope hierarchyScope, RevisionStatusType revisionStatus, string hierarchyType = null, IEnumerable<HiveId> requiredEntityIds = null) { ScopeStartIds = startIds; ExcludeEntityIds = excludeIds; ExcludeParentIds = excludeStartIds; HierarchyScope = hierarchyScope; RevisionStatusType = revisionStatus; RequiredEntityIds = requiredEntityIds ?? Enumerable.Empty<HiveId>(); HierarchyType = hierarchyType ?? string.Empty; }
/// <summary> /// Get the XML of the specified hierarchy; used for sorting and XmlDialog /// </summary> /// <param name="scope"></param> /// <returns></returns> public XElement GetHierarchy(HierarchyScope scope = HierarchyScope.hsPages) { // get our own copy Application.GetHierarchy(null, scope, out var xml); if (!string.IsNullOrEmpty(xml)) { return(XElement.Parse(xml)); } return(null); }
public async Task <string> GetHierarchyContentAsync(string hierarchyId, HierarchyScope scope) { string content = null; await UseOneNoteAppInSingleThreadAsync(app => { app.GetHierarchy(hierarchyId, scope, out content, OneNoteConstants.CurrentOneNoteSchema); }); return(content); }
/// <summary> /// Get the XML descriptor of nodes in the OneNote hierarchy /// </summary> /// <remarks>Only basic information (as of OneNote 2010) is returned.</remarks> /// <param name="nodeID">id of the starting node</param> /// <param name="scope"> scope of the nodes to return</param> /// <returns>XML document describing the nodes in the OneNote hierarchy</returns> /// <exception cref="COMException">Call to OneNote failed</exception> public XDocument GetHierarchy(string nodeID, HierarchyScope scope) { TraceLogger.Log(TraceCategory.Info(), "Start Node = {0}; Scope = {1}", nodeID, scope); return(ExecuteMethodProtected <XDocument>(o => { string outXml; o.GetHierarchy(nodeID, scope, out outXml, OneNoteSchema); return XDocument.Parse(outXml); })); }
private void ShowHierarchy(HierarchyScope scope) { var element = manager.GetHierarchy(scope); if (element != null) { var xml = element.ToString(SaveOptions.None); hierBox.Text = xml; } else { hierBox.Text = $"Cannot get hierarchy for {scope.ToString()}"; } }
/// <summary> /// /// </summary> /// <param name="oneNoteApp"></param> /// <param name="hierarchyId"></param> /// <param name="scope"></param> /// <param name="refreshCache">Стоит ли загружать данные из OneNote (true) или из кэша (false)</param> /// <returns></returns> public HierarchyElement GetHierarchy(ref Application oneNoteApp, string hierarchyId, HierarchyScope scope, bool refreshCache = false) { OneNoteHierarchyContentId contentId = new OneNoteHierarchyContentId() { ID = hierarchyId, ContentScope = scope }; HierarchyElement result; if (!_hierarchyContentCache.ContainsKey(contentId) || refreshCache) { lock (_locker) { string xml = null; try { OneNoteUtils.UseOneNoteAPI(ref oneNoteApp, (oneNoteAppSafe) => { oneNoteAppSafe.GetHierarchy(hierarchyId, scope, out xml, Constants.CurrentOneNoteSchema); }); } catch (Exception ex) { throw new HierarchyNotFoundException(string.Format("Не удаётся найти иерархию типа '{0}' для элемента '{1}': {2}", scope, hierarchyId, OneNoteUtils.ParseErrorAndMakeItMoreUserFriendly(ex.Message))); } XmlNamespaceManager xnm; XDocument doc = OneNoteUtils.GetXDocument(xml, out xnm); if (!_hierarchyContentCache.ContainsKey(contentId)) { _hierarchyContentCache.Add(contentId, new HierarchyElement() { Id = contentId, Content = doc, Xnm = xnm }); } else { _hierarchyContentCache[contentId].Content = doc; } } } result = _hierarchyContentCache[contentId]; return(result); }
public FromClause SetFromClause(string startId, HierarchyScope hierarchyScope, RevisionStatusType revisionStatus) { From = new FromClause(startId, hierarchyScope, revisionStatus); return(From); }
///////////////////////////////////////////////////////////////////////////////////// private string GetOneNoteXML( string _strStartID, HierarchyScope _hierarchyScope ) { string strOneNoteXML = ""; this.oneNote.GetHierarchy( _strStartID, _hierarchyScope, out strOneNoteXML ); return strOneNoteXML; }
public static XDocument GetHierarchyElement(ref Application oneNoteApp, string hierarchyId, HierarchyScope scope, out XmlNamespaceManager xnm) { string xml = null; UseOneNoteAPI(ref oneNoteApp, (oneNoteAppSafe) => { oneNoteAppSafe.GetHierarchy(hierarchyId, scope, out xml, Constants.CurrentOneNoteSchema); }); return(GetXDocument(xml, out xnm)); }
public FromClause(IEnumerable <HiveId> startIds, HierarchyScope hierarchyScope, RevisionStatusType revisionStatus, string hierarchyType = null, IEnumerable <HiveId> requiredEntityIds = null) : this(startIds, Enumerable.Empty <HiveId>(), Enumerable.Empty <HiveId>(), hierarchyScope, revisionStatus, hierarchyType, requiredEntityIds) { }
public FromClause(IEnumerable<HiveId> startIds, HierarchyScope hierarchyScope, RevisionStatusType revisionStatus, string hierarchyType = null, IEnumerable<HiveId> requiredEntityIds = null) : this(startIds, Enumerable.Empty<HiveId>(), Enumerable.Empty<HiveId>(), hierarchyScope, revisionStatus, hierarchyType, requiredEntityIds) { }