Print Page | Close Window

checkpointing with multiple forms

Printed From: IdeaBlade
Category: DevForce
Forum Name: DevForce Classic
Forum Discription: For .NET 2.0
URL: http://www.ideablade.com/forum/forum_posts.asp?TID=955
Printed Date: 10-Jun-2026 at 5:45am


Topic: checkpointing with multiple forms
Posted By: yongbum75
Subject: checkpointing with multiple forms
Date Posted: 29-Sep-2008 at 8:43pm
Hi, I am using a single instance of PersistenceManager throughout my MDI Windows app.

1. User opens Customer List form.
2. BeginCheckPoint() is called in the constructor.
3. User makes changes to a customer.
4. Without closing Customer form, user then opens Order List form.
5. BeginCheckPoint() is called in the constructor.
6. User makes changes to an order.
7. User decides to go back to Customer List form then cancels changes and closes the form at which point RollbackCheckPoint() is called.

It looks like the RollbackCheckPoint() call rolls back changes made to the order at step 6 not the customer.

I think I understand why this happens but I wonder if there is any way to achieve what I am trying to achieve that is to roll back changes made to the customer at step 3.  Is there any way to do that without using more than one instance of PersistenceManager?

Thanks for your help in advance.



Replies:
Posted By: GregD
Date Posted: 02-Oct-2008 at 2:55pm
If you want rollback-by-form with the ability to have multiple forms open with unsaved changes, then multiple PMs is the only way to get it.
 
Greg Dunn
 
 
 
 


Posted By: yongbum75
Date Posted: 04-Oct-2008 at 9:25pm
OK, I can use multiple PMs.  How do I merge changes saved by different PMs?  Is there a quick and efficient way to do it?


Posted By: davidklitzke
Date Posted: 07-Oct-2008 at 8:38am
Read this post:
 
http://www.ideablade.com/forum/forum_posts.asp?TID=234 - http://www.ideablade.com/forum/forum_posts.asp?TID=234
 


Posted By: yongbum75
Date Posted: 07-Oct-2008 at 8:05pm
I actually saw this post but wasn't quite sure how to use the pm.importentities() method to "refresh" anything.

I have two forms, let's call it FormA and FormB.  Each form is using its own instance of the PM.

In FormA, I have a grid control that displays the customer listing.

In FormB, I followed the steps suggested in the post ( forum_posts.asp?TID=234 - http://www.ideablade.com/forum/forum_posts.asp?TID=234 ) in order to sync up data between the two PMs.  My "import entities" code looks something like below:

FormAPersMgr.ImportEntities(mModifiedEntityList, MergeStrategy.OverwriteChanges)
FormAPersMgr.ImportEntities(mAddedEntityList, MergeStrategy.OverwriteChanges)

mModifiedEntityList contains modified entities while mAddedEntityList contains added entities that I saved in the PM's Saving event.

Now, after I execute the above two statements, I would expect FormA's PM to have the changes I made in FormB.  However, it doesn't.

What am I doing wrong?



Posted By: yongbum75
Date Posted: 08-Oct-2008 at 9:00am
I think I found out why.

I actually misstated by saying that FormA's PM does not have the changes I made in FormB.  In fact, it does have all the changes I made in FormB.  However, the controls in FormA that are bound to the bindingsource object populated by FormA's PM do not automatically reflect changed data.  For instance, I added a new customer record in FormB, above statements are executed resulting in FormA's PM now having the newly added customer record.  I check the grid control on FormA but do not see the newly added customer record.  Do I need to do something to refresh data in FormA?  When I was using a shared PM before, this did not used to be an issue.  In other words, data was auto refreshed.


Posted By: davidklitzke
Date Posted: 08-Oct-2008 at 10:55am
You are correct.  It is not automatic.  Furthermore, not all users want it to be automatic.  Many users do not want their forms being modified by other PM's.  As a developer, you get to decide how you want your separate PM's tp interact with each other.


Posted By: yongbum75
Date Posted: 08-Oct-2008 at 11:17am
So, is it just a matter of calling the GetEntities() method from FormA's PM?

mCustomers.ReplaceRange(FormAPersMgr.GetEntities(Of Customer)())


Posted By: davidklitzke
Date Posted: 09-Oct-2008 at 10:24am
or you can use ImportEntities.


Posted By: yongbum75
Date Posted: 09-Oct-2008 at 4:05pm
But I already did that in FormB:

FormAPersMgr.ImportEntities(mModifiedEntityList, MergeStrategy.OverwriteChanges)
FormAPersMgr.ImportEntities(mAddedEntityList, MergeStrategy.OverwriteChanges)

When I do this, I can see that FormA's PM has all the changes I made in FormB.

But, in FormA, the controls bound to a bindingsource whose datasource is an entitylist populated by FormAPersMgr, aren't automatically refreshed.






Print Page | Close Window