Esempio n. 1
0
        /// <summary>
        /// find the page that contains the mindmanager guid
        /// </summary>
        /// <param name="mmguid"></param>
        /// <returns></returns>
        public static string GetHyperLinkBymmGuid(string mmguid)
        {
            //OnenoteApplication onApplication = new OnenoteApplication();
            string outstr    = string.Empty;
            string retString = string.Empty;

            try
            {
                OneNote.Instance().FindMeta(string.Empty, "mindmanagerguid", out outstr);
                var doc = XDocument.Parse(outstr);
                var ns  = doc.Root.Name.Namespace;

                var pageNode =
                    from page in doc.Descendants(ns + "Notebook").Descendants(ns + "Section").Descendants(ns + "Page")
                    let isInRecycleBin = GetAttributeValue(page, "isInRecycleBin", string.Empty) == string.Empty
                                         from meta in page.Descendants(ns + "Meta")
                                         where isInRecycleBin && meta.Attribute("content").Value == mmguid
                                         select page.Attribute("ID").ToString();

                //todo: hanadle reults with zero results
                if (pageNode.Count() != 0)
                {
                    var pageNodeId = pageNode.Single().ToString();

                    pageNodeId = pageNodeId.Replace("ID=\"", "").Replace("\"", "");
                    retString  = GetHyperLinkByObjectId(pageNodeId);
                }
            }
            catch (COMException ex)
            {
                throw new OneMapException(OneNoteHresultDescriptions.GetErrorDescription(ex.ErrorCode),
                                          ex, ex.GetBaseException());
            }

            return(retString);
        }