[quoted text, click to view] "Jet Set Willy" <JetSetWilly@manic-miner.freeserve.co.uk> wrote in message news:<#igZL7B3DHA.1816@TK2MSFTNGP12.phx.gbl>...
> "Steve Nelson" <n33470@yahoo.com> wrote in message
> news:9b6763d2.0401060622.252f672b@posting.google.com...
> > n33470@yahoo.com (Steve Nelson) wrote in message
> news:<9b6763d2.0312310916.13fe28d5@posting.google.com>...
> >
> > > 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!
> > >
> > > --steve
> >
> > In case anyone is interested, I did figure this out the other day.
>
> I'm interested ! Cos I can't get it working...
>
> > 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.
>
> don't suppose there is any chance of you posting some code is there ?
>
> TIA
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.