public ActionResult Index()
        {
            #region Debug
            log.Debug("Entrada no método Index...");
            #endregion Debug

            List <Script_CondicaoScript_CT_VO> Cts     = new List <Script_CondicaoScript_CT_VO>();
            List <Script_CondicaoScriptVO>     scripts = new List <Script_CondicaoScriptVO>();
            #region Debug
            log.Debug("Inicializada a lista de CTs...");
            log.Debug("Executando PROC na base...");
            #endregion Debug
            ViewBag.ListaFaseCT = db.CT.DistinctBy(x => x.Fase).ToList();
            ViewBag.ListCTs     = db.CT.ToList();

            SqlParameter[] param =
            {
                new SqlParameter("@ID_AMBIENTE_EXECUCAO", DBNull.Value),
                new SqlParameter("@ID_AUT",               DBNull.Value)
            };

            scripts = db.Database.SqlQuery <Script_CondicaoScriptVO>("EXEC PR_LISTAR_SCRIPT_CONDICAO_SCRIPT @ID_AMBIENTE_EXECUCAO, @ID_AUT", param).ToList();

            List <listaVO> listaVOs = new List <listaVO>();
            for (int i = 0; i < scripts.Count; i++)
            {
                string desc = scripts[i].DescricaoCondicaoScript == null ? scripts[i].DescricaoScript : scripts[i].DescricaoScript + " - " + scripts[i].DescricaoCondicaoScript;

                listaVO obj = new listaVO
                {
                    Id        = scripts[i].Id,
                    Descricao = desc
                };

                listaVOs.Add(obj);
            }

            ViewBag.ListScripts           = listaVOs;
            ViewBag.ListaSistemas         = db.AUT.ToList();
            ViewBag.ListaAmbienteExecucao = db.AmbienteExecucao.ToList();

            Cts = db.Database.SqlQuery <Script_CondicaoScript_CT_VO>("EXEC PR_LISTAR_SCRIPT_CONDICAO_SCRIPT_CT ").ToList();

            #region Debug
            log.Debug("PROC executada com sucesso, foram retornados " + Cts.Count() + " registros.");
            #endregion Debug

            return(View(Cts));
        }
        public JsonResult CarregarScript(int?IdAut = null, int?IdAmbienteExecucao = null)
        {
            try
            {
                List <listaVO> list = new List <listaVO>();
                List <Script_CondicaoScriptVO> scripts = new List <Script_CondicaoScriptVO>();

                SqlParameter[] param =
                {
                    new SqlParameter("@ID_AUT",               IdAut),
                    new SqlParameter("@ID_AMBIENTE_EXECUCAO", IdAmbienteExecucao)
                };

                if (IdAut == null)
                {
                    param[0].Value = DBNull.Value;
                }

                if (IdAmbienteExecucao == null)
                {
                    param[1].Value = DBNull.Value;
                }

                scripts = db.Database.SqlQuery <Script_CondicaoScriptVO>("EXEC PR_LISTAR_SCRIPT_CONDICAO_SCRIPT @ID_AMBIENTE_EXECUCAO, @ID_AUT", param).ToList();
                log.Info("Proc. executada com sucesso. Retornou " + scripts.Count + " registros.");

                for (int i = 0; i < scripts.Count; i++)
                {
                    string desc = scripts[i].DescricaoCondicaoScript == null ? scripts[i].DescricaoScript : scripts[i].DescricaoScript + " - " + scripts[i].DescricaoCondicaoScript;

                    listaVO obj = new listaVO
                    {
                        Id        = scripts[i].Id,
                        Descricao = desc
                    };

                    list.Add(obj);
                }

                return(Json(new { result = list }, JsonRequestBehavior.AllowGet));
            }
            catch (Exception ex)
            {
                return(Json(new { result = "Erro: " + ex.Message }, JsonRequestBehavior.AllowGet));

                log.Error("Erro: " + ex.Message);
            }
        }
        public JsonResult CarregarCT(int?IdAut = null, string FaseCT = null)
        {
            try
            {
                List <listaVO> list = new List <listaVO>();

                SqlParameter[] param =
                {
                    new SqlParameter("@IDAUT",  IdAut),
                    new SqlParameter("@IDCT",   DBNull.Value),
                    new SqlParameter("@FASECT", FaseCT)
                };

                if (IdAut == null)
                {
                    param[0].Value = DBNull.Value;
                }

                if (FaseCT == "null")
                {
                    param[2].Value = DBNull.Value;
                }

                ViewBag.CTs = db.Database.SqlQuery <listaVO>("EXEC PR_LISTAR_CT @IDAUT, @IDCT, @FASECT", param).ToList();
                log.Info("Proc. executada com sucesso. Retornou " + ViewBag.CTs.Count + " registros.");

                for (int i = 0; i < ViewBag.CTs.Count; i++)
                {
                    listaVO obj = new listaVO
                    {
                        Id        = ViewBag.CTs[i].Id,
                        Descricao = ViewBag.CTs[i].Descricao
                    };

                    list.Add(obj);
                }
                return(Json(new { result = list }, JsonRequestBehavior.AllowGet));

                log.Info("retornou com sucesso");
            }
            catch (Exception ex)
            {
                return(Json(new { result = "Erro: " + ex.Message }, JsonRequestBehavior.AllowGet));

                log.Error("Erro: " + ex.Message);
            }
        }