Client Upload, Server Update and Client Download in the same sync session #822
Replies: 2 comments
-
That's a good feedback
GetChanges from Client, Upload to Server, Get Changes from Server, Download to Client
Interesting scenario ... I've just added an interceptor called Be careful, this interceptor is called "just after" a batch of rows are applied. Here is a example, where I'm adding a prefix to a var progress = new SynchronousProgress<ProgressArgs>(s =>
Console.WriteLine($"{s.ProgressPercentage:p}: \t[{s?.Source[..Math.Min(4, s.Source.Length)]}] {s.TypeName}: {s.Message}"));
// Creating an agent that will handle all the process
var agent = new SyncAgent(clientProvider, serverProvider, options);
var results = await agent.SynchronizeAsync(setup, progress: progress);
await DBHelper.AddProductCategoryRowAsync(clientProvider);
agent.RemoteOrchestrator.OnRowsChangesApplied(args =>
{
if (args.SchemaTable.TableName == "ProductCategory")
{
var command = args.Connection.CreateCommand();
command.CommandText = "Update ProductCategory Set Name=@Name where ProductCategoryID=@ProductCategoryID";
command.Connection = args.Connection;
command.Transaction = args.Transaction;
var pId = command.CreateParameter();
pId.ParameterName = "@ProductCategoryID";
pId.DbType = DbType.Guid;
command.Parameters.Add(pId);
var pName = command.CreateParameter();
pName = command.CreateParameter();
pName.ParameterName = "@Name";
pName.DbType = DbType.String;
command.Parameters.Add(pName);
foreach (var row in args.SyncRows)
{
pId.Value = new Guid(row["ProductCategoryId"].ToString());
pName.Value = $"SV_{row["Name"]}";
command.ExecuteNonQuery();
}
}
});
results = await agent.SynchronizeAsync(setup, progress: progress); You can test from the last commit from the master branch. Please do not hesitate to give feedback on it ! Thanks |
Beta Was this translation helpful? Give feedback.
-
Thank once again for you great suport. |
Beta Was this translation helpful? Give feedback.
-
Hello, I have several sqlite clients that synchronize trought webservice to a SQL server database.
I need that, in the same sync session the records are upload to server, the server updates the number column, and finally the records are downloaded to the client.
Is this possible? By the way, Bidirectional SyncDirection performs Upload or Download first?
Beta Was this translation helpful? Give feedback.
All reactions