Example #1
0
        static void Main(string[] args)
        {
            HighlightsExtractor extractor = new HighlightsExtractor();
            extractor.LogIn("*****@*****.**", "enter your password here.");

            foreach (BookWithHighlights bookWithHighlights in extractor.Crawl())
            {
                Console.WriteLine("===============================");
                Console.WriteLine("BookName {0}", bookWithHighlights.BookName);
                foreach (string highlight in bookWithHighlights.Highlights)
                {
                    Console.WriteLine(highlight);
                }
            }
        }
        public void KindleSync(IRibbonControl control)
        {
            // Extract information from the form.
            //
            AmazonRegistrationForm inputForm = new AmazonRegistrationForm();
            inputForm.ShowDialog();
            inputForm.Focus();

            if (inputForm.User == null)
            {
                return;
            }

            string username = inputForm.User.UserName;
            string password = inputForm.User.Password;

            string sectionId = onApp.Windows.CurrentWindow.CurrentSectionId;

            // Getting content from amazon site.
            //
            HighlightsExtractor extractor = new HighlightsExtractor();
            extractor.LogIn(username, password);

            foreach (BookWithHighlights bookWithHighlights in extractor.Crawl())
            {
                StringBuilder sb = new StringBuilder();
                foreach (string highlight in bookWithHighlights.Highlights)
                {
                    sb.AppendLine(highlight);
                    sb.AppendLine();
                }

                string newPageId;
                onApp.CreateNewPage(sectionId, out newPageId);

                string newPageContent;
                onApp.GetPageContent(newPageId, out newPageContent);
                var doc = XDocument.Parse(newPageContent);
                var ns = doc.Root.Name.Namespace;

                onApp.UpdatePageContent(GetXDocForNewPage(newPageId, ns, bookWithHighlights.BookName, sb.ToString()).ToString());
            }
        }