Controlling BO Updates in a less than typical scenarios

Author Message
 Posted 9/24/2008 7:56:04 PM
StrataFrame Beginner

StrataFrame BeginnerStrataFrame BeginnerStrataFrame BeginnerStrataFrame BeginnerStrataFrame BeginnerStrataFrame BeginnerStrataFrame BeginnerStrataFrame BeginnerStrataFrame Beginner

Group: Forum Members
Last Login: 9/25/2008 5:52:11 PM
Posts: 3, Visits: 5
I am currently evaluating SF as a framework for our migration to .NET
I have played extensively with several other products over the past 6 months or so, and I was suprised when I did stumble onto SF that I hadn't come across it before.
At first glance, it seems to me it should at least be holding as prominent a position as other tools such as IB,ES...

Anyway, I want to evaluate SF's capacity to adapt to some less than typical scenario's and I'd appreciate a heads-up from anyone who's willing.

Lets suppose I have a BO called IncidentBO, and I have it hooked up to an SF Maintenance Form.
I want to allow the user to Add a New or Edit an exisiting Incident.

However, when the user saves an Edited Incident, I want to leave the original row untouched and add a new row, which has the new details.
I already have a PK structure that supports this.
What I would like an insight into is where to hook the logic I would use and how to turn the updated BO into a new BO instance so it gets inserted.

I think the answer to this will also give me an insight into some other questions I have.

Cheers

Geoff

Post #19682
Add to Twitter Add to Facebook
 Posted 9/24/2008 8:06:14 PM
StrataFrame Beginner

StrataFrame BeginnerStrataFrame BeginnerStrataFrame BeginnerStrataFrame BeginnerStrataFrame BeginnerStrataFrame BeginnerStrataFrame BeginnerStrataFrame BeginnerStrataFrame Beginner

Group: Forum Members
Last Login: 9/25/2008 5:52:11 PM
Posts: 3, Visits: 5
BTW, I know I can do this using triggers in the back-end, this really is more of an exercise of exploration.
Post #19683
Add to Twitter Add to Facebook
 Posted 9/25/2008 2:33:45 AM
StrataFrame VIP

StrataFrame VIPStrataFrame VIPStrataFrame VIPStrataFrame VIPStrataFrame VIPStrataFrame VIPStrataFrame VIPStrataFrame VIPStrataFrame VIP

Group: StrataFrame Users
Last Login: 1/19/2021 11:57:36 AM
Posts: 2,436, Visits: 24,158
geoffAtDatagaard (09/25/2008)
I want to allow the user to Add a New or Edit an existing Incident.

However, when the user saves an Edited Incident, I want to leave the original row untouched and add a new row, which has the new details.
I already have a PK structure that supports this.
What I would like an insight into is where to hook the logic I would use and how to turn the updated BO into a new BO instance so it gets inserted.

Basically what I understand from your message above is the that when you Edit a record, actually you want to simply create a new one with the information of the edited one (a copied record).  That is pretty easy to accomplish by manipulating the primary bo Editing State and using the CopyData methods of the BO. 

Of course such an action is not what I would consider a standard or common rule, so it would not be a straight forward path from the framework stand point, but it is doable as the framework is very flexible and allow you to go anywhere your business rules require.

Edhy Rijo
(Using VB.Net 2019/SQL Server 2017)
Post #19686
Add to Twitter Add to Facebook
 Posted 9/25/2008 3:26:56 AM
StrataFrame Developer

StrataFrame DeveloperStrataFrame DeveloperStrataFrame DeveloperStrataFrame DeveloperStrataFrame DeveloperStrataFrame DeveloperStrataFrame DeveloperStrataFrame DeveloperStrataFrame Developer

Group: StrataFrame Developers
Last Login: 11/20/2019 8:57:25 AM
Posts: 6,610, Visits: 6,776
Like Edhy mentioned, that is one option, but you could really go several different ways with this.  When you setup your development environment with SF we always recommend created a base BO (you can see and example of this in the StrataFlix sample).  Anyway, all you really would need to do is change the row in question from a Modifed record state to an Added record state and the BO will do the rest.  So if this is something common, you could place this logic in your base BO so you wouldn't have to recode this.  But in short, it would look something like this on a modified record:

MyBo.CurrentRow.SetAdded()

That will change the row state from being in a edited state to being identified as a new record.  When updating the business layer will take this state into account.  There may be a few other things that I am not thinking of thqat you may have to tweak in regards to your PK (if you allow auto-incrementing PKs, etc.).  But it really would not be much more difficult than this.

Post #19690
Add to Twitter Add to Facebook
 Posted 9/25/2008 4:59:46 PM
StrataFrame Beginner

StrataFrame BeginnerStrataFrame BeginnerStrataFrame BeginnerStrataFrame BeginnerStrataFrame BeginnerStrataFrame BeginnerStrataFrame BeginnerStrataFrame BeginnerStrataFrame Beginner

Group: Forum Members
Last Login: 9/25/2008 5:52:11 PM
Posts: 3, Visits: 5
Thanks for that, much appreciated.

In most of our applications we also have a requirement to return a scalar value from the database, for example our current inhouse framework has a GetServerNow method which simply returns the current datetime from the database server. 
Is there a recommended best practise for these types of queries in SF?
I note that the BusinessLayer has an ExecuteScalar, so Im guessing that I should use that by adding GetServerNow to my ApBaseBO.


 

