Ejemplo n.º 1
0
        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);
            }
        }
Ejemplo n.º 2
0
 //public static string (string asyncId, AsyncDialogCallback callback)
 //{
 //    return GetAsyncValue(asyncId, true, callback, false) as string;
 //}
 public static string AsyncDialog(string asyncId, AsyncDialogCallback callback, bool IsDialogValue)
 {
     return(GetAsyncValue(asyncId, true, callback, IsDialogValue) as string);
 }
Ejemplo n.º 3
0
 /// <summary>
 /// 单值对话框
 /// </summary>
 protected string AsyncDialog(string asyncId, AsyncDialogCallback callback, bool isDialog)
 {
     return(AsyncDialog(asyncId, callback, isDialog));
 }
Ejemplo n.º 4
0
 /// <summary>
 /// 获取异步对话框的值
 /// </summary>
 /// <param name="asyncId">异步值Id</param>
 /// <param name="callback">对话框回调方法</param>
 public static string AsyncDialog(string asyncId, AsyncDialogCallback callback)
 {
     return(GetAsyncValue(asyncId, true, callback, false) as string);
 }
Ejemplo n.º 5
0
 /// <summary>
 /// 获取异步对话框的值
 /// </summary>
 /// <param name="asyncId">异步值Id</param>
 /// <param name="callback">对话框回调方法</param>
 /// <returns></returns>
 public static new WebMeta AsyncDialog(string asyncId, AsyncDialogCallback callback)
 {
     return(GetAsyncValue(asyncId, false, callback, false) as WebMeta);
 }