Get Help:Ask a Question in our Forums|Report a Bug|More Help Resources
Last post Nov 29, 2012 10:08 PM by pratiksolanki
Nov 23, 2012 06:51 PM|LINK
I have bunch of session for eg.
Session["a"], Session["b"], Session["c"]
Is there any way or is it possible to save all this session as one object or one session into database.
Thank you so much for help.
Nov 23, 2012 07:01 PM|LINK
You want out of proc, SqlServer for session?
Nov 25, 2012 03:04 AM|LINK
Nov 26, 2012 07:40 AM|LINK
To store session objects in sql server database
change the following settings in web.config, specify the connection string :
sqlConnectionString="data source=127.0.0.1;user id=username;password=password"
Also refer this article:
Nov 26, 2012 07:30 PM|LINK
Can you explain bit more. It is not good idea to store lot of things into any type of session. If you can explain bit more than there may be better work around which would be efficient and scalable.
Nov 26, 2012 08:54 PM|LINK
This is what am i trying to do. I am creating a web applications for Customer service. when customer drop their calls we are saving all the session in tables as one so incase if they comeback later we will search from their name and if we find their name
then we will restore their old session. If you or anybody has any good way to do this let me know. So far i was able to store one session like this.
using (MemoryStream ms = new MemoryStream())
object a = Session["name"];
BinaryFormatter formatter = new BinaryFormatter();
ms.Position = 0;
bSession = ms.ToArray();
Nov 27, 2012 01:55 PM|LINK
Personally, I'd decouple yourself from Session and model the call as its own object. Then you have a self-contained model for the call and then persisting it is then easy (and you won't have to dig into each and every session value to save to remeber the
state of the call). This seems like a cleaner approach to modeling the call.
Then for acquiring the instance for the current call, perhaps you could use session or you could do a DB query, depengin upon the context. This is your call, but I'd warn
against session in general.
Nov 28, 2012 10:46 PM|LINK
After your little explaination. I assume when customer representative on call he will use your application and go through from various steps (record input into DB) and once call dropped before completion of all steps, later after 2 or 10 days when same customer
come accorss and you want to start with where customer left. If this is the scenario in your application then what you are doing is absolutely incorrect. You have to rethink your process and re-design your architecture.
If you think the business process I described as above is correct then let me know if you want then I can give you suggestion how you can accomplish your requirement.
Nov 29, 2012 04:18 AM|LINK
You are correct. Please advise me.
Nov 29, 2012 10:08 PM|LINK
Read this carefully as this describes process.
You need to have a table called "Tbl_SurveyMonitor".
Tbl_SurveyMonitor table would be shown as below (Add any other necessary coloumns if require)
ID, CustID, StepID, SurveyComplete (True/False)
I assume you stores Customer details when customer representative start talking on phone with customer, I assume you use stored procedure(SP) to insert customer details. Use @@IDENTITY to get new cutomer ID and store in this table.
(1) When first time customer representative contact to customer, your program needs to create an entry for the new customer in Tbl_SurveyMonitor table. Fill with data into the "CustID", "StepID" (First step ID), IsStepComplete = 0, SurveyComplete=0.
(Note: enhance your existing SP to add new insert statement as explain above to record into the new table)
(2) On every steps just update this customers StepID (create new SP called "usp_UpdateCustomerStep", on click on next update StepID with next stepID)
(3) On completion of survey update StepID and CompletionID = 1 (Create new SP called "usp_CompleteCustomerStep"
In Case of call dropped before completion, you now records in your DB on which step customer has dropped call (Note: If customer has dropped at end of a step then make sure Customer Representative click "next" to record next StepID).
In your program, at first you need to check whether this customer exists or not (To check this you need to write stored procedure), if exists then look into the Tbl_SurveyMonitor table, get the stepID where SurveyComplete =0. So now you have StepID and CustomerID,
now populate your respective page/view or wizard (if you have use wizard then).
Note: To check customer exists or not (I assume you are doing right now using SP) if have SP then enhance that SP and check current customer's survey has been completed or not. if not then return CustID and Step ID so in your program you can jump on
respective view otherwise start new survey (as usual).
I hope this make sense to you.