how to know "logically" on server side of DataPortal

how to know "logically" on server side of DataPortal

Old forum URL: forums.lhotka.net/forums/t/6685.aspx


swegele posted on Thursday, March 26, 2009

Hey yall.  Looking for different ideas on how to achieve this elegantly.

I would like to have a flag that says that we have logically gone through the DataPortal mechanism...don't care about the physical location...local or remote.

On the surface one might think (as I first did) to use the Csla.ApplicationContext.ExecutionLocations.Server feature.  The problem is that this property maps to the 'physical' location of the code.  So in a local deployment that property will never say Server even though logically we are operating on the server side of the DataPortal.  I want a way to know that I am on the "logical" server side of the DataPortal.

Obviously I could

  1. Subclass CSLA objects and add my flag in the OnDataPortalInvoke &  OnDataPortalInvokeComplete & OnDataPortalException methods
  2. Capture those events in each of my business classes
  3. Alter CSLA framework

Problem with #1 is it runs me into the issue that Rocky discusses on page 249 of his latest book.
Problem with #2 is it is a lot of redundant code
Problem with #3 is it makes it that much harder to keep updated with new CSLA updates later

Any other bright ideas out there

Sean

swegele replied on Thursday, March 26, 2009

Seek and ye shall find!  LOL :-)

Looks like someone already asked for this because I just noticed the property

Csla.ApplicationContext.LogicalExecutionLocation

Sweet!  I have to remember to poke around in intellesense first next time.

Sean

 

ctkach replied on Friday, March 27, 2009

Any idea what version of the framework this is in?  I tried looking through the change management logs but couldn't find this property being added and I can't find it in the current version I'm using (3.5.1).

 

Thanks,

- Chris

ajj3085 replied on Friday, March 27, 2009

I think it was added at some point in the 2.x series.

swegele replied on Friday, March 27, 2009

I am using the latest 3.6 code.  I also didn't remember it being there before, but maybe I just missed it.

Works great!

Sean

rsbaker0 replied on Sunday, March 29, 2009

Have you tried this when using the local data portal?

I'm running CSLA 3.5.1, and it appears in the CSLA code that the value of ExecutionLocation remains "client" all the time unless you are using a remote data portal:

 

private static void SetContext(DataPortalContext context)

{

// if the dataportal is not remote then

// do nothing

if (!context.IsRemotePortal) return;

// set the context value so everyone knows the

// code is running on the server

ApplicationContext.SetExecutionLocation(ApplicationContext.ExecutionLocations.Server);

ajj3085 replied on Monday, March 30, 2009

Right... that's why the ApplicationContext.LogicalExeutionLocation was added.

rsbaker0 replied on Monday, March 30, 2009

Mea culpa. I should have been paying closer attention.

(And that looks like another reason to upgrade to 3.6...)

ajj3085 replied on Monday, March 30, 2009

Hey, it's Monday. Smile [:)]

sergeyb replied on Sunday, March 29, 2009

It was added in 3.6 version

--Sergey.

Copyright (c) Marimer LLC