コード例 #1
0
        /// <summary>
        ///     Check to see if the passed in CE provider needs Schema from server
        /// </summary>
        /// <param name="localProvider"></param>
        private void CheckIfProviderNeedsSchema(SqlSyncProvider localProvider)
        {
            if (localProvider != null)
            {
                var ceConn   = (SqlConnection)localProvider.Connection;
                var ceConfig =
                    new SqlSyncScopeProvisioning(ceConn);
                ceConfig.ObjectSchema = "dbo";
                var scopeName = localProvider.ScopeName;

                //if the scope does not exist in this store
                if (!ceConfig.ScopeExists(scopeName))
                {
                    //create a reference to the server proxy
                    var serverProxy =
                        new RelationalProviderProxy(scopeName,
                                                    Settings.Default.ServiceUrl);

                    //retrieve the scope description from the server
                    var scopeDesc = serverProxy.GetScopeDescription();
                    serverProxy.Dispose();

                    //use scope description from server to intitialize the client
                    ceConfig.PopulateFromScopeDescription(scopeDesc);
                    ceConfig.Apply();
                }
            }
        }
コード例 #2
0
        public SyncResults SynchronizeProductsEmployees()
        {
            SyncResults results = null;
            // Create the SQL CE Sync Provider for the given scope name


            var localProvider =
                ConfigureSQLSyncProvider("NorthwindServerSyncScope");


            // Create the remote provider for the given scope name
            var destinationProxy =
                new RelationalProviderProxy("NorthwindServerSyncScope",
                                            Settings.Default.ServiceUrl);

            // Synchronize and collect results
            results = new SyncResults("NorthwindServerSyncScope",
                                      SynchronizeProviders(localProvider, destinationProxy,
                                                           SyncDirectionOrder.DownloadAndUpload));
            destinationProxy.Dispose();
            localProvider.Dispose();
            return(results);
        }