コード例 #1
0
        private void Return(WxeContext context)
        {
            ArgumentUtility.CheckNotNull("context", context);

            NameValueCollection postBackCollection;

            if (StringUtility.AreEqual(context.HttpContext.Request.HttpMethod, "POST", false))
            {
                postBackCollection = context.HttpContext.Request.Form;
            }
            else
            {
                postBackCollection = context.HttpContext.Request.QueryString;
            }

            postBackCollection = postBackCollection.Clone();
            if (_backedUpPostBackData != null)
            {
                foreach (var key in _backedUpPostBackData.AllKeys)
                {
                    postBackCollection[key] = _backedUpPostBackData[key];
                }
            }
            else
            {
                postBackCollection.Remove(ControlHelper.PostEventSourceID);
                postBackCollection.Remove(ControlHelper.PostEventArgumentID);
            }
            _pageStep.SetReturnState(_function, true, postBackCollection);

            _backedUpPostBackData = null;

            _isReturningPostBack = true;
        }
コード例 #2
0
 public void AreEqual()
 {
     Assert.That(StringUtility.AreEqual("test1", "test1", false), Is.EqualTo(true));
     Assert.That(StringUtility.AreEqual("test1", "test1", true), Is.EqualTo(true));
     Assert.That(StringUtility.AreEqual("test1", "TEST1", false), Is.EqualTo(false));
     Assert.That(StringUtility.AreEqual("test1", "TEST1", true), Is.EqualTo(true));
     Assert.That(StringUtility.AreEqual("täst1", "TÄST1", false), Is.EqualTo(false));
     Assert.That(StringUtility.AreEqual("täst1", "TÄST1", true), Is.EqualTo(true));
 }
コード例 #3
0
        private NameValueCollection DeterminePostBackMode(HttpContext httpContext)
        {
            WxeContext wxeContext = WxeContext.Current;

            if (wxeContext == null)
            {
                return(null);
            }
            if (!CurrentPageStep.IsPostBack)
            {
                return(null);
            }
            if (CurrentPageStep.PostBackCollection != null)
            {
                return(CurrentPageStep.PostBackCollection);
            }
            if (httpContext.Request == null)
            {
                return(null);
            }

            NameValueCollection collection;

            if (StringUtility.AreEqual(httpContext.Request.HttpMethod, "POST", false))
            {
                collection = httpContext.Request.Form;
            }
            else
            {
                collection = httpContext.Request.QueryString;
            }

            if ((collection[ControlHelper.ViewStateFieldPrefixID] == null) && (collection[ControlHelper.PostEventSourceID] == null))
            {
                return(null);
            }
            else
            {
                return(collection);
            }
        }
コード例 #4
0
        /// <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);
            }
        }