/// <exception cref="WxePostbackOutOfSequenceException"> /// Thrown if a postback with an incorrect sequence number is handled. /// </exception> protected virtual void HandleLoadPostData(NameValueCollection postBackCollection) { ArgumentUtility.CheckNotNull("postBackCollection", postBackCollection); WxeContext wxeContext = WxeContext.Current; int postBackID = int.Parse(postBackCollection[WxePageInfo.PostBackSequenceNumberID]); if (postBackID != wxeContext.PostBackID) { CurrentPageStep.SetIsOutOfSequencePostBack(true); } string returningToken = postBackCollection[WxePageInfo.ReturningTokenID]; if (!string.IsNullOrEmpty(returningToken)) { WxeFunctionStateManager functionStates = WxeFunctionStateManager.Current; WxeFunctionState functionState = functionStates.GetItem(returningToken); if (functionState != null) { CurrentPageStep.SetReturnState(functionState.Function, true, null); _returningFunctionState = functionState; } } }
/// <summary> Resumes an existing <see cref="WxeFunction"/>. </summary> /// <include file='..\doc\include\ExecutionEngine\WxeHandler.xml' path='WxeHandler/ResumeExistingFunctionState/*' /> protected WxeFunctionState ResumeExistingFunctionState(HttpContext context, string functionToken) { ArgumentUtility.CheckNotNull("context", context); ArgumentUtility.CheckNotNullOrEmpty("functionToken", functionToken); string action = context.Request.Params[Parameters.WxeAction]; bool isRefresh = StringUtility.AreEqual(action, Actions.Refresh, true); bool isAbort = StringUtility.AreEqual(action, Actions.Abort, true) || StringUtility.AreEqual(action, Actions.Cancel, true); bool isPostBackAction = isRefresh || isAbort; bool isPostRequest = string.Compare(context.Request.HttpMethod, "POST", true) == 0; if (!WxeFunctionStateManager.HasSession) { if (isPostRequest || isPostBackAction) { s_log.Error(string.Format("Error resuming WxeFunctionState {0}: The ASP.NET session has timed out.", functionToken)); throw new WxeTimeoutException("Session timeout.", functionToken); // TODO: display error message } try { return(CreateNewFunctionState(context, GetType(context))); } catch (WxeException e) { s_log.Error(string.Format("Error resuming WxeFunctionState {0}: The ASP.NET session has timed out.", functionToken)); throw new WxeTimeoutException("Session timeout.", functionToken, e); // TODO: display error message } } WxeFunctionStateManager functionStateManager = WxeFunctionStateManager.Current; if (functionStateManager.IsExpired(functionToken)) { if (isPostRequest || isPostBackAction) { s_log.Error(string.Format("Error resuming WxeFunctionState {0}: The function state has timed out or was aborted.", functionToken)); throw new WxeTimeoutException("Function Timeout.", functionToken); // TODO: display error message } try { return(CreateNewFunctionState(context, GetType(context))); } catch (WxeException e) { s_log.Error(string.Format("Error resuming WxeFunctionState {0}: The function state has timed out or was aborted.", functionToken)); throw new WxeTimeoutException("Function Timeout.", functionToken, e); // TODO: display error message } } WxeFunctionState functionState = functionStateManager.GetItem(functionToken); if (functionState.IsAborted) { s_log.Error(string.Format("Error resuming WxeFunctionState {0}: The function state has been aborted.", functionState.FunctionToken)); throw new InvalidOperationException(string.Format("WxeFunctionState {0} is aborted.", functionState.FunctionToken)); // TODO: display error message } if (isRefresh) { functionStateManager.Touch(functionToken); functionStateManager.CleanUpExpired(); return(null); } else if (isAbort) { functionStateManager.CleanUpExpired(); functionStateManager.Abort(functionState); return(null); } else { functionStateManager.Touch(functionToken); functionStateManager.CleanUpExpired(); if (functionState.Function == null) { throw new WxeException(string.Format("Function missing in WxeFunctionState {0}.", functionState.FunctionToken)); } return(functionState); } }