Exemple #1
0
        private void DoSync(Version version, int serverVersion)
        {
            logger.Info("SyncServerToClient begin: " + version.ServerVersion + ":" + version.ClientVersion);
            var serverNotes = syncFeign.GetNotes(version.SyncUser, version.SyncToken);

            logger.Info("服务端下发数据:\n" + serializer.SerializToStr(serverNotes));

            // 备份本地
            notesService.BackupAll();

            // 保存服务端拉到的提醒
            foreach (var note in serverNotes)
            {
                // 直接使用服务端的id,不再使用客户端ID了
                notesService.Save(note);
            }

            version.ServerVersion = serverVersion;
            version.ClientVersion = serverVersion;
            version.LastSyncTime  = DateTime.Now;
            versionRepository.Save(version);
            logger.Info("SyncServerToClient end: " + version.ServerVersion + ":" + version.ClientVersion);

            // 刷新主界面
            FormHelper.Invoke(MainForm.Default, () => MainForm.Default.LoadNotes());
        }