コード例 #1
0
        private Tuple <IRemoteStorageSyncPersistance, List <INote>, int, int> DoSync(RemoteStorageAccount acc, AlephLogger log)
        {
            var data = SelectedProvider.CreateEmptyRemoteSyncData();

            var conn = acc.Plugin.CreateRemoteStorageConnection(PluginManagerSingleton.Inst.GetProxyFactory().Build(), acc.Config, new HierarchyEmulationConfig(false, "\\", '\\'));

            var resultNotes  = new ConcurrentQueue <INote>();
            var resultErrors = new ConcurrentQueue <string>();

            int fullCount;

            Application.Current.Dispatcher.Invoke(() => { SyncInfoText = "Connect to remote"; });
            conn.StartSync(data, new List <INote>(), new List <INote>());
            {
                Application.Current.Dispatcher.Invoke(() => { SyncInfoText = "List notes from remote"; });
                var missing = conn.ListMissingNotes(new List <INote>());

                fullCount = missing.Count;

                Application.Current.Dispatcher.Invoke(() =>
                {
                    CanAbort = !acc.Plugin.SupportsNewDownloadMultithreading || missing.Count < AppSettings.DEFAULT_INITIALDOWNLOAD_PARALLELISM_THRESHOLD;
                });

                SynchronizationThread.ExecuteInParallel(
                    log,
                    "InitialDownloadNewNotes",
                    acc.Plugin.SupportsNewDownloadMultithreading,
                    missing,
                    AppSettings.DEFAULT_INITIALDOWNLOAD_PARALLELISM_LEVEL,
                    AppSettings.DEFAULT_INITIALDOWNLOAD_PARALLELISM_THRESHOLD,
                    (e, xnoteid) =>
                {
                    resultErrors.Enqueue(xnoteid);
                    return(true);
                },
                    xnoteid =>
                {
                    var msg = $"Download Note {resultNotes.Count}/{missing.Count}";
                    Application.Current.Dispatcher.Invoke(() => { SyncInfoText = msg; });

                    var note = conn.DownloadNote(xnoteid, out var isnewnote);
                    if (isnewnote)
                    {
                        note.SetLocalDirty("Set Note LocalDirty=true after download in Startupmode");
                        note.ResetRemoteDirty("Set Note RemoteDirty=false after download in Startupmode");
                        resultNotes.Enqueue(note);
                    }
                    else
                    {
                        log.Warn("Sync_FirstStart", $"Download new note {{id:'{xnoteid}'}} returned false");
                    }
                });
            }
            Application.Current.Dispatcher.Invoke(() => { SyncInfoText = "Finish synchronization"; });
            conn.FinishSync(out var _);

            return(Tuple.Create(data, resultNotes.ToList(), resultErrors.Count, fullCount));
        }
コード例 #2
0
        public void StartAcceptingConnections()
        {
            //Start synchronization thread so Controller knows the clients.
            SynchronizationThread.Start();

            //Start accepting connections from both controller(s) and client(s).
            ServerSocket.StartAcceptingConnections();
        }