public NpgsqlConnection returnConnexion(ENTITE.Serveur bean, string adresse, bool retry) { try { NpgsqlConnection con = new NpgsqlConnection(); if (isConnection(out con, bean, adresse)) { return(con); } else { if (!Utils.asString(adresse) && retry) { if (DialogResult.Retry == Messages.Erreur_Retry("Connexion impossible !Entrer de nouveaux parametres")) { new IHM.Form_Serveur().ShowDialog(); } else { Environment.Exit(1); } } return(null); } } catch (Exception ex) { if (retry) { Messages.Exception("Connexion (returnConnexion) ", ex); } return(null); } }
public bool isConnection(out NpgsqlConnection con, ENTITE.Serveur bean) { con = null; try { if (bean != null) { string constr = "PORT=" + bean.Port + ";TIMEOUT=15;POOLING=True;MINPOOLSIZE=1;MAXPOOLSIZE=20;COMMANDTIMEOUT=20;COMPATIBLE= 2.0.14.3;DATABASE=" + bean.Database + ";HOST=" + bean.Adresse + ";PASSWORD="******";USER ID=" + bean.User + ""; con = new NpgsqlConnection(constr); try { con.Open(); return(true); } catch (System.StackOverflowException ex) { return(isConnection(out con, bean)); } } else { return(false); } } catch (Exception ex) { return(false); } }
public static bool Connection_Test(ENTITE.Serveur bean) { if (bean.Control_()) { NpgsqlConnection con = new NpgsqlConnection(); try { string constr = "PORT=" + bean.getPort + ";TIMEOUT=15;POOLING=True;MINPOOLSIZE=1;MAXPOOLSIZE=20;COMMANDTIMEOUT=20;COMPATIBLE= 2.0.14.3;DATABASE=" + bean.getDatabase + ";HOST=" + bean.getAdresse + ";PASSWORD="******";USER ID=" + bean.getUser + ""; con = new NpgsqlConnection(constr); con.Open(); return(true); } catch (NpgsqlException ex) { Messages.Exception(ex); return(false); } finally { con.Close(); con.Dispose(); } } return(false); }
public NpgsqlConnection returnConnexion(ENTITE.Serveur bean) { try { NpgsqlConnection con = new NpgsqlConnection(); if (isConnection(out con, bean)) { return(con); } else { if (DialogResult.Retry == Messages.ErrorRetryCancel("Connexion impossible !Entrer de nouveaux parametres")) { new IHM.Form_Serveur().ShowDialog(); } else { Environment.Exit(1); } return(null); } } catch (Exception ex) { Messages.Exception("Connexion (returnConnexion) ", ex); return(null); } }
private ENTITE.Serveur RecopiewView() { ENTITE.Serveur bean = new ENTITE.Serveur(); bean.getAdresse = txt_adress.Text.Trim(); bean.getDatabase = txt_db.Text.Trim(); bean.getPassword = txt_pwd.Text.Trim(); bean.getUser = txt_user.Text.Trim(); bean.getPort = Convert.ToInt16((!txt_port.Text.Trim().Equals("")) ? txt_port.Text.Trim() : "5432"); return bean; }
private ENTITE.Serveur RecopiewView() { ENTITE.Serveur bean = new ENTITE.Serveur(); bean.getAdresse = txt_adress.Text.Trim(); bean.getDatabase = txt_db.Text.Trim(); bean.getPassword = txt_pwd.Text.Trim(); bean.getUser = txt_user.Text.Trim(); bean.getPort = Convert.ToInt16((!txt_port.Text.Trim().Equals("")) ? txt_port.Text.Trim() : "5432"); return(bean); }
public ENTITE.Serveur getServeur() { ENTITE.Serveur bean = new ENTITE.Serveur(); bean.Adresse = txt_adress.Text.Trim(); bean.Database = txt_db.Text.Trim(); bean.Password = txt_pwd.Text.Trim(); bean.User = txt_user.Text.Trim(); bean.Port = Convert.ToInt32((txt_port.Text.Trim() != "") ? txt_port.Text.Trim() : "5432"); return(bean); }
private void btn_save_Click(object sender, EventArgs e) { ENTITE.Serveur bean = RecopiewView(); if (bean.Control()) { if (new BLL.ServeurBll(bean).CreateServeur()) { Application.Restart(); } } }
public bool isConnection(ENTITE.Serveur bean, string adresse) { try { NpgsqlConnection con; return(isConnection(out con, bean, adresse)); } catch (Exception ex) { return(false); } }
private void btn_tester_Click(object sender, EventArgs e) { ENTITE.Serveur serveur = getServeur(); if (new TOOLS.Connexion().isConnection(serveur)) { Messages.Information("Connecté"); } else { Messages.ShowErreur("Echec"); } }
private void LoadCurrentServeur() { ENTITE.Serveur s = BLL.ServeurBLL.ReturnServeur(); if (s != null ? !(s.Adresse == null || s.Adresse.Trim().Equals("")) : false) { txt_adress.Text = s.Adresse; txt_db.Text = s.Database; txt_pwd.Text = s.Password; txt_user.Text = s.User; txt_port.Text = s.Port.ToString(); } }
private void btn_save_Click(object sender, EventArgs e) { ENTITE.Serveur serveur = getServeur(); if (new TOOLS.Connexion().isConnection(serveur)) { if (BLL.ServeurBLL.CreateServeur(serveur)) { ask_ = true; //Application.ExitThread(); Application.Restart(); } } }
private static NpgsqlConnection isConnection(ENTITE.Serveur bean) { try { string constr = "PORT=" + bean.getPort + ";TIMEOUT=15;POOLING=True;MINPOOLSIZE=1;MAXPOOLSIZE=20;COMMANDTIMEOUT=20;COMPATIBLE= 2.0.14.3;DATABASE=" + bean.getDatabase + ";HOST=" + bean.getAdresse + ";PASSWORD="******";USER ID=" + bean.getUser + ""; return(new NpgsqlConnection(constr)); } catch (Exception ex) { Messages.Exception(ex); } return(null); }
public NpgsqlConnection Connection(string adresse) { if (Utils.asString(adresse)) { ENTITE.Serveur bean = ServeurBLL.ReturnServeur(); if ((bean != null) ? bean.Port != 0 : false) { NpgsqlConnection connexion = returnConnexion(bean, adresse, true); return(connexion); } return(null); } else { return(Connection()); } }
private ENTITE.Serveur RecopiewView() { ENTITE.Serveur bean = new ENTITE.Serveur(); bean.Adresse = txt_adress.Text.Trim(); bean.Database = txt_db.Text.Trim(); bean.Password = txt_pwd.Text.Trim(); bean.User = txt_user.Text.Trim(); try { bean.Port = Convert.ToInt16((!txt_port.Text.Trim().Equals("")) ? txt_port.Text.Trim() : "5432"); } catch (Exception ex) { Messages.ShowErreur("Le port est une valeur numerique"); bean.Port = 5432; } return(bean); }
public NpgsqlConnection Connection() { if (INSTANCE != null) { if (INSTANCE.State == System.Data.ConnectionState.Closed) { INSTANCE.Open(); } } else { ENTITE.Serveur bean = ServeurBLL.ReturnServeur(); if ((bean != null) ? bean.Port != 0 : false) { INSTANCE = returnConnexion(bean, true); } } return(INSTANCE); }
public static bool isInfosServeur(ENTITE.Serveur bean) { try { if (bean != null) { string constr = "PORT=" + bean.Port + ";TIMEOUT=15;POOLING=True;MINPOOLSIZE=1;MAXPOOLSIZE=20;COMMANDTIMEOUT=20;COMPATIBLE= 2.0.14.3;DATABASE=" + bean.Database + ";HOST=" + bean.Adresse + ";PASSWORD="******";USER ID=" + bean.User + ""; NpgsqlConnection con = new NpgsqlConnection(constr); return(true); } else { return(false); } } catch (Exception ex) { Messages.Exception("Connexion (isInfosServeur) ", ex); return(false); } }
public bool isConnection(out NpgsqlConnection con, ENTITE.Serveur bean, string adresse) { con = null; if (bean == null) { return(false); } try { string current = bean.Adresse; if (Utils.asString(adresse)) { current = adresse; } return(isConnection(out con, current, bean.Port, bean.Database, bean.User, bean.Password)); } catch (Exception ex) { return(false); } }
private void btn_tester_Click(object sender, EventArgs e) { try { Societe societe = recopie(); string adresse = null; if (Utils.asString(societe.AdresseIp)) { adresse = societe.AdresseIp; } else { ENTITE.Serveur bean = ServeurBLL.ReturnServeur(); adresse = bean.Adresse; } if (!Utils.IsLocalAdress(adresse)) { string fileName = TOOLS.Chemins.CheminBackup("localhost") + "localhost.csv"; if (!File.Exists(fileName)) { Logs.WriteCsv(fileName, new IOEMDevice()); } fileName = new RemoteAcces(adresse, societe.Port, societe.TypeConnexion, societe.Users, societe.Password).GetPathFile(@fileName); if (Utils.asString(fileName)) { Messages.Information("Connecté"); } else { Messages.ShowErreur("Echec"); } } } catch (Exception ex) { Messages.Exception(ex); } }
private static NpgsqlConnection getConnexion(ENTITE.Serveur bean) { try { if (bean.Control_()) { NpgsqlConnection con = isConnection(bean); con.Open(); return(con); } else { if (DialogResult.Retry == Messages.Erreur_Retry("Connexion impossible ! Entrer de nouveaux parametres")) { new IHM.Form_Serveur().Show(); } } } catch (NpgsqlException ex) { Messages.Exception(ex); } return(null); }
private static NpgsqlConnection getConnexion_(ENTITE.Serveur bean) { try { if (bean.Control_()) { string constr = "PORT=" + bean.Port + ";TIMEOUT=15;POOLING=True;MINPOOLSIZE=1;MAXPOOLSIZE=20;COMMANDTIMEOUT=20;COMPATIBLE= 2.0.14.3;HOST=" + bean.Adresse + ";PASSWORD="******";USER ID=" + bean.User + ""; NpgsqlConnection con = new NpgsqlConnection(constr); con.Open(); return(con); } else { if (DialogResult.Retry == Messages.Erreur_Retry("Connexion impossible ! Entrer de nouveaux parametres")) { new IHM.Form_Serveur().ShowDialog(); } else { Application.Exit(); } } } catch (NpgsqlException ex) { if (DialogResult.Retry == Messages.Erreur_Retry("Connexion impossible ! Entrer de nouveaux parametres")) { new IHM.Form_Serveur().ShowDialog(); } else { Application.Exit(); } } return(null); }
public bool isConnection(out NpgsqlConnection con, ENTITE.Serveur bean) { return(isConnection(out con, bean, null)); }
public bool isConnection(ENTITE.Serveur bean) { return(isConnection(bean, null)); }
public NpgsqlConnection returnConnexion(ENTITE.Serveur bean, bool retry) { return(returnConnexion(bean, null, retry)); }