Documentation for version 0.8.0 and/or advice on getting list of changes #1224
Replies: 4 comments
-
I guess you have already look at the official doc here https://dotmimsync.readthedocs.io/ ? Otherwise, I can help you if you don't find. Unfortunately my answers will be based on the last version, but it should be a good starting point. Regarding your question, it lacks a little bit of information about your use case, but let's try to find out. If you are on the server side, and you want to know for all your clients (or one in particular if you know its ID), what are the changes that should be synced next time.
Here is a piece of code you can evaluate:
// Creating a remote orchestrator
var remoteOrchestrator = new RemoteOrchestrator(serverProvider);
// Getting all scope client to evaluate the changes
var scopeInfoClients = await remoteOrchestrator.GetAllScopeInfoClientsAsync();
// for each scope, get the changes
foreach (var scopeInfoClient in scopeInfoClients)
{
// First idea: Just get the estimated changes count, as the method is faster than getting all rows
var estimatedChanges = await remoteOrchestrator.GetEstimatedChangesCountAsync(scopeInfoClient);
Console.WriteLine($"Estimated tables changes count for scope {scopeInfoClient.Id} : {estimatedChanges.ServerChangesSelected.TableChangesSelected.Count} tables");
Console.WriteLine($"Estimated rows changes count for scope {scopeInfoClient.Id} : {estimatedChanges.ServerChangesSelected.TotalChangesSelected} rows");
// Second idea: Get all changes
// Get the batches changes serialized on disk
var changes = await remoteOrchestrator.GetChangesAsync(scopeInfoClient);
// load all the tables in memory
var tables = remoteOrchestrator.LoadTablesFromBatchInfo(changes.ServerBatchInfo);
// iterate
foreach (var table in tables.ToList())
{
Console.WriteLine($"Changes for table {table.GetFullName()}");
foreach (var row in table.Rows)
{
Console.WriteLine($"Row {row}");
}
}
|
Beta Was this translation helpful? Give feedback.
-
Thank you very much for your reply. I apologize for the tardy response.
I've read the official docs. Unfortunately, the old version doesn't have the same methods. For example, there is no GetAllScopeInfoClientsAsync(). I'm sorry I didn't capture the docs when we first implemented the feature. I'm trying to figure out how to do what the current docs recommend with what I have in place.
I know we need to update, but my client hasn't prioritized that.
I seem to recall a migration help document somewhere back when .9 was released, but I'm not finding it now. I may have been imagining that. Is there such a thing? I apologize if it's obvious.
I really do appreciate your response. Thanks, again.
Nancy Folsom<https://www.codemag.com/People/Bio/Nancy.Folsom>
Senior Software Developer
she, her
CODE Group: www.codegroup.io<http://www.codegroup.io/>
CODE Magazine: www.codemag.com<http://www.codemag.com/>
CODE Staffing: www.codestaffing.com<http://www.codestaffing.com/>
***@***.***
…________________________________
From: Sébastien Pertus ***@***.***>
Sent: Friday, August 2, 2024 12:58 AM
To: Mimetis/Dotmim.Sync ***@***.***>
Cc: Nancy Folsom ***@***.***>; Author ***@***.***>
Subject: Re: [Mimetis/Dotmim.Sync] Documentation for version 0.8.0 and/or advice on getting list of changes (Discussion #1224)
I guess you have already look at the official doc here https://dotmimsync.readthedocs.io/ ?
Otherwise, I can help you if you don't find. Unfortunately my answers will be based on the last version, but it should be a good starting point.
Regarding your question, it lacks a little bit of information about your use case, but let's try to find out.
If you are on the server side, and you want to know for all your clients (or one in particular if you know its ID), what are the changes that should be synced next time.
You need to consider that:
* These changes are hypothetical as new changes could come between your evaluation timeframe and the real sync.
* The changes you will get will not take into account any conflicts, as we don't know what are the client rows.
Here is a piece of code you can evaluate:
You should have already done a successful sync between your server and your clients before using this code.
I'm assuming that DMS has already provisioned both side.
// Creating a remote orchestrator
var remoteOrchestrator = new RemoteOrchestrator(serverProvider);
// Getting all scope client to evaluate the changes
var scopeInfoClients = await remoteOrchestrator.GetAllScopeInfoClientsAsync();
// for each scope, get the changes
foreach (var scopeInfoClient in scopeInfoClients)
{
// First idea: Just get the estimated changes count, as the method is faster than getting all rows
var estimatedChanges = await remoteOrchestrator.GetEstimatedChangesCountAsync(scopeInfoClient);
Console.WriteLine($"Estimated tables changes count for scope {scopeInfoClient.Id} : {estimatedChanges.ServerChangesSelected.TableChangesSelected.Count} tables");
Console.WriteLine($"Estimated rows changes count for scope {scopeInfoClient.Id} : {estimatedChanges.ServerChangesSelected.TotalChangesSelected} rows");
// Second idea: Get all changes
// Get the batches changes serialized on disk
var changes = await remoteOrchestrator.GetChangesAsync(scopeInfoClient);
// load all the tables in memory
var tables = remoteOrchestrator.LoadTablesFromBatchInfo(changes.ServerBatchInfo);
// iterate
foreach (var table in tables.ToList())
{
Console.WriteLine($"Changes for table {table.GetFullName()}");
foreach (var row in table.Rows)
{
Console.WriteLine($"Row {row}");
}
}
—
Reply to this email directly, view it on GitHub<#1224 (comment)>, or unsubscribe<https://github.com/notifications/unsubscribe-auth/AE6W5W3HQE65HNBFAAMI6GDZPM34DAVCNFSM6AAAAABL3GWTF6VHI2DSMVQWIX3LMV43URDJONRXK43TNFXW4Q3PNVWWK3TUHMYTAMRSGA4DINY>.
You are receiving this because you authored the thread.Message ID: ***@***.***>
|
Beta Was this translation helpful? Give feedback.
-
Damn, I'm sorry I even don't know if What you can do is looking at the stored procedures generated on the server that looks like This stored procedure is used to get the changes from the server that should be sent to the client ALTER PROCEDURE [dbo].[ProductCategory_changes]
@sync_min_timestamp bigint = 0,
@sync_scope_id uniqueidentifier = NULL
AS
BEGIN
SELECT DISTINCT [side].[ProductCategoryID],
[base].[ParentProductCategoryID],
[base].[Name],
[base].[rowguid],
[base].[ModifiedDate],
[base].[IsActive],
[side].[sync_row_is_tombstone] as [sync_row_is_tombstone],
[side].[update_scope_id] as [sync_update_scope_id]
FROM [ProductCategory] [base]
RIGHT JOIN [ProductCategory_tracking] [side] ON [base].[ProductCategoryID] = [side].[ProductCategoryID]
WHERE (
[side].[timestamp] > @sync_min_timestamp
AND ([side].[update_scope_id] <> @sync_scope_id OR [side].[update_scope_id] IS NULL)
) The two parameters are:
This is the kind of things you can test to get the hypothetical changes |
Beta Was this translation helpful? Give feedback.
-
Thanks. I'm just grateful you respond when I'm sure you're a busy person and we really, really, really need to upgrade.
I was looking into the change tracking on SQL server, but your suggestion seems much simpler.
Your example did give me some ideas, though, so I haven't given up using the orchestrator.
Thanks again!
Nancy Folsom<https://www.codemag.com/People/Bio/Nancy.Folsom>
Senior Software Developer
she, her
CODE Group: www.codegroup.io<http://www.codegroup.io/>
CODE Magazine: www.codemag.com<http://www.codemag.com/>
CODE Staffing: www.codestaffing.com<http://www.codestaffing.com/>
***@***.***
…________________________________
From: Sébastien Pertus ***@***.***>
Sent: Thursday, August 8, 2024 2:05 PM
To: Mimetis/Dotmim.Sync ***@***.***>
Cc: Nancy Folsom ***@***.***>; Author ***@***.***>
Subject: Re: [Mimetis/Dotmim.Sync] Documentation for version 0.8.0 and/or advice on getting list of changes (Discussion #1224)
Damn, I'm sorry I even don't know if GetChangesAsync was actually existing in DMS version 0.8....
What you can do is looking at the stored procedures generated on the server that looks like ProductCategory_changes (or something lije that)
This stored procedure is used to get the changes from the server that should be sent to the client
ALTER PROCEDURE [dbo].[ProductCategory_changes]
@sync_min_timestamp bigint = 0,
@sync_scope_id uniqueidentifier = NULL
AS
BEGIN
SELECT DISTINCT [side].[ProductCategoryID],
[base].[ParentProductCategoryID],
[base].[Name],
[base].[rowguid],
[base].[ModifiedDate],
[base].[IsActive],
[side].[sync_row_is_tombstone] as [sync_row_is_tombstone],
[side].[update_scope_id] as [sync_update_scope_id]
FROM [ProductCategory] [base]
RIGHT JOIN [ProductCategory_tracking] [side] ON [base].[ProductCategoryID] = [side].[ProductCategoryID]
WHERE (
[side].[timestamp] > @sync_min_timestamp
AND ([side].[update_scope_id] <> @sync_scope_id OR [side].[update_scope_id] IS NULL)
)
The two parameters are:
* @sync_scope_id is the client database (that you should have in the scope info table)
* @sync_min_timestamp is the timestamp to start from
This is the kind of things you can test to get the hypothetical changes
—
Reply to this email directly, view it on GitHub<#1224 (comment)>, or unsubscribe<https://github.com/notifications/unsubscribe-auth/AE6W5W2JS7SUPMCBDEOCN2TZQPMP7AVCNFSM6AAAAABL3GWTF6VHI2DSMVQWIX3LMV43URDJONRXK43TNFXW4Q3PNVWWK3TUHMYTAMRXHE4TANI>.
You are receiving this because you authored the thread.Message ID: ***@***.***>
|
Beta Was this translation helpful? Give feedback.
-
Where can I find old documentation and samples? I am using version 0.8.0, so...old. Anyway, I am looking for a way to see what rows have changes, and am struggling to find even what events I should look at or how to use them. If I could get the documentation or sample code from that old version I'd be grateful. Or a suggestion would also be appreciated.
Thanks in advance.
Beta Was this translation helpful? Give feedback.
All reactions