Asyncronous Save (like AutoSave) on a EBL

Asyncronous Save (like AutoSave) on a EBL

Old forum URL: forums.lhotka.net/forums/t/7426.aspx


Jack posted on Saturday, August 08, 2009

Just curious if anybody has a proven and reliable method for AutoSaving the IsDirty set of data in the background and continuing on without interrupting the user.  I'm planning on using a CommandBO to send my data to the server and have it update the database.  My only real problem is that I need to keep insync the last_update_timestamp for concurrency.

I was going to try something along the lines of:

Option A:
1) Add three new properties: 
 
    - LastUpdateDate
    - AutoSavingFlag
    - AutoSavingIsDirtyFlag
 
   a) copy my UpdateDate property to the LastUpdateDate property in my Get/LoadData

   b) Modify OnPropertyChanged to do:
       If !(ProperyName="AutoSaveFlag") AutoSavingIsDirty = AutoSavingFlag

2) On AutoSave or AsyncSave
    a) set a AutoSaveCommand UpdateDate property to DateTime.Now

    b) flag all dirty data with:
        i)   UpdateDate = AutoSaveCommand.UpdateDate
        ii)  AutoSavingIsDirtyFlag = False
        iii) AutoSavingFlag = True
  
    c) fire off my AutoSaveCommandBO
 
3) on the completion of my AutoSaveCommand 
 
   a) if fail, then notify user + undo data from step 2b
   b) if pass, then for all AutoSaving data

      i) set the UpdateDate = LastUpdateDate

      ii) Set IsDirty = !AutoSavingIsDirtyFlag  
   
Option B:   
Same basic premise but instead of using AutoSaveDirty flags I would clone each piece of dirty data and then try to compare it to its self after the AutoSave completed...

Any pitfalls, ideas, advice?

I don't actually care too much if my IsDirty logic isn't too precise as the cost to update the same data again is nil.  All the data gets send from the client to the server either way.

Thanks

jack

Copyright (c) Marimer LLC