/// <summary> /// 重新请求 /// </summary> /// <param name="mode">模块</param> /// <param name="cmd">命令</param> /// <param name="dialog">对话框</param> public void Redirect(string mode, string cmd, UMC.Web.UIDialog dialog) { this.Headers.Set(EventType.AsyncDialog, dialog.ToAsyncArgs()); this.ClientEvent |= WebEvent.AsyncDialog; this.ClientRedirect = new ClientRedirect { Model = mode, Command = cmd }; this.End(); }
/// <summary> /// 重新请求 /// </summary> /// <param name="mode">模块</param> /// <param name="cmd">命令</param> /// <param name="endResponse">是否结束响应返回客户端</param> public void Redirect(string mode, string cmd, bool endResponse) { this.ClientRedirect = new ClientRedirect { Model = mode, Command = cmd }; if (endResponse) { this.End(); } }
/// <summary> /// 重新请求 /// </summary> /// <param name="mode">模块</param> /// <param name="cmd">命令</param> /// <param name="arguments">参数</param> public void Redirect(string mode, string cmd, WebMeta arguments, bool endResponse) { this.ClientRedirect = new ClientRedirect { Model = mode, Command = cmd, Value = Data.JSON.Serialize(arguments) }; if (endResponse) { this.End(); } }
internal void RedirectDialog(string mode, string cmd, UMC.Web.UIDialog dialog, WebRequest req) { this.Headers.Set(EventType.AsyncDialog, dialog.ToAsyncArgs()); if (req.Items.Count > 0) { req.Arguments.Set(WebRequest.KEY_ARGUMENTS_ITEMS, req.Items); } this.Headers.Set(WebRequest.KEY_HEADER_ARGUMENTS, req.Arguments); this.ClientEvent |= WebEvent.AsyncDialog | WebEvent.Dialog; this.ClientRedirect = new ClientRedirect { Model = mode, Command = cmd }; this.End(); }
void Send(System.Collections.IDictionary doc2) { this.IsEmptyReq = false; var context = this.Context = doc2 == null?WebRuntime.Start(this) : WebRuntime.ProcessRequest(doc2, this); var response = context.Response; if (IsEmptyReq) { _lastRedirect = null; } this.Session.Check(context); this.RedirectTimes++; var clientEvent = response.ClientEvent; this.InnerHeaders.Clear(); this.ModelCommand(context.Request.Model, context.Request.Command, this.InnerHeaders); if ((Convert.ToInt32(clientEvent) & OuterDataEvent) == OuterDataEvent) { this.ClientEvent = clientEvent; this.OutputHeader(response.Headers); return; } var clientRedirect = response.ClientRedirect; if ((clientEvent & WebEvent.AsyncDialog) == WebEvent.AsyncDialog) { this.InnerHeaders[WebRequest.KEY_HEADER_ARGUMENTS] = response.Headers.GetMeta(WebRequest.KEY_HEADER_ARGUMENTS); if (clientRedirect != null) { if ((clientEvent & WebClient.Prompt) != WebClient.Prompt) { this.ModelCommand(clientRedirect.Model, clientRedirect.Command, this.InnerHeaders); clientRedirect = response.ClientRedirect = null; } } if ((clientEvent & WebEvent.Dialog) == WebEvent.Dialog) { clientEvent ^= WebEvent.Dialog; this.InnerHeaders["POS-DIALOG"] = "YES"; } } if (clientRedirect != null) { if (this.RedirectTimes > 10) { throw new Exception(String.Format("{0}.{1},请求重定向超过最大次数", clientRedirect.Model, clientRedirect.Command)); } var args = response.Headers.GetMeta(WebRequest.KEY_HEADER_ARGUMENTS); _lastRedirect = clientRedirect; if (clientEvent != WebEvent.None) { this.ClientEvent |= clientEvent; response.Headers.Remove(WebRequest.KEY_HEADER_ARGUMENTS); OutputHeader(response.Headers); } if (String.IsNullOrEmpty(response.ClientRedirect.Value)) { this.Redirect(clientRedirect.Model, clientRedirect.Command, args); } else { if (clientRedirect.Value.IndexOf("&") > -1) { var nquery = System.Web.HttpUtility.ParseQueryString(clientRedirect.Value); this.Redirect(clientRedirect.Model, clientRedirect.Command, nquery); } else if (clientRedirect.Value.StartsWith("{")) { var p = UMC.Data.JSON.Deserialize(clientRedirect.Value) as Hashtable; var pos = new NameValueCollection(); var em = p.GetEnumerator(); while (em.MoveNext()) { pos[em.Key.ToString()] = em.Value.ToString(); } this.Redirect(clientRedirect.Model, clientRedirect.Command, pos); } else { this.Redirect(clientRedirect.Model, clientRedirect.Command, clientRedirect.Value); } } return; } response.Headers.Remove(WebRequest.KEY_HEADER_ARGUMENTS); OutputHeader(response.Headers); this.ClientEvent = this.ClientEvent | clientEvent; if (IsEmptyReq == false) { if (_lastRedirect != null && XHRTime > 1) { this.ClientEvent = this.ClientEvent | WebEvent.Reset; response.Headers.Put("Reset", _lastRedirect); } } }