コード例 #1
0
 private static void Provision(SqlConnection server, SqlConnection client,
                               string tablename, string direction)
 {
     try
     {
         Provisioning.ProvisionTable(server, client, tablename);
     }
     catch (SyncConstraintConflictNotAllowedException)
     {
         Console.ForegroundColor = ConsoleColor.Red;
         string message = string.Format("Scope called {0} already exists. Please use --deprovision first", tablename);
         Console.Error.WriteLine(message);
         Console.ResetColor();
     }
     Console.WriteLine("Provision complete");
     if (server.ConnectionString != client.ConnectionString)
     {
         if (client.State == System.Data.ConnectionState.Closed)
         {
             client.Open();
         }
         Console.WriteLine("Adding to scopes table on client");
         Provisioning.AddScopeToScopesTable(client, tablename,
                                            utils.StringToEnum <SyncDirectionOrder>(direction));
     }
     Console.ForegroundColor = ConsoleColor.Green;
     Console.WriteLine("Complete");
     Console.ResetColor();
 }
コード例 #2
0
        private void UpdateSyncedTablesList()
        {
            ListBox_ProvisionedClientTables.Items.Clear();

            if (!string.IsNullOrEmpty(ClientConnectionString) && !string.IsNullOrWhiteSpace(ClientConnectionString) && !string.IsNullOrEmpty(ProviderConnectionString) && !string.IsNullOrWhiteSpace(ProviderConnectionString)) //Using 'ProviderConnectionExists()' & 'ClientConnectionExists()' would cause a message to be shown
            {
                foreach (string tableName in Provisioning.GetSyncedTables(ProviderConnectionString, ClientConnectionString))
                {
                    ListBox_ProvisionedClientTables.Items.Add(tableName);
                }
            }
        }
コード例 #3
0
        public void setWebPropertiesTest()
        {
            Hashtable properties = new Hashtable();

            properties.SetProperty("isMatterActive", "1");



            using (SPWeb web = new SPSite(UnitTest.Default.testWebUrl).OpenWeb())
            {
                Provisioning.setWebProperties(web, properties);
            }
        }
コード例 #4
0
ファイル: Program.cs プロジェクト: vamon1122/DatabaseSyncTool
        static void Main(string[] args)
        {
            // this introduction article is worth a read
            // https://visualstudiomagazine.com/articles/2012/06/01/database-synchronization-with-the-microsoft-sync-framework.aspx
            // sync framework tips from TechNet
            // https://social.technet.microsoft.com/wiki/contents/articles/1858.sync-framework-tips-and-troubleshooting.aspx
            // might want to look at this too for Change Tracking
            // https://mentormate.com/blog/database-synchronization-with-microsoft-sync-framework/

            Provisioning.CreateProviderProvision("BenTableScope", "BenTable", DataStore.ServerConn);
            Console.WriteLine("BenTableScope was created!");
            Console.ReadLine();
            Provisioning.CreateProviderProvision("ProductsScope", "Products", DataStore.ServerConn);
            Provisioning.CreateProviderProvision("OrdersScope", "Orders", DataStore.ServerConn);

            return;
        }
コード例 #5
0
        private void Button_DeprovisionClient_Click(object sender, EventArgs e)
        {
            if (ClientConnectionStringExists())
            {
                try
                {
                    Provisioning.DeprovisionDatabase(InputClientConnectionString.Text);
                }
                catch (DbNotProvisionedException)
                {
                    string            message = "This database has already been unsubscribed!";
                    string            caption = "Already Unsubscribed";
                    MessageBoxButtons buttons = MessageBoxButtons.OK;
                    MessageBox.Show(message, caption, buttons);
                }
            }

            UpdateAllLists();
        }
