protected static object GetAsyncValue(string asyncId, bool singleValue, AsyncDialogCallback callback, bool IsDialog) { var context = WebContext.Current; var request = context.Request; var response = context.Response; if (singleValue) { var rValue = request.Arguments.Get(asyncId); if (String.IsNullOrEmpty(rValue)) { var value = request.Headers[EventType.Dialog]; var isSVs = false; if (String.IsNullOrEmpty(value) && request.Headers.ContainsKey(EventType.Dialog)) { var meValue = request.Headers.GetMeta(EventType.Dialog); if (meValue != null) { value = meValue[asyncId]; } } if (String.IsNullOrEmpty(value)) { if (IsDialog == false) { if (WebRuntime.Current.Items.ContainsKey(context.CurrentActivity) == false) { value = request.SendValue; } if (String.IsNullOrEmpty(value)) { var obj = request.Headers.GetDictionary()[request.Model]; if (obj is WebMeta) { var mob = ((WebMeta)obj); value = mob[asyncId]; mob.Remove(asyncId); isSVs = true; } else if (obj is IDictionary) { var idc = ((IDictionary)obj); value = idc[asyncId] as string; idc.Remove(asyncId); isSVs = true; } } } } if (String.IsNullOrEmpty(value) == false) { if (isSVs) { request.Arguments[(asyncId)] = value; return(value); } else if (WebRuntime.Current.Items.ContainsKey(context.CurrentActivity) == false) { WebRuntime.Current.Items.Add(context.CurrentActivity, true); request.Arguments[(asyncId)] = value; return(value); } } var dialog = callback(asyncId); dialog.AsyncId = asyncId; if (dialog is POSDialogValue) { var dv = dialog as POSDialogValue; request.Arguments[(asyncId)] = dv.InputValue; return(dv.InputValue); } response.RedirectDialog(request.Model, request.Command, dialog, request); } return(rValue); } else { var rValue = request.Arguments.GetMeta(asyncId); if (rValue == null) { rValue = request.Headers.GetMeta(EventType.Dialog);//?? request.SendValues; if (rValue == null) { if (request.SendValues != null && request.SendValues.ContainsKey(KEY_DIALOG_ID)) { if (request.SendValues[KEY_DIALOG_ID] == asyncId) { rValue = new WebMeta(request.SendValues.GetDictionary()); rValue.Remove(KEY_DIALOG_ID); var em = request.Arguments.GetDictionary().GetEnumerator(); while (em.MoveNext()) { rValue.Remove(em.Key as string); } } } } if (rValue == null || WebRuntime.Current.Items.ContainsKey(context.CurrentActivity)) { var dialog = callback(asyncId); dialog.AsyncId = asyncId; if (dialog is POSFromValue) { var dfv = dialog as POSFromValue; request.Arguments.Set(asyncId, dfv.InputValues); return(dfv.InputValues); } response.RedirectDialog(request.Model, request.Command, dialog, request); } else { WebRuntime.Current.Items.Add(context.CurrentActivity, true); request.Arguments.Set(asyncId, rValue);; } } return(rValue); } }