示例#1
0
 public void Synchronize()
 {
     if (this.repl != null)
     {
         IAsyncResult ar = repl.BeginSynchronize(
             new AsyncCallback(this.SyncCompletedCallback),
             new OnStartTableUpload(this.OnStartTableUploadCallback),
             new OnStartTableDownload(this.OnStartTableDownloadCallback),
             new OnSynchronization(this.OnSynchronizationCallback),
             repl);
     }
 }
示例#2
0
        /// <summary>
        /// Initiate a synchronization with the Web Agent based on the settings in app.config
        /// </summary>
        /// <param name="connection">A SqlCeConnection that point to the local database. Preferably closed.</param>
        /// <param name="hostName">The parameter used to filter the Publication (not required)</param>
        /// <param name="additionalId">Additional identification</param>
        /// <param name="additionalInfo">Additional information</param>
        /// <param name="option">ReinitializeOption</param>
        public void Synchronize(SqlCeConnection connection, string hostName, int additionalId, string additionalInfo, ReinitializeOption option)
        {
            _hostName       = hostName;
            _additionalId   = additionalId;
            _additionalInfo = additionalInfo;
            _connection     = connection;
            CreateDatabaseIfNotExists(connection);

            if (connection.State == ConnectionState.Open)
            {
                connection.Close();
            }

            var props = GetProperties();

            var repl = new SqlCeReplication();

            repl.Subscriber = hostName;
            repl.SubscriberConnectionString = GetSubscriberConnectionString(connection);
            if (!string.IsNullOrWhiteSpace(hostName))
            {
                repl.HostName   = hostName;
                repl.Subscriber = hostName;
            }
            if (!string.IsNullOrWhiteSpace(props.Subscriber))
            {
                repl.Subscriber = props.Subscriber;
            }

            repl.PostSyncCleanup = 2;
            SetProperties(props, repl);

            InsertSyncLog(connection, hostName, additionalId, "Attempt", additionalInfo);
            if (option == ReinitializeOption.ReinitializeNoUpload)
            {
                repl.ReinitializeSubscription(false);
            }
            if (option == ReinitializeOption.ReinitializeUploadSubscriberChanges)
            {
                repl.ReinitializeSubscription(true);
            }

            repl.BeginSynchronize(
                SyncCompletedCallback,
                OnStartTableUploadCallback,
                OnStartTableDownloadCallback,
                OnSynchronizationCallback,
                repl);
        }
示例#3
0
        public void Synchronize()
        {
            if (this.repl != null)
            {
                if (!_isNew)
                {
                    if (_reinitialize == ReinitializeOption.DiscardSubscriberChanges)
                    {
                        repl.ReinitializeSubscription(false);
                    }
                    if (_reinitialize == ReinitializeOption.UploadSubscriberChanges)
                    {
                        repl.ReinitializeSubscription(true);
                    }
                }

                IAsyncResult ar = repl.BeginSynchronize(
                    new AsyncCallback(this.SyncCompletedCallback),
                    new OnStartTableUpload(this.OnStartTableUploadCallback),
                    new OnStartTableDownload(this.OnStartTableDownloadCallback),
                    new OnSynchronization(this.OnSynchronizationCallback),
                    repl);
            }
        }
示例#4
0
 internal void BeginSync(SqlCeReplication replication)
 {
     this.replication = replication;
     asyncResult      = replication.BeginSynchronize(OnSyncCompletion, OnStartTableUpload, OnStartTableDownload, OnSynchronization, null);
 }