/// <summary> /// Metodo que permite cargar las tablas en el arbol. /// </summary> public void Populate(CnnString pCnn) { //if (_Tables == null) LoadTables(pCnn); if (_Tables == null) { this.tvwChilds.Nodes.Clear(); return; } if (_Tables.Count == 0) { this.tvwChilds.Nodes.Clear(); return; } TreeViewHelper.LoadTreeView(this.tvwChilds, _Tables); _Selected = _Tables[0]; lblTreeViewSelected.Text = String.Empty; }
private void btnNext_Click(object sender, EventArgs e) { _cnn = GetAuxiliarCnnString(); //UserDefinedTypesBack wUserDefinedTypesBack = new UserDefinedTypesBack(_cnn); //FwkGeneratorHelper.UserDefinedTypes = wUserDefinedTypesBack.UserDefinedTypes; base.DoEvent(null, CodeGeneratorCommon.WizardButton.Next); }
private void SetUI(CnnString cnn) { WindowsAutentificaction.Checked = cnn.WindowsAutentification; cmbDataBases.Text = cnn.InitialCatalog; cmbServer.Text = cnn.DataSource; if (cnn.WindowsAutentification) { txtUserName.Text = string.Empty; txtPassword.Text = string.Empty; txtUserName.Enabled = false; txtPassword.Enabled = false; lblUserName.ForeColor = System.Drawing.Color.Black; lblPassword.ForeColor = System.Drawing.Color.Black; } else { txtUserName.Text = cnn.User; txtPassword.Text = cnn.Password; txtUserName.Enabled = true; txtPassword.Enabled = true; lblUserName.ForeColor = System.Drawing.Color.DimGray; lblPassword.ForeColor = System.Drawing.Color.DimGray; } if (string.IsNullOrEmpty(cnn.DataSource) || string.IsNullOrEmpty(cnn.InitialCatalog)) { return; } txtCnnString.Text = cnn.ToString(); }
/// <summary> /// Carga las bses de datos del server /// </summary> /// <param name="pCnnString"></param> void FillDatabaseCombo(CnnString pCnnString) { if (onInitServerCollection) { return; } SqlConnection sqlConnection = new SqlConnection(pCnnString.ToString()); ServerConnection serverConnection = new ServerConnection(sqlConnection); try { _Server = new Server(serverConnection); cmbDataBases.Items.Clear(); foreach (Database db in _Server.Databases) { cmbDataBases.Items.Add(db.Name); } cmbDataBases.SelectedIndex = 0; } catch (Exception ex) { MessageBox.Show(HelperFunctions.GetAllMessageException(ex)); } }
/// <summary> /// Metodo que permite cargar las tablas en el arbol. /// </summary> public void Populate(CnnString pCnn) { //if (_Tables == null) LoadTables(pCnn); if (_Views == null) { this.tvwChilds.Nodes.Clear(); return; } if (_Views.Count == 0) { this.tvwChilds.Nodes.Clear(); return; } TreeViewHelper.LoadTreeView(this.tvwChilds, _Views); _SelectedView = _Views[0]; lblTreeViewSelected.Text = String.Empty; }
public DAL() { var cns = new CnnString(); _connection = cns.cns; _cnn = new SqlConnection(_connection); _command = new SqlCommand("", _cnn); _adapter = new SqlDataAdapter(); }
public CnnString CreateConnection() { _CurrentCnnString = new CnnString(); _DataBaseConnections.Connections.Add(_CurrentCnnString); return _CurrentCnnString; }
public bool Test() { _cnn = GetAuxiliarCnnString(); if (string.IsNullOrEmpty(_cnn.DataSource)) { MessageBox.Show("Ingrese servidor de SQL.-", Fwk.GuidPk.Properties.Resources.ProductTitle); cmbServer.Focus(); return(false); } if (string.IsNullOrEmpty(_cnn.InitialCatalog)) { MessageBox.Show("Seleccione o ingrese una base de datos.-", Fwk.GuidPk.Properties.Resources.ProductTitle); cmbDataBases.Focus(); return(false); } if (!_cnn.WindowsAutentification) { if (string.IsNullOrEmpty(_cnn.User)) { MessageBox.Show("Ingrese usuario.-", Fwk.GuidPk.Properties.Resources.ProductTitle); txtUserName.Focus(); return(false); } } SqlConnection sqlConnection = new SqlConnection(_cnn.ToString()); Microsoft.SqlServer.Management.Common.ServerConnection serverConnection = new Microsoft.SqlServer.Management.Common.ServerConnection(sqlConnection); try { _Server = new Server(serverConnection); //_Server.Databases[_cnn.InitialCatalog].Tables.Refresh(); ////iterate over all Databases //foreach (Database db in _Server.Databases) //{ MessageBox.Show("Coneccion exitosa.- a " + _Server.Information.Product.ToString(), Fwk.GuidPk.Properties.Resources.ProductTitle); //} } catch (Exception ex) { MessageBox.Show(Fwk.CodeGenerator.HelperFunctions.GetAllMessageException(ex), Fwk.GuidPk.Properties.Resources.ProductTitle); return(false); } return(true); }
/// <summary> /// Serializa en binario el diccionario /// </summary> /// <param name="fs"></param> /// <param name="dict"></param> private static void SerializeDictionary(FileStream fs, CnnString dict) { // Create a BinaryFormatter object to perform the serialization BinaryFormatter bf = new BinaryFormatter(); // Use the BinaryFormatter object to serialize the data to the file bf.Serialize(fs, dict); // Close the file fs.Close(); }
private void cmbDataBases_SelectedIndexChanged(object sender, EventArgs e) { _cnn = GetAuxiliarCnnString(); setIDictionaryService(_cnn); if (!_cnn.DataSource.Equals(cmbServer.Text.Trim()) || cmbDataBases.Items.Count == 0) { _cnn.DataSource = cmbServer.Text.Trim(); FillDatabaseCombo(_cnn); } }
private void button4_Click(object sender, EventArgs e) { DataBaseConnections _DataBaseConnections = new DataBaseConnections(); CnnString X1 = new CnnString(); X1.DataSource = "dddd"; X1.InitialCatalog = "dddd"; X1.User = "******"; _DataBaseConnections.Connections.Add(X1); _DataBaseConnections.Save(); }
private void btnTestConnection_Click(object sender, EventArgs e) { _cnn = GetAuxiliarCnnString(); if (string.IsNullOrEmpty(_cnn.DataSource)) { MessageBox.Show("Ingrese servidor de SQL.-", "Fwk wizard"); cmbServer.Focus(); return; } if (string.IsNullOrEmpty(_cnn.InitialCatalog)) { MessageBox.Show("Seleccione o ingrese una base de datos.-", "Fwk wizard"); cmbDataBases.Focus(); return; } if (!_cnn.WindowsAutentification) { if (string.IsNullOrEmpty(_cnn.User)) { MessageBox.Show("Ingrese usuario.-", "Fwk wizard"); txtUserName.Focus(); return; } } SqlConnection sqlConnection = new SqlConnection(_cnn.ToString()); Microsoft.SqlServer.Management.Common.ServerConnection serverConnection = new Microsoft.SqlServer.Management.Common.ServerConnection(sqlConnection); try { _Server = new Server(serverConnection); ////iterate over all Databases foreach (Database db in _Server.Databases) { MessageBox.Show("Coneccion exitosa.-", "Fwk wizard"); return; } } catch (Exception ex) { MessageBox.Show(HelperFunctions.GetAllMessageException(ex), "Fwk wizard"); } }
/// <summary> /// Obtiene un diccionario ConfigManager con la deserializacion en binario del IsolatedStorageFile /// Este diccionario contiene el par [NombreArchivo,Ruta] /// </summary> void Load() { IsolatedStorageFile userStore = IsolatedStorageFile.GetUserStoreForAssembly(); //If No data saved for this user if (userStore.GetFileNames(EnvDTESetting).Length == 0) { _CnnString = new CnnString(); return; } IsolatedStorageFileStream userStream = new IsolatedStorageFileStream(EnvDTESetting, FileMode.Open, userStore); _CnnString = DeSerializeDictionary(userStream); }
public void setIDictionaryService(CnnString cnn) { IDictionaryService dictionaryService = GetService(typeof(IDictionaryService)) as IDictionaryService; if (cnn == null) { dictionaryService.SetValue("ConnectionString", null); dictionaryService.SetValue("DatabaseName", null); } else { dictionaryService.SetValue("ConnectionString", cnn.ToString()); dictionaryService.SetValue("DatabaseName", cnn.InitialCatalog); } }
void LoadDatabaseObjects() { IDictionaryService dictionaryService = GetService(typeof(IDictionaryService)) as IDictionaryService; string connectionString = dictionaryService.GetValue("ConnectionString").ToString(); if (!string.IsNullOrEmpty(connectionString)) { _cnn = new CnnString("c1", connectionString); RefreshDataObject(); } // txtTargetNamespace.Text = dictionaryService.GetValue("TargetNamespace").ToString(); }
private void LoadTables(CnnString cnn) { SqlConnection sqlConnection = new SqlConnection(cnn.ToString()); ServerConnection serverConnection = new ServerConnection(sqlConnection); try { Server wServer = new Server(serverConnection); Database db = new Database(wServer, cnn.InitialCatalog); db.Views.Refresh(); _Views = db.Views; } catch (Exception ex) { MessageBox.Show(HelperFunctions.GetAllMessageException(ex)); } }
private void SetUI(CnnString cnn) { WindowsAutentificaction.Checked = cnn.WindowsAutentification; cmbDataBases.Text = cnn.InitialCatalog; cmbServer.Text = cnn.DataSource; if (cnn.WindowsAutentification) { txtUserName.Text = string.Empty; txtPassword.Text = string.Empty; } else { txtUserName.Text = cnn.User; txtPassword.Text = cnn.Password; } }
/// <summary> /// Deserializa en binario el diccionario /// </summary> /// <param name="fs"></param> /// <param name="dict"></param> private static CnnString DeSerializeDictionary(FileStream fs) { CnnString dict; // Create a BinaryFormatter object to perform the serialization BinaryFormatter bf = new BinaryFormatter(); try { // Use the BinaryFormatter object to serialize the data to the file dict = (CnnString)bf.Deserialize(fs); } catch (System.Runtime.Serialization.SerializationException) { dict = new CnnString(); } finally { // Close the file fs.Close(); } return(dict); }
public static cnnStrings get_cnnStrings(List <ConnectionString> connectionStrings) { cnnStrings list = new cnnStrings(); foreach (ConnectionString c in connectionStrings) { CnnString sqlBuilder = new CnnString(c.name, c.cnnString); if (!string.IsNullOrEmpty(sqlBuilder.InitialCatalog)) { cnnString cnnString = new cnnString(); cnnString.name = c.name; cnnString.serverName = sqlBuilder.DataSource; cnnString.databaseName = sqlBuilder.InitialCatalog; cnnString.userName = sqlBuilder.User; cnnString.windowsAutentification = sqlBuilder.WindowsAutentification; list.Add(cnnString); } } return(list); }
private CnnString GetAuxiliarCnnString() { CnnString wCnnString = new CnnString(); wCnnString.InitialCatalog = cmbDataBases.Text.Trim(); wCnnString.DataSource = txtServer.Text.Trim(); if (WindowsAutentificaction.Checked) { wCnnString.User = String.Empty; wCnnString.Password = String.Empty; } else { wCnnString.User = txtUserName.Text.Trim(); wCnnString.Password = txtPassword.Text.Trim(); } wCnnString.WindowsAutentification = WindowsAutentificaction.Checked; return(wCnnString); }
/// <summary> /// /// </summary> /// <param name="pException"></param> /// <param name="pCnnString"></param> public DataBaseExeption(Exception pException, CnnString pCnnString) { _CnnString = pCnnString; if (pException.GetType() == typeof(System.Security.Cryptography.CryptographicException)) { _Msg = "La password encriptada en el archivo de configuracion fue violada. " + Environment.NewLine + "Reescriba su clave y guarde su configuracion"; } if (pException.GetType() == typeof(SqlException)) { System.Data.SqlClient.SqlException ex = (System.Data.SqlClient.SqlException)pException; //ex.Number == 18456 Login fail _Msg = pException.Message + Environment.NewLine + "Vuelva a ingresar la informacion de conección"; } if (pException.GetType() == typeof(System.IO.FileNotFoundException)) { _Msg = pException.Message; } }
/// <summary> /// Carga las bses de datos del server /// </summary> /// <param name="pCnnString"></param> void FillDatabaseCombo(CnnString pCnnString) { if (onInitServerCollection) return; SqlConnection sqlConnection = new SqlConnection(pCnnString.ToString()); ServerConnection serverConnection = new ServerConnection(sqlConnection); try { _Server = new Server(serverConnection); cmbDataBases.Items.Clear(); foreach (Database db in _Server.Databases) { cmbDataBases.Items.Add(db.Name); } cmbDataBases.SelectedIndex = 0; } catch (Exception ex) { MessageBox.Show(HelperFunctions.GetAllMessageException(ex)); } }
private CnnString GetAuxiliarCnnString() { CnnString wCnnString = new CnnString(); wCnnString.InitialCatalog = cmbDataBases.Text.Trim(); wCnnString.DataSource = txtServer.Text.Trim(); if (WindowsAutentificaction.Checked) { wCnnString.User = String.Empty; wCnnString.Password = String.Empty; } else { wCnnString.User = txtUserName.Text.Trim(); wCnnString.Password = txtPassword.Text.Trim(); } wCnnString.WindowsAutentification = WindowsAutentificaction.Checked; return wCnnString; }
public bool Test() { _cnn = GetAuxiliarCnnString(); if (string.IsNullOrEmpty(_cnn.DataSource)) { MessageBox.Show("Ingrese servidor de SQL.-", Fwk.GuidPk.Properties.Resources.ProductTitle); cmbServer.Focus(); return false; } if (string.IsNullOrEmpty(_cnn.InitialCatalog)) { MessageBox.Show("Seleccione o ingrese una base de datos.-", Fwk.GuidPk.Properties.Resources.ProductTitle); cmbDataBases.Focus(); return false; } if (!_cnn.WindowsAutentification) { if (string.IsNullOrEmpty(_cnn.User)) { MessageBox.Show("Ingrese usuario.-", Fwk.GuidPk.Properties.Resources.ProductTitle); txtUserName.Focus(); return false; } } SqlConnection sqlConnection = new SqlConnection(_cnn.ToString()); Microsoft.SqlServer.Management.Common.ServerConnection serverConnection = new Microsoft.SqlServer.Management.Common.ServerConnection(sqlConnection); try { _Server = new Server(serverConnection); //_Server.Databases[_cnn.InitialCatalog].Tables.Refresh(); ////iterate over all Databases //foreach (Database db in _Server.Databases) //{ MessageBox.Show("Coneccion exitosa.- a " + _Server.Information.Product.ToString(), Fwk.GuidPk.Properties.Resources.ProductTitle); //} } catch (Exception ex) { MessageBox.Show(Fwk.CodeGenerator.HelperFunctions.GetAllMessageException(ex), Fwk.GuidPk.Properties.Resources.ProductTitle); return false; } return true; }
/// <summary> /// /// </summary> /// <param name="pCnnString"></param> /// <returns></returns> public static bool TestConnection(CnnString pCnnString) { using (SqlConnection wCnn = new SqlConnection(pCnnString.ToString())) { try { wCnn.Open(); wCnn.Close(); return true; } catch (Exception ex) { throw new DataBaseExeption(ex, pCnnString); } } }
/// <summary> /// /// </summary> public Metadata(CnnString cnnString) : base(String.Empty) { _Tables = new Tables(); _StoreProcedures = new StoreProcedures(); _DataBaseServer = new DataBaseServer(true); _DataBaseServer.CurrentCnnString = cnnString; }
private void btnGuardar_Click(object sender, System.EventArgs e) { //DataBaseServer wDataBaseServer = null; if (String.IsNullOrEmpty(txtServer.Text)) { MessageBox.Show("Falta ingresar nombre del servidor"); txtServer.Focus(); return; } if (!WindowsAutentificaction.Checked) { if (String.IsNullOrEmpty(txtUserName.Text)) { MessageBox.Show("Falta ingresar nombre de usuario"); txtUserName.Focus(); return; } } try { _DataBaseServer = new DataBaseServer(true); CnnString wCnnString = GetAuxiliarCnnString(); //Pregunto si los datos ingresados dan OK a una coneccion antes de //guardar la configuracion.- if (DataBaseServer.TestConnection(wCnnString)) { FillCurrentCnnString(); //wDataBaseServer.SaveSetting(wCnnString); if (_DataBaseServer.SaveSetting(wCnnString)) { //wDataBaseServer.CurrentCnnString.Name = cmbConnections.Text; } ConnectionOK = true; } else { MessageBox.Show("La conexion no se pudo realizar", "Error de conección"); ConnectionOK = false; } } catch (DataBaseExeption wDataBaseExeption) { ConnectionOK = false; txtServer.Text = wDataBaseExeption.CnnString.DataSource; txtUserName.Text = wDataBaseExeption.CnnString.User; txtPassword.Text = wDataBaseExeption.CnnString.Password; WindowsAutentificaction.Checked = wDataBaseExeption.CnnString.WindowsAutentification; cmbDataBases.Items.Add(wDataBaseExeption.CnnString.InitialCatalog); cmbDataBases.Text = wDataBaseExeption.CnnString.InitialCatalog; txtPassword.Focus(); MessageBox.Show(wDataBaseExeption.Message); } catch (Exception ex) { ConnectionOK = false; MessageBox.Show(ex.Message, "Error de conección"); } finally { OnAceptEvent(ConnectionOK); } }
/// <summary> /// Deserializa en binario el diccionario /// </summary> /// <param name="fs"></param> /// <param name="dict"></param> private static CnnString DeSerializeDictionary(FileStream fs) { CnnString dict; // Create a BinaryFormatter object to perform the serialization BinaryFormatter bf = new BinaryFormatter(); try { // Use the BinaryFormatter object to serialize the data to the file dict = (CnnString) bf.Deserialize(fs); } catch(System.Runtime.Serialization.SerializationException) { dict = new CnnString(); } finally { // Close the file fs.Close(); } return dict; }
internal void LoadCnn(string cnnString) { _cnn = new CnnString("c1", cnnString.ToString()); ctrlTreeViewTables1.Populate(_cnn); }
/// <summary> /// Almacena la configuracion con los datos que se pasan como parametros.- /// </summary> /// <param name="pCnnString">Coneccion</param> ///<param name="pAppend">Agrega nuevo elemento</param> public bool SaveSetting(CnnString pCnnString) { bool isNew = false; if (_DataBaseConnections.Connections.Any<CnnString>(c => c.Name.Equals(pCnnString.Name, StringComparison.OrdinalIgnoreCase))) { //modifico la configuracion .- CnnString cnn = _DataBaseConnections.Connections.First<CnnString>(c => c.Name.Equals(pCnnString.Name, StringComparison.OrdinalIgnoreCase)); if (cnn.Name != null) { cnn.Password = pCnnString.Password; cnn.DataSource = pCnnString.DataSource; cnn.User = pCnnString.User; cnn.WindowsAutentification = pCnnString.WindowsAutentification; cnn.InitialCatalog = pCnnString.InitialCatalog; } isNew =false; } else { //Almaceno la configuracion .- _DataBaseConnections.Connections.Add(pCnnString); isNew = true; } _CurrentCnnString = pCnnString; _DataBaseConnections.Save(); return isNew; }
public void Populate(CnnString pCnn) { this.ctrlTreeViewTables1.Populate(pCnn); }
internal void LoadCnn(CnnString cnn) { cmbDataBases.Text = cnn.InitialCatalog; cmbServer.Text = cnn.DataSource; WindowsAutentificaction.Checked = cnn.WindowsAutentification; }
private void SetUI(CnnString cnn) { WindowsAutentificaction.Checked = cnn.WindowsAutentification; cmbDataBases.Text = cnn.InitialCatalog; cmbServer.Text = cnn.DataSource; if (cnn.WindowsAutentification) { txtUserName.Text = string.Empty; txtPassword.Text = string.Empty; txtUserName.Enabled = false; txtPassword.Enabled = false; lblUserName.ForeColor = System.Drawing.Color.Black; lblPassword.ForeColor = System.Drawing.Color.Black; } else { txtUserName.Text = cnn.User; txtPassword.Text = cnn.Password; txtUserName.Enabled = true; txtPassword.Enabled = true; lblUserName.ForeColor = System.Drawing.Color.DimGray; lblPassword.ForeColor = System.Drawing.Color.DimGray; } if (string.IsNullOrEmpty(cnn.DataSource) || string.IsNullOrEmpty(cnn.InitialCatalog)) return; txtCnnString.Text = cnn.ToString(); }
internal void LoadCnn(CnnString cnn) { cmbDataBases.Text = cnn.InitialCatalog; cmbServer.Text = cnn.DataSource ; WindowsAutentificaction.Checked = cnn.WindowsAutentification; }
public Storage() { _CnnString = new CnnString(); }
/// <summary> /// /// </summary> /// <param name="pServerName"></param> /// <param name="pUserName"></param> /// <param name="pPassword"></param> /// <param name="pWindowsAutChecked"></param> /// <returns></returns> private static CnnString GetCnnStringToMaster(string pServerName, string pUserName, string pPassword, bool pWindowsAutChecked) { CnnString _CnnStringToMapper = new CnnString(); _CnnStringToMapper.DataSource = pServerName; _CnnStringToMapper.InitialCatalog = "master"; _CnnStringToMapper.User = pUserName; _CnnStringToMapper.Password = pPassword; _CnnStringToMapper.WindowsAutentification = pWindowsAutChecked; return _CnnStringToMapper; }
private void btnTestConnection_Click(object sender, EventArgs e) { _cnn = GetAuxiliarCnnString(); if (string.IsNullOrEmpty(_cnn.DataSource)) { MessageBox.Show("Ingrese servidor de SQL.-", "Fwk wizard"); cmbServer.Focus(); return; } if (string.IsNullOrEmpty(_cnn.InitialCatalog)) { MessageBox.Show("Seleccione o ingrese una base de datos.-","Fwk wizard"); cmbDataBases.Focus(); return; } if (!_cnn.WindowsAutentification) { if (string.IsNullOrEmpty(_cnn.User)) { MessageBox.Show("Ingrese usuario.-", "Fwk wizard"); txtUserName.Focus(); return; } } SqlConnection sqlConnection = new SqlConnection(_cnn.ToString()); Microsoft.SqlServer.Management.Common.ServerConnection serverConnection = new Microsoft.SqlServer.Management.Common.ServerConnection(sqlConnection); try { _Server = new Server(serverConnection); ////iterate over all Databases foreach (Database db in _Server.Databases) { MessageBox.Show("Coneccion exitosa.-", "Fwk wizard"); return; } } catch (Exception ex) { MessageBox.Show(HelperFunctions.GetAllMessageException(ex), "Fwk wizard"); } }
private static CnnString GetCnnStringToMaster(CnnString pCnnString) { CnnString _CnnStringToTest = new CnnString(); _CnnStringToTest.DataSource = pCnnString.DataSource; _CnnStringToTest.InitialCatalog = "master"; _CnnStringToTest.User = pCnnString.User; _CnnStringToTest.Password = pCnnString.Password; _CnnStringToTest.WindowsAutentification = pCnnString.WindowsAutentification; return _CnnStringToTest; }
/// <summary> /// Permite leer nuevamente el archivo de configuracion donde esta el acceso a la BD para recargar la coneccion.- /// </summary> public void InitializeConfig() { try { _DataBaseConnections.Load(); if(_DataBaseConnections.Connections.Count > 0) _CurrentCnnString = _DataBaseConnections.Connections[0]; } catch (FileNotFoundException) { string msg = "No se encuentra el archivo de configuracion de base de datos:"; throw new System.Exception(msg); } catch (System.Security.Cryptography.CryptographicException e) { _CurrentCnnString.Password = String.Empty; throw new DataBaseExeption(e, _CurrentCnnString); } catch (Exception) { string msg = "Verifique que el archivo de configuracion tiene seteado el archivo de conecciones a la base de datos.-"; throw new System.Exception(msg); } }