標籤:
System.Web.HttpContext httpContext = System.Web.HttpContext.Current;
Hashtable departmentSalary = (Hashtable)httpContext.Application["DepartmentSalary"];
try
{
if (departmentSalary != null && departmentSalary.ContainsValue(KEYID))
{
throw ServiceException.NewException(MethodBase.GetCurrentMethod().Name + ":該XXXX已有人操作");
}
departmentSalary = new Hashtable();
departmentSalary[httpContext.Session.SessionID] = KEYID; //初始化目前使用者的 sessionid
httpContext.Application.Lock();
httpContext.Application["DepartmentSalary"] = departmentSalary;
httpContext.Application.UnLock();
調用wcf介面
}
catch (Exception)
{
throw;
}
finally
{
departmentSalary.Remove(httpContext.Session.SessionID);
httpContext.Application.Lock();
httpContext.Application["DepartmentSalary"] = departmentSalary;
httpContext.Application.UnLock();
}
mvc wcf 並發提示,儲存Application,驗證是否有使用者在操作