public bool Generate()
        {
            try
            {
                dict1 = new Dictionary <Page, eBriefingMobile.Annotation>();
                dict2 = new Dictionary <Page, List <eBriefingMobile.Note> >();

                foreach (var page in pageList)
                {
                    // Add annotations to dictionary if necessary
                    if (Annotation == ANNOTATION.WITH)
                    {
                        Annotation ann = BooksOnDeviceAccessor.GetAnnotation(bookID, page.ID);
                        dict1.Add(page, ann);
                    }

                    // Add notes to dictionary if necessary
                    if (Note == NOTE.WITH)
                    {
                        List <Note> noteList = new List <eBriefingMobile.Note>();
                        Note        note     = null;
                        if (String.IsNullOrEmpty(URL.MultipleNoteURL))
                        {
                            note = BooksOnDeviceAccessor.GetNote(bookID, page.ID);
                            if (note != null)
                            {
                                noteList.Add(note);
                                dict2.Add(page, noteList);
                            }
                        }
                        else
                        {
                            noteList = BooksOnDeviceAccessor.GetNotes(bookID, page.ID);
                            if (noteList != null && noteList.Count > 0)
                            {
                                dict2.Add(page, noteList);
                            }
                        }
                    }
                }

                return(GenerateImage(dict1, dict2));
            }
            catch (Exception ex)
            {
                Logger.WriteLineDebugging("PrintHelper - Generate: {0}", ex.ToString());
                return(false);
            }
        }
        public static Note SaveNote(Book book, String pageID, String text, String noteID = "")
        {
            String ID = String.Empty;

            if (String.IsNullOrEmpty(URL.MultipleNoteURL))
            {
                ID = pageID;
            }
            else
            {
                ID = noteID;
            }

            Note note = BooksOnDeviceAccessor.GetNote(book.ID, ID);

            if (note == null)
            {
                if (!String.IsNullOrEmpty(text))
                {
                    note             = new Note();
                    note.BookID      = book.ID;
                    note.PageID      = pageID;
                    note.NoteID      = Guid.NewGuid().ToString();
                    note.Text        = text;
                    note.BookVersion = book.Version;
                    note.ModifiedUtc = note.CreatedUtc = DateTime.UtcNow;
                    Add(note);
                }
            }
            else
            {
                if (String.IsNullOrEmpty(text))
                {
                    Remove(book.ID, ID);
                }
                else
                {
                    note.Text        = text;
                    note.ModifiedUtc = DateTime.UtcNow;

                    Update(note);
                }
            }

            BooksOnDeviceAccessor.UpdateUserModifiedDate(book);

            return(note);
        }
Exemple #3
0
        public void UpdateNote(String pageID)
        {
            // Save previous note
            SaveNote();

            // Show new note
            this.pageID = pageID;

            Note note = BooksOnDeviceAccessor.GetNote(NoteBook.ID, pageID);
            if (note == null)
            {
                textView.Text = String.Empty;

                UpdateOpacity(0.7f, 0.7f);
            }
            else
            {
                textView.Text = note.Text;

                UpdateOpacity(0f, 0.7f);
            }
        }
Exemple #4
0
        private static void PullNotesWork(Book book)
        {
            List <Note> sNotes = null;

            if (String.IsNullOrEmpty(URL.MultipleNoteURL))
            {
                sNotes = SaveMyStuff.GetMyNotes(book.ID);
            }
            else
            {
                sNotes = SaveMyStuff.GetMyNotes(book.ID, book.LastSyncedDate);
            }

            if (sNotes != null && sNotes.Count > 0)
            {
                foreach (var sNote in sNotes)
                {
                    Note dNote = null;
                    if (String.IsNullOrEmpty(URL.MultipleNoteURL))
                    {
                        dNote = BooksOnDeviceAccessor.GetNote(book.ID, sNote.PageID);
                    }
                    else
                    {
                        dNote = BooksOnDeviceAccessor.GetNote(book.ID, sNote.NoteID);
                    }

                    if (dNote == null)
                    {
                        // This is a new note from the server
                        BooksOnDeviceAccessor.AddNote(sNote);
                    }
                    else
                    {
                        if (dNote.ModifiedUtc <= sNote.ModifiedUtc)
                        {
                            if (sNote.Removed)
                            {
                                // Remove note if the note on the cloud has 'Removed' checked
                                if (String.IsNullOrEmpty(URL.MultipleNoteURL))
                                {
                                    BooksOnDeviceAccessor.RemoveNote(dNote.BookID, dNote.PageID);
                                }
                                else
                                {
                                    BooksOnDeviceAccessor.RemoveNote(dNote.BookID, dNote.NoteID);
                                }
                            }
                            else
                            {
                                BooksOnDeviceAccessor.UpdateNote(sNote);
                            }
                        }
                    }
                }
            }

            // Update the last time synced for this book
            book.LastSyncedDate = DateTime.UtcNow;
            BooksOnDeviceAccessor.UpdateBook(book);
        }
Exemple #5
0
        static void HandleGetMyNotesEvent(String bookID, List <Note> sNotes, bool lastItem)
        {
            try
            {
                List <Note> dNotes = BooksOnDeviceAccessor.GetNotes(bookID);
                if (dNotes != null && dNotes.Count > 0)
                {
                    foreach (Note dNote in dNotes)
                    {
                        if (sNotes != null && sNotes.Count > 0)
                        {
                            foreach (Note sNote in sNotes)
                            {
                                if (dNote.PageID == sNote.PageID)
                                {
                                    if (dNote.ModifiedUtc < sNote.ModifiedUtc)
                                    {
                                        if (sNote.Removed)
                                        {
                                            // Remove note if note on the cloud has 'Removed' checked
                                            BooksOnDeviceAccessor.RemoveNote(dNote.BookID, dNote.PageID);
                                        }
                                        else
                                        {
                                            // Update note if note on the cloud has the latest ModifiedUtc
                                            dNote.BookVersion = sNote.BookVersion;
                                            dNote.Text        = sNote.Text;
                                            dNote.ModifiedUtc = sNote.ModifiedUtc;

                                            BooksOnDeviceAccessor.UpdateNote(dNote);
                                        }
                                    }
                                    break;
                                }
                            }
                        }
                    }
                }

                // Add note if the note is not on the device
                if (sNotes != null && sNotes.Count > 0)
                {
                    foreach (Note sNote in sNotes)
                    {
                        if (!sNote.Removed)
                        {
                            if (BooksOnDeviceAccessor.GetNote(sNote.BookID, sNote.PageID) == null)
                            {
                                BooksOnDeviceAccessor.AddNote(sNote);
                            }
                        }
                    }
                }

                // Check if syncing is done
                if (cancelled)
                {
                    SetReceive(true);

                    CheckReceiveDone();
                }
                else
                {
                    if (lastItem)
                    {
                        SaveMyStuff.GetMyNotesEvent -= HandleGetMyNotesEvent;
                        receiveNotes = true;

                        CheckReceiveDone();
                    }
                }
            }
            catch (Exception ex)
            {
                SetReceive(true);

                CheckReceiveDone();

                Logger.WriteLineDebugging("CloudSync - HandleGetMyNotesEvent: {0}", ex.ToString());
            }
        }