all groups > dotnet distributed apps > december 2003 >
You're in the

dotnet distributed apps

group:

Using the UIP with Tasks and MemoryPersistence


Using the UIP with Tasks and MemoryPersistence n33470 NO[at]SPAM yahoo.com
12/31/2003 9:16:22 AM
dotnet distributed apps:
Hi all!

My goal is to create a Windows app using the UIP, in conjunction with
my own tasks using MemoryStatePersistence.

To prototype this, I took the QuickStart sample for the ShoppingCart
using the WinUI. What I wanted to try was to change the QuickStart
from using SQLServerStatePersistence to using MemoryStatePersistence.
In order to do this, I added the following stanza to the
<objecttypes> section of the app.config:

<statePersistenceProvider
name="MemoryStatePersistence"
type="Microsoft.ApplicationBlocks.UIProcess.MemoryStatePersistence,
Microsoft.ApplicationBlocks.UIProcess,
Version=1.0.1.0,Culture=neutral,PublicKeyToken=null"/>

I then changed the <navigationGraph> node to look like this:

<navigationGraph
iViewManager="WinFormViewManager"
name="Shopping"
state="State"
statePersist="MemoryStatePersistence"
startView="cart">

The rest of the QuickStart was left alone. When I start it up, I get
an error that says: "Task ID not found". This is thrown from line 312
from ConcreteFactories.cs

Has anyone else tried to do this? I would think it would be possible
to create the CartTask in memory, instead of persistent to SQL
Servier, right?

I suspect the problem is in the CartTask.Create method. When a task
is created using MemoryStatePersistence, what do you need to do
"initialize" the task in memory?

TIA!

Re: Using the UIP with Tasks and MemoryPersistence n33470 NO[at]SPAM yahoo.com
1/6/2004 6:22:06 AM
[quoted text, click to view]

In case anyone is interested, I did figure this out the other day.

In order to convert the QuickStart store to use
MemoryStatePersistence, the CartTask needs to be modified. The
CartTask assumes that it will go to SQLServer to lookup the mapping of
TaskIds to UserLogon strings. After a minor redesign of the
CartTask, I got the system converted just fine.

Re: Using the UIP with Tasks and MemoryPersistence Jet Set Willy
1/16/2004 10:52:06 AM

[quoted text, click to view]

I'm interested ! Cos I can't get it working...

[quoted text, click to view]

don't suppose there is any chance of you posting some code is there ?

TIA
--
jsw



Re: Using the UIP with Tasks and MemoryPersistence n33470 NO[at]SPAM yahoo.com
1/20/2004 8:32:28 AM
[quoted text, click to view]


jsw,

I only made enough modifications so that I could understand how it
works. I only modified enough to get the app to start, and to be able
to add items to the cart. I did not make enough modifications to get
the checkout process to work.

</soapbox on>
The most important thing to understand is that your persistence model
(either SQL Server, in memory, or otherwise) is an important
architecture decision that tends to have an effect on how your code
gets implemented. In other words, you can't expect an application to
be developed with MemoryStatePersistence and then at the last moment
switch it to SqlServerStatePersistence without expecting some aspects
of your application to be redesigned.
</soapbox off>

First, you need to go into SQL Server, in the "UIPStore" database,
open the 'CartTask' table, and delete all the rows in it. Then, in
the 'CartTask' class, you should change the 'Create' method to look
like this.

public void Create(Guid taskId)
{
// cache task id given to us by UIPManager (or whatever entity)
_taskId = taskId;
}

Then in the app.config file, you need to create the stanze for
'MemoryStatePersistence'

<statePersistenceProvider
name="MemoryStatePersistence"
type="Microsoft.ApplicationBlocks.UIProcess.MemoryStatePersistence,
Microsoft.ApplicationBlocks.UIProcess,
Version=1.0.1.0,Culture=neutral,PublicKeyToken=null"/>

Lastly, change the 'statePersist' attribute in the NavigationGraph:

statePersist="MemoryStatePersistence"

This should be all you need to at least get the QuickStart for the
Store example, WinUI to start up.

Re: Using the UIP with Tasks and MemoryPersistence n33470 NO[at]SPAM yahoo.com
1/23/2004 10:47:12 AM
[quoted text, click to view]

JSW,

Just to clarify, this was the point I was trying to make. When you
look at the ShoppingCart example, consider the changes we had to make
to go from SqlServerStatePersistence to MemoryStatePersistence. One
of the changes dealt with the CartTask. The CartTask object was
design expressly with the knowledge that it would be persisted in
SqlServer. The first change we had to make was to alter the CartTask
so that it wouldn't interact with SqlServer. So, in other words, the
design decision to use SqlServer for State management effected the
design of the CartTask.

Does this make sense? Do you understand my point? Sometimes design
decisions like this have a tendency to ripple through other aspects of
your design. That's all I meant.


Re: Using the UIP with Tasks and MemoryPersistence Jet Set Willy
1/23/2004 3:05:08 PM

[quoted text, click to view]

<snip stuff about using memory persistance rather
than sqlserver persistance>

[quoted text, click to view]

This is interesting - I could be getting this totally wrong
but I thought that the UIP stuff allowed you to do *exactly*
this without too much hassle. (ie once your State class
implements IStatePersistence then it should work fine).

One of the two of us is wrong and please note it could very
well be me ! If anyone else could shed some light it would
be apreciated.

<snip code samples>

[quoted text, click to view]

:-)
It certainly was - it was a bit of a fight but I got there in
the end. Many thanks for your time and code.

--
jsw



AddThis Social Bookmark Button