public override void ProcessChangeBatch(ConflictResolutionPolicy resolutionPolicy, ChangeBatch sourceChanges, object changeDataRetriever, SyncCallbacks syncCallbacks, SyncSessionStatistics sessionStatistics)
        {
            DbSyncContext context = changeDataRetriever as DbSyncContext;

            // Check if the data is batched
            if (context != null && context.IsDataBatched)
            {
                string filename = new FileInfo(context.BatchFileName).Name;
                // Retrieve the remote id from the MadeWithKnowledge.ReplicaId. MadeWithKnowledge is the local knowledge of the peer
                // that is enumerating the changes
                string remoteId = context.MadeWithKnowledge.ReplicaId.ToString();
                // Check if service already has this file
                if (!Proxy.HasUploadedBatchFile(filename, remoteId))
                {
                    // Upload this file to remote service
                    byte[] content = null;
                    using (Stream stream = new FileStream(context.BatchFileName, FileMode.Open, FileAccess.Read)) {
                        content = new byte[stream.Length];
                        stream.Read(content, 0, content.Length);
                    }
                    if (content != null)
                    {
                        Proxy.UploadBatchFile(filename, content, remoteId);
                    }
                }

                context.BatchFileName = filename;
            }

            SyncSessionStatistics stats = Proxy.ApplyChanges(resolutionPolicy, sourceChanges, changeDataRetriever);

            sessionStatistics.ChangesApplied += stats.ChangesApplied;
            sessionStatistics.ChangesFailed  += stats.ChangesFailed;
        }
Exemple #2
0
        public override void ProcessChangeBatch(ConflictResolutionPolicy resolutionPolicy, ChangeBatch sourceChanges, object changeDataRetriever, SyncCallbacks syncCallbacks, SyncSessionStatistics sessionStatistics)
        {
            SyncSessionStatistics stats = Proxy.ApplyChanges(resolutionPolicy, sourceChanges, changeDataRetriever);

            sessionStatistics.ChangesApplied += stats.ChangesApplied;
            sessionStatistics.ChangesFailed  += stats.ChangesFailed;
        }