Example #1
0
        //Bouton de connection
        private void connectButton_Click(object sender, EventArgs e)
        {
            connectButton.DialogResult = DialogResult.OK;

            //Vérifie les infos
            if (checkInfoValiditie())
            {
                SR2DDatabase db = new SR2DDatabase();

                //Connecte
                SR2DMessages m = db.connect(userTextBox.Text, passwordTextBox.Text, pathTextBox.Text, sourceTextBox.Text, portNumUpDown.Value.ToString());

                if (m == SR2DMessages.SUC_100)
                {
                    form.updateStatutOnWorker("Mise a jour de la base de donnée", 35);

                    if (/*db.updateDatabase(pathTextBox.Text)*/ true)
                    {
                        form.setDatabase(db);

                        this.returnStatut = true;
                        this.Close();
                    }
                }
                else
                {
                    DialogResult failBox = MessageBox.Show("Une erreur est survenue lors de la connection à la base de donnée ! Veuillez vérifier la validité de vos informations de connection.", "Erreur", MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
            }
        }
Example #2
0
        //********** END FONCTION INITIALISATION DES FICHIERS **********//

        //********** FONCTION INITIALISATION DE LA BASE DE DONNEE **********//

        public bool initDatabase()
        {
            string defaultConnectionName = hasDefaultConnection();

            if (defaultConnectionName.Split(';')[0] == "true")
            {
                XmlDocument xmlDoc = new XmlDocument();

                xmlDoc.Load(SR2DURLs.connectionXmlFile.getUrlFromRoot()); //Load connection file

                XmlNode root = xmlDoc.DocumentElement;

                XmlNodeList nodeList = root.ChildNodes;

                foreach (XmlNode node in nodeList)
                {
                    if (node.Attributes[0].Value == defaultConnectionName.Split(';')[1])
                    {
                        db = new SR2DDatabase();

                        SR2DMessages m = db.connect(node.ChildNodes[1].Attributes[0].Value, node.ChildNodes[2].Attributes[0].Value, node.ChildNodes[0].Attributes[0].Value, node.ChildNodes[4].Attributes[0].Value, node.ChildNodes[3].Attributes[0].Value);

                        if (m != SR2DMessages.SUC_100)
                        {
                            //??? Rajout modification connection (defaut, ajout , supression ...) ???//

                            writeConsole("Impossible de se connecter à la base de donnée");

                            return(false);
                        }
                    }
                }
            }
            else
            {
                //??? Rajout modification connection (defaut, ajout , supression ...) ???//

                writeConsole("Données de connections invalides");

                return(false);
            }

            return(true);
        }
Example #3
0
        private bool threadInit()
        {
            updateStatutOnWorker("Chargement des fichiers", 0);

            if (!checkPathExist(SR2DURLs.mainFolder.getUrlFromRoot()))
            {
                if (!createFolder(SR2DURLs.mainFolder.getUrlFromRoot()))
                {
                    return(false);
                }
            }

            if (!checkFileExist(SR2DURLs.connectionXmlFile.getUrlFromRoot()))
            {
                if (!createConnectionFile())
                {
                    return(false);
                }
            }

            if (!checkFileExist(SR2DURLs.configXmlFile.getUrlFromRoot()))
            {
                if (!createConfigFile())
                {
                    return(false);
                }
            }

            if (!updateConfig(SR2DURLs.configXmlFile.getUrlFromRoot()))
            {
                return(false);
            }

            vars = new SR2DVars();

            updateStatutOnWorker("Chargement des connections", 20);

            string defaultConnectionName = hasDefaultConnection();

            updateStatutOnWorker("Mise a jour des fichiers tiers", 25);

            updateStatutOnWorker("Connection", 30);

            if (defaultConnectionName.Split(';')[0] == "true")
            {
                XmlDocument xmlDoc = new XmlDocument();

                try
                {
                    xmlDoc.Load(SR2DURLs.connectionXmlFile.getUrlFromRoot());

                    XmlNode root = xmlDoc.DocumentElement;

                    XmlNodeList nodeList = root.ChildNodes;

                    foreach (XmlNode node in nodeList)
                    {
                        if (node.Attributes[0].Value == defaultConnectionName.Split(';')[1])
                        {
                            database = new SR2DDatabase();

                            SR2DMessages m = database.connect(node.ChildNodes[1].Attributes[0].Value, node.ChildNodes[2].Attributes[0].Value, node.ChildNodes[0].Attributes[0].Value, node.ChildNodes[4].Attributes[0].Value, node.ChildNodes[3].Attributes[0].Value);

                            if (m != SR2DMessages.SUC_100)
                            {
                                DialogResult failBox = MessageBox.Show("Une erreur est survenue lors de la connection a la base de donnée par defaut !", "Erreur", MessageBoxButtons.OK, MessageBoxIcon.Error);

                                ConnectionForm connectionForm = new ConnectionForm(this);

                                DialogResult r = connectionForm.ShowDialog();

                                while (r != DialogResult.OK || connectionForm.returnStatut != true)
                                {
                                    connectionForm = new ConnectionForm(this);

                                    r = connectionForm.ShowDialog();
                                }



                                Console.WriteLine("conected");
                            }
                            else
                            {
                                updateStatutOnWorker("Mise a jour de la base de donnée", 35);
                            }
                        }
                    }
                }
                catch (Exception e)
                {
                    Console.WriteLine(e.StackTrace);
                }
            }
            else
            {
                ConnectionForm connectionForm = new ConnectionForm(this);

                DialogResult r = connectionForm.ShowDialog();

                while (r != DialogResult.OK && connectionForm.returnStatut != true)
                {
                    connectionForm = new ConnectionForm(this);

                    r = connectionForm.ShowDialog();
                }

                Console.WriteLine("connected");
            }

            updateStatutOnWorker("Connection au serveur", 50);

            if (!connectToServer())
            {
                return(false);
            }

            updateStatutOnWorker("Aquisition des données", 70);

            database.initDataset();

            updateStatutOnWorker("Lancement", 100);

            return(true);
        }