none
On Maintaining 1 to 1 Scope between server and client. still it reflect same data on sync with another client as i syn with first one. Why? RRS feed

  • Question

  • Hello,

    I have create Scope different between each client and one server in scope_info table in DB. Once i sync with first client on filter condition it work correct but on changing filter condition with another client still it sync same data as i get previously. My code as given below :

    Here Value is diferent identity of Client

    ArrayList UnSyncTable = new ArrayList();
                    SqlConnection clientConn = new SqlConnection(ClientString);
                    SqlConnection serverConn = new SqlConnection(ServerString);
    
                    for (int i = 0; i < ClientDs.Tables[0].Rows.Count; i++)
                    {
                        //if (ClientDs.Tables[0].Rows[i][0].ToString() == "BookMaster")
                        //{
    
                        #region Start Sync
                        //////////////////////////////////////////////////////////////////////////////////
    
                        if (serverConn.State == ConnectionState.Closed)
                        {
                            serverConn.Open();
                        }
    
                        if (clientConn.State == ConnectionState.Closed)
                        {
                            clientConn.Open();
                        }
                        try
                        {
    
                            #region Step1 for ServerSide
                    
                            DbSyncScopeDescription scopeDesc = new DbSyncScopeDescription(ClientDs.Tables[0].Rows[i][0].ToString() + "_SyncScope" + Value);
                           
                            DbSyncTableDescription tableDesc = SqlSyncDescriptionBuilder.GetDescriptionForTable(ClientDs.Tables[0].Rows[i][0].ToString(), serverConn);
                           
                            scopeDesc.Tables.Add(tableDesc);
                           
                            SqlSyncScopeProvisioning serverProvision = new SqlSyncScopeProvisioning(serverConn, scopeDesc);
                           
                            serverProvision.SetCreateTableDefault(DbSyncCreationOption.Skip);
    
                            #region Filter Condition
                            if (DBFilteredTables.Contains(ClientDs.Tables[0].Rows[i][0].ToString()))
                            {
                                serverProvision.SetCreateTableDefault(DbSyncCreationOption.Skip);
                                serverProvision.Tables[ClientDs.Tables[0].Rows[i][0].ToString()].AddFilterColumn(AttributeName);
                                serverProvision.Tables[ClientDs.Tables[0].Rows[i][0].ToString()].FilterClause = "[side].[" + AttributeName + "] =" + Value;
                                
                            }
                            #endregion
    
                            // start the provisioning process
                            serverProvision.Apply();
                            #endregion
    
                        }
                        catch
                        {
                        }
    
                        try
                        {
                            #region Step2 for ClientSide
                            DbSyncScopeDescription scopeDesc1 = SqlSyncDescriptionBuilder.GetDescriptionForScope(ClientDs.Tables[0].Rows[i][0].ToString() + "_SyncScope" + Value, serverConn);
                            
                            SqlSyncScopeProvisioning clientProvision = new SqlSyncScopeProvisioning(clientConn, scopeDesc1);
                                      
                            clientProvision.Apply();
                            #endregion
                        }
                        catch
                        {
                        }
    
                        try
                        {
                            #region Step3
                            SyncOrchestrator syncOrchestrator = new SyncOrchestrator();
    
                            syncOrchestrator.LocalProvider = new SqlSyncProvider(ClientDs.Tables[0].Rows[i][0].ToString() + "_SyncScope" + Value, clientConn);
    
                            syncOrchestrator.RemoteProvider = new SqlSyncProvider(ClientDs.Tables[0].Rows[i][0].ToString() + "_SyncScope" + Value, serverConn);
    
                            if (SyncCondition == 1)
                                syncOrchestrator.Direction = SyncDirectionOrder.Download;
                            else if (SyncCondition == 2)
                                syncOrchestrator.Direction = SyncDirectionOrder.DownloadAndUpload;
                            else if (SyncCondition == 3)
                                syncOrchestrator.Direction = SyncDirectionOrder.Upload;
                            else if (SyncCondition == 4)
                                syncOrchestrator.Direction = SyncDirectionOrder.UploadAndDownload;
    
                            ((SqlSyncProvider)syncOrchestrator.LocalProvider).ApplyChangeFailed += new EventHandler<DbApplyChangeFailedEventArgs>(Program_ApplyChangeFailed);
    
                            SyncOperationStatistics syncStats = syncOrchestrator.Synchronize();
    
                            
                            //print statistics
                            string Msg = "Start Time : " + syncStats.SyncStartTime + "\n";
                            Msg += "Table Name : " + ClientDs.Tables[0].Rows[i][0].ToString() + "\n";
                            Msg += "Total Changes Uploaded : " + syncStats.UploadChangesTotal + "\n";
                            Msg += "Total Changes Downloaded : " + syncStats.DownloadChangesTotal + "\n";
                            Msg += "Complete Time : " + syncStats.SyncEndTime + "\n";
    
                            #endregion
                        }
                        catch
                        {
                            UnSyncTable.Add(ClientDs.Tables[0].Rows[i][0].ToString());
                        }
    
                        #endregion
    
                     
                    }


    Wednesday, May 14, 2014 7:56 AM

All replies

  • so how many scopes do you have on the server? i suggest you check out filter template scopes in the documentation.
    Wednesday, May 21, 2014 11:39 AM
    Moderator