/// <summary> /// Check to see if the passed in SqlSyncProvider needs Schema from server /// </summary> /// <param name="localProvider"></param> private void CheckIfProviderNeedsSchema(SqlSyncProvider localProvider) { if (localProvider != null) { SqlConnection conn = (SqlConnection)localProvider.Connection; SqlSyncScopeProvisioning sqlConfig = new SqlSyncScopeProvisioning(conn); string scopeName = localProvider.ScopeName; //if the scope does not exist in this store if (!sqlConfig.ScopeExists(scopeName)) { //create a reference to the server proxy SqlSyncProviderProxy serverProxy = new SqlSyncProviderProxy("CardsScope", connString); //retrieve the scope description from the server DbSyncScopeDescription scopeDesc = serverProxy.GetScopeDescription(); serverProxy.Dispose(); //use scope description from server to intitialize the client sqlConfig.PopulateFromScopeDescription(scopeDesc); sqlConfig.Apply(); } } }
/// <summary> /// Check to see if the passed in SQL provider needs Schema from server. /// This method assumes the provider is remote and uses a proxy instead /// of directly leveraging a provider. /// </summary> /// <param name="localProvider"></param> private void CheckIfProviderNeedsSchema(string scopeName, string clientConnectionString, string serverConnectionString, SqlSyncProviderProxy remoteProxy) { if (remoteProxy != null && remoteProxy.NeedsScope(scopeName, clientConnectionString)) { SqlSyncProviderProxy serverProxy = new SqlSyncProviderProxy(scopeName, serverConnectionString); DbSyncScopeDescription scopeDesc = serverProxy.GetScopeDescription(scopeName, serverConnectionString); serverProxy.Dispose(); remoteProxy.CreateScopeDescription(scopeDesc); } }
/// <summary> /// Check to see if the passed in SQL provider needs Schema from server. /// This method assumes the provider is remote and uses a proxy instead /// of directly leveraging a provider. /// </summary> /// <param name="localProvider"></param> private void CheckIfProviderNeedsSchema(SqlSyncProviderProxy remoteProxy) { if (remoteProxy != null && remoteProxy.NeedsScope()) { //create a reference to the server proxy SqlSyncProviderProxy serverProxy = new SqlSyncProviderProxy("CardsScope", connString); //retrieve the scope description from the server DbSyncScopeDescription scopeDesc = serverProxy.GetScopeDescription(); serverProxy.Dispose(); //intitialize remote store based on scope description from the server remoteProxy.CreateScopeDescription(scopeDesc); } }
/// <summary> /// Check to see if the passed in SQL provider needs Schema from server. /// This method assumes the provider is remote and uses a proxy instead /// of directly leveraging a provider. /// </summary> /// <param name="localProvider"></param> private void CheckIfProviderNeedsSchema(SqlSyncProviderProxy remoteProxy) { if (remoteProxy != null && remoteProxy.NeedsScope()) { //create a reference to the server proxy SqlSyncProviderProxy serverProxy = new SqlSyncProviderProxy(SyncUtils.ScopeName, SyncUtils.GenerateSqlConnectionString(this.serverHostName, SyncUtils.FirstPeerDBName, null, null, true)); //retrieve the scope description from the server DbSyncScopeDescription scopeDesc = serverProxy.GetScopeDescription(); serverProxy.Dispose(); //intitialize remote store based on scope description from the server remoteProxy.CreateScopeDescription(scopeDesc); } }
private void synchronizeBtn_Click(object sender, EventArgs e) { //Before calling synchronize, save any changes made to any of the peer tables foreach (TabPage page in this.peerTabsControl.TabPages) { if (page != null) { ((TablesViewControl)page.Controls["TablesViewCtrl"]).UpdateValues(); } } SqlSyncProvider srcProvider = providersCollection[this.srcProviderComboBox.SelectedItem.ToString()]; SqlSyncProvider destinationProvider = providersCollection[this.destProviderComboBox.SelectedItem.ToString()]; string hostName = ((SqlConnection)destinationProvider.Connection).DataSource; SqlSyncProviderProxy destinationProxy = new SqlSyncProviderProxy( SyncUtils.ScopeName, ((SqlConnection)destinationProvider.Connection).ConnectionString); //Set memory data cache size property. 0 represents non batched mode srcProvider.MemoryDataCacheSize = this._batchSize; //No need to set memory cache size for Proxy as since the source is enabled for batching, both upload and download will //be batched. //Set batch spool location. Default value if not set is %Temp% directory. if (!string.IsNullOrEmpty(this.batchSpoolLocation.Text)) { srcProvider.BatchingDirectory = this.batchSpoolLocation.Text; destinationProxy.BatchingDirectory = this.batchSpoolLocation.Text; } SyncOperationStatistics stats = synchronizationHelper.SynchronizeProviders(srcProvider, destinationProxy); TimeSpan diff = stats.SyncEndTime.Subtract(stats.SyncStartTime); destinationProxy.Dispose(); //Print Sync stats object this.syncStats.Text = string.Format("Batching: {4} - Total Time To Synchronize = {0}:{1}:{2}:{3}", diff.Hours, diff.Minutes, diff.Seconds, diff.Milliseconds, (this._batchSize > 0) ? "Enabled" : "Disabled"); this.ReadTableValuesForSelectedTab(); }
/// <summary> /// Check to see if the passed in SqlSyncProvider needs Schema from server /// </summary> /// <param name="localProvider"></param> private void CheckIfProviderNeedsSchema(SqlSyncProvider localProvider, string serverConnectionString) { if (localProvider != null) { SqlConnection conn = (SqlConnection)localProvider.Connection; SqlSyncScopeProvisioning sqlConfig = new SqlSyncScopeProvisioning(conn); string scopeName = localProvider.ScopeName; if (!sqlConfig.ScopeExists(scopeName)) { SqlSyncProviderProxy serverProxy = new SqlSyncProviderProxy(scopeName, serverConnectionString); DbSyncScopeDescription scopeDesc = serverProxy.GetScopeDescription(scopeName, serverConnectionString); serverProxy.Dispose(); sqlConfig.PopulateFromScopeDescription(scopeDesc); sqlConfig.Apply(); } } }