示例#1
0
 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);
     }
 }
示例#2
0
 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);
     }
 }
示例#3
0
 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);
 }
示例#4
0
 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);
     }
 }
示例#5
0
 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;
 }
示例#6
0
 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);
 }
示例#7
0
 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);
 }
示例#8
0
 private void btn_save_Click(object sender, EventArgs e)
 {
     ENTITE.Serveur bean = RecopiewView();
     if (bean.Control())
     {
         if (new BLL.ServeurBll(bean).CreateServeur())
         {
             Application.Restart();
         }
     }
 }
示例#9
0
 public bool isConnection(ENTITE.Serveur bean, string adresse)
 {
     try
     {
         NpgsqlConnection con;
         return(isConnection(out con, bean, adresse));
     }
     catch (Exception ex)
     {
         return(false);
     }
 }
示例#10
0
 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");
     }
 }
示例#11
0
 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();
     }
 }
示例#12
0
 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();
         }
     }
 }
示例#13
0
 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);
 }
示例#14
0
 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());
     }
 }
示例#15
0
 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);
 }
示例#16
0
 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);
 }
示例#17
0
 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);
     }
 }
示例#18
0
 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);
     }
 }
示例#19
0
 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);
     }
 }
示例#20
0
 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);
 }
示例#21
0
 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);
 }
示例#22
0
 public bool isConnection(out NpgsqlConnection con, ENTITE.Serveur bean)
 {
     return(isConnection(out con, bean, null));
 }
示例#23
0
 public bool isConnection(ENTITE.Serveur bean)
 {
     return(isConnection(bean, null));
 }
示例#24
0
 public NpgsqlConnection returnConnexion(ENTITE.Serveur bean, bool retry)
 {
     return(returnConnexion(bean, null, retry));
 }