示例#1
0
        public override Task <ErrorResponse> IDoNotLogRpcExceptionCorrectly(ErrorRequest request, ServerCallContext context)
        {
            var exception = new Exception("I am the inner exception");
            var rpcStatus = new Status(StatusCode.Internal, "I will result in the right rpc status code. But i only will only be logged as information under 'Grpc.AspNetCore.Server.ServerCallHandler'. Nobody on server side will normally see me", exception);

            throw new RpcException(rpcStatus, exception.ToString());
        }
        const string JUNAIO_KEY          = Auth.ApiKey; //Reference to API Key

        protected void Page_Load(object sender, EventArgs e)
        {
            JunaioAuthentication junAuthenticate = new JunaioAuthentication(AUTH_DATE_TOLERANCE, JUNAIO_KEY);

            if (!junAuthenticate.checkAuthentication())
            {
                var request = new ErrorRequest(Request.Params);
                Response.Write(request.GenerateResults());
            }
            else
            {
                string   path      = Request.PathInfo;
                string[] pathArray = path.Split('/');

                try
                {
                    var request = RequestFactory.GenerateRequest(pathArray[2], Request.Params);
                    Response.Write(request.GenerateResults());
                }
                catch (Exception exceptions)
                {
                    Response.StatusCode        = 404;
                    Response.StatusDescription = "Not found";
                    Response.Flush();
                    Response.Close();
                }
            }
        }
示例#3
0
 public override async Task <ErrorResponse> GiveMeADetailedUnhandledException(ErrorRequest request, ServerCallContext context)
 {
     return(await grpcExceptionHandler.HandleExceptions <ErrorResponse>(() =>
     {
         var innerException = new Exception("I am the inner exception");
         throw new InvalidOperationException("Unexpected exception occurred.", innerException);
     }, context, logger));
 }
示例#4
0
 protected internal virtual void OnErrorRequest(object sender, IErrorRequestEventArgs <TService> e)
 {
     if (!Enabled)
     {
         return;
     }
     ErrorRequest?.Invoke(sender, e);
 }
示例#5
0
        ErrorResponse IHellaAPCECOInterface.Error(ErrorRequest errorrequest)
        {
            ErrorResponse MyErrorResponse = new ErrorResponse();

            Task[] MyTaskList = null;//无任务应答
            MyErrorResponse.task_message = MyTaskList;
            Preprocessing2(errorrequest.error_message);

            return(MyErrorResponse);
        }
示例#6
0
        // Get a message from the server, choose what action to executed depending if it is a request, a response, notification or an error
        // If it is a request, use the callback when the request is finished
        public void HandleMessage(string json, SuccessRequest onSuccessRequest, ErrorRequest onErrorRequest)
        {
            //Debug.Log("Message: " + json);
            var data = Json.Deserialize(json) as Dictionary <string, object>;

            if (data.ContainsKey("error")) // Response error from a request this client made to the server
            {
                var    idAction     = data["id"].ToString();
                var    errorData    = data["error"] as Dictionary <string, object>;
                int    code         = Convert.ToInt32(errorData["code"]);
                string errorMessage = errorData["message"].ToString();

                // Check if there is data inside the error
                Dictionary <string, object> dataError = null;
                if (errorData.ContainsKey("data"))
                {
                    dataError = errorData["data"] as Dictionary <string, object>;
                }

                _handler.handleError(idAction, code, errorMessage, dataError);
            }
            else if (data.ContainsKey("result")) // result the server is sending to this client, from a request this client made to the server previously
            {
                var    idAction = data["id"].ToString();
                object result   = data["result"];
                _handler.handleResponse(idAction, result);
            }
            else // request message or notification. A request the server is asking to this client, or a notification the server is sending to this client
            {
                string method = data["method"].ToString();
                Dictionary <string, object> param = null;
                if (data.ContainsKey("params"))
                {
                    param = Json.Deserialize(data["params"].ToString()) as Dictionary <string, object>;
                }

                string idAction = null;
                if (data.ContainsKey("id")) // if it have id, it is a request
                {
                    idAction = data["id"].ToString();
                    try{
                        var result = _handler.handleRequest(method, param);
                        onSuccessRequest(result, idAction);
                    }catch (Exception e)
                    {
                        onErrorRequest(idAction, new Dictionary <string, object>(), e);
                    }
                }
                else // Notification
                {
                    _handler.handleNotification(method, param);
                }
            }
        }
 public WWW POST(string url, Dictionary<string, string> post, CompleteRequest FunctionRequest, ErrorRequest Err = null)
 {
     WWWForm form = new WWWForm();
     foreach (KeyValuePair<string, string> post_arg in post)
     {
         form.AddField(post_arg.Key, post_arg.Value);
     }
     WWW www = new WWW(url, form);
     StartCoroutine(WaitForRequest(www, FunctionRequest, Err));
     return www;
 }
 public IEnumerator WaitForRequest(WWW www, CompleteRequest FunctionRequest, ErrorRequest Err)
 {
     yield return www;
     if (www.error == null)
     {
         if (FunctionRequest != null)
             FunctionRequest(www);
     }
     else
     {
         if (Err != null)
             Err(www);
     }
 }
        public async Task AddError(ErrorRequest errorRequest)
        {
            Error newError = await _errorRepository
                             .Insert(new Error(Guid.NewGuid(), errorRequest.Type, errorRequest.Title, errorRequest.Details));

            if (errorRequest.Files.Count > 0)
            {
                List <ErrorFile> errorFiles = ConvertFile(errorRequest.Files);

                errorFiles.ForEach(x => x.ErrorId = newError.Id);

                await _errorFileRepository.InsertRange(errorFiles);
            }
        }