Post #19751
Add to Twitter Add to Facebook
 Posted 9/26/2008 2:20:59 AM
StrataFrame VIP

StrataFrame VIPStrataFrame VIPStrataFrame VIPStrataFrame VIPStrataFrame VIPStrataFrame VIPStrataFrame VIPStrataFrame VIPStrataFrame VIP

Group: StrataFrame Users
Last Login: 1/19/2021 11:57:36 AM
Posts: 2,436, Visits: 24,158
geoffAtDatagaard (09/25/2008)
Is there a recommended best practise for these types of queries in SF?
I note that the BusinessLayer has an ExecuteScalar, so Im guessing that I should use that by adding GetServerNow to my ApBaseBO. 

Hi,

Yes you are correct, the ExecuteScalar is the path for these types of queries.

Edhy Rijo
(Using VB.Net 2019/SQL Server 2017)
Post #19757
Add to Twitter Add to Facebook
 Posted 9/26/2008 3:43:17 AM
StrataFrame Developer

StrataFrame DeveloperStrataFrame DeveloperStrataFrame DeveloperStrataFrame DeveloperStrataFrame DeveloperStrataFrame DeveloperStrataFrame DeveloperStrataFrame DeveloperStrataFrame Developer

Group: StrataFrame Developers
Last Login: 11/20/2019 8:57:25 AM
Posts: 6,610, Visits: 6,776
We use scalar methods consistently within our medical software and StrataFrame provides a simple and straight forward way of executing scalare methods via the BO.  The business objects have an intrinsic method called ExecuteScalar that accepts all of the different command types or query texts depending on the immediate need.  But yes, scalar methods are very simple and easy to implement with SF.
Post #19767
Add to Twitter Add to Facebook
 Posted 7/9/2013 6:19:34 AM
StrataFrame User

StrataFrame UserStrataFrame UserStrataFrame UserStrataFrame UserStrataFrame UserStrataFrame UserStrataFrame UserStrataFrame UserStrataFrame User

Group: StrataFrame Users
Last Login: 2/3/2014 5:46:13 AM
Posts: 153, Visits: 1,155
Thanks Edhy for this old post. this saved me this time. something simple about how to update a BO was complicated to think and you give the correct solution, fill a BO with needed-to-update record, copy from that BO to actual BO, alter field as needed, save that and voila Smile

gracias nuevamente!

Edhy Rijo (9/25/2008)
geoffAtDatagaard (09/25/2008)
I want to allow the user to Add a New or Edit an existing Incident. However, when the user saves an Edited Incident, I want to leave the original row untouched and add a new row, which has the new details.
I already have a PK structure that supports this.
What I would like an insight into is where to hook the logic I would use and how to turn the updated BO into a new BO instance so it gets inserted.



Basically what I understand from your message above is the that when you Edit a record, actually you want to simply create a new one with the information of the edited one (a copied record).  That is pretty easy to accomplish by manipulating the primary bo Editing State and using the CopyData methods of the BO. 

Of course such an action is not what I would consider a standard or common rule, so it would not be a straight forward path from the framework stand point, but it is doable as the framework is very flexible and allow you to go anywhere your business rules require.


Tags:

Edited: 7/9/2013 6:20:17 AM by Fabian R Silva, -
Post #32139
Add to Twitter Add to Facebook
 Posted 7/10/2013 12:35:38 PM
StrataFrame VIP

StrataFrame VIPStrataFrame VIPStrataFrame VIPStrataFrame VIPStrataFrame VIPStrataFrame VIPStrataFrame VIPStrataFrame VIPStrataFrame VIP

Group: StrataFrame Users
Last Login: 1/19/2021 11:57:36 AM
Posts: 2,436, Visits: 24,158
Hi Fabian,

I am glad you were able to find the information you needed, that is exactly what the forums are for. 

I keep using that technique over and over all the time, specially now that I am using the DevExpress Grid control via the SF Binding Source and when editing multiple records in a child form, could cause the records in the BO to go crazy and yield to the wrong data being saved, copying those records to another temporary BO and handling the data there and then re-fill the original one does the trick all the time and everybody is happy.

Of course, sometimes with this trick there could be some sort of processing penalties, but in my case it is not noticeable for the end user.  Hope with the upcoming SF V2 binding to other controls like DevExpress could be done more naturally without a binding source.


Edhy Rijo
(Using VB.Net 2019/SQL Server 2017)
Post #32146
Add to Twitter Add to Facebook
 Posted 7/10/2013 12:45:56 PM
StrataFrame User

StrataFrame UserStrataFrame UserStrataFrame UserStrataFrame UserStrataFrame UserStrataFrame UserStrataFrame UserStrataFrame UserStrataFrame User

Group: Forum Members
Last Login: 2/2/2015 1:05:23 AM
Posts: 448, Visits: 12,502
Edhy I see you use a "Temporary BO" in some of your forms. So does that mean you have a Temp table in your database or are you able to get a Temp BO some other way?

TIA
Post #32148
Add to Twitter Add to Facebook


Similar Topics

Expand / Collapse

Reading This Topic

Expand / Collapse

Site Map - Home - My Account - Forum - About Us - Contact Us - Try It - Buy It

Microsoft, Visual Studio, and the Visual Studio logo are trademarks or registered trademarks of Microsoft Corporation in the United States and/or other countries.