示例#1
0
文件: NotesList.cs 项目: xopuct/notes
 public virtual void AddRange(NotesList addedRange)
 {
     if (addedRange.notes.Count > 0)
     {
         foreach (var kvp in addedRange.notes)
         {
             if (notes.ContainsKey(kvp.Key))
                 SolveIdConflictWhenAddNewNote(kvp.Value);
             else
                 notes.Add(kvp.Key, kvp.Value);
         }
         SaveNotes();
     }
 }
示例#2
0
 public void RemoveNotesFromUser(string userName, NotesList removeNotes)
 {
     var oldNotes = GetUserNotes(userName);
     oldNotes.RemoveRange(removeNotes);
 }
示例#3
0
 public void ModifyNotesToUser(string userName, NotesList modifiedNotes)
 {
     var oldNotes = GetUserNotes(userName);
     oldNotes.ModifyRange(modifiedNotes);
 }
示例#4
0
 public void AddNotesToUser(string userName, NotesList AddedNotes)
 {
     var oldNotes = GetUserNotes(userName);
     oldNotes.AddRange(AddedNotes);
 }
示例#5
0
 public void OnRemoveNotes(NotesList notes)
 {
     var res = RemoveRange(notes);
     if (res && NotesDeleted!= null)
         NotesDeleted(notes.GetNotes());
 }
示例#6
0
 public void OnModifyNotes(NotesList notes)
 {
     var res = ModifyRange(notes);
     if (res && NotesModified != null)
         NotesModified(notes.GetNotes());
 }
示例#7
0
 public void OnAddNotes(NotesList notes)
 {
     AddRange(notes);
     if (NotesAdded != null)
         NotesAdded(notes.GetNotes());
 }
示例#8
0
文件: NotesList.cs 项目: xopuct/notes
 public virtual bool RemoveRange(NotesList removedRange)
 {
     bool res = false;
     if (removedRange.notes.Count > 0)
     {
         var confirmed = new List<uint>();
         foreach (var n in removedRange.notes)
         {
             if (notes.Remove(n.Key))
                 confirmed.Add(n.Key);
         }
         res = confirmed.Count > 0;
         foreach (var c in confirmed)
             notes.Remove(c);
         if (res)
             SaveNotes();
     }
     return res;
 }
示例#9
0
文件: NotesList.cs 项目: xopuct/notes
 public virtual bool ModifyRange(NotesList modifiedRange)
 {
     bool res = false;
     if (modifiedRange.notes.Count > 0)
     {
         var confirmed = new List<uint>();
         foreach (var n in modifiedRange.notes)
         {
             if (notes.ContainsKey(n.Key))
             {
                 notes[n.Key] = n.Value;
                 confirmed.Add(n.Key);
             }
         }
         res = confirmed.Count > 0;
         if (res)
             SaveNotes();
     }
     return res;
 }
示例#10
0
 public static bool SyncNotes(NotesList notes, NotesSyncType syncType)
 {
     return SendMessage(new CToSNotesRequest() { notes = notes, syncType = syncType });
 }