BatchInfo update #817
Replies: 13 comments 12 replies
-
Hi @JiriOgurek Thanks for the feedback I have a small issue regarding this code, that will be fixed in next release. That being said, I think there is a more comfortable way to remote rows you don't want to sync. var setup = new SyncSetup("ProductCategory", "Product");
setup.Tables["ProductCategory"].SyncDirection = SyncDirection.DownloadOnly; If it's not fitting your scenario, you can filter the rows, during the read of your database, like that: agent.RemoteOrchestrator.OnRowsChangesSelected(args =>
{
if (args.SchemaTable.TableName == "ProductCategory" && args.SyncRow.RowState == SyncRowState.Deleted)
args.SyncRow = null;
}); If you don't want to filter rows during read time, but more the rows are serialized locally (and connection closed), you can use your code, rewrite like this:
agent.RemoteOrchestrator.OnTableChangesSelected(async args =>
{
foreach (var bpi in args.BatchPartInfos)
{
var table = await agent.RemoteOrchestrator.LoadTableFromBatchPartInfoAsync(args.BatchInfo, bpi);
foreach (var row in table.Rows.ToArray())
if (row.RowState == SyncRowState.Deleted)
table.Rows.Remove(row);
await agent.RemoteOrchestrator.SaveTableToBatchPartInfoAsync(args.BatchInfo, bpi, table);
}
}); Let me know if it's working for you |
Beta Was this translation helpful? Give feedback.
-
Hi @Mimetis, I've delayed this update to the end of the year (when we will setup new database) to avoid the upgrade troubles (to start from scratch). However upon first attempt to sync I get this error message: "No Schema in your server scopeInfo DefaultScope", what's wrong, please? Take a look at the source code diff when upgrading v0.9.4 --> 0.9.7, please. |
Beta Was this translation helpful? Give feedback.
-
Hi @Mimetis, thank you for your kind help. I've commented out the upgrade attempt and passed setup to the SynchronizeAsync() method. The first sync init went fine, trackings are created, however second sync run (with new data added) throws exception: "Object reference not set to an instance of an object." Do you have a clue what's wrong, please? |
Beta Was this translation helpful? Give feedback.
-
Hi @Mimetis, I have upgraded to beta as you suggested. First sync init OK, tracking tables created. One batch of data added to local and sync run seems to be fine (see uploaded records count in the screenshot), however in fact there are no new records at the remote server. When I add more data batches and try to sync new exception raises: "Cannot write to a closed TextWriter." Any suggestions, please? |
Beta Was this translation helpful? Give feedback.
-
@Mimetis, sure. on the left side it's working v0.9.4; on the right it's latest beta version throwing exceptions. |
Beta Was this translation helpful? Give feedback.
-
@Mimetis, so source code seems to be fine, please? |
Beta Was this translation helpful? Give feedback.
-
@Mimetis, you mean Windows regional settings? Probably not, is there a solution? |
Beta Was this translation helpful? Give feedback.
-
@Mimetis, I've tried comment out the LocalOrchestrator.OnTableChangesSelected event method and it works as expected :-) The only problem is, I have to remove local delete trackings since I have to preserve all server records, can you suggest proper way how to acomplish this, please? |
Beta Was this translation helpful? Give feedback.
-
@Mimetis, I am using UploadOnly, I don't want do download anything from remote server, plus I don't want to upload local deletes. I've been using this code successfully till v0.9.4. However BatchInfo structure has been changed. Can you post how to remove local deletes in UploadOnly scenario, please?
|
Beta Was this translation helpful? Give feedback.
-
@Mimetis, I am sorry, I thought it's related to Download scenario only, I do apologize. It seems to be working fine :-) Thank you for your kind help, I will run more tests now. |
Beta Was this translation helpful? Give feedback.
-
@Mimetis, with small updates everything works as expected, when I add thousands of records (in one batch) I get this exception "Cannot write to a closed TextWriter", can you help me, please? |
Beta Was this translation helpful? Give feedback.
-
@Mimetis, sure! I will do so and let you know. |
Beta Was this translation helpful? Give feedback.
-
@Mimetis, congratulations! :-) It's working as expected, I will perform additional tests now. |
Beta Was this translation helpful? Give feedback.
-
Hi, you have suggested to remove deleted rows using this code:
However, it's not working anymore since BatchInfo class has changed, would you be so kind and suggest new approach, please?
Beta Was this translation helpful? Give feedback.
All reactions