public JsonResult Index(ConecctionCredential model)
 {
     if (_ISQL.TestConnection(model))
     {
         SqlConnectionSessionManager.SaveConnection(model);
         return(JsonHelper.Success("La conexión con el servidor fué exitosa"));
     }
     return(JsonHelper.Fail("Lo sentimos, servidor no encontrado o fuera del alcance"));
 }
        /// <summary>
        /// Este metodo genera un string de conexión al servidor de SQL Server
        /// </summary>
        /// <param name="model">El objeto para obtener las credenciales para generar el string</param>
        /// <returns>El String de conexión</returns>
        public static String GetConnectionString(ConecctionCredential model)
        {
            SqlConnectionStringBuilder manageString = new SqlConnectionStringBuilder();

            if (!model.WindowsAuthentication)
            {
                manageString.UserID   = model.User;
                manageString.Password = model.Password;
            }

            if (!String.IsNullOrEmpty(model.Database))
            {
                manageString.InitialCatalog = model.Database;
            }
            manageString.IntegratedSecurity = model.WindowsAuthentication;
            manageString.DataSource         = model.Server;
            manageString.ConnectTimeout     = 10;
            return(manageString.ConnectionString);
        }
Exemple #3
0
        public InfoRequestModel StressRequest(InfoRequestModel request, ConecctionCredential credential)
        {
            credential.Database    = request.DataBaseName;
            request.SuccessRequest = 0;
            request.FailRequest    = 0;
            bool Exception = false;

            request.InitialDateRequest = DateTime.Now;
            var Hilo = new Thread[request.CantThreads];

            for (int i = 0; i < request.CantThreads; i++)
            {
                Hilo[i] =
                    new Thread(new ThreadStart((Action)(() => {
                    for (int j = 0; j < request.CantRequest; j++)
                    {
                        try {
                            _SQLRepository.StressRequest(request, credential);
                            request.SuccessRequest++;
                        } catch (Exception) {
                            request.FailRequest++;
                            Exception = true;
                        }
                    }
                })));
            }

            for (int i = 0; i < request.CantThreads; i++)
            {
                Hilo[i].Start();
            }
            for (int i = 0; i < request.CantThreads; i++)
            {
                Hilo[i].Join();
            }

            request.FinishDateRequest = DateTime.Now;
            request.DurationRequest   = (request.InitialDateRequest - request.FinishDateRequest);
            return(request);
        }
Exemple #4
0
 public bool TestConnection(ConecctionCredential model)
 {
     return(_SQLRepository.TestConnection(model));
 }
Exemple #5
0
 public List <TableModel> GetAllTables(ConecctionCredential credential, string database)
 {
     credential.Database = database;
     return(_SQLRepository.GetAllTables(credential).ToEntityList <TableModel>());
 }
Exemple #6
0
 public List <DataBaseModel> GetAllDatabases(ConecctionCredential credential)
 {
     return(_SQLRepository.GetDatabasesNames(credential).ToEntityList <DataBaseModel>());
 }
Exemple #7
0
 public SQLDatabase(ConecctionCredential model)
 {
     oCN = new SqlConnection(ManageConnectionString.GetConnectionString(model));
 }
 public static void SaveConnection(ConecctionCredential model)
 {
     HttpContext.Current.Session["StringConnection"] = model;
 }
Exemple #9
0
 public void StressRequest(InfoRequestModel request, ConecctionCredential credential)
 {
     using (var DB = new SQLDatabase(credential)) {
         DB.SelectData(new SqlCommand($"SELECT * FROM {request.TableName} "));
     }
 }
Exemple #10
0
 public bool TestConnection(ConecctionCredential model)
 {
     using (var DB = new SQLDatabase(model)) {
         return(DB.OpenConnection());
     }
 }
Exemple #11
0
 public DataTable GetAllTables(ConecctionCredential credential)
 {
     using (var DB = new SQLDatabase(credential)) {
         return(DB.SelectData(new SqlCommand("SELECT TABLE_NAME AS TableName FROM INFORMATION_SCHEMA.TABLES")));
     }
 }
Exemple #12
0
 public DataTable GetDatabasesNames(ConecctionCredential credential)
 {
     using (var DB = new SQLDatabase(credential)) {
         return(DB.SelectData(new SqlCommand("SELECT name as Name FROM master.dbo.sysdatabases WHERE name NOT IN('master', 'tempdb', 'model', 'msdb','DWDiagnostics','DWConfiguration','DWQueue');")));
     }
 }