예제 #1
0
        private void SyncCompletedCallback(IAsyncResult ar)
        {
            SqlCeReplication repl = (SqlCeReplication)ar.AsyncState;

            try
            {
                repl.EndSynchronize(ar);
                repl.SaveProperties();
                var result = "Successfully completed sync" + Environment.NewLine;
                result += string.Format("Number of changes downloaded: {0}{1}", repl.PublisherChanges.ToString(), Environment.NewLine);
                result += string.Format("Number of changes uploaded: {0}{1}", repl.SubscriberChanges.ToString(), Environment.NewLine);
                result += string.Format("Number of conflicts at Publisher:   {0}{1}", repl.PublisherConflicts.ToString(), Environment.NewLine);
                var args = new SyncArgs(result, null, 100, SyncStatus.SyncComplete, null);
                Completed?.Invoke(this, args);
                InsertSyncLog(_connection, _hostName, _additionalId, "Success", _additionalInfo);
            }
            catch (SqlCeException e)
            {
                InsertSyncLog(_connection, _hostName, _additionalId, "Error", _additionalInfo + Environment.NewLine + ShowErrors(e));
                SyncArgs args;
                if (e.NativeError == 29006)
                {
                    args = new SyncArgs("Publication may have expired, or the snapshot is invalid", new PublicationMayHaveExpiredException("Publication may have expired, or the snapshot is invalid", e), 100, SyncStatus.SyncFailed, null);
                }
                else
                {
                    args = new SyncArgs("Errors occured during sync", e, 100, SyncStatus.SyncFailed, null);
                }
                Completed?.Invoke(this, args);
            }
            finally
            {
                if (repl != null)
                {
                    repl.Dispose();
                }
                if (_connection != null)
                {
                    _connection.Close();
                    _connection.Dispose();
                }
            }
        }
예제 #2
0
        private void OnStartTableDownloadCallback(IAsyncResult ar, string tableName)
        {
            var args = new SyncArgs("Began downloading table : " + tableName, null, 0, SyncStatus.BeginDownload, tableName);

            Progress?.Invoke(this, args);
        }
예제 #3
0
        private void OnSynchronizationCallback(IAsyncResult ar, int percentComplete)
        {
            var args = new SyncArgs("Sync with SQL Server is " + percentComplete.ToString() + "% complete.", null, percentComplete, SyncStatus.PercentComplete, null);

            Progress?.Invoke(this, args);
        }