How to Prevent Concurrent Data Collisions


Author
Message
Ger Cannoll
Ger Cannoll
Advanced StrataFrame User (866 reputation)Advanced StrataFrame User (866 reputation)Advanced StrataFrame User (866 reputation)Advanced StrataFrame User (866 reputation)Advanced StrataFrame User (866 reputation)Advanced StrataFrame User (866 reputation)Advanced StrataFrame User (866 reputation)Advanced StrataFrame User (866 reputation)Advanced StrataFrame User (866 reputation)
Group: StrataFrame Users
Posts: 430, Visits: 507
If two users modify data at the same time ( e.g. user 1 Reads data into a BO, Changes It, Users 2 reads same Data into a BO, User 1 then saves the BO, and then User 2 Attempts to Save the same data), a message comes up:

Data Collision... Another user made changes to the same record..choose the changes to accept  (MyValue or Server Value)

Now, this is fine most of the time (say for Master File Changes)

However, If say an Invocie is being modified in this way, I NEVER want the second user to have their changes accepted. In this case, I would prefer if an error was raised and a notification to this effect ended up in the BrokenRules Collection

In my BusinessObject, I would like to do something like:

if (DataCollision = true) {this.AddBrokenRule("XXX", "Another User has just amended the transaction ");}

and I do not want the user to have the option to choose what is to be done.

 

Replies
Ivan George Borges
Ivan George Borges
Strategic Support Team Member (4.9K reputation)Strategic Support Team Member (4.9K reputation)Strategic Support Team Member (4.9K reputation)Strategic Support Team Member (4.9K reputation)Strategic Support Team Member (4.9K reputation)Strategic Support Team Member (4.9K reputation)Strategic Support Team Member (4.9K reputation)Strategic Support Team Member (4.9K reputation)Strategic Support Team Member (4.9K reputation)
Group: StrataFrame MVPs
Posts: 1.9K, Visits: 21K
1. Even though I have code to AddbrokenRules, it does not seem to be doing this. If there is a collision, it is not now showing the SF Collision Form and it is not saving (which is what I want) but I want to update the BrokenRule collection so that all errors are seen from the same place


If you let it try resaving, after adding the broken rule, won't it work the way you want?


2. In the above, for testing, I was setting the propeties on the Form Instances , rather than on a subclassed form, as I am having difficulty setting a Property on a SubClassed form. I have previosuly  added functionality to other controls successfully , but this is the first time I am trying to add functionality to a subclassed Form. The AutoHandleCollisions = false does not seem to be doing anything.  My Code to subclass the form is:


Sorry, I am a bit confused on this one. Would you like to produce a small simple sample application of what you want to accomplish? Then it could be easier to follow it.
Ger Cannoll
Ger Cannoll
Advanced StrataFrame User (866 reputation)Advanced StrataFrame User (866 reputation)Advanced StrataFrame User (866 reputation)Advanced StrataFrame User (866 reputation)Advanced StrataFrame User (866 reputation)Advanced StrataFrame User (866 reputation)Advanced StrataFrame User (866 reputation)Advanced StrataFrame User (866 reputation)Advanced StrataFrame User (866 reputation)
Group: StrataFrame Users
Posts: 430, Visits: 507
Hi Ivan.

I will do up a small project to iluustrate both issues.
Ger Cannoll
Ger Cannoll
Advanced StrataFrame User (866 reputation)Advanced StrataFrame User (866 reputation)Advanced StrataFrame User (866 reputation)Advanced StrataFrame User (866 reputation)Advanced StrataFrame User (866 reputation)Advanced StrataFrame User (866 reputation)Advanced StrataFrame User (866 reputation)Advanced StrataFrame User (866 reputation)Advanced StrataFrame User (866 reputation)
Group: StrataFrame Users
Posts: 430, Visits: 507
Hi Ivan.

I have attached a Sample Project to illustrate the second problem I am having. Just trying to Subclass a StratatFrame Form and have the AutoHandleCollisions set to False in my SubClass

In the Sample, My Subclass is called MyForm, and I have a line in it with this.AutoHandleCollisions = false

