Okay. One of the challenges the I feel this site needs to address is saving state. Professors spend a long time building a book and this leaves them vulnerable to session timeouts. And if they have spent a long time building a book and then lose it, they get pissed.
So the solution is to catch a session timeout and save their data. This turns out to be tricky. My first thought was to use Session_OnEnd or whatever. This turns out to not work. Session_OnEnd is managed by the process and when session state is managed by an outside server (as it must be on a farm) IT IS NOT FIRED. Toss away this idea.
The next idea is to use the ApplicationCache. It is a handy dandy application wide cache. You can toss crap into it with simple timeouts or toss in event handlers to be fired when a timeout on an object occurs. I used it to cache various configuration things and to reduce database hits for things like parameters or suggested table of contents. So you could use it for session state to. You just pop all the state you are keeping in session into the application cache every time you access your session. You set the key as the session id. You set the timeout as your session timeout. And you set up a nice little timeout handler which will save your session state if it times out in your application cache.
Ok, this gets a little tricky. I mentioned farm up above. It is possible that the thread handling this session will be run on different machines WITH DIFFERENT APPLICATION CACHES. Damn! But the timeouts will still fire and your data will be saved. In fact it will be saved at strange and unknown points. But if saves overwrite the last save should be the valid save. (Am I angering the god of strange timing events?) Of course, you will not be able to remove stuff from this multi-machine virtual application cache so it will save your session state regardless. Even if the prof saves the order normally session state will be saved and YOU CAN'T STOP IT. So even Profs who never time out will end up finding little autosave entries. This probably is ok...
Also the whole thing reeks of timing problems. I can't (subconsciosly don't want to) think of any really bad occurences since you make no real guarantees beside best effort to save state.
Ok, this leads to another design flaw I built in. This original site built an xml document in the page code that represented an order. In a moment of dumbassery I copied this structure even though the ability to translate itself into XML should be part of the Order object. So when I came to saving state I had to decide how to actually save the state. It should basically use the same system for saving a TOC, but it should use a keyword instead of an ISBN like 'SAVED' and it should always overwrite 'SAVED'. This led my to my previous design error. It also brought up another problem. In the current setup there is a delay between saving and seeing that your oject is saved. So 'SAVED' data may not be seen.
I could live with this error, since again it is a 'hopefully the back end redesign will fix it' problems. But will the BBDataManager support a saved TOC and overwriting? If not I will have to create another solution. If it does lots of useless save files will be tossed into the xml file repository, but then you could see just how often the Application cache was trying to save....
Yeah. I will have to come up with another solution.
Probably an ugly function that directly saves the orderinfo into the database. This should go into the data layer so that it can be redone later.
So what should I do? I will shift the XML saving stuff into the Order object, allow directly placing an Order object into a Message, and then build a datalayer function that can saved a TOC and basic info into the order table and can overwrite based on user identity and SAVED isbn.