Ejemplo n.º 1
0
        private void AjaxError(jQueryXmlHttpRequest request, string textStatus, Exception error)
        {
            if (request.Status == 401)
            {
                // hide all modals first
                ((jQueryBootstrap)jQuery.Select(".modal")).Modal("hide");

                // Show login modal & error message
                LoginModal.GetUserName(
                    delegate(LoginResponse response)
                    {
                        // logged in, retry the request
                        SendRequest();
                    },
                    delegate(Exception error2)
                    {
                        // Login is cancelled, refresh the app
                        Application.Refresh();
                    },
                    true,
                    true);

                // error modal
                ErrorModal.ShowError(Strings.Get("UnauthorizedError"));
            }
            else
            {
                Failure(error);
            }
        }
Ejemplo n.º 2
0
		public void CancelRequests()
		{
			if (ajaxRequest != null)
			{
				ajaxRequest.Abort();
				ajaxRequest = null;
			}
		}
		protected override void MakeRequest(string text, Dictionary<object, object> requestParameters, int maxNumberOfItemsToGet)
		{
			Dictionary<object, object> parameters = new Dictionary<object, object>();
			parameters["text"] = text;
			parameters["maxNumberOfItemsToGet"] = maxNumberOfItemsToGet;
			parameters["parameters"] = requestParameters;
			//if (webRequest != null && webRequest.Executor.Started) webRequest.Executor.Abort();
			//webRequest = WebServiceProxy.Invoke(
			//    url,
			//    this.MethodName,
			//    true,
			//    parameters, 
			//    this.SuccessCallback,
			//    Trace.WebServiceFailure, text, -1
			//);
			if (ajaxRequest != null)
			{
				try
				{
					ajaxRequest.Abort();
				}
				catch { }
			}

			jQueryAjaxOptions o = new jQueryAjaxOptions();
			o.Url = url + "/" + this.MethodName;
			o.Timeout = 10000;
			o.Type = "POST";
			o.Async = true;
			o.Cache = false;
			o.ContentType = "application/json; charset=utf-8";
			o.Data = JSON.stringify(parameters);
			o.DataType = "json";
			o.Error =
				delegate(jQueryXmlHttpRequest request, string error, System.Exception exception)
				{
					//this.FailureCallback(
					//    new WebServiceError(
					//        exception.GetType().ToString(),
					//        error,
					//        exception.ToString(),
					//        request.Status,
					//        request.Status == 408),
					//    textSoFar,
					//    webServiceCommand);
				};
			o.Success =
				delegate(object data, string textStatus, jQueryXmlHttpRequest request)
				{
					this.SuccessCallback(((Dictionary<string, object>)data)["d"], text, this.MethodName);
				};
			ajaxRequest = jQuery.Ajax(o);

		}
Ejemplo n.º 4
0
		internal FailRequest(jQueryXmlHttpRequest request){

			Status = request.Status;
			StatusText = request.StatusText;
			ResponseText = request.ResponseText;

			try
			{
				var r = (dynamic)Json.Parse(request.ResponseText ?? "{}");
				Response= UI.Cast<ResponseStatus>( r.ResponseStatus?? new ResponseStatus());
			}
			catch(Exception){
				Response = new ResponseStatus ();
			}

			if (Response.Message.IsNullOrEmpty () && StatusText == "ValidationException")
				Response.Message = "User/Password Invalid";

			if (Response.ErrorCode.IsNullOrEmpty ()) {
				Response.ErrorCode = StatusText;
			}
		}
Ejemplo n.º 5
0
		public void RequestSuggestions(string textSoFar)
		{
			Dictionary<object, object> parameters = new Dictionary<object, object>();
			parameters["text"] = textSoFar;
			parameters["maxNumberOfItemsToGet"] = maxNumberOfItemsToGet;
			CancelRequests();
		//	webRequest = WebServiceProxy.Invoke(webServiceUrl, webServiceCommand, true, parameters, this.SuccessCallback, this.FailureCallback, textSoFar, -1);

			jQueryAjaxOptions o = new jQueryAjaxOptions();
			o.Url = webServiceUrl + "/" + webServiceCommand;
			o.Timeout = 10000;
			o.Type = "POST";
			o.Async = true;
			o.Cache = false;
			o.ContentType = "application/json; charset=utf-8";
			o.Data = JSON.stringify(parameters);
			o.DataType = "json";
			o.Error = 
				delegate(jQueryXmlHttpRequest request, string error, System.Exception exception)
				{
					this.FailureCallback(
						new WebServiceError(
							exception.GetType().ToString(),
							error,
							exception.ToString(),
							request.Status,
							request.Status == 408),
						textSoFar,
						webServiceCommand);
				};
			o.Success =
			    delegate(object data, string textStatus, jQueryXmlHttpRequest request)
			    {
					this.SuccessCallback(((Dictionary<string, object>)data)["d"], textSoFar, webServiceCommand);
			    };
			ajaxRequest = jQuery.Ajax(o);
			
		}
Ejemplo n.º 6
0
        private void AjaxSuccess(object responseData, string textStatus, jQueryXmlHttpRequest request)
        {
            if (Script.IsNullOrUndefined(responseData))
            {
                return;
            }

            ErrorResponse error = (ErrorResponse)responseData;
            if (Script.IsValue(error.errorCode) || Script.IsValue(error.errorMsg))
            {
                Failure(new Exception(Strings.Get(error.errorMsg)));
                return;
            }

            Success(responseData);
        }
Ejemplo n.º 7
0
		void gotCalendar(string data, string textStatus, jQueryXmlHttpRequest req, string args)
		{
			int requestIdFromArgs = int.Parse((string)args);
			if (requestId == requestIdFromArgs)
			{
				//Debug("gotCalendar data.Length = " + data.Length.ToString() + ", args = " + (args == null ? "null" : args.ToString()) + " (processing)");
				loadId++;
				view.CalendarHolder.InnerHTML = data;
				view.CalendarHolderOuter.Style.Display = "";
				view.CalendarLoadingOverlay.Style.Display = "none";
				view.LoadingLabel.Style.Display = "none";
				view.MonthLabel.Style.Display = "";
			}
			//else
			//	Debug("gotCalendar data.Length = " + data.Length.ToString() + ", args = " + (args == null ? "null" : args.ToString()) + " (skipping)");
		}
Ejemplo n.º 8
0
 private void FailedWsdl(jQueryXmlHttpRequest request, string textStatus, string error)
 {
     _wsdlErrorCallback(request, textStatus, error);
 }
		void gotCalendar(string data, string textStatus, jQueryXmlHttpRequest req, string args)
		{
			
			int requestIdFromArgs = int.Parse((string)args);
			if (requestId == requestIdFromArgs)
			{
				loadId++;
				view.CalendarHolder.InnerHTML = data;
				view.CalendarHolderOuter.Style.Display = "";
				view.CalendarLoadingOverlay.Style.Display = "none";
				view.LoadingLabel.Style.Display = "none";
				view.MonthLabel.Style.Display = "";
			}
		}
		void gotContent(string data, string textStatus, jQueryXmlHttpRequest req, string args)
		{
			int requestIdFromArgs = int.Parse((string)args);
			if (requestId == requestIdFromArgs)
			{
				loadId++;
				view.Result.InnerHTML = data;
				view.ResultOuter.Style.Display = "";
				view.LoadingOverlay.Style.Display = "none";
			}
		}
		internal override void DoAbortCurrentRequest()
		{
			if (ajaxRequest != null)
			{
				ajaxRequest.Abort();
				ajaxRequest = null;
			}
		}