Ejemplo n.º 1
0
        public IActionResult Post(StringConnection s)
        {
            try
            {
                string dbDataConn = string.Format("Data Source={0} ;Initial Catalog={1} ;User ID={2} ;Password={3} ;MultipleActiveResultSets=True;Application Name=EntityFramework"

                                                  , s.source.Trim()
                                                  , s.database.Trim()
                                                  , s.user.Trim()
                                                  , s.password.Trim());

                byte[] plainTextBytes = Encoding.UTF8.GetBytes(dbDataConn);

                string jsonString = "{\"data\":[{\"dbconn\":\"" + Convert.ToBase64String(plainTextBytes).Trim() + "\"},{\"dbname\":\"" + s.database + "\"}]}";

                TextWriter archivo;

                archivo = new StreamWriter("conf.json");

                archivo.WriteLine(jsonString);

                archivo.Close();

                SqlConnection con = new SqlConnection(dbDataConn);
                con.Open();
                con.Close();

                return(Ok("[{\"status\":\"Conectado a la base de datos: " + s.database + "\"}]"));
            }
            catch (Exception err)
            {
                string message = "[{\"status\":\"" + err.Message + "\"}]";
                return(StatusCode(200, message));
            }
        }
Ejemplo n.º 2
0
        public Startup(IConfiguration configuration)
        {
            Configuration = configuration;

            StringConnection = Configuration.GetConnectionString("Development");
            StringConnection = StringConnection.Replace("#password#", Configuration["Connection:Password"]);
        }
        // GET: ContaRegistos
        public ActionResult Index()
        {
            StringConnection connection = new StringConnection();
            string           query      = "select count(*) from tarefas";

            ViewBag.registos = connection.ContaRegistos(connection.getSConnection(), query).Rows[0][0];


            return(View());
        }
Ejemplo n.º 4
0
        public IActionResult Post(StringConnection s)
        {
            try
            {
                string cmd = string.Format("execute articulos_insert '{0}','{1}','{2}','{3}'"

                                           , s.source.Trim()
                                           , s.database.Trim()
                                           , s.user.Trim()
                                           , s.password.Trim());

                DataSet Ds = SqlServerDbConn.Ejecutar(cmd);

                return(Ok(Ds));
            }
            catch (Exception err)
            {
                return(StatusCode(400, "Revise la sentencia sql" + err));
            }
        }