예제 #1
0
 protected void SaveHandler(ServiceCallOptions options, Action <ServiceResponse> callback)
 {
     Q.ServiceCall(options);
 }
예제 #2
0
 public static void ServiceRequest <TResponse>(string service, ServiceRequest request, Action <TResponse> onSuccess, ServiceCallOptions options = null)
     where TResponse : ServiceResponse
 {
     ServiceCall(jQuery.ExtendObject(new ServiceCallOptions <TResponse>
     {
         Service   = service,
         Request   = request,
         OnSuccess = onSuccess
     }, options.As <ServiceCallOptions <TResponse> >()));
 }
예제 #3
0
        public static jQueryXmlHttpRequest ServiceCall <TResponse>(ServiceCallOptions <TResponse> options)
            where TResponse : ServiceResponse
        {
            options = jQuery.ExtendObject(new ServiceCallOptions <TResponse>
            {
                DataType    = "json",
                ContentType = "application/json",
                Type        = "POST",
                Cache       = false,
                BlockUI     = true,
                Url         = options.Service != null && !options.Service.StartsWith('~') && !options.Service.StartsWith('/') ?
                              Q.ResolveUrl("~/services/" + options.Service) : Q.ResolveUrl(options.Service),
                Data    = Q.ToJSON(options.Request),
                Success = (data, textStatus, request) =>
                {
                    //try
                    {
                        var response = data.As <TResponse>();
                        try
                        {
                            if (response.Error == null)
                            {
                                if (options.OnSuccess != null)
                                {
                                    options.OnSuccess(response);
                                }
                            }
                            else
                            {
                                if (Q.Config.NotLoggedInHandler != null &&
                                    response != null &&
                                    response.Error != null &&
                                    response.Error.Code == "NotLoggedIn" &&
                                    Q.Config.NotLoggedInHandler(options.As <ServiceCallOptions>(), response))
                                {
                                    return;
                                }

                                if (options.OnError != null)
                                {
                                    options.OnError(response);
                                }
                                else
                                {
                                    Q.ErrorHandling.ShowServiceError(response.Error);
                                }
                            }
                        }
                        finally
                        {
                            if (options.BlockUI)
                            {
                                Q.BlockUndo();
                            }

                            if (options.OnCleanup != null)
                            {
                                options.OnCleanup();
                            }
                        }
                    }
                    //catch (Exception e)
                    //{
                    //    StackTrace.Log(e);
                    //}
                },
                Error = (xhr, status, ev) =>
                {
                    //try
                    {
                        try
                        {
                            if (xhr.Status == 403)
                            {
                                string l = null;
                                try { l = xhr.GetResponseHeader("Location"); }
                                catch { l = null; }
                                if (l != null)
                                {
                                    Window.Top.Location.Href = l;
                                    return;
                                }
                            }

                            var html = xhr.ResponseText;

                            Q.Externals.IFrameDialog(new { html = html });
                        }
                        finally
                        {
                            if (options.BlockUI)
                            {
                                Q.BlockUndo();
                            }

                            if (options.OnCleanup != null)
                            {
                                options.OnCleanup();
                            }
                        }
                    }
                    //catch (Exception e)
                    //{
                    //    StackTrace.Log(e);
                    //}
                }
            }, options);

            if (options.BlockUI)
            {
                Q.BlockUI();
            }

            return(jQuery.Ajax(options.As <jQueryAjaxOptions>()));
        }
예제 #4
0
 public static extern XmlHttpRequest ServiceCall(ServiceCallOptions options);
예제 #5
0
 protected void LoadByIdHandler(ServiceCallOptions <RetrieveResponse <TEntity> > options, Action <RetrieveResponse <TEntity> > callback)
 {
     Q.ServiceCall(options);
 }
예제 #6
0
 protected virtual void UndeleteHandler(ServiceCallOptions <UndeleteResponse> options, Action <UndeleteResponse> callback)
 {
     Q.ServiceCall(options);
 }
예제 #7
0
 protected virtual void ExecuteQueryByKey(ServiceCallOptions <RetrieveResponse <TItem> > options)
 {
     Q.ServiceCall(options);
 }
예제 #8
0
 protected virtual void ExecuteQuery(ServiceCallOptions <ListResponse <TItem> > options)
 {
     Q.ServiceCall(options);
 }