New Posts New Posts RSS Feed: checkpointing with multiple forms
  FAQ FAQ  Forum Search   Calendar   Register Register  Login Login

checkpointing with multiple forms

 Post Reply Post Reply
Author
yongbum75 View Drop Down
Newbie
Newbie


Joined: 21-Jul-2008
Posts: 17
Post Options Post Options   Quote yongbum75 Quote  Post ReplyReply Direct Link To This Post Topic: checkpointing with multiple forms
    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.
Back to Top
GregD View Drop Down
IdeaBlade
IdeaBlade
Avatar

Joined: 09-May-2007
Posts: 374
Post Options Post Options   Quote GregD Quote  Post ReplyReply Direct Link To This Post 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
 
 
 
 
Back to Top
yongbum75 View Drop Down
Newbie
Newbie


Joined: 21-Jul-2008
Posts: 17
Post Options Post Options   Quote yongbum75 Quote  Post ReplyReply Direct Link To This Post 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?
Back to Top
davidklitzke View Drop Down
IdeaBlade
IdeaBlade
Avatar

Joined: 14-Jun-2007
Posts: 715
Post Options Post Options   Quote davidklitzke Quote  Post ReplyReply Direct Link To This Post Posted: 07-Oct-2008 at 8:38am
Back to Top
yongbum75 View Drop Down
Newbie
Newbie


Joined: 21-Jul-2008
Posts: 17
Post Options Post Options   Quote yongbum75 Quote  Post ReplyReply Direct Link To This Post 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 (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?

Back to Top
yongbum75 View Drop Down
Newbie
Newbie


Joined: 21-Jul-2008
Posts: 17
Post Options Post Options   Quote yongbum75 Quote  Post ReplyReply Direct Link To This Post 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.
Back to Top
davidklitzke View Drop Down
IdeaBlade
IdeaBlade
Avatar

Joined: 14-Jun-2007
Posts: 715
Post Options Post Options   Quote davidklitzke Quote  Post ReplyReply Direct Link To This Post 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.
Back to Top
yongbum75 View Drop Down
Newbie
Newbie


Joined: 21-Jul-2008
Posts: 17
Post Options Post Options   Quote yongbum75 Quote  Post ReplyReply Direct Link To This Post 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)())
Back to Top
davidklitzke View Drop Down
IdeaBlade
IdeaBlade
Avatar

Joined: 14-Jun-2007
Posts: 715
Post Options Post Options   Quote davidklitzke Quote  Post ReplyReply Direct Link To This Post Posted: 09-Oct-2008 at 10:24am
or you can use ImportEntities.
Back to Top
yongbum75 View Drop Down
Newbie
Newbie


Joined: 21-Jul-2008
Posts: 17
Post Options Post Options   Quote yongbum75 Quote  Post ReplyReply Direct Link To This Post 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.



Back to Top
 Post Reply Post Reply

Forum Jump Forum Permissions View Drop Down