コード例 #6
0
        private void UpdateUnsyncedTablesList()
        {
            CheckedListBox_UnprovisionedProviderTables.Items.Clear();

            if (!string.IsNullOrEmpty(ProviderConnectionString) && !string.IsNullOrWhiteSpace(ProviderConnectionString)) //Using 'ProviderConnectionExists()' would cause a message to be shown
            {
                if (!string.IsNullOrEmpty(ClientConnectionString) && !string.IsNullOrWhiteSpace(ClientConnectionString)) //Using 'ClientConnectionExists()' would cause a message to be shown
                {
                    foreach (string tableName in Provisioning.GetUnsyncedTables(ProviderConnectionString, ClientConnectionString))
                    {
                        CheckedListBox_UnprovisionedProviderTables.Items.Add(tableName);
                    }
                }
                else
                {
                    foreach (string tableName in Provisioning.GetBaseTables(ProviderConnectionString))
                    {
                        CheckedListBox_UnprovisionedProviderTables.Items.Add(tableName);
                    }
                }
            }
        }
コード例 #7
0
ファイル: syncing.cs プロジェクト: s-chand/qmap
    /// <summary>
    /// Sync a single scope from the client to the server.
    /// </summary>
    /// <param name="server">Provider for the server.</param>
    /// <param name="client">Provider for the client.</param>
    /// <param name="tablename">The able name to sync.</param>
    public static SyncOperationStatistics syncscope(SqlConnection server, SqlConnection client,
                                                    string scope, SyncDirectionOrder order,
                                                    Action <object, DbApplyingChangesEventArgs> callback,
                                                    Action <object, DbApplyingChangesEventArgs> mastercallback)
    {
        // If we are only doing a download and the scope on the database
        // is out of date then we need to reprovision the data, but for now just
        // error.
        if (order == SyncDirectionOrder.Download &&
            ScopesDiffer(server, client, scope))
        {
            ProgressUpdate("Scope has changed on server. Reprovisoning client");
            Provisioning.ProvisionTable(server, client, scope, true);
        }
        else if (order != SyncDirectionOrder.Download &&
                 ScopesDiffer(server, client, scope))
        {
            throw new DbSyncException("Can not sync twoway tables with changed scopes");
        }

        using (SqlSyncProvider masterProvider = new SqlSyncProvider(scope, server),
               slaveProvider = new SqlSyncProvider(scope, client))
        {
            SyncOrchestrator orchestrator = new SyncOrchestrator
            {
                LocalProvider  = slaveProvider,
                RemoteProvider = masterProvider,
                Direction      = order
            };

            slaveProvider.ApplyingChanges   += new EventHandler <DbApplyingChangesEventArgs>(callback);
            masterProvider.ApplyingChanges  += new EventHandler <DbApplyingChangesEventArgs>(mastercallback);
            slaveProvider.ApplyChangeFailed += slaveProvider_ApplyChangeFailed;
            return(orchestrator.Synchronize());
        }
    }
コード例 #8
0
 private void Button_SyncNow_Click(object sender, EventArgs e)
 {
     if (ClientConnectionStringExists() && ProviderConnectionStringExists())
     {
         foreach (string tableName in Provisioning.GetProvisionedTables(ClientConnectionString))
         {
             if (Provisioning.GetProvisionedTables(ProviderConnectionString).Contains(tableName.ToString()))
             {
                 try
                 {
                     txtStatus.Text += Sync.Synchronise(tableName + "Scope", ProviderConnectionString, ClientConnectionString);
                 }
                 catch
                 {
                     MessageBox.Show(string.Format("There was an error whilst syncing the \"{0}\" table. Please check the log.", tableName.ToString()), "Sync Error", MessageBoxButtons.OK);
                 }
             }
             else
             {
                 MessageBox.Show(string.Format("The \"{0}\" table did not exist on the provider database anymore.", tableName.ToString()), "Sync Error", MessageBoxButtons.OK);
             }
         }
     }
 }
