Exemplo n.º 1
0
 private void Flush()
 {
     // write out the manifest to our xml file
     using (var output = new FileStream(path, FileMode.Create)) {
         SyncManifest.Write(Manifest, output);
     }
 }
Exemplo n.º 2
0
        partial void SyncNotes(NSObject sender)
        {
            var          dest_manifest_path = Path.Combine(settings.syncURL, "manifest.xml");
            SyncManifest dest_manifest;

            if (!File.Exists(dest_manifest_path))
            {
                using (var output = new FileStream(dest_manifest_path, FileMode.Create)) {
                    SyncManifest.Write(new SyncManifest(), output);
                }
            }
            using (var input = new FileStream(dest_manifest_path, FileMode.Open)) {
                dest_manifest = SyncManifest.Read(input);
            }
            var dest_storage = new DiskStorage(settings.syncURL);
            var dest_engine  = new Engine(dest_storage);

            var client       = new FilesystemSyncClient(NoteEngine, manifestTracker.Manifest);
            var server       = new FilesystemSyncServer(dest_engine, dest_manifest);
            var sync_manager = new SyncManager(client, server);

            sync_manager.DoSync();
            RefreshNotesWindowController();
            // write back the dest manifest
            using (var output = new FileStream(dest_manifest_path, FileMode.Create)) {
                SyncManifest.Write(dest_manifest, output);
            }
        }
Exemplo n.º 3
0
        public ManifestTracker(Engine engine, string path)
        {
            this.path = path;

            if (!File.Exists(path))
            {
                Manifest = new SyncManifest();
                using (var output = new FileStream(path, FileMode.Create)) {
                    SyncManifest.Write(Manifest, output);
                }
                foreach (Note note in engine.GetNotes().Values)
                {
                    Manifest.NoteRevisions [note.Guid] = Manifest.LastSyncRevision + 1;
                }
                Flush();
            }

            using (var input = new FileStream(path, FileMode.Open)) {
                this.Manifest = SyncManifest.Read(input);
            }
            engine.NoteAdded += (Note note) => {
                Console.WriteLine("Note added");
                Manifest.NoteRevisions [note.Guid] = Manifest.LastSyncRevision + 1;
            };

            engine.NoteUpdated += (Note note) => {
                Console.WriteLine("Note updated");
                Manifest.NoteRevisions [note.Guid] = Manifest.LastSyncRevision + 1;
            };

            engine.NoteRemoved += (Note note) => {
                Console.WriteLine("Note removed: " + note.Guid);
                Manifest.NoteDeletions.Add(note.Guid, note.Title);
            };
        }
Exemplo n.º 4
0
 public void Dispose()
 {
     // write back the manifest
     using (var output_stream = new FileStream(this.manifestPath, FileMode.OpenOrCreate)) {
         SyncManifest.Write(this.Manifest, output_stream);
     }
     userLocks [Username].Release();
 }
Exemplo n.º 5
0
 public void Dispose()
 {
     // write back the manifest
     using (var xmlwriter = new XmlTextWriter(this.manifestPath, Encoding.UTF8)) {
         SyncManifest.Write(xmlwriter, this.Manifest);
     }
     userLocks [Username].Release();
 }