using System; >>using System.Collections.Generic; >>using System.Linq; >>using System.Text; >> >>using System.Data; >>using System.Data.SqlClient; >> >>using Microsoft.Synchronization; >>using Microsoft.Synchronization.Data; >>using Microsoft.Synchronization.Data.SqlServer; >> >>using System.Configuration; >>using System.IO; >> >>namespace ProvisionServer >>{ >> class Program >> { >> static void Main(string[] args) >> { >> try >> { >> Console.WriteLine("Getting connection string"); >> string serverConnection = ConfigurationManager.ConnectionStrings["Server"].ConnectionString; >> >> // connect to server database >> Console.WriteLine("connect to server database"); >> SqlConnection serverConn = new SqlConnection(serverConnection); >> >> // define a new scope named CompleteScope >> DbSyncScopeDescription scopeDesc = new DbSyncScopeDescription("CompleteScope"); >> >> // add the description of all the tables from the database >> //DbSyncTableDescription tableDesc = SqlSyncDescriptionBuilder.GetDescriptionForTable("Accounts", serverConn); >> >> // add the table description to the sync scope definition >> //scopeDesc.Tables.Add(tableDesc); >> ... // lots of unDRY code snipped >> tableDesc = SqlSyncDescriptionBuilder.GetDescriptionForTable("Vendors", serverConn); >> scopeDesc.Tables.Add(tableDesc); >> >> tableDesc = SqlSyncDescriptionBuilder.GetDescriptionForTable("VFPCommands", serverConn); >> scopeDesc.Tables.Add(tableDesc); >> >> // create a server scope provisioning object based on the ProductScope >> SqlSyncScopeProvisioning serverProvision = new SqlSyncScopeProvisioning(serverConn, scopeDesc); >> >> // skipping the creation of table since table already exists on server >> serverProvision.SetCreateTableDefault(DbSyncCreationOption.Skip); >> >> // start the provisioning process >> serverProvision.Apply(); >> } >> catch (Exception error) >> { >> using (StreamWriter tw = new StreamWriter("BPOSync.log", true)) >> { >> // write a line of text to the file >> tw.WriteLine(DateTime.Now); >> tw.WriteLine("Error"); >> tw.WriteLine(error.ToString()); >> //tw.WriteLine(error.InnerException); >> tw.WriteLine("---"); >> >> // close the stream >> tw.Close(); >> } >> } >> } >> } >>}