Ejemplo n.º 1
0
        public ActionResult GetUIFunctionalities()
        {
            var watch = System.Diagnostics.Stopwatch.StartNew();

            GlobalVars.ResultUIFunctionalities resultUIFunctionalities = new GlobalVars.ResultUIFunctionalities();
            try
            {
                logger.Info("GetUIFunctionalities API Request.");
                resultUIFunctionalities = SQLFunctionsUsers.GetUIFunctionalities();
                switch (resultUIFunctionalities.ReturnCode)
                {
                case 0:
                    logger.Info("GetUIFunctionalities API Request was executed Successfully.");
                    Response.StatusCode = (int)HttpStatusCode.OK;
                    break;

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

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

            logger.Info("Leaving GetUIFunctionalities API.");
            //return Json(messaje);
            return(Content(messaje));
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Get List of UI Functionalities
        /// </summary>
        /// <returns></returns>
        static public GlobalVars.ResultUIFunctionalities GetUIFunctionalities()
        {
            List <GlobalVars.UIFunctionality> uiFunctionalities = new List <GlobalVars.UIFunctionality>();

            GlobalVars.ResultUIFunctionalities resultUIFunctionalities = new GlobalVars.ResultUIFunctionalities()
            {
                ReturnCode     = 0,
                Message        = "",
                ReturnValue    = uiFunctionalities,
                RecordsCount   = 0,
                HttpStatusCode = ""
            };
            try
            {
                logger.Trace("Entering into GetUIFunctionalities Method ...");
                using (ScanningDBContext DB = new ScanningDBContext())
                {
                    var results = DB.Sssfunctionality;
                    resultUIFunctionalities.RecordsCount = results.Count();
                    if (results.Count() >= 1)
                    {
                        foreach (var x in results)
                        {
                            GlobalVars.UIFunctionality uiFunctionality = new GlobalVars.UIFunctionality()
                            {
                                FunctionalityID = x.FunctionalityId,
                                Description     = (x.Functionality ?? "").Trim(),
                            };
                            uiFunctionalities.Add(uiFunctionality);
                        }
                    }
                }
                resultUIFunctionalities.ReturnValue = uiFunctionalities;
                resultUIFunctionalities.Message     = "GetUIFunctionalities transaction completed successfully. Number of records found: " + resultUIFunctionalities.RecordsCount;
                logger.Debug(resultUIFunctionalities.Message);
            }
            catch (Exception e)
            {
                logger.Error("Error:" + e.Message + "\n" + "Exception: " + e.InnerException);
                resultUIFunctionalities.ReturnCode = -2;
                resultUIFunctionalities.Message    = e.Message;
                var baseException = e.GetBaseException();
                resultUIFunctionalities.Exception = baseException.ToString();
            }
            logger.Trace("Leaving GetUIFunctionalities Method ...");
            return(resultUIFunctionalities);
        }