Beispiel #1
0
        public void UpdateNote(NoteData data)
        {
            bool noteExists = false;

            for (int i = 0; i < notes.Count; i++)
            {
                if (notes[i].uniqueId == data.i)
                {
                    notes[i].SetTitle(data.l);
                    notes[i].SetColor(data.c);
                    notes[i].SetContent(data.t);
                    notes[i].ChangeFolder(data.f);

                    DateTime dt = DateTime.FromBinary(long.Parse(data.s));
                    notes[i].SetSyncDate(dt);

                    SaveNoteToDisk(notes[i]);

                    noteExists = true;
                }
            }

            if (!noteExists)
            {
                string notePath = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData), "Tinote", "notes", data.i);

                if (!File.Exists(notePath))
                {
                    Note note = new Note(data.i, data.c, DateTime.FromBinary(long.Parse(data.d)));
                    note.SetContent(data.t);
                    note.SetTitle(data.l);

                    notes.Add(note);

                    NoteAddedEventArgs args = new NoteAddedEventArgs()
                    {
                        Note = note
                    };
                    OnNoteAdded(args);

                    SaveNoteToDisk(note);
                }
            }
        }
Beispiel #2
0
        public async void SyncNote(Note note)
        {
            try
            {
                var data = new NoteData
                {
                    i = note.uniqueId,
                    u = curUser.Email,
                    l = note.title,
                    t = note.contentRtf,
                    s = DateTime.Now.ToBinary().ToString(),
                    c = note.colorStr,
                    d = note.dateCreated.ToBinary().ToString(),
                    f = note.folderName
                };

                await firebaseClient.Child("notes").Child(note.uniqueId.ToString()).PutAsync <NoteData>(data);
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex);
            }
        }