コード例 #9
0
        private void SetupClientWithMockEndpoints()
        {
            _client = new AquariusClient
            {
                ServerVersion = CreateDeveloperBuild()
            };

            _mockPublish       = CreateMockServiceClient();
            _mockAcquisition   = CreateMockServiceClient();
            _mockProvisioning  = CreateMockServiceClient();
            _mockAuthenticator = CreateMockAuthenticator();

            var mockHost = "http://example.com";

            _client.AddServiceClient(AquariusClient.ClientType.PublishJson, _mockPublish, PublishV2.ResolveEndpoint(mockHost));
            _client.AddServiceClient(AquariusClient.ClientType.AcquisitionJson, _mockAcquisition, AcquisitionV2.ResolveEndpoint(mockHost));
            _client.AddServiceClient(AquariusClient.ClientType.ProvisioningJson, _mockProvisioning, Provisioning.ResolveEndpoint(mockHost));

            _client.Connection = new Connection(
                _fixture.Create <string>(),
                _fixture.Create <string>(),
                _fixture.Create <string>(),
                _mockAuthenticator,
                connection => { });
        }
コード例 #10
0
 static void Main(string[] args)
 {
     Provisioning.CreateClientProvision("ProductsScope", DataStore.ClientConn, DataStore.ServerConn);
     Provisioning.CreateClientProvision("OrdersScope", DataStore.ClientConn, DataStore.ServerConn);
 }
コード例 #11
0
        private void Button_ProvisionTables_Click(object sender, EventArgs e)
        {
            if (ClientConnectionStringExists() && ProviderConnectionStringExists())
            {
                ProvisionTablesOnProvider();
                ProvisionTablesOnClient();
            }

            UpdateAllLists();

            void ProvisionTablesOnClient()
            {
                if (ClientConnectionStringExists() && ProviderConnectionStringExists())
                {
                    foreach (var itemChecked in CheckedListBox_UnprovisionedProviderTables.CheckedItems)
                    {
                        if (Provisioning.GetProvisionedTables(ProviderConnectionString).Contains(itemChecked.ToString()))
                        {
                            try
                            {
                                Provisioning.ProvisionTableOnClient(itemChecked.ToString() + "Scope", ProviderConnectionString, ClientConnectionString);
                            }
                            catch
                            {
                                MessageBox.Show(string.Format("There was an error whilst provisioning the \"{0}\" table on the client database. Please check the log.", itemChecked.ToString()), "Provisioning Error", MessageBoxButtons.OK);
                            }
                        }
                        else
                        {
                            MessageBox.Show(string.Format("Could not provision the table on the client. The \"{0}\" table did not exist on the provider database anymore.", itemChecked.ToString()), "Provisioning Error", MessageBoxButtons.OK);
                        }
                    }
                    //MessageBox.Show("All tables were successfully provisioned on the client database.", "Success", MessageBoxButtons.OK);
                }
            }

            void ProvisionTablesOnProvider()
            {
                if (ProviderConnectionStringExists())
                {
                    foreach (var itemChecked in CheckedListBox_UnprovisionedProviderTables.CheckedItems)
                    {
                        if (Provisioning.GetUnprovisionedTables(ProviderConnectionString).Contains(itemChecked.ToString()))
                        {
                            try
                            {
                                Provisioning.ProvisionTableOnProvider(itemChecked.ToString() + "Scope", itemChecked.ToString(), ProviderConnectionString);
                            }
                            catch
                            {
                                MessageBox.Show(string.Format("There was an error whilst provisioning the \"{0}\" table on the provider database. Please check the log.", itemChecked.ToString()), "Provisioning Error", MessageBoxButtons.OK);
                            }
                        }
                        else
                        {
                            //MessageBox.Show(string.Format("The \"{0}\" table has already been provisioned on the provider!", itemChecked.ToString()), "Provisioning Error", MessageBoxButtons.OK);
                        }

                        //MessageBox.Show("All tables were successfully provisioned on the provider database.", "Success", MessageBoxButtons.OK);
                    }
                }
            }
        }