Ejemplo n.º 1
0
        /// <summary>
        ///		Download data for the subscription from the server, and don't return until the download
        ///		finishes.
        /// </summary>
        /// <param name="subscription">
        ///		The subscription for which you want to download data from the server.
        /// </param>
        public void Synchronize(Subscription subscription)
        {
            Guard.ArgumentNotNull(subscription, "subscription");

            if (!Subscriptions.Contains(subscription))
            {
                throw new ArgumentException(Properties.Resources.NoSuchSubscription);
            }

            SubscriptionCredentials credentials = subscriptionCredentials.FindCredentials(subscription);
            SqlCeReplication        replication = GetSyncReplication(subscription);

            if (credentials != null)
            {
                credentials.ApplyCredentials(replication);
            }

            try
            {
                replication.Synchronize();
            }
            finally
            {
                replication.Dispose();

                ReloadSubscriptions();
            }
        }
Ejemplo n.º 2
0
        /// <summary>
        ///		Begin downloading data for the subscription and return control immediately.
        /// </summary>
        /// <remarks>
        /// <para>
        ///		Before you call this method, you can register to receive events from the <paramref name="subscription"/>
        ///		object. This will allow you to monitor the progress of the synchronization.
        /// </para>
        /// <para>
        ///		Once the synchronization completes, you must call <see cref="EndSync"/>.
        /// </para>
        /// </remarks>
        /// <param name="subscription">
        ///		The subscription you want to synchronize.
        /// </param>
        public void BeginSynchronize(Subscription subscription)
        {
            Guard.ArgumentNotNull(subscription, "subscription");

            if (!Subscriptions.Contains(subscription))
            {
                throw new ArgumentException(Properties.Resources.NoSuchSubscription);
            }

            SubscriptionCredentials credentials = subscriptionCredentials.FindCredentials(subscription);
            SqlCeReplication        replication = GetSyncReplication(subscription);

            if (credentials != null)
            {
                credentials.ApplyCredentials(replication);
            }
            subscription.BeginSync(replication);
        }