When I run up my Form (Form2, called from Form1) , I have a button whcih displays a messagebox, indicating what the AutoHandleCollisions property is. It is saying True, even though my BaseClass has set it to false. (This may very well be the result of my Inexperience of Subclassing a Form and I may have left out something or not done it the correct way.

(Sample project based on the Customers Tbale in the StartaFrame sample database)
Attachments
TestConcurr1.ZIP (157 views, 97.00 KB)
Ger Cannoll
Ger Cannoll
Advanced StrataFrame User (866 reputation)Advanced StrataFrame User (866 reputation)Advanced StrataFrame User (866 reputation)Advanced StrataFrame User (866 reputation)Advanced StrataFrame User (866 reputation)Advanced StrataFrame User (866 reputation)Advanced StrataFrame User (866 reputation)Advanced StrataFrame User (866 reputation)Advanced StrataFrame User (866 reputation)
Group: StrataFrame Users
Posts: 430, Visits: 507
Hi Ivan.

Any update on this. (Trying to subclass a and have the AutoHandleCollisions set to False in my SubClass...see attached Sample on laste thread)
Ivan George Borges
Ivan George Borges
Strategic Support Team Member (4.9K reputation)Strategic Support Team Member (4.9K reputation)Strategic Support Team Member (4.9K reputation)Strategic Support Team Member (4.9K reputation)Strategic Support Team Member (4.9K reputation)Strategic Support Team Member (4.9K reputation)Strategic Support Team Member (4.9K reputation)Strategic Support Team Member (4.9K reputation)Strategic Support Team Member (4.9K reputation)
Group: StrataFrame MVPs
Posts: 1.9K, Visits: 21K
Hi Ger.

I tried to have a look at your sample but couldn't find out how to solve your problem. As I told you, I do vb.net and tried to Google how the C# inheritance should behave, but didn't get to a conclusion why yours is not working. In my solutions, my base form is set with AutoHandleCollisions to False and all inherited forms from it also has it like that.

So, I hope someone will jump in and clarify this for you.
Edited 13 Years Ago by Ivan George Borges
Ger Cannoll
Ger Cannoll
Advanced StrataFrame User (866 reputation)Advanced StrataFrame User (866 reputation)Advanced StrataFrame User (866 reputation)Advanced StrataFrame User (866 reputation)Advanced StrataFrame User (866 reputation)Advanced StrataFrame User (866 reputation)Advanced StrataFrame User (866 reputation)Advanced StrataFrame User (866 reputation)Advanced StrataFrame User (866 reputation)
Group: StrataFrame Users
Posts: 430, Visits: 507
Hi Ivan. I am back to the concurrency issue  now. I have resolved being able to SubClass a Form (Uing C#) , thanks to another thread.

To Recap. If there is a DataColission, I want to add the fact to the BrokenRules collection and display a Message indicating this, and not allow the save. I have atached a Sample App. I have done the following in the App:

In my Base Form, Set AutoHandleCollisions to False

In the BO, left the CollisionNotificationType to RaiseEvent (The Default)

In My Base BO, put code into the BO_ConcurrencyException event as follows:

1. AddBrokenRule message

2. e.ReSaveRecord = true  (Set the flag so it will attempt to Resave the data) 

3.  this.Save  (Attemp to Save the record, which then should trigger the broken rules)

What is happening is that , for the Concurrency problem  record, The Broken Rule is NOT being displayed . It does not save the record (which is fine) but I want it to display the BrokenRules to indicate to the user that there has been a problem.
Attachments
Concurrency_04April.ZIP (123 views, 2.00 MB)
Ivan George Borges
Ivan George Borges
Strategic Support Team Member (4.9K reputation)Strategic Support Team Member (4.9K reputation)Strategic Support Team Member (4.9K reputation)Strategic Support Team Member (4.9K reputation)Strategic Support Team Member (4.9K reputation)Strategic Support Team Member (4.9K reputation)Strategic Support Team Member (4.9K reputation)Strategic Support Team Member (4.9K reputation)Strategic Support Team Member (4.9K reputation)
Group: StrataFrame MVPs
Posts: 1.9K, Visits: 21K
Hi Ger.

I have changed your sample project and am posting it here back to you.
I have created a new Base BO and added some code to it to demonstrate how you can accomplish what you are looking for.
If you feel like it, have a look at the help file under "Application Framework" -> "Business Layer" -> "Common Business Object Tasks" ->"Creating and Checking Business Rules" to get the a better understanding of the flow.

Hope it helps. Wink
Attachments
Concurrency_04April_A.ZIP (137 views, 2.00 MB)
Ger Cannoll
Ger Cannoll
Advanced StrataFrame User (866 reputation)Advanced StrataFrame User (866 reputation)Advanced StrataFrame User (866 reputation)Advanced StrataFrame User (866 reputation)Advanced StrataFrame User (866 reputation)Advanced StrataFrame User (866 reputation)Advanced StrataFrame User (866 reputation)Advanced StrataFrame User (866 reputation)Advanced StrataFrame User (866 reputation)
Group: StrataFrame Users
Posts: 430, Visits: 507
Hi Ivan.

I have downloaded and extracted the amnded sample and it does what I want. Many thanks for putting in the time.

I will need to have a look at the code to get an understanding of how it works.
Ivan George Borges
Ivan George Borges
Strategic Support Team Member (4.9K reputation)Strategic Support Team Member (4.9K reputation)Strategic Support Team Member (4.9K reputation)Strategic Support Team Member (4.9K reputation)Strategic Support Team Member (4.9K reputation)Strategic Support Team Member (4.9K reputation)Strategic Support Team Member (4.9K reputation)Strategic Support Team Member (4.9K reputation)Strategic Support Team Member (4.9K reputation)
Group: StrataFrame MVPs
Posts: 1.9K, Visits: 21K
You're welcome, Ger. Cool
Ger Cannoll
Ger Cannoll
Advanced StrataFrame User (866 reputation)Advanced StrataFrame User (866 reputation)Advanced StrataFrame User (866 reputation)Advanced StrataFrame User (866 reputation)Advanced StrataFrame User (866 reputation)Advanced StrataFrame User (866 reputation)Advanced StrataFrame User (866 reputation)Advanced StrataFrame User (866 reputation)Advanced StrataFrame User (866 reputation)
Group: StrataFrame Users
Posts: 430, Visits: 507
Hi Ivan. I am now trying to incorporate your suggestions into my live project  and am having two problems:

1. In the Base SubClass, when I try to add InitializeComponent into each constructor, it comes up with a error in the compiler (InitializeComponent does not exist in the current context)..... now if I comment the line out, it seems to work ok... Do I need this line in ?

2. In my actaul BO classes, I need to have specific code in the CheckRulesOnCurrentRow, so I want to run the Base Code in my subclass. When I put in  base.CheckRulesOnCurrentRow()  or base.CheckRulesOnCurrentRow(CheckRulesEventArgs e) I  get a complier message --> CheckRulesOnCurrentRow can only appear on the left hand side of += or -=

     
Ger Cannoll
Ger Cannoll
Advanced StrataFrame User (866 reputation)Advanced StrataFrame User (866 reputation)Advanced StrataFrame User (866 reputation)Advanced StrataFrame User (866 reputation)Advanced StrataFrame User (866 reputation)Advanced StrataFrame User (866 reputation)Advanced StrataFrame User (866 reputation)Advanced StrataFrame User (866 reputation)Advanced StrataFrame User (866 reputation)
Group: StrataFrame Users
Posts: 430, Visits: 507
Hi. I am really stuck on this as I cannot seem to get the Base Code running from my specific CheckRulesOnCurrentRow

Any feedback appreciated
Ger Cannoll
Ger Cannoll
Advanced StrataFrame User (866 reputation)Advanced StrataFrame User (866 reputation)Advanced StrataFrame User (866 reputation)Advanced StrataFrame User (866 reputation)Advanced StrataFrame User (866 reputation)Advanced StrataFrame User (866 reputation)Advanced StrataFrame User (866 reputation)Advanced StrataFrame User (866 reputation)Advanced StrataFrame User (866 reputation)
Group: StrataFrame Users
Posts: 430, Visits: 507
Anbody ?
GO

Merge Selected

Merge into selected topic...



Merge into merge target...



Merge into a specific topic ID...




Threaded View
Threaded View
Ger Cannoll - 13 Years Ago
Ivan George Borges - 13 Years Ago
Ger Cannoll - 13 Years Ago
Ivan George Borges - 13 Years Ago
Ger Cannoll - 13 Years Ago
                         [quote]1. Even though I have code to AddbrokenRules, it does not seem...
Ivan George Borges - 13 Years Ago
                             Hi Ivan. I will do up a small project to iluustrate both issues.
Ger Cannoll - 13 Years Ago
                             Hi Ivan. I have attached a Sample Project to illustrate the second...
Ger Cannoll - 13 Years Ago
                                 Hi Ivan. Any update on this. (Trying to subclass a and have the...
Ger Cannoll - 13 Years Ago
                                     Hi Ger. I tried to have a look at your sample but couldn't find out...
Ivan George Borges - 13 Years Ago
                                         Hi Ivan. I am back to the concurrency issue now. I have resolved being...
Ger Cannoll - 13 Years Ago
                                             Hi Ger. I have changed your sample project and am posting it here...
Ivan George Borges - 13 Years Ago
                                                 Hi Ivan. I have downloaded and extracted the amnded sample and it...
Ger Cannoll - 13 Years Ago
                                                     You're welcome, Ger. :cool:
Ivan George Borges - 13 Years Ago
                                                 Hi Ivan. I am now trying to incorporate your suggestions into my live...
Ger Cannoll - 13 Years Ago
                                                     Hi. I am really stuck on this as I cannot seem to get the Base Code...
Ger Cannoll - 13 Years Ago
                                                         Anbody ?
Ger Cannoll - 13 Years Ago
Fabian R Silva, - - 13 Years Ago
Ger Cannoll - 13 Years Ago
Trevor Hendricks - 13 Years Ago
Ger Cannoll - 13 Years Ago

Similar Topics

Reading This Topic

Login

Explore
Messages
Mentions
Search