public void RemoveSyncGroup(SyncGroup syncGroup) { Settings.SyncGroups.Remove(syncGroup); syncGroup.Leds.CollectionChanged -= syncGroup.LedsChangedEventHandler; syncGroup.LedGroup.Detach(); syncGroup.LedGroup = null; }
public SampleSyncAgent() { //Instantiate a client synchronization provider and specify it //as the local provider for this synchronization agent. this.LocalProvider = new SampleClientSyncProvider(); //Instantiate a server synchronization provider and specify it //as the remote provider for this synchronization agent. this.RemoteProvider = new SampleServerSyncProvider(); //Create a Customer SyncGroup. This is not required //for the single table we are synchronizing; it is typically //used so that changes to multiple related tables are //synchronized at the same time. SyncGroup customerSyncGroup = new SyncGroup("Customer"); //Add the Customer table: specify a synchronization direction of //DownloadOnly and that an existing table should be dropped. //<snippetOCS_CS_DownloadOnly_CustomerSyncTable> SyncTable customerSyncTable = new SyncTable("Customer"); customerSyncTable.CreationOption = TableCreationOption.DropExistingOrCreateNewTable; customerSyncTable.SyncDirection = SyncDirection.DownloadOnly; customerSyncTable.SyncGroup = customerSyncGroup; this.Configuration.SyncTables.Add(customerSyncTable); //</snippetOCS_CS_DownloadOnly_CustomerSyncTable> }
public SyncBrush(SyncGroup syncGroup) { this._syncGroup = syncGroup; syncGroup.PropertyChanged += SyncGroupOnPropertyChanged; _syncLed = syncGroup.SyncLed?.GetLed(); }
public TestDynamicsCrmSyncAgent(string sqlCompactConnectionString, string crmConnectionString) { //Instantiate a client synchronization provider and specify it //as the local provider for this synchronization agent. this.LocalProvider = new TestClientSyncProvider(sqlCompactConnectionString); //Instantiate a server synchronization provider and specify it //as the remote provider for this synchronization agent. this.RemoteProvider = new TestDynamicsCrmServerSyncProvider(crmConnectionString); //Create a Customer SyncGroup. This is not required //for the single table we are synchronizing; it is typically //used so that changes to multiple related tables are //synchronized at the same time. SyncGroup customerSyncGroup = new SyncGroup("dynamics"); //Add the Customer table: specify a synchronization direction of //Bidirectional, and that an existing table should be dropped. SyncTable customerSyncTable = new SyncTable(TestDynamicsCrmServerSyncProvider.TestEntityName); customerSyncTable.CreationOption = TableCreationOption.DropExistingOrCreateNewTable; customerSyncTable.SyncDirection = SyncDirection.Bidirectional; customerSyncTable.SyncGroup = customerSyncGroup; this.Configuration.SyncTables.Add(customerSyncTable); }
public void CloudEndpointInvokeChangeDetectionTest() { var handler = new RecordedDelegatingHandler { StatusCodeToReturn = HttpStatusCode.OK }; using (MockContext context = MockContext.Start(this.GetType())) { IResourceManagementClient resourcesClient = StorageSyncManagementTestUtilities.GetResourceManagementClient(context, handler); IStorageSyncManagementClient storageSyncManagementClient = StorageSyncManagementTestUtilities.GetStorageSyncManagementClient(context, handler); // Create ResourceGroup string resourceGroupName = StorageSyncManagementTestUtilities.CreateResourceGroup(resourcesClient); // Create CloudEndpoint Name string storageSyncServiceName = TestUtilities.GenerateName("sss-cepchangedetection"); string syncGroupName = TestUtilities.GenerateName("sg-cepchangedetection"); string cloudEndpointName = TestUtilities.GenerateName("cepchangedetection"); var storageSyncServiceParameters = StorageSyncManagementTestUtilities.GetDefaultStorageSyncServiceParameters(); var syncGroupParameters = StorageSyncManagementTestUtilities.GetDefaultSyncGroupParameters(); var cloudEndpointParameters = StorageSyncManagementTestUtilities.GetDefaultCloudEndpointParameters(); StorageSyncService storageSyncServiceResource = storageSyncManagementClient.StorageSyncServices.Create(resourceGroupName, storageSyncServiceName, storageSyncServiceParameters); Assert.NotNull(storageSyncServiceResource); StorageSyncManagementTestUtilities.VerifyStorageSyncServiceProperties(storageSyncServiceResource, true); SyncGroup syncGroupResource = storageSyncManagementClient.SyncGroups.Create(resourceGroupName, storageSyncServiceResource.Name, syncGroupName, syncGroupParameters); Assert.NotNull(syncGroupResource); StorageSyncManagementTestUtilities.VerifySyncGroupProperties(syncGroupResource, true); CloudEndpoint cloudEndpointResource = storageSyncManagementClient.CloudEndpoints.Create(resourceGroupName, storageSyncServiceResource.Name, syncGroupResource.Name, cloudEndpointName, cloudEndpointParameters); Assert.NotNull(cloudEndpointResource); StorageSyncManagementTestUtilities.VerifyCloudEndpointProperties(cloudEndpointResource, true); // invoke with directory path storageSyncManagementClient.CloudEndpoints.TriggerChangeDetection( resourceGroupName: resourceGroupName, storageSyncServiceName: storageSyncServiceName, syncGroupName: syncGroupName, cloudEndpointName: cloudEndpointName, parameters: new TriggerChangeDetectionParameters( directoryPath: "", changeDetectionMode: ChangeDetectionMode.Recursive)); // invoke with individual paths storageSyncManagementClient.CloudEndpoints.TriggerChangeDetection( resourceGroupName: resourceGroupName, storageSyncServiceName: storageSyncServiceName, syncGroupName: syncGroupName, cloudEndpointName: cloudEndpointName, parameters: new TriggerChangeDetectionParameters( paths: new string[] { "dir1/subdir1", "file.txt" })); storageSyncManagementClient.CloudEndpoints.Delete(resourceGroupName, storageSyncServiceResource.Name, syncGroupName, cloudEndpointName); storageSyncManagementClient.SyncGroups.Delete(resourceGroupName, storageSyncServiceResource.Name, syncGroupName); storageSyncManagementClient.StorageSyncServices.Delete(resourceGroupName, storageSyncServiceResource.Name); StorageSyncManagementTestUtilities.RemoveResourceGroup(resourcesClient, resourceGroupName); } }
public SampleSyncAgent() { //Instantiate a client synchronization provider and specify it //as the local provider for this synchronization agent. this.LocalProvider = new SampleClientSyncProvider(); //Instantiate a server synchronization provider and specify it //as the remote provider for this synchronization agent. this.RemoteProvider = new SampleServerSyncProvider(); //<snippetOCS_CS_Batching_SyncGroupAndTables> //Create a SyncGroup so that changes to Customer //and OrderHeader are made in one transaction. SyncGroup customerOrderSyncGroup = new SyncGroup("CustomerOrder"); //Add each table: specify a synchronization direction of //DownloadOnly. SyncTable customerSyncTable = new SyncTable("Customer"); customerSyncTable.CreationOption = TableCreationOption.DropExistingOrCreateNewTable; customerSyncTable.SyncDirection = SyncDirection.DownloadOnly; customerSyncTable.SyncGroup = customerOrderSyncGroup; this.Configuration.SyncTables.Add(customerSyncTable); SyncTable orderHeaderSyncTable = new SyncTable("OrderHeader"); orderHeaderSyncTable.CreationOption = TableCreationOption.DropExistingOrCreateNewTable; orderHeaderSyncTable.SyncDirection = SyncDirection.DownloadOnly; orderHeaderSyncTable.SyncGroup = customerOrderSyncGroup; this.Configuration.SyncTables.Add(orderHeaderSyncTable); //</snippetOCS_CS_Batching_SyncGroupAndTables> }
public void SyncGroupGetTest() { var handler = new RecordedDelegatingHandler { StatusCodeToReturn = HttpStatusCode.OK }; using (MockContext context = MockContext.Start(this.GetType().FullName)) { IResourceManagementClient resourcesClient = StorageSyncManagementTestUtilities.GetResourceManagementClient(context, handler); IStorageSyncManagementClient storageSyncManagementClient = StorageSyncManagementTestUtilities.GetStorageSyncManagementClient(context, handler); // Create ResourceGroup string resourceGroupName = StorageSyncManagementTestUtilities.CreateResourceGroup(resourcesClient); // Create SyncGroup Name string storageSyncServiceName = TestUtilities.GenerateName("ssscreate-sgget"); string syncGroupName = TestUtilities.GenerateName("sgget"); var storageSyncServiceParameters = StorageSyncManagementTestUtilities.GetDefaultStorageSyncServiceParameters(); var syncGroupParameters = StorageSyncManagementTestUtilities.GetDefaultSyncGroupParameters(); StorageSyncService storageSyncServiceResource = storageSyncManagementClient.StorageSyncServices.Create(resourceGroupName, storageSyncServiceName, storageSyncServiceParameters); Assert.NotNull(storageSyncServiceResource); StorageSyncManagementTestUtilities.VerifyStorageSyncServiceProperties(storageSyncServiceResource, true); SyncGroup syncGroupResource = storageSyncManagementClient.SyncGroups.Create(resourceGroupName, storageSyncServiceResource.Name, syncGroupName, syncGroupParameters); syncGroupResource = storageSyncManagementClient.SyncGroups.Get(resourceGroupName, storageSyncServiceResource.Name, syncGroupName); StorageSyncManagementTestUtilities.VerifySyncGroupProperties(syncGroupResource, false); storageSyncManagementClient.SyncGroups.Delete(resourceGroupName, storageSyncServiceResource.Name, syncGroupName); storageSyncManagementClient.StorageSyncServices.Delete(resourceGroupName, storageSyncServiceResource.Name); StorageSyncManagementTestUtilities.RemoveResourceGroup(resourcesClient, resourceGroupName); } }
private static void AddSync(string uid, Sync sync) { if (!_syncGroups.ContainsKey(uid)) { _syncGroups[uid] = new SyncGroup(); } _syncGroups[uid][sync.RequestId] = sync; }
private void RegisterSyncGroup(SyncGroup syncGroup) { syncGroup.LedGroup = new ListLedGroup(syncGroup.Leds.GetLeds()) { Brush = new SyncBrush(syncGroup) }; syncGroup.LedsChangedEventHandler = (sender, args) => UpdateLedGroup(syncGroup.LedGroup, args); syncGroup.Leds.CollectionChanged += syncGroup.LedsChangedEventHandler; }
public static void VerifySyncGroupProperties(SyncGroup resource, bool useDefaults) { Assert.NotNull(resource); Assert.NotNull(resource.Id); Assert.NotNull(resource.Name); // Enable SyncGroup tags when this feature is completed as SyncGroupMetadata if (useDefaults) { } }
public SampleSyncAgent() { //Instantiate a client synchronization provider and specify it //as the local provider for this synchronization agent. this.LocalProvider = new SampleClientSyncProvider(); //Instantiate a server synchronization provider and specify it //as the remote provider for this synchronization agent. this.RemoteProvider = new SampleServerSyncProvider(); //<snippetOCS_CS_Filter_Builder_SyncGroupAndTables> //Create two SyncGroups so that changes to OrderHeader //and OrderDetail are made in one transaction. Depending on //application requirements, you might include Customer //in the same group. SyncGroup customerSyncGroup = new SyncGroup("Customer"); SyncGroup orderSyncGroup = new SyncGroup("Order"); //Add each table: specify a synchronization direction of //DownloadOnly. SyncTable customerSyncTable = new SyncTable("Customer"); customerSyncTable.CreationOption = TableCreationOption.DropExistingOrCreateNewTable; customerSyncTable.SyncDirection = SyncDirection.DownloadOnly; customerSyncTable.SyncGroup = customerSyncGroup; this.Configuration.SyncTables.Add(customerSyncTable); SyncTable orderHeaderSyncTable = new SyncTable("OrderHeader"); orderHeaderSyncTable.CreationOption = TableCreationOption.DropExistingOrCreateNewTable; orderHeaderSyncTable.SyncDirection = SyncDirection.DownloadOnly; orderHeaderSyncTable.SyncGroup = orderSyncGroup; this.Configuration.SyncTables.Add(orderHeaderSyncTable); SyncTable orderDetailSyncTable = new SyncTable("OrderDetail"); orderDetailSyncTable.CreationOption = TableCreationOption.DropExistingOrCreateNewTable; orderDetailSyncTable.SyncDirection = SyncDirection.DownloadOnly; orderDetailSyncTable.SyncGroup = orderSyncGroup; this.Configuration.SyncTables.Add(orderDetailSyncTable); //</snippetOCS_CS_Filter_Builder_SyncGroupAndTables> //Specify a value for the @SalesPerson parameter that is added //in the server synchronization provider. This value would //typically be provided by a user in the application, but we //have hardcoded it here for convenience. //<snippetOCS_CS_Filter_Builder_AgentSyncParam> this.Configuration.SyncParameters.Add( new SyncParameter("@SalesPerson", "Brenda Diaz")); //</snippetOCS_CS_Filter_Builder_AgentSyncParam> }
public void CloudEndpointDeleteTest() { var handler = new RecordedDelegatingHandler { StatusCodeToReturn = HttpStatusCode.OK }; using (MockContext context = MockContext.Start(this.GetType())) { IResourceManagementClient resourcesClient = StorageSyncManagementTestUtilities.GetResourceManagementClient(context, handler); IStorageSyncManagementClient storageSyncManagementClient = StorageSyncManagementTestUtilities.GetStorageSyncManagementClient(context, handler); // Create ResourceGroup string resourceGroupName = StorageSyncManagementTestUtilities.CreateResourceGroup(resourcesClient); // Create CloudEndpoint Name string storageSyncServiceName = TestUtilities.GenerateName("sss-cepdelete"); string syncGroupName = TestUtilities.GenerateName("sg-cepdelete"); string cloudEndpointName = TestUtilities.GenerateName("cepdelete"); var storageSyncServiceParameters = StorageSyncManagementTestUtilities.GetDefaultStorageSyncServiceParameters(); var syncGroupParameters = StorageSyncManagementTestUtilities.GetDefaultSyncGroupParameters(); var cloudEndpointParameters = StorageSyncManagementTestUtilities.GetDefaultCloudEndpointParameters(); StorageSyncService storageSyncServiceResource = storageSyncManagementClient.StorageSyncServices.Create(resourceGroupName, storageSyncServiceName, storageSyncServiceParameters); Assert.NotNull(storageSyncServiceResource); StorageSyncManagementTestUtilities.VerifyStorageSyncServiceProperties(storageSyncServiceResource, true); SyncGroup syncGroupResource = storageSyncManagementClient.SyncGroups.Create(resourceGroupName, storageSyncServiceResource.Name, syncGroupName, syncGroupParameters); Assert.NotNull(syncGroupResource); StorageSyncManagementTestUtilities.VerifySyncGroupProperties(syncGroupResource, true); // Delete CloudEndpoint before its created. storageSyncManagementClient.CloudEndpoints.Delete(resourceGroupName, storageSyncServiceResource.Name, syncGroupResource.Name, cloudEndpointName); CloudEndpoint cloudEndpointResource = storageSyncManagementClient.CloudEndpoints.Create(resourceGroupName, storageSyncServiceResource.Name, syncGroupResource.Name, cloudEndpointName, cloudEndpointParameters); Assert.NotNull(cloudEndpointResource); StorageSyncManagementTestUtilities.VerifyCloudEndpointProperties(cloudEndpointResource, true); // Delete CloudEndpoint storageSyncManagementClient.CloudEndpoints.Delete(resourceGroupName, storageSyncServiceResource.Name, syncGroupResource.Name, cloudEndpointName); // Delete CloudEndpoint which was just deleted storageSyncManagementClient.CloudEndpoints.Delete(resourceGroupName, storageSyncServiceResource.Name, syncGroupResource.Name, cloudEndpointName); storageSyncManagementClient.SyncGroups.Delete(resourceGroupName, storageSyncServiceResource.Name, syncGroupName); storageSyncManagementClient.StorageSyncServices.Delete(resourceGroupName, storageSyncServiceResource.Name); StorageSyncManagementTestUtilities.RemoveResourceGroup(resourcesClient, resourceGroupName); } }
public SampleSyncAgent() { //Instantiate a client synchronization provider and specify it //as the local provider for this synchronization agent. this.LocalProvider = new SampleClientSyncProvider(); //Instantiate a server synchronization provider and specify it //as the remote provider for this synchronization agent. this.RemoteProvider = new SampleServerSyncProvider(); //Create two SyncGroups so that changes to OrderHeader //and OrderDetail are made in one transaction. Depending on //application requirements, you might include Customer //and CustomerContact in the same group. SyncGroup customerSyncGroup = new SyncGroup("Customer"); SyncGroup orderSyncGroup = new SyncGroup("Order"); //Add each table: specify a synchronization direction of //Bidirectional. We create the Customer table before sync: //we set CreationOption to UseExistingTableOrFail so //we are sure that the table exists. SyncTable customerSyncTable = new SyncTable("Customer"); customerSyncTable.CreationOption = TableCreationOption.UseExistingTableOrFail; customerSyncTable.SyncDirection = SyncDirection.Bidirectional; customerSyncTable.SyncGroup = customerSyncGroup; this.Configuration.SyncTables.Add(customerSyncTable); SyncTable customerContactSyncTable = new SyncTable("CustomerContact"); customerContactSyncTable.CreationOption = TableCreationOption.DropExistingOrCreateNewTable; customerContactSyncTable.SyncDirection = SyncDirection.Bidirectional; customerContactSyncTable.SyncGroup = customerSyncGroup; this.Configuration.SyncTables.Add(customerContactSyncTable); SyncTable orderHeaderSyncTable = new SyncTable("OrderHeader"); orderHeaderSyncTable.CreationOption = TableCreationOption.DropExistingOrCreateNewTable; orderHeaderSyncTable.SyncDirection = SyncDirection.Bidirectional; orderHeaderSyncTable.SyncGroup = orderSyncGroup; this.Configuration.SyncTables.Add(orderHeaderSyncTable); SyncTable orderDetailSyncTable = new SyncTable("OrderDetail"); orderDetailSyncTable.CreationOption = TableCreationOption.DropExistingOrCreateNewTable; orderDetailSyncTable.SyncDirection = SyncDirection.Bidirectional; orderDetailSyncTable.SyncGroup = orderSyncGroup; this.Configuration.SyncTables.Add(orderDetailSyncTable); }
public SampleSyncAgent() { //Instantiate a client synchronization provider and specify it //as the local provider for this synchronization agent. this.LocalProvider = new SampleClientSyncProvider(); //Instantiate a server synchronization provider and specify it //as the remote provider for this synchronization agent. this.RemoteProvider = new SampleServerSyncProvider(); //Create two SyncGroups so that changes to OrderHeader //and OrderDetail are made in one transaction. Depending on //application requirements, you might include Customer //in the same group. SyncGroup customerSyncGroup = new SyncGroup("Customer"); SyncGroup orderSyncGroup = new SyncGroup("Order"); //Add each table: specify a synchronization direction of //Bidirectional. SyncTable customerSyncTable = new SyncTable("Customer"); customerSyncTable.CreationOption = TableCreationOption.DropExistingOrCreateNewTable; customerSyncTable.SyncDirection = SyncDirection.Bidirectional; customerSyncTable.SyncGroup = customerSyncGroup; this.Configuration.SyncTables.Add(customerSyncTable); SyncTable orderHeaderSyncTable = new SyncTable("OrderHeader"); orderHeaderSyncTable.CreationOption = TableCreationOption.DropExistingOrCreateNewTable; orderHeaderSyncTable.SyncDirection = SyncDirection.Bidirectional; orderHeaderSyncTable.SyncGroup = orderSyncGroup; this.Configuration.SyncTables.Add(orderHeaderSyncTable); SyncTable orderDetailSyncTable = new SyncTable("OrderDetail"); orderDetailSyncTable.CreationOption = TableCreationOption.DropExistingOrCreateNewTable; orderDetailSyncTable.SyncDirection = SyncDirection.Bidirectional; orderDetailSyncTable.SyncGroup = orderSyncGroup; this.Configuration.SyncTables.Add(orderDetailSyncTable); //Handle the StateChanged and SessionProgress events, and //display information to the console. SampleStatsAndProgress sampleStats = new SampleStatsAndProgress(); this.StateChanged += new EventHandler <SessionStateChangedEventArgs>(sampleStats.DisplaySessionProgress); this.SessionProgress += new EventHandler <SessionProgressEventArgs>(sampleStats.DisplaySessionProgress); }
private void RegisterSyncGroup(SyncGroup syncGroup) { try { syncGroup.LedGroup = new ListLedGroup(syncGroup.Leds.GetLeds()) { Brush = new SyncBrush(syncGroup) }; syncGroup.LedsChangedEventHandler = (sender, args) => UpdateLedGroup(syncGroup.LedGroup, args); syncGroup.Leds.CollectionChanged += syncGroup.LedsChangedEventHandler; } catch (Exception ex) { Logger.Error("Error registering group: " + syncGroup.Name); Logger.Error(ex); } }
public SampleSyncAgent() { //Instantiate a client synchronization provider and specify it //as the local provider for this synchronization agent. this.LocalProvider = new SampleClientSyncProvider(); //Instantiate a server synchronization provider and specify it //as the remote provider for this synchronization agent. this.RemoteProvider = new SampleServerSyncProvider(); //Create two SyncGroups so that changes to OrderHeader //and OrderDetail are made in one transaction. Depending on //application requirements, you might include Customer //in the same group. SyncGroup customerSyncGroup = new SyncGroup("Customer"); SyncGroup orderSyncGroup = new SyncGroup("Order"); //Add each table: specify a synchronization direction of //Snapshot, and that any existing tables should be dropped. //<snippetOCS_CS_Snapshot_CustomerSyncTable> SyncTable customerSyncTable = new SyncTable("Customer"); customerSyncTable.CreationOption = TableCreationOption.DropExistingOrCreateNewTable; customerSyncTable.SyncDirection = SyncDirection.Snapshot; customerSyncTable.SyncGroup = customerSyncGroup; this.Configuration.SyncTables.Add(customerSyncTable); //</snippetOCS_CS_Snapshot_CustomerSyncTable> SyncTable orderHeaderSyncTable = new SyncTable("OrderHeader"); orderHeaderSyncTable.CreationOption = TableCreationOption.DropExistingOrCreateNewTable; orderHeaderSyncTable.SyncDirection = SyncDirection.Snapshot; orderHeaderSyncTable.SyncGroup = orderSyncGroup; this.Configuration.SyncTables.Add(orderHeaderSyncTable); SyncTable orderDetailSyncTable = new SyncTable("OrderDetail"); orderDetailSyncTable.CreationOption = TableCreationOption.DropExistingOrCreateNewTable; orderDetailSyncTable.SyncDirection = SyncDirection.Snapshot; orderDetailSyncTable.SyncGroup = orderSyncGroup; this.Configuration.SyncTables.Add(orderDetailSyncTable); }
/// <summary> /// Updates a sync group. /// </summary> /// <param name='operations'> /// The operations group for this extension method. /// </param> /// <param name='resourceGroupName'> /// The name of the resource group that contains the resource. You can obtain /// this value from the Azure Resource Manager API or the portal. /// </param> /// <param name='serverName'> /// The name of the server. /// </param> /// <param name='databaseName'> /// The name of the database on which the sync group is hosted. /// </param> /// <param name='syncGroupName'> /// The name of the sync group. /// </param> /// <param name='parameters'> /// The requested sync group resource state. /// </param> /// <param name='cancellationToken'> /// The cancellation token. /// </param> public static async Task <SyncGroup> BeginUpdateAsync(this ISyncGroupsOperations operations, string resourceGroupName, string serverName, string databaseName, string syncGroupName, SyncGroup parameters, CancellationToken cancellationToken = default(CancellationToken)) { using (var _result = await operations.BeginUpdateWithHttpMessagesAsync(resourceGroupName, serverName, databaseName, syncGroupName, parameters, null, cancellationToken).ConfigureAwait(false)) { return(_result.Body); } }
public void SyncGroupCRUDTest() { string testPrefix = "syncgroupcrudtest-"; using (SqlManagementTestContext context = new SqlManagementTestContext(this)) { ResourceGroup resourceGroup = context.CreateResourceGroup(); SqlManagementClient sqlClient = context.GetClient <SqlManagementClient>(); Server server = context.CreateServer(resourceGroup); // Create sync database string syncDatabaseName = SqlManagementTestUtilities.GenerateName(testPrefix + "sync"); Database syncDatabase = sqlClient.Databases.CreateOrUpdate(resourceGroup.Name, server.Name, syncDatabaseName, new Database() { Location = server.Location, }); Assert.NotNull(syncDatabase); Assert.NotNull(syncDatabase.Id); // Create database string testDatabaseName = SqlManagementTestUtilities.GenerateName(testPrefix + "test"); Database testDatabase = sqlClient.Databases.CreateOrUpdate(resourceGroup.Name, server.Name, testDatabaseName, new Database() { Location = server.Location, }); Assert.NotNull(testDatabase); // Create sync group string syncGroupName = SqlManagementTestUtilities.GenerateName(testPrefix + "syncgroup"); int interval1 = -1; // Manual string conflictPolicy = SyncConflictResolutionPolicy.MemberWin; SyncGroup createSyncGroup = sqlClient.SyncGroups.CreateOrUpdate(resourceGroup.Name, server.Name, testDatabaseName, syncGroupName, new SyncGroup { Interval = interval1, ConflictResolutionPolicy = conflictPolicy, SyncDatabaseId = syncDatabase.Id, HubDatabaseUserName = SqlManagementTestUtilities.DefaultLogin, HubDatabasePassword = SqlManagementTestUtilities.DefaultPassword }); Assert.NotNull(createSyncGroup); Assert.Equal(interval1, createSyncGroup.Interval); Assert.Equal(conflictPolicy, createSyncGroup.ConflictResolutionPolicy); Assert.Equal(syncDatabase.Id, createSyncGroup.SyncDatabaseId); // Get sync group SyncGroup getSyncGroup = sqlClient.SyncGroups.Get(resourceGroup.Name, server.Name, testDatabaseName, syncGroupName); Assert.NotNull(getSyncGroup); Assert.Equal(interval1, getSyncGroup.Interval); Assert.Equal(conflictPolicy, getSyncGroup.ConflictResolutionPolicy); Assert.Equal(syncDatabase.Id, getSyncGroup.SyncDatabaseId); // List sync group IPage <SyncGroup> listSyncGroups = sqlClient.SyncGroups.ListByDatabase(resourceGroup.Name, server.Name, testDatabaseName); Assert.NotNull(listSyncGroups); Assert.Equal(1, listSyncGroups.Count()); Assert.Equal(syncGroupName, listSyncGroups.Single().Name); // Update sync group int interval2 = 600; SyncGroup updateSyncGroup = sqlClient.SyncGroups.Update(resourceGroup.Name, server.Name, testDatabaseName, syncGroupName, new SyncGroup { Interval = interval2 }); Assert.NotNull(updateSyncGroup); Assert.Equal(interval2, updateSyncGroup.Interval); // Get updated sync group SyncGroup getUpdatedSyncGroup = sqlClient.SyncGroups.Get(resourceGroup.Name, server.Name, testDatabaseName, syncGroupName); Assert.NotNull(getUpdatedSyncGroup); Assert.Equal(interval2, getUpdatedSyncGroup.Interval); Assert.Equal(conflictPolicy, getUpdatedSyncGroup.ConflictResolutionPolicy); Assert.Equal(syncDatabase.Id, getUpdatedSyncGroup.SyncDatabaseId); // Update sync group with an empty model Assert.Throws <CloudException>(() => { sqlClient.SyncGroups.Update(resourceGroup.Name, server.Name, testDatabaseName, syncGroupName, new SyncGroup()); }); // Refresh hub schema sqlClient.SyncGroups.RefreshHubSchema(resourceGroup.Name, server.Name, testDatabaseName, syncGroupName); // List hub schemas IPage <SyncFullSchemaProperties> listHubSchemas = sqlClient.SyncGroups.ListHubSchemas(resourceGroup.Name, server.Name, testDatabaseName, syncGroupName); Assert.NotNull(listHubSchemas); // List logs string startTime = "2017-01-01T00:00:00"; string endTime = "2099-12-31T00:00:00"; string logType = SyncGroupLogType.All; IPage <SyncGroupLogProperties> listLogs = sqlClient.SyncGroups.ListLogs(resourceGroup.Name, server.Name, testDatabaseName, syncGroupName, startTime, endTime, logType); Assert.NotNull(listLogs); foreach (SyncGroupLogProperties log in listLogs) { Assert.NotNull(log); Assert.NotNull(log.Timestamp); Assert.NotNull(log.Type); Assert.NotNull(log.Details); Assert.NotNull(log.Source); } // Delete sync group sqlClient.SyncGroups.Delete(resourceGroup.Name, server.Name, testDatabaseName, syncGroupName); } }
public void AddSyncGroup(SyncGroup syncGroup) { Settings.SyncGroups.Add(syncGroup); RegisterSyncGroup(syncGroup); }
protected override IConfigurable ConvertDataObjectToPresentationObject(IConfigurable dataObject) { return(SyncGroup.FromDataObject((ADGroup)dataObject)); }
private static void VerifySyncGroupInformation(SyncGroup syncGroup, int interval, string syncDatabaseId, string hubDatabaseUserName, ConflictResolutionPolicyType?conflictResolutionPolicy) { Assert.Equal(interval, syncGroup.Properties.Interval); Assert.Equal(conflictResolutionPolicy, syncGroup.Properties.ConflictResolutionPolicy); Assert.Equal(syncDatabaseId, syncGroup.Properties.SyncDatabaseId); }
// SqlCeConnection ce = null; public void CreateInitialLocalDB(string strConnectionString, bool isCreated) { try { strClientConnectionString = strConnectionString; // sync = new SqlCeClientSyncProvider(strClientConnectionString); clientSyncProvider = new SqlCeClientSyncProvider(strClientConnectionString); if (!isCreated) { SqlCeEngine clientEngine = new SqlCeEngine(strClientConnectionString); clientEngine.CreateDatabase(); clientEngine.Dispose(); tblCallTable = CreateCallTable(); tblLeadsTable = CreateLeadsTable(); tblCallBackTable = CreateCallBackTable(); } else { tblCallTable = new SyncTable("Call"); tblCallTable.SyncDirection = SyncDirection.UploadOnly; tblLeadsTable = new SyncTable("Leads"); tblLeadsTable.SyncDirection = SyncDirection.UploadOnly; tblCallBackTable = new SyncTable("CallBack"); tblCallBackTable.SyncDirection = SyncDirection.UploadOnly; } strClientConnectionString = strConnectionString; // sync = new SqlCeClientSyncProvider(strClientConnectionString); serverSyncProvider = new DbServerSyncProvider(); syncAgent = new SyncAgent(); // syncAgent.ServerSyncProvider = serverSyncProvider; syncAgent.RemoteProvider = serverSyncProvider; serverConnection = new SqlConnection(VMuktiInfo.MainConnectionString); serverSyncProvider.Connection = serverConnection; //SqlCommand cmdAnchor = new SqlCommand(); // cmdAnchor.CommandType = CommandType.Text; // cmdAnchor.CommandText = "SELECT @@DBTS"; // serverSyncProvider.SelectNewAnchorCommand = cmdAnchor; // SqlCommand cmdClientId = new SqlCommand(); // cmdClientId.CommandType = CommandType.Text; // cmdClientId.CommandText = "SELECT 1"; // serverSyncProvider.SelectClientIdCommand = cmdClientId; //syncAgent.ClientSyncProvider = clientSyncProvider; syncAgent.LocalProvider = clientSyncProvider; myGroup = new SyncGroup("DialerGroup"); tblCallTable.SyncGroup = myGroup; tblLeadsTable.SyncGroup = myGroup; tblCallBackTable.SyncGroup = myGroup; //syncAgent.SyncTables.Add(tblCallTable); //syncAgent.SyncTables.Add(tblLeadsTable); //syncAgent.SyncTables.Add(tblCallBackTable); syncAgent.Configuration.SyncTables.Add(tblCallTable); syncAgent.Configuration.SyncTables.Add(tblLeadsTable); syncAgent.Configuration.SyncTables.Add(tblCallBackTable); CallAdapter = new SqlSyncAdapterBuilder(); CallAdapter.Connection = serverConnection; CallAdapter.SyncDirection = SyncDirection.UploadOnly; CallAdapter.TableName = "Call"; CallAdapter.DataColumns.Add("ID"); CallAdapter.DataColumns.Add("LeadID"); CallAdapter.DataColumns.Add("CalledDate"); CallAdapter.DataColumns.Add("ModifiedDate"); CallAdapter.DataColumns.Add("ModifiedBy"); CallAdapter.DataColumns.Add("GeneratedBy"); CallAdapter.DataColumns.Add("StartDate"); CallAdapter.DataColumns.Add("StartTime"); CallAdapter.DataColumns.Add("DurationInSecond"); CallAdapter.DataColumns.Add("DespositionID"); CallAdapter.DataColumns.Add("CampaignID"); CallAdapter.DataColumns.Add("ConfID"); CallAdapter.DataColumns.Add("IsDeleted"); CallAdapter.DataColumns.Add("CallNote"); CallAdapter.DataColumns.Add("IsDNC"); CallAdapter.DataColumns.Add("IsGlobal"); CallAdapterSyncAdapter = CallAdapter.ToSyncAdapter(); CallAdapterSyncAdapter.DeleteCommand = null; serverSyncProvider.SyncAdapters.Add(CallAdapterSyncAdapter); LeadAdapter = new SqlSyncAdapterBuilder(); LeadAdapter.Connection = serverConnection; LeadAdapter.SyncDirection = SyncDirection.UploadOnly; LeadAdapter.TableName = "Leads"; LeadAdapter.DataColumns.Add("ID"); LeadAdapter.DataColumns.Add("PhoneNo"); LeadAdapter.DataColumns.Add("LeadFormatID"); LeadAdapter.DataColumns.Add("CreatedDate"); LeadAdapter.DataColumns.Add("CreatedBy"); LeadAdapter.DataColumns.Add("DeletedDate"); LeadAdapter.DataColumns.Add("DeletedBy"); LeadAdapter.DataColumns.Add("IsDeleted"); LeadAdapter.DataColumns.Add("ModifiedDate"); LeadAdapter.DataColumns.Add("ModifiedBy"); LeadAdapter.DataColumns.Add("DNCFlag"); LeadAdapter.DataColumns.Add("DNCBy"); LeadAdapter.DataColumns.Add("ListID"); LeadAdapter.DataColumns.Add("LocationID"); LeadAdapter.DataColumns.Add("RecycleCount"); LeadAdapter.DataColumns.Add("Status"); LeadAdapter.DataColumns.Add("IsGlobalDNC"); //LeadAdapter.DataColumns.Add("LastEditDate"); //LeadAdapter.DataColumns.Add("CreationDate"); LeadAdapterSyncAdapter = LeadAdapter.ToSyncAdapter(); LeadAdapterSyncAdapter.DeleteCommand = null; LeadAdapterSyncAdapter.InsertCommand = null; //LeadAdapterSyncAdapter.ColumnMappings.Add("Status", "Status"); //LeadAdapterSyncAdapter.ColumnMappings.Add("DNCFlag", "DNCFlag"); //LeadAdapterSyncAdapter.ColumnMappings.Add("DNCBy", "DNCBy"); serverSyncProvider.SyncAdapters.Add(LeadAdapterSyncAdapter); CallBackAdapter = new SqlSyncAdapterBuilder(); CallBackAdapter.Connection = serverConnection; CallBackAdapter.SyncDirection = SyncDirection.UploadOnly; CallBackAdapter.TableName = "CallBack"; CallBackAdapter.DataColumns.Add("ID"); CallBackAdapter.DataColumns.Add("CallID"); CallBackAdapter.DataColumns.Add("CallBackDate"); CallBackAdapter.DataColumns.Add("Comment"); CallBackAdapter.DataColumns.Add("IsPublic"); CallBackAdapter.DataColumns.Add("IsDeleted"); CallBackAdapterSyncAdapter = CallBackAdapter.ToSyncAdapter(); CallBackAdapterSyncAdapter.DeleteCommand = null; serverSyncProvider.SyncAdapters.Add(CallBackAdapterSyncAdapter); CheckPreviousSyncWithServer(); } catch (Exception ex) { VMuktiAPI.VMuktiHelper.ExceptionHandler(ex, "CreateInitialLocalDB()", "ClsUserDataService.cs"); //MessageBox.Show("CreateInitialLocalDB: " + ex.Message); } }
/// <summary> /// Updates a sync group. /// </summary> /// <param name='operations'> /// The operations group for this extension method. /// </param> /// <param name='resourceGroupName'> /// The name of the resource group that contains the resource. You can obtain /// this value from the Azure Resource Manager API or the portal. /// </param> /// <param name='serverName'> /// The name of the server. /// </param> /// <param name='databaseName'> /// The name of the database on which the sync group is hosted. /// </param> /// <param name='syncGroupName'> /// The name of the sync group. /// </param> /// <param name='parameters'> /// The requested sync group resource state. /// </param> public static SyncGroup BeginUpdate(this ISyncGroupsOperations operations, string resourceGroupName, string serverName, string databaseName, string syncGroupName, SyncGroup parameters) { return(operations.BeginUpdateAsync(resourceGroupName, serverName, databaseName, syncGroupName, parameters).GetAwaiter().GetResult()); }
/// <summary> /// Construct AzureSqlSyncGroupModel for Management.Sql.Models.syncGroup object /// </summary> /// <param name="resourceGroupName">Resource group name</param> /// <param name="serverName">Server name</param> /// <param name="databaseName">Databse name</param> /// <param name="syncGroup">sync group object</param> public AzureSqlSyncGroupModel(string resourceGroupName, string serverName, string databaseName, SyncGroup syncGroup) { ResourceGroupName = resourceGroupName; ServerName = serverName; DatabaseName = databaseName; ResourceId = syncGroup.Id; SyncGroupName = syncGroup.Name; IntervalInSeconds = syncGroup.Properties.Interval; SyncDatabaseId = syncGroup.Properties.SyncDatabaseId; HubDatabaseUserName = syncGroup.Properties.HubDatabaseUserName; ConflictResolutionPolicy = syncGroup.Properties.ConflictResolutionPolicy == null ? null : syncGroup.Properties.ConflictResolutionPolicy.ToString(); SyncState = syncGroup.Properties.SyncState; LastSyncTime = syncGroup.Properties.LastSyncTime; Schema = syncGroup.Properties.Schema == null ? null : new AzureSqlSyncGroupSchemaModel(syncGroup.Properties.Schema); }
private void PremadeSyncGroups() { AsusMainboardRGBDevice auraMB = RGBSurface.Instance.Devices.OfType <AsusMainboardRGBDevice>().First(); CorsairKeyboardRGBDevice corsairKeyboard = RGBSurface.Instance.Devices.OfType <CorsairKeyboardRGBDevice>().First(); double keyboardWidth = corsairKeyboard.Max(x => x.LedRectangle.Location.X); CorsairMousepadRGBDevice corsairMousepad = RGBSurface.Instance.Devices.OfType <CorsairMousepadRGBDevice>().First(); CorsairHeadsetStandRGBDevice corsairHeadsetStand = RGBSurface.Instance.Devices.OfType <CorsairHeadsetStandRGBDevice>().First(); List <CorsairCustomRGBDevice> corsairCustomDevices = RGBSurface.Instance.Devices.OfType <CorsairCustomRGBDevice>().ToList(); CorsairCustomRGBDevice stripOne = corsairCustomDevices[0]; CorsairCustomRGBDevice stripTwo = corsairCustomDevices[1]; CorsairCustomRGBDevice stripThree = corsairCustomDevices[2]; CorsairCustomRGBDevice stripFour = corsairCustomDevices[3]; CorsairCustomRGBDevice fanOne = corsairCustomDevices[4]; CorsairCustomRGBDevice fanTwo = corsairCustomDevices[5]; CorsairCustomRGBDevice fanThree = corsairCustomDevices[6]; CorsairCustomRGBDevice fanFour = corsairCustomDevices[7]; CorsairCustomRGBDevice fanFive = corsairCustomDevices[8]; CorsairCustomRGBDevice fanSix = corsairCustomDevices[9]; //CorsairCustomRGBDevice stripOne = surface.Devices.OfType<CorsairCustomRGBDevice>(). //backIO = 0 SyncLed backIO = new SyncLed(auraMB.ElementAt(0)); List <Led> backIOTargets = new List <Led>(); backIOTargets.AddRange(corsairKeyboard.Where(x => x.LedRectangle.Location.X <= keyboardWidth / 4).ToList()); backIOTargets.AddRange(corsairMousepad.Take(4)); backIOTargets.Add(corsairHeadsetStand.ElementAt(8)); backIOTargets.AddRange(stripOne); backIOTargets.AddRange(fanOne); backIOTargets.AddRange(fanTwo); SyncGroup syncBackIO = new SyncGroup { SyncLed = backIO, Leds = new ObservableCollection <SyncLed>(backIOTargets.Select(x => new SyncLed(x)).ToList()) }; RegisterSyncGroup(syncBackIO); //pch = 1 SyncLed pch = new SyncLed(auraMB.ElementAt(1)); List <Led> pchTargets = new List <Led>(); pchTargets.AddRange(corsairKeyboard.Where(x => x.LedRectangle.Location.X > keyboardWidth / 4 && x.LedRectangle.Location.X <= keyboardWidth / 2).ToList()); pchTargets.AddRange(corsairMousepad.Skip(4).Take(3)); pchTargets.Add(corsairHeadsetStand.ElementAt(6)); pchTargets.AddRange(stripThree); pchTargets.AddRange(fanFour); SyncGroup syncPch = new SyncGroup { SyncLed = pch, Leds = new ObservableCollection <SyncLed>(pchTargets.Select(x => new SyncLed(x)).ToList()) }; RegisterSyncGroup(syncPch); //headerOne = 2 SyncLed headerOne = new SyncLed(auraMB.ElementAt(2)); List <Led> headerOneTargets = new List <Led>(); headerOneTargets.AddRange(corsairKeyboard.Where(x => x.LedRectangle.Location.X > keyboardWidth / 2 && x.LedRectangle.Location.X <= keyboardWidth / 4 * 3).ToList()); headerOneTargets.AddRange(corsairMousepad.Skip(8).Take(3)); headerOneTargets.Add(corsairHeadsetStand.ElementAt(4)); headerOneTargets.AddRange(stripTwo); headerOneTargets.AddRange(fanThree); SyncGroup syncHeaderOne = new SyncGroup { SyncLed = headerOne, Leds = new ObservableCollection <SyncLed>(headerOneTargets.Select(x => new SyncLed(x)).ToList()) }; RegisterSyncGroup(syncHeaderOne); //headerTwo = 3 SyncLed headerTwo = new SyncLed(auraMB.ElementAt(3)); List <Led> headerTwoTargets = new List <Led>(); headerTwoTargets.AddRange(corsairKeyboard.Where(x => x.LedRectangle.Location.X > keyboardWidth / 4 * 3).ToList()); headerTwoTargets.AddRange(corsairMousepad.Skip(11).Take(4)); headerTwoTargets.Add(corsairHeadsetStand.ElementAt(2)); headerTwoTargets.AddRange(stripFour); headerTwoTargets.AddRange(fanFive); headerTwoTargets.AddRange(fanSix); SyncGroup syncHeaderTwo = new SyncGroup { SyncLed = headerTwo, Leds = new ObservableCollection <SyncLed>(headerTwoTargets.Select(x => new SyncLed(x)).ToList()) }; RegisterSyncGroup(syncHeaderTwo); //average backIO and pch List <SyncLed> avgBackPch = new List <SyncLed>() { backIO, pch }; List <Led> avgBackPchTargets = new List <Led>() { corsairHeadsetStand.ElementAt(7) }; AverageSyncGroup syncAvgBackPch = new AverageSyncGroup { SyncLed = new ObservableCollection <SyncLed>(avgBackPch.ToList()), Leds = new ObservableCollection <SyncLed>(avgBackPchTargets.Select(x => new SyncLed(x)).ToList()) }; RegisterAverageSyncGroup(syncAvgBackPch); //average backIO and headerTwo List <SyncLed> avgBackTwo = new List <SyncLed>() { backIO, headerTwo }; List <Led> avgBackTwoTargets = new List <Led>() { corsairHeadsetStand.ElementAt(1) }; AverageSyncGroup syncAvgBackTwo = new AverageSyncGroup { SyncLed = new ObservableCollection <SyncLed>(avgBackTwo.ToList()), Leds = new ObservableCollection <SyncLed>(avgBackTwoTargets.Select(x => new SyncLed(x)).ToList()) }; RegisterAverageSyncGroup(syncAvgBackTwo); //average pch and headerOne List <SyncLed> avgPchOne = new List <SyncLed>() { pch, headerOne }; List <Led> avgPchOneTargets = new List <Led>() { corsairHeadsetStand.ElementAt(5), corsairMousepad.ElementAt(7) }; AverageSyncGroup syncAvgPchOne = new AverageSyncGroup { SyncLed = new ObservableCollection <SyncLed>(avgPchOne.ToList()), Leds = new ObservableCollection <SyncLed>(avgPchOneTargets.Select(x => new SyncLed(x)).ToList()) }; RegisterAverageSyncGroup(syncAvgPchOne); //average headerOne and headerTwo List <SyncLed> avgOneTwo = new List <SyncLed>() { headerOne, headerTwo }; List <Led> avgOneTwoTargets = new List <Led>() { corsairHeadsetStand.ElementAt(3) }; AverageSyncGroup syncAvgOneTwo = new AverageSyncGroup { SyncLed = new ObservableCollection <SyncLed>(avgOneTwo.ToList()), Leds = new ObservableCollection <SyncLed>(avgOneTwoTargets.Select(x => new SyncLed(x)).ToList()) }; RegisterAverageSyncGroup(syncAvgOneTwo); //average backIO and pch and headerOne and headerTwo List <SyncLed> avgAll = new List <SyncLed>() { backIO, pch, headerOne, headerTwo }; List <Led> avgAllTargets = new List <Led>() { corsairHeadsetStand.ElementAt(0) }; AverageSyncGroup syncAvgAll = new AverageSyncGroup { SyncLed = new ObservableCollection <SyncLed>(avgAll.ToList()), Leds = new ObservableCollection <SyncLed>(avgAllTargets.Select(x => new SyncLed(x)).ToList()) }; RegisterAverageSyncGroup(syncAvgAll); }
/// <summary> /// Converts the response from the service to a powershell sync group object /// </summary> /// <param name="resourceGroupName">The resource group the sync group is in</param> /// <param name="serverName">The name of the server</param> /// <param name="databaseName">The name of the database</param> /// <param name="syncGroup">The sync group object from the response</param> /// <returns>The converted model</returns> public static AzureSqlSyncGroupModel CreateSyncGroupModelFromResponse(string resourceGroupName, string serverName, string databaseName, SyncGroup syncGroup) { return(new AzureSqlSyncGroupModel(resourceGroupName, serverName, databaseName, syncGroup)); }
public void CreateInitialLocalDB(string strConnectionString,bool isCreated) { try { strClientConnectionString = strConnectionString; // sync = new SqlCeClientSyncProvider(strClientConnectionString); clientSyncProvider = new SqlCeClientSyncProvider(strClientConnectionString); if (!isCreated) { SqlCeEngine clientEngine = new SqlCeEngine(strClientConnectionString); clientEngine.CreateDatabase(); clientEngine.Dispose(); tblCallTable = CreateCallTable(); tblLeadsTable = CreateLeadsTable(); tblCallBackTable = CreateCallBackTable(); tblDispositionTable = CreateDispositionTable(); } else { tblCallTable = new SyncTable("Call"); tblCallTable.SyncDirection = SyncDirection.UploadOnly; tblLeadsTable = new SyncTable("Leads"); tblLeadsTable.SyncDirection = SyncDirection.UploadOnly; tblCallBackTable = new SyncTable("CallBack"); tblCallBackTable.SyncDirection = SyncDirection.UploadOnly; //Creating Disposition Table (Added by Alpa) tblDispositionTable = new SyncTable("Disposition"); tblDispositionTable.SyncDirection = SyncDirection.UploadOnly; } strClientConnectionString = strConnectionString; // sync = new SqlCeClientSyncProvider(strClientConnectionString); serverSyncProvider = new DbServerSyncProvider(); syncAgent = new SyncAgent(); // syncAgent.ServerSyncProvider = serverSyncProvider; syncAgent.RemoteProvider = serverSyncProvider; serverConnection = new SqlConnection(VMuktiAPI.VMuktiInfo.MainConnectionString); serverSyncProvider.Connection = serverConnection; serverSyncProvider.ApplyChangeFailed += new EventHandler<ApplyChangeFailedEventArgs>(serverSyncProvider_ApplyChangeFailed); //syncAgent.ClientSyncProvider = clientSyncProvider; syncAgent.LocalProvider = clientSyncProvider; myGroup = new SyncGroup("DialerGroup"); tblCallTable.SyncGroup = myGroup; tblLeadsTable.SyncGroup = myGroup; tblCallBackTable.SyncGroup = myGroup; tblDispositionTable.SyncGroup = myGroup; syncAgent.Configuration.SyncTables.Add(tblCallTable); syncAgent.Configuration.SyncTables.Add(tblLeadsTable); syncAgent.Configuration.SyncTables.Add(tblCallBackTable); syncAgent.Configuration.SyncTables.Add(tblDispositionTable); CallAdapter = new SqlSyncAdapterBuilder(); CallAdapter.Connection = serverConnection; CallAdapter.SyncDirection = SyncDirection.UploadOnly; CallAdapter.TableName = "Call"; // CallAdapter.DataColumns.Add("ID"); CallAdapter.DataColumns.Add("LeadID"); CallAdapter.DataColumns.Add("CalledDate"); CallAdapter.DataColumns.Add("ModifiedDate"); CallAdapter.DataColumns.Add("ModifiedBy"); CallAdapter.DataColumns.Add("GeneratedBy"); CallAdapter.DataColumns.Add("StartDate"); CallAdapter.DataColumns.Add("StartTime"); CallAdapter.DataColumns.Add("DurationInSecond"); CallAdapter.DataColumns.Add("DespositionID"); CallAdapter.DataColumns.Add("CampaignID"); CallAdapter.DataColumns.Add("ConfID"); CallAdapter.DataColumns.Add("IsDeleted"); CallAdapter.DataColumns.Add("CallNote"); CallAdapter.DataColumns.Add("IsDNC"); CallAdapter.DataColumns.Add("IsGlobal"); CallAdapter.DataColumns.Add("RecordedFileName"); //For Recording File Name CallAdapterSyncAdapter = CallAdapter.ToSyncAdapter(); CallAdapterSyncAdapter.DeleteCommand = null; serverSyncProvider.SyncAdapters.Add(CallAdapterSyncAdapter); LeadAdapter = new SqlSyncAdapterBuilder(); LeadAdapter.Connection = serverConnection; LeadAdapter.SyncDirection = SyncDirection.UploadOnly; LeadAdapter.TableName = "Leads"; LeadAdapter.DataColumns.Add("ID"); LeadAdapter.DataColumns.Add("PhoneNo"); LeadAdapter.DataColumns.Add("LeadFormatID"); LeadAdapter.DataColumns.Add("CreatedDate"); LeadAdapter.DataColumns.Add("CreatedBy"); LeadAdapter.DataColumns.Add("DeletedDate"); LeadAdapter.DataColumns.Add("DeletedBy"); LeadAdapter.DataColumns.Add("IsDeleted"); LeadAdapter.DataColumns.Add("ModifiedDate"); LeadAdapter.DataColumns.Add("ModifiedBy"); LeadAdapter.DataColumns.Add("DNCFlag"); LeadAdapter.DataColumns.Add("DNCBy"); LeadAdapter.DataColumns.Add("ListID"); LeadAdapter.DataColumns.Add("LocationID"); LeadAdapter.DataColumns.Add("RecycleCount"); LeadAdapter.DataColumns.Add("Status"); LeadAdapter.DataColumns.Add("IsGlobalDNC"); //LeadAdapter.DataColumns.Add("LastEditDate"); //LeadAdapter.DataColumns.Add("CreationDate"); LeadAdapterSyncAdapter = LeadAdapter.ToSyncAdapter(); LeadAdapterSyncAdapter.DeleteCommand = null; LeadAdapterSyncAdapter.InsertCommand = null; serverSyncProvider.SyncAdapters.Add(LeadAdapterSyncAdapter); CallBackAdapter = new SqlSyncAdapterBuilder(); CallBackAdapter.Connection = serverConnection; CallBackAdapter.SyncDirection = SyncDirection.UploadOnly; CallBackAdapter.TableName = "CallBack"; CallBackAdapter.DataColumns.Add("ID"); CallBackAdapter.DataColumns.Add("CallID"); CallBackAdapter.DataColumns.Add("CallBackDate"); CallBackAdapter.DataColumns.Add("Comment"); CallBackAdapter.DataColumns.Add("IsPublic"); CallBackAdapter.DataColumns.Add("IsDeleted"); CallBackAdapterSyncAdapter = CallBackAdapter.ToSyncAdapter(); CallBackAdapterSyncAdapter.DeleteCommand = null; serverSyncProvider.SyncAdapters.Add(CallBackAdapterSyncAdapter); //Creating Disposition Table in sdf (Added by Alpa) DispositionAdapter = new SqlSyncAdapterBuilder(); DispositionAdapter.Connection = serverConnection; DispositionAdapter.SyncDirection = SyncDirection.UploadOnly; DispositionAdapter.TableName = "Disposition"; DispositionAdapter.DataColumns.Add("ID"); DispositionAdapter.DataColumns.Add("DespositionName"); DispositionAdapter.DataColumns.Add("Description"); DispositionAdapter.DataColumns.Add("IsActive"); DispositionAdapter.DataColumns.Add("IsDeleted"); DispositionAdapter.DataColumns.Add("CreatedDate"); DispositionAdapter.DataColumns.Add("CreatedBy"); DispositionAdapter.DataColumns.Add("ModifiedDate"); DispositionAdapter.DataColumns.Add("ModifiedBy"); DispositionAdapterSyncAdapter = DispositionAdapter.ToSyncAdapter(); DispositionAdapterSyncAdapter.DeleteCommand = null; DispositionAdapterSyncAdapter.InsertCommand = null; serverSyncProvider.SyncAdapters.Add(DispositionAdapterSyncAdapter); ce = new SqlCeConnection(strClientConnectionString); ce.Open(); CheckPreviousSyncWithServer(); } catch (Exception ex) { MessageBox.Show(ex.Message); } }
public void ServerEndpointAllOperationsTest() { var handler = new RecordedDelegatingHandler { StatusCodeToReturn = HttpStatusCode.OK }; using (MockContext context = MockContext.Start(this.GetType())) { IResourceManagementClient resourcesClient = StorageSyncManagementTestUtilities.GetResourceManagementClient(context, handler); IStorageSyncManagementClient storageSyncManagementClient = StorageSyncManagementTestUtilities.GetStorageSyncManagementClient(context, handler); // Create ResourceGroup string resourceGroupName = StorageSyncManagementTestUtilities.CreateResourceGroup(resourcesClient); // Create ServerEndpoint string storageSyncServiceName = TestUtilities.GenerateName("sss-sepall"); string syncGroupName = TestUtilities.GenerateName("sg-sepall"); string resourceName = TestUtilities.GenerateName("sepall"); var storageSyncServiceParameters = StorageSyncManagementTestUtilities.GetDefaultStorageSyncServiceParameters(); var syncGroupParameters = StorageSyncManagementTestUtilities.GetDefaultSyncGroupParameters(); var cloudEndpointParameters = StorageSyncManagementTestUtilities.GetDefaultCloudEndpointParameters(); StorageSyncService storageSyncServiceResource = storageSyncManagementClient.StorageSyncServices.Create(resourceGroupName, storageSyncServiceName, storageSyncServiceParameters); Assert.NotNull(storageSyncServiceResource); StorageSyncManagementTestUtilities.VerifyStorageSyncServiceProperties(storageSyncServiceResource, true); SyncGroup syncGroupResource = storageSyncManagementClient.SyncGroups.Create(resourceGroupName, storageSyncServiceResource.Name, syncGroupName, syncGroupParameters); Assert.NotNull(syncGroupResource); StorageSyncManagementTestUtilities.VerifySyncGroupProperties(syncGroupResource, true); CloudEndpoint cloudEndpointResource = storageSyncManagementClient.CloudEndpoints.Create(resourceGroupName, storageSyncServiceResource.Name, syncGroupResource.Name, resourceName, cloudEndpointParameters); Assert.NotNull(cloudEndpointResource); StorageSyncManagementTestUtilities.VerifyCloudEndpointProperties(cloudEndpointResource, true); RegisteredServer registeredServerResource = EnsureRegisteredServerResource(storageSyncManagementClient, resourceGroupName, storageSyncServiceName, syncGroupName, storageSyncServiceResource); Assert.NotNull(registeredServerResource); StorageSyncManagementTestUtilities.VerifyRegisteredServerProperties(registeredServerResource, true); var serverEndpointParameters = StorageSyncManagementTestUtilities.GetDefaultServerEndpointParameters(registeredServerResource.Id); var serverEndpointUpdateParameters = StorageSyncManagementTestUtilities.GetDefaultServerEndpointUpdateParameters(); // Delete Test before it exists. storageSyncManagementClient.ServerEndpoints.Delete(resourceGroupName, storageSyncServiceResource.Name, syncGroupResource.Name, resourceName); ServerEndpoint serverEndpointResource = storageSyncManagementClient.ServerEndpoints.Create(resourceGroupName, storageSyncServiceResource.Name, syncGroupResource.Name, resourceName, serverEndpointParameters); Assert.NotNull(serverEndpointResource); StorageSyncManagementTestUtilities.VerifyServerEndpointProperties(serverEndpointResource, true); // GET Test serverEndpointResource = storageSyncManagementClient.ServerEndpoints.Get(resourceGroupName, storageSyncServiceResource.Name, syncGroupResource.Name, resourceName); Assert.NotNull(serverEndpointResource); StorageSyncManagementTestUtilities.VerifyServerEndpointProperties(serverEndpointResource, true); // List Test IEnumerable <ServerEndpoint> serverEndpoints = storageSyncManagementClient.ServerEndpoints.ListBySyncGroup(resourceGroupName, storageSyncServiceResource.Name, syncGroupResource.Name); Assert.Single(serverEndpoints); Assert.NotNull(serverEndpoints.Single()); StorageSyncManagementTestUtilities.VerifyServerEndpointProperties(serverEndpoints.Single(), true); // Recall Test RecallActionParameters recallActionParameters = StorageSyncManagementTestUtilities.GetDefaultRecallActionParameters(); ServerEndpointsRecallActionHeaders serverEndpointsRecallActionHeaders = storageSyncManagementClient.ServerEndpoints.RecallAction(resourceGroupName, storageSyncServiceResource.Name, syncGroupResource.Name, resourceName, recallActionParameters); Assert.NotNull(serverEndpointsRecallActionHeaders); Assert.NotEmpty(serverEndpointsRecallActionHeaders.XMsCorrelationRequestId); Assert.NotEmpty(serverEndpointsRecallActionHeaders.XMsRequestId); // Update Test serverEndpointResource = storageSyncManagementClient.ServerEndpoints.Update(resourceGroupName, storageSyncServiceResource.Name, syncGroupResource.Name, resourceName, serverEndpointUpdateParameters); Assert.NotNull(serverEndpointResource); StorageSyncManagementTestUtilities.VerifyServerEndpointUpdateProperties(serverEndpointResource, true); // Delete Test storageSyncManagementClient.ServerEndpoints.Delete(resourceGroupName, storageSyncServiceResource.Name, syncGroupResource.Name, resourceName); storageSyncManagementClient.CloudEndpoints.Delete(resourceGroupName, storageSyncServiceResource.Name, syncGroupName, resourceName); storageSyncManagementClient.SyncGroups.Delete(resourceGroupName, storageSyncServiceResource.Name, syncGroupName); storageSyncManagementClient.RegisteredServers.Delete(resourceGroupName, storageSyncServiceResource.Name, registeredServerResource.ServerId.Trim('"')); storageSyncManagementClient.StorageSyncServices.Delete(resourceGroupName, storageSyncServiceResource.Name); StorageSyncManagementTestUtilities.RemoveResourceGroup(resourcesClient, resourceGroupName); } }
public void SyncMemberCRUDTest() { string testPrefix = "syncmembercrudtest-"; using (SqlManagementTestContext context = new SqlManagementTestContext(this)) { ResourceGroup resourceGroup = context.CreateResourceGroup(); SqlManagementClient sqlClient = context.GetClient <SqlManagementClient>(); Server server = context.CreateServer(resourceGroup); // Create sync database string syncDatabaseName = SqlManagementTestUtilities.GenerateName(testPrefix + "sync"); Database syncDatabase = sqlClient.Databases.CreateOrUpdate(resourceGroup.Name, server.Name, syncDatabaseName, new Database() { Location = server.Location, }); Assert.NotNull(syncDatabase); Assert.NotNull(syncDatabase.Id); // Create database string testDatabaseName = SqlManagementTestUtilities.GenerateName(testPrefix + "test"); Database testDatabase = sqlClient.Databases.CreateOrUpdate(resourceGroup.Name, server.Name, testDatabaseName, new Database() { Location = server.Location, }); Assert.NotNull(testDatabase); // Create member database string memberDatabaseName = SqlManagementTestUtilities.GenerateName(testPrefix + "member"); Database memberDatabase = sqlClient.Databases.CreateOrUpdate(resourceGroup.Name, server.Name, memberDatabaseName, new Database() { Location = server.Location, }); Assert.NotNull(memberDatabase); // Create sync group string syncGroupName = SqlManagementTestUtilities.GenerateName(testPrefix + "syncgroup"); SyncGroup createSyncGroup = sqlClient.SyncGroups.CreateOrUpdate(resourceGroup.Name, server.Name, testDatabaseName, syncGroupName, new SyncGroup { Interval = -1, // Manual ConflictResolutionPolicy = SyncConflictResolutionPolicy.MemberWin, SyncDatabaseId = syncDatabase.Id, HubDatabaseUserName = SqlManagementTestUtilities.DefaultLogin, HubDatabasePassword = SqlManagementTestUtilities.DefaultPassword }); Assert.NotNull(createSyncGroup); #region Azure SQL database member // Create an Azure SQL database member string syncMemberName = SqlManagementTestUtilities.GenerateName(testPrefix + "azsyncmember"); string syncMemberDirection = SyncDirection.OneWayMemberToHub; string syncMemberDatabaseType = SyncMemberDbType.AzureSqlDatabase; SyncMember createSyncMember = sqlClient.SyncMembers.CreateOrUpdate(resourceGroup.Name, server.Name, testDatabaseName, syncGroupName, syncMemberName, new SyncMember { SyncDirection = syncMemberDirection, DatabaseType = syncMemberDatabaseType, DatabaseName = memberDatabaseName, ServerName = server.Name, UserName = SqlManagementTestUtilities.DefaultLogin, Password = SqlManagementTestUtilities.DefaultPassword, }); Assert.NotNull(createSyncMember); Assert.Equal(syncMemberDirection, createSyncMember.SyncDirection); Assert.Equal(syncMemberDatabaseType, createSyncMember.DatabaseType); Assert.Equal(memberDatabaseName, createSyncMember.DatabaseName); Assert.Equal(server.Name, createSyncMember.ServerName); // Get Azure SQL database member SyncMember getSyncMember = sqlClient.SyncMembers.Get(resourceGroup.Name, server.Name, testDatabaseName, syncGroupName, syncMemberName); Assert.NotNull(getSyncMember); Assert.Equal(syncMemberDirection, getSyncMember.SyncDirection); Assert.Equal(syncMemberDatabaseType, getSyncMember.DatabaseType); Assert.Equal(memberDatabaseName, getSyncMember.DatabaseName); Assert.Equal(server.Name, getSyncMember.ServerName); // List sync members IPage <SyncMember> listSyncMembers = sqlClient.SyncMembers.ListBySyncGroup(resourceGroup.Name, server.Name, testDatabaseName, syncGroupName); Assert.NotNull(listSyncMembers); Assert.Equal(1, listSyncMembers.Count()); Assert.Equal(syncMemberName, listSyncMembers.Single().Name); // Update sync member string updateSyncMemberDirection = SyncDirection.Bidirectional; SyncMember updateSyncMember = sqlClient.SyncMembers.Update(resourceGroup.Name, server.Name, testDatabaseName, syncGroupName, syncMemberName, new SyncMember { SyncDirection = updateSyncMemberDirection, DatabaseType = syncMemberDatabaseType, UserName = SqlManagementTestUtilities.DefaultLogin, Password = SqlManagementTestUtilities.DefaultPassword, }); Assert.NotNull(updateSyncMember); Assert.Equal(updateSyncMemberDirection, updateSyncMember.SyncDirection); Assert.NotEqual(syncMemberDirection, updateSyncMemberDirection); // Update sync member with an empty model Assert.Throws <CloudException>(() => { sqlClient.SyncMembers.Update(resourceGroup.Name, server.Name, testDatabaseName, syncGroupName, syncMemberName, new SyncMember()); }); // Refresh member schemas sqlClient.SyncMembers.RefreshMemberSchema(resourceGroup.Name, server.Name, testDatabaseName, syncGroupName, syncMemberName); // List member schemas IPage <SyncFullSchemaProperties> memberSchemas = sqlClient.SyncMembers.ListMemberSchemas(resourceGroup.Name, server.Name, testDatabaseName, syncGroupName, syncMemberName); Assert.NotNull(memberSchemas); // Delete Azure SQL database member sqlClient.SyncMembers.Delete(resourceGroup.Name, server.Name, testDatabaseName, syncGroupName, syncMemberName); #endregion } }