Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Multiple Scopes SQL Server- sync to SQLite client #986

Open
abdulhamid3183924 opened this issue Mar 22, 2023 · 1 comment
Open

Multiple Scopes SQL Server- sync to SQLite client #986

abdulhamid3183924 opened this issue Mar 22, 2023 · 1 comment

Comments

@abdulhamid3183924
Copy link

I have project where I need to sync Multiscope from SQL server DB to SQLite using Asp.net core API, the local database server is SQL and the remote database server is SQLite , running on Windows with the sync proxy running on IIS, by following the documentation I always get Default Scope in Post() which ends up with "webserverAgent was null"

This is Setup Server side

public void ConfigureServices(IServiceCollection services)
{
services.AddControllers();
services.AddMemoryCache();

        services.AddDistributedMemoryCache();
        services.AddSession(options => options.IdleTimeout = TimeSpan.FromMinutes(30));

        // [Required]: Get a connection string to your server data source
        var connectionString = Configuration.GetSection("ConnectionStrings")["DefaultConnection"];


        var ItemsTB = new string[] { "ItemId", "ItemCode", "ArabicItemName", "CategoryOneEnabled", "CategoryTwoEnabled", "CategoryThreeEnabled", "CategoryOneListEnabled", "CategoryTwoListEnabled", "LatestLocalCost", "LatestForeignCost", "LatestLocalPurchasePrice" };
        services.AddSyncServer<SqlSyncChangeTrackingProvider>(connectionString, "Items", ItemsTB);

        var ItemUnitPriceTB = new string[] { "UnitItemID", "ItemID", "UnitID", "UnitQuantityX", "FirstPrice", "SecondPrice", "ThirdPrice", "FourthPrice", "FifthPrice", "LeastPrice" };
        services.AddSyncServer<SqlSyncChangeTrackingProvider>(connectionString, "ItemUnitPrice", ItemUnitPriceTB);

        var barcodeTB = new string[] { "BarcodeID", "Barcode", "UnitItemID" };
        services.AddSyncServer<SqlSyncChangeTrackingProvider>(connectionString, "barcode", barcodeTB);

        var UnitsTB = new string[] { "UnitID", "UnitDiscription" };
        services.AddSyncServer<SqlSyncChangeTrackingProvider>(connectionString, "Units", UnitsTB);

        var StoresTB = new string[] { "StoreId", "ArabicStoreName" };
        services.AddSyncServer<SqlSyncChangeTrackingProvider>(connectionString, "Stores", StoresTB);

        var StockTB = new string[] { "StockID", "ItemID", "StoreID", "CategoryOne", "CategoryTwo", "CategoryThree", "QuantityIn", "QuantityOut", "ObjectID", "InvoiceID", "InvoiceItemsID", "InvoiceDateTimeIssue" };
        services.AddSyncServer<SqlSyncChangeTrackingProvider>(connectionString, "Stock", StockTB);

        var CostInCostOutTB = new string[] { "CostInCostOutID", "ItemId", "StoreId", "CostIn", "CostOut", "QuantityIn", "QuantityOut", "ObjectID", "InvoiceID", "InvoiceItemsID", "InvoiceDateTimeIssue" };
        services.AddSyncServer<SqlSyncChangeTrackingProvider>(connectionString, "CostInCostOut", CostInCostOutTB);


    }

and this tis Client side

private async void SyncApp0()
{

       var serverOrchestrator = new WebRemoteOrchestrator("https://localhost:44342/api/sync");

        var clientProvider = new SqliteSyncProvider("C:\\Abo\\SQLLight\\advworks101.db3"); ;

       SyncAgent agent = new SyncAgent(clientProvider, serverOrchestrator);

        var result = await agent.SynchronizeAsync();
      
    }
@Mimetis
Copy link
Owner

Mimetis commented Apr 10, 2023

you need to specify the scope you want to sync from client perspective

var result = await agent.SynchronizeAsync("CostInCostOut");

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants