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); }
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); }
public bool TestConnection(ConecctionCredential model) { return(_SQLRepository.TestConnection(model)); }
public List <TableModel> GetAllTables(ConecctionCredential credential, string database) { credential.Database = database; return(_SQLRepository.GetAllTables(credential).ToEntityList <TableModel>()); }
public List <DataBaseModel> GetAllDatabases(ConecctionCredential credential) { return(_SQLRepository.GetDatabasesNames(credential).ToEntityList <DataBaseModel>()); }
public SQLDatabase(ConecctionCredential model) { oCN = new SqlConnection(ManageConnectionString.GetConnectionString(model)); }
public static void SaveConnection(ConecctionCredential model) { HttpContext.Current.Session["StringConnection"] = model; }
public void StressRequest(InfoRequestModel request, ConecctionCredential credential) { using (var DB = new SQLDatabase(credential)) { DB.SelectData(new SqlCommand($"SELECT * FROM {request.TableName} ")); } }
public bool TestConnection(ConecctionCredential model) { using (var DB = new SQLDatabase(model)) { return(DB.OpenConnection()); } }
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"))); } }
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');"))); } }