Beispiel #1
0
        public static void LoadArchivedNotesIfNecessary()
        {
            if (archivedNotes != null && archivedNotes.Count > 0)
            {
                return;
            }

            archivedNotes = LocalDB.GetAllWithChildren <Note>(x => x.IsArchived == true && x.DeletedAt == null).OrderByDescending(x => x.ArchivedAt).ToList();
            if (archivedNotes == null)
            {
                archivedNotes = new Notes();
            }
        }
Beispiel #2
0
        private static async void MergeRoamingWithLocalDB()
        {
            var allLocalNotes   = LocalDB.GetAllWithChildren <Note>();
            var allRoamingNotes = RoamingDB.GetAllWithChildren <Note>();

            foreach (var roamingNote in allRoamingNotes)
            {
                var localNote = LocalDB.Find <Note>(roamingNote.ID);

                //create local note
                if (localNote == null)
                {
                    CreateNote(roamingNote, false);
                    Debug.WriteLine("Roaming: Note created");
                }

                //archive local note
                else if (roamingNote.IsArchived && !localNote.IsArchived && roamingNote.ArchivedAt > localNote.UpdatedAt)
                {
                    ArchiveNote(localNote, false);
                    UpdateNote(roamingNote, false);
                    localNote.ReplaceWith(roamingNote);
                    Debug.WriteLine("Roaming: Note archived");
                }

                //delete local note
                else if (roamingNote.DeletedAt != localNote.DeletedAt && roamingNote.DeletedAt > localNote.UpdatedAt)
                {
                    await RemoveNote(localNote, false);

                    UpdateNote(roamingNote, false);
                    localNote.ReplaceWith(roamingNote);
                    Debug.WriteLine("Roaming: Note deleted");
                }

                //update local note
                else if (roamingNote.UpdatedAt > localNote.UpdatedAt)
                {
                    UpdateNote(roamingNote, false);
                    localNote.ReplaceWith(roamingNote);
                    Debug.WriteLine("Roaming: Note updated");
                }
            }
        }