locked
how to do upload and download separately RRS feed

  • Question

  •             // 1. Create instance of the sync components (client, agent, server)
                OfflineServerSyncProvider serverSyncProvider = new OfflineServerSyncProvider();
                SQLExpressClientSyncProvider clientSyncProvider = new SQLExpressClientSyncProvider();
                SyncAgent syncAgent = new SyncAgent();
                syncAgent.RemoteProvider = serverSyncProvider;
                syncAgent.LocalProvider = clientSyncProvider;
                serverSyncProvider.Connection = serverConnection;
                clientSyncProvider.Connection = clientConnection;
                
    
    
                //4. Create SyncTables and SyncGroups
                // To sync a table, a SyncTable object needs to be created and setup with desired properties:
                // TableCreationOption tells the agent how to initialize the new table in the local database
                // SyncDirection is how changes from with respect to client {Download, Upload, Bidirectional or Snapshot}
    
                SyncTable tableAdministration = new SyncTable("Administration");
                //tableServiceOrderNote.CreationOption = TableCreationOption.DropExistingOrCreateNewTable;
                tableAdministration.SyncDirection = SyncDirection.UploadOnly;
                SyncTable tableServiceOrder = new SyncTable("ServiceOrder");
                tableServiceOrder.SyncDirection = SyncDirection.DownloadOnly;
    If I click up button  upload table(and their adapters) alone should be called.
    If i click down button download table(and their adapters) should be alone called.
    Thanks, Bharathi
    • Moved by Max Wang_1983 Thursday, April 21, 2011 10:44 PM forum consolidation (From:SyncFx - Microsoft Sync Framework Database Providers [ReadOnly])
    Monday, November 2, 2009 12:05 PM

Answers

  • Hi,

    There is no sample for this specific scenario because it is not a real sync issue, it is just a code pattern. Let me try to describe the idea with the code snippet in "Getting Started: Client and Server Synchronization" -- http://msdn.microsoft.com/en-us/library/bb726015(SQL.105).aspx.

    Assume that your have UI event methods as Click_Upload() and Click_Download(). You expect to move the code of Microsoft.Samples.Synchronization.Program.Main() into this two Click methods, and create SyncAgent with a parameter:

            bool isUpload; // true if from Click_Upload, false if from Click_Download
            SampleSyncAgent sampleSyncAgent = new SampleSyncAgent(isUpload);

    Then, in the SyncAgent constructor, you will based on the input parameter to add only upload or download tables into the Configuration.SyncTables. Also, you should create local and remote sync providers with the the same input parameter:

             this.LocalProvider = new SampleClientSyncProvider(isUpload);
             this.RemoteProvider = new SampleServerSyncProvider(isUpload);

    Inside the provider constructors, only add the SyncAdapter for upload or download tables to the Provider.SyncAdapters based on the input parameter.

    I hope the above steps will be helpful.

    Thanks,
    Dong


    This posting is provided AS IS with no warranties, and confers no rights.
    Tuesday, November 3, 2009 6:28 PM
    Moderator

All replies

  • Hi,

    Within one sync, SyncAgent will handle upload tables first and then download tables. If you want to only sync upload or download only tables in one sync, you should add corresponding tables into SyncTables and SyncAdapters after the UI button is clicked.

    Thanks,
    Dong


    This posting is provided AS IS with no warranties, and confers no rights.
    Monday, November 2, 2009 7:32 PM
    Moderator
  • Hi,

    Within one sync, SyncAgent will handle upload tables first and then download tables. If you want to only sync upload or download only tables in one sync, you should add corresponding tables into SyncTables and SyncAdapters after the UI button is clicked.

    Thanks,
    Dong


    This posting is provided AS IS with no warranties, and confers no rights.
    Dong,
    Thanks for our reply. can you please provide a simple example for the above scenario.Or, please provide me the sample links that uses this kind of situations

    Thanks, Bharathi
    Tuesday, November 3, 2009 4:09 AM
  • Hi,

    There is no sample for this specific scenario because it is not a real sync issue, it is just a code pattern. Let me try to describe the idea with the code snippet in "Getting Started: Client and Server Synchronization" -- http://msdn.microsoft.com/en-us/library/bb726015(SQL.105).aspx.

    Assume that your have UI event methods as Click_Upload() and Click_Download(). You expect to move the code of Microsoft.Samples.Synchronization.Program.Main() into this two Click methods, and create SyncAgent with a parameter:

            bool isUpload; // true if from Click_Upload, false if from Click_Download
            SampleSyncAgent sampleSyncAgent = new SampleSyncAgent(isUpload);

    Then, in the SyncAgent constructor, you will based on the input parameter to add only upload or download tables into the Configuration.SyncTables. Also, you should create local and remote sync providers with the the same input parameter:

             this.LocalProvider = new SampleClientSyncProvider(isUpload);
             this.RemoteProvider = new SampleServerSyncProvider(isUpload);

    Inside the provider constructors, only add the SyncAdapter for upload or download tables to the Provider.SyncAdapters based on the input parameter.

    I hope the above steps will be helpful.

    Thanks,
    Dong


    This posting is provided AS IS with no warranties, and confers no rights.
    Tuesday, November 3, 2009 6:28 PM
    Moderator