我有这组代码,其中包含setsession
和getsession
protected void btnCall_Click(Object sender, EventArgs e)
{
if (isCallComplete())
{
Collection<Greeting> collGreeting = sessionHelper.GetSession("CurrentGreetingData") as Collection<Greeting>;
if (collGreeting.Count > 0)
{
Collection<CounterbySA> collCounterBySA = new ServiceFacade(User).SelectByFieldName<CounterbySA>("SAID", 106);//CurrentApplicationUser.id
if (collCounterBySA.Count > 0)
{
Counter counter = new ServiceFacade(User).SelectById<Counter>(collCounterBySA[0].CounterID);
Greeting greeting = collGreeting[0];
BoardQueue boardQueue = new BoardQueue();
boardQueue.BranchID = CurrentApplicationUser.BranchID;
boardQueue.CounterID = counter.ID;
boardQueue.SAID = 106; //CurrentApplicationUser.ID
boardQueue.PlatNumber = greeting.PlatNumber;
boardQueue.Status = (int)CallCustomerStatus.Open;
ResultStatus rs = new ServiceFacade(User).InsertBoardQueue(boardQueue);
voiceCall(string.Format("{0}di{1}", greeting.PlatNumber, counter.Name));
MessageBox.Show(string.Format("{0} Silahkan ke {1}", greeting.PlatNumber, counter.Name));
btnCall.Enabled = false;
btnReCall.Enabled = true;
btnComplete.Enabled = true;
sessionHelper.SetSession("CurrentCallData", boardQueue);
sessionHelper.SetSession("CurrentGreetingTemp", greeting);
}
else
{
MessageBox.Show("SA ini Belom terdaftar di Loket, Silahkan ke manu AssignSA untuk mendaftarkan/menempatkan SA ke Loket");
}
}
else
{
MessageBox.Show("Tidak Ada Customer Untuk Di panggil");
}
}
else if (isCurrentUser())
{
MessageBox.Show("sedang memanggil customer, click panggil ulang apabila customer belum datang");
btnCall.Enabled = true;
btnReCall.Enabled = true;
btnComplete.Enabled = true;
}
else
{
MessageBox.Show("SA lain sedang memanggil Customer, harap menunggu");
}
所以,如果我点击按钮调用它将设置2 session
这就是我得到会议的地方
protected void btnReCall_Click(Object sender, EventArgs e)
{
BoardQueue boardQueue = sessionHelper.GetSession("CurrentCallData") as BoardQueue;
if (boardQueue != null)
{
Counter counter = new ServiceFacade(User).SelectById<Counter>(boardQueue.CounterID);
voiceCall(string.Format("{0}di{1}", boardQueue.PlatNumber, counter.Name));
MessageBox.Show(string.Format("{0} Silahkan ke {1}", boardQueue.PlatNumber, counter.Name));
btnNext.Enabled = true;
}
else
{
MessageBox.Show("Harap Memanggil Customer terlebih Dahulu");
}
}
在页面刷新之前,它可以正常工作。但在页面刷新后会话消失了。
我已经对这个主题做了一些研究,但我无法得到答案
以下是会话的get和set方法
public void SetSession(string sKey, object sValue)
{
HttpContext.Current.Session[sKey] = sValue;
AddSession(sKey, true);
}
public object GetSession(string sKey)
{
return ((object)(HttpContext.Current.Session[sKey]));
}