コード例 #1
0
        public ActionResult GetVFRInfoByJobID(int jobID)
        {
            var watch = System.Diagnostics.Stopwatch.StartNew();

            GlobalVars.ResultsVFR resultVFR = new GlobalVars.ResultsVFR();
            try
            {
                logger.Info("GetVFRInfoByJobID API Request. Job ID: " + jobID);
                if (jobID == 0)
                {
                    Response.StatusCode  = (int)HttpStatusCode.BadRequest;
                    resultVFR.ReturnCode = -1;
                    resultVFR.Message    = "Missing argument Job ID";
                    logger.Warn("GetJobsByProjectID API Request ends with an Error.");
                    logger.Warn(resultVFR.Message);
                }
                else
                {
                    resultVFR = SQLFunctionsVFR.GetVFRInfoByJobID(jobID);
                    switch (resultVFR.ReturnCode)
                    {
                    case 0:
                        logger.Info("GetVFRInfoByJobID API Request was executed Successfully.");
                        Response.StatusCode = (int)HttpStatusCode.OK;
                        break;

                    case -2:
                        Response.StatusCode = (int)HttpStatusCode.InternalServerError;
                        logger.Fatal("GetVFRInfoByJobID API Request ends with a Fatal Error.");
                        logger.Debug("Returned value:" + JsonConvert.SerializeObject(resultVFR, Formatting.Indented));
                        Response.StatusCode = (int)HttpStatusCode.InternalServerError;
                        break;
                    }
                }
            }
            catch (Exception e)
            {
                logger.Fatal("GetVFRInfoByJobID API Request ends with a Fatal Error.");
                resultVFR.ReturnCode = -2;
                resultVFR.Message    = e.Message;
                var baseException = e.GetBaseException();
                resultVFR.Exception = baseException.ToString();
                logger.Fatal("Returned value:" + JsonConvert.SerializeObject(resultVFR, Formatting.Indented));
                Response.StatusCode = (int)HttpStatusCode.InternalServerError;
            }
            Response.ContentType = "application/json";
            watch.Stop();
            var elapsedMs = watch.ElapsedMilliseconds;

            elapsedMs             = elapsedMs / 1000;
            resultVFR.ElapsedTime = elapsedMs.ToString();
            logger.Debug("Returned value:" + JsonConvert.SerializeObject(resultVFR, Formatting.Indented));
            resultVFR.HttpStatusCode = Response.StatusCode.ToString();
            var messaje = JsonConvert.SerializeObject(resultVFR, Formatting.Indented);

            logger.Info("Leaving GetVFRInfoByJobID API.");
            //return Json(messaje);
            return(Content(messaje));
        }
コード例 #2
0
        public ActionResult UpdateVFRInfo([FromBody] string vfrJS)
        {
            var watch = System.Diagnostics.Stopwatch.StartNew();

            GlobalVars.ResultGeneric result = new GlobalVars.ResultGeneric()
            {
                Message    = "",
                ReturnCode = 0,
                //ReturnValue = ""
            };
            try
            {
                if (vfrJS == null)
                {
                    Response.StatusCode = (int)HttpStatusCode.BadRequest;
                    result.ReturnCode   = -1;
                    result.Message      = "Missing argument vfrJS";
                    logger.Warn("UpdateVFRInfo API Request ends with an Error.");
                    logger.Warn(result.Message);
                }
                else
                {
                    GlobalVars.VFR vfr = JsonConvert.DeserializeObject <GlobalVars.VFR>(vfrJS);
                    logger.Info("UpdateVFRInfo API Request.");
                    if (vfr.JobID != 0)
                    {
                        logger.Debug("Parameter:" + JsonConvert.SerializeObject(vfr, Formatting.Indented));

                        result = SQLFunctionsVFR.UpdateVFRInfo(vfr);
                        switch (result.ReturnCode)
                        {
                        case 0:
                            logger.Info("UpdateVFRInfo API Request was executed Successfully.");
                            Response.StatusCode = (int)HttpStatusCode.OK;
                            break;

                        case -1:
                            logger.Info("UpdateVFRInfo API Request ends with a warning.");
                            Response.StatusCode = (int)HttpStatusCode.OK;
                            break;

                        case -2:
                            Response.StatusCode = (int)HttpStatusCode.InternalServerError;
                            logger.Fatal("UpdateVFRInfo API Request ends with a Fatal Error.");
                            logger.Debug("Returned value:" + JsonConvert.SerializeObject(result, Formatting.Indented));
                            Response.StatusCode = (int)HttpStatusCode.InternalServerError;
                            break;
                        }
                    }
                    else
                    {
                        Response.StatusCode = (int)HttpStatusCode.BadRequest;
                        result.ReturnCode   = -1;
                        result.Message      = "Job ID value is not valid.";
                        logger.Warn("UpdateVFRInfo API Request ends with an Error.");
                        logger.Warn(result.Message);
                    }
                }
            }
            catch (Exception e)
            {
                logger.Fatal("UpdateVFRInfo API Request ends with a Fatal Error.");
                result.ReturnCode = -2;
                result.Message    = e.Message;
                var baseException = e.GetBaseException();
                result.Exception = baseException.ToString();
                logger.Fatal("Returned value:" + JsonConvert.SerializeObject(result, Formatting.Indented));
                Response.StatusCode = (int)HttpStatusCode.InternalServerError;
            }
            Response.ContentType = "application/json";
            watch.Stop();
            var elapsedMs = watch.ElapsedMilliseconds;

            elapsedMs             = elapsedMs / 1000;
            result.ElapsedTime    = elapsedMs.ToString();
            result.HttpStatusCode = Response.StatusCode.ToString();
            var messaje = JsonConvert.SerializeObject(result, Formatting.Indented);

            logger.Info("Leaving UpdateVFRInfo API");
            //return Json(messaje);
            return(Content(messaje));
        }