multi-user data entry

  • Thread starter Thread starter Patrick McGuire
  • Start date Start date
P

Patrick McGuire

I am instantiating several custom objects from a subset
of data contained in an XML file. I then might edit
these objects and save the changes back to the XML file.
However, I want to compare the original state of the
objects with the current object data stored in the XML
file to alert the user to any changes that were made by
other users during the time that the user was making his
own edits.

So I'm doing this:

objEdit= createobject(xmldata)
objOriginal= createobject(xmldata)

DATA EDITING (of objEdit)
..
..
..

objCurrent = createobject(xmldata)

if not objCurrent.Equals(objOriginal) then

msgbox "Another user made changes..."
..
..
..

else

savedata(objEdit)

end if

Two questions:
1) Is this the best approach?
2) For some reason the edits affect objOriginal as well
as objEdit. Why is that happening?

Thanks.

Pat
 
An ADO.NET group will be able to handle this better, but there are lots of
ways to do this such as using something as simple as GetChanges.. I think a
dataset also implements IComparable in which case you can get the changes
out.

-CJ
 
Hmm. Correct me if I'm wrong, but I think your
suggestion finds the changed rows that the user makes
himself. The underlying XML file may have been changed
several times during the user's editing activities. I
want to find if the XML file has been changed (by other
users) during the user's editing activities.

Thanks,

Pat
 
This is a common thing I see, I use SQL though to do Pessemistic locking
(something you should be VERY careful with). What I'm saying is, you could
reload the XML file, and then validate changes agasint both of them, and do
whatever BL you need to do..

Now if you want to get "creative" you could use a FileSystemWatcher to
watch to see if the XML file was updated at anytime, and notify the user
instantly if they want to import these changes. Depending on how many users
you have / how many updates there are, this could get ugly. (File keeps
changing, user keeps getting notified) You also would have to write your
own handler in updating the UI when a file changes and getting the changes
(seeing if it affects the current record or not). but you have to remember
Datasets are disconnected so it can't necessarily watch to see when someone
else updates automaticalliy.

If you have some extra money check out Microsoft ADO.NET Core Reference
guid. ISBN 0-7356-1423-7 which I found pretty useful when learning about
Pessemistic locking.
USA pricing is 59.99. Canada 86.99,

Has a CD too...
 
Back
Top