示例#10
0
        // GET: UserLogins
        public async Task <IActionResult> Index()
        {
            var ret = await _context.userLogin.ToListAsync();

            if (ret == null || ret.Count == 0)
            {
                var error = new ErrorRequest();
                error.Message = "no hay usuarios";


                return(BadRequest(new JsonResult(error)));
            }

            return(Ok(new JsonResult(ret)));
        }
示例#11
0
        public IActionResult Login([FromBody] userLogin model)
        {
            var PassEncript = Seguridad.Encriptarpass(model.Password);
            var user        = _context.userLogin.Where(u => u.Email == model.Email && u.Password == PassEncript).FirstOrDefault();

            if (user != null)
            {
                if (user.Token == null)
                {
                    setToken(user);
                }
                var userRet = new userReturn(user.Nombre, user.Apellido, user.Token);

                return(Ok(new JsonResult(userRet)));
            }

            var error = new ErrorRequest("Datos incorrectos");

            return(NotFound(error.ToJson()));
        }
示例#12
0
        // GET: UserLogins/Details/5
        public async Task <IActionResult> Details(int?id)
        {
            if (id == null)
            {
                var errorNull = new ErrorRequest();
                errorNull.Message = "debe indicar el id del usuario";

                return(NotFound(new JsonResult(errorNull)));
            }

            var userLogin = await _context.userLogin
                            .FirstOrDefaultAsync(m => m.Id == id);


            if (userLogin == null)
            {
                var error = new ErrorRequest();
                error.Message = "No existe el usuario";

                return(NotFound(error.ToJson()));
            }

            return(Ok(new JsonResult(userLogin)));
        }
示例#13
0
        public async Task <IActionResult> Get(ErrorRequest errorRequest)
        {
            try
            {
                var group = await _groupRepository.Get(errorRequest.ApplicationGroup);

                if (group != null)
                {
                    var application = await _applicationRepository.Get(group.Id, errorRequest.ApplicationName);

                    if (application != null)
                    {
                        return(Json(await _errorTemplateRepository.Get(application.Id, errorRequest.ApplicationErrorCode)));
                    }
                }

                return(Json(null));
            }
            catch (Exception e)
            {
                _logger.LogError($"[{System.Reflection.MethodBase.GetCurrentMethod().Name}] {e.Message ?? ""}", e);
                return(BadRequest(e.Message ?? ""));
            }
        }
	// Use this for initialization
    public WWW GET(string url, CompleteRequest FunctionRequest, ErrorRequest Err = null)
    {
        WWW www = new WWW(url);
        StartCoroutine(WaitForRequest(www, FunctionRequest, Err));
        return www;
    }
示例#15
0
        // GET: UserLogins/Edit/5
        public IActionResult Edit(int?id)
        {
            var error = new ErrorRequest("la solicitud debe ser por POST");

            return(NotFound(error.ToJson()));
        }
示例#16
0
        public override Task <ErrorResponse> IDoNotHandleErrorCorrectly(ErrorRequest request, ServerCallContext context)
        {
            var innerException = new Exception("I am the inner exception");

            throw new Exception("I will result in a status code UNKNOWN. I also will be logged as error under 'Grpc.AspNetCore.Server.ServerCallHandler'.", innerException);
        }
示例#17
0
 protected virtual void OnErrorRequest(ClientRequestErrorEventArgs e)
 {
     ErrorRequest?.Invoke(this, e);
 }
示例#18
0
        public async Task <IActionResult> Add(ErrorRequest errorRequest)
        {
            await _errorAppService.AddError(errorRequest);

            return(Ok());
        }