public static string Sauvegarde(BaseDonnee myDatabase, bool download = false)
        {
            string cheminFile = string.Empty;

            if (File.Exists(Param.MysqlBinPath) && myDatabase != null)
            {
                string repPath = string.Empty;
                if (download)
                {
                    repPath = Param.TMP;
                }
                else
                {
                    repPath = myDatabase.cheminSauvegarde;
                }

                cheminFile = Path.Combine(repPath, "bdd-" + myDatabase.databaseName + "-" + DateTime.Now.ToString("yyyyMMddhhmmss") + ".sql");

                //string args = " -h " + myDatabase.host + " -u " + myDatabase.user + " -p" + myDatabase.password + " -r \"" + cheminFile + "\" " + myDatabase.databaseName;
                //Process.Start(Param.MysqlBinPath, args);



                //On lance le processus
                ProcessStartInfo myProcessStartInfo = new ProcessStartInfo();
                myProcessStartInfo.FileName    = "cmd";
                myProcessStartInfo.Arguments   = "/c \"\"" + Param.MysqlBinPath + "\" -h " + myDatabase.host + " -u " + myDatabase.user + " -p" + myDatabase.password + " --quick -B " + myDatabase.databaseName + "  > \"" + cheminFile + "\"\"";
                myProcessStartInfo.WindowStyle = ProcessWindowStyle.Hidden;
                Process myProcess = new Process();
                myProcess.StartInfo = myProcessStartInfo;
                myProcess.Start();
                myProcess.WaitForExit();

                if (File.Exists(cheminFile))
                {
                    string zipfile = Path.Combine(repPath, Path.GetFileNameWithoutExtension(cheminFile) + ".zip");
                    if (File.Exists(zipfile))
                    {
                        File.Delete(zipfile);
                    }

                    using (ZipArchive zip = ZipFile.Open(zipfile, ZipArchiveMode.Create))
                    {
                        zip.CreateEntryFromFile(cheminFile, Path.GetFileName(cheminFile));
                        File.Delete(cheminFile);
                        cheminFile = Path.Combine(repPath, zipfile);
                    }
                }
            }
            return(cheminFile);
        }
        public static string Sauvegarde(BaseDonnee myDatabase, bool download = false)
        {
            string cheminFile = string.Empty;
            if (File.Exists(Param.MysqlBinPath) && myDatabase != null)
            {
                string repPath = string.Empty;
                if (download)
                    repPath = Param.TMP;
                else
                    repPath = myDatabase.cheminSauvegarde;

                cheminFile = Path.Combine(repPath, "bdd-" + myDatabase.databaseName + "-" + DateTime.Now.ToString("yyyyMMddhhmmss") + ".sql");

                //string args = " -h " + myDatabase.host + " -u " + myDatabase.user + " -p" + myDatabase.password + " -r \"" + cheminFile + "\" " + myDatabase.databaseName;
                //Process.Start(Param.MysqlBinPath, args);

                //On lance le processus
                ProcessStartInfo myProcessStartInfo = new ProcessStartInfo();
                myProcessStartInfo.FileName = "cmd";
                myProcessStartInfo.Arguments = "/c \"\"" + Param.MysqlBinPath + "\" -h " + myDatabase.host + " -u " + myDatabase.user + " -p" + myDatabase.password + " --quick -B " + myDatabase.databaseName + "  > \"" + cheminFile + "\"\"";
                myProcessStartInfo.WindowStyle = ProcessWindowStyle.Hidden;
                Process myProcess = new Process();
                myProcess.StartInfo = myProcessStartInfo;
                myProcess.Start();
                myProcess.WaitForExit();

                if (File.Exists(cheminFile))
                {
                    string zipfile = Path.Combine(repPath, Path.GetFileNameWithoutExtension(cheminFile) + ".zip");
                    if (File.Exists(zipfile))
                    {
                        File.Delete(zipfile);
                    }

                    using (ZipArchive zip = ZipFile.Open(zipfile, ZipArchiveMode.Create))
                    {
                        zip.CreateEntryFromFile(cheminFile, Path.GetFileName(cheminFile));
                        File.Delete(cheminFile);
                        cheminFile = Path.Combine(repPath, zipfile);
                    }
                }
            }
            return cheminFile;
        }
 public static BaseDonnee Update(BaseDonnee myItem)
 {
     return BaseDonneeDB.Update(myItem);
 }
 public static BaseDonnee Insert(BaseDonnee myItem)
 {
     return BaseDonneeDB.Insert(myItem);
 }
    protected void btnEditDatabaseSave_Click(object sender, EventArgs e)
    {
        Projet myProjet = GetProjet();
        if (myProjet != null)
        {
            bool isModif = false;
            BaseDonnee myDatabase = new BaseDonnee();
            if (!string.IsNullOrEmpty(hfDatabseId.Value))
            {
                myDatabase = BaseDonneeManager.Load(iZyInt.ConvertStringToInt(hfDatabseId.Value));
                if (myDatabase != null) isModif = true;
                else myDatabase = new BaseDonnee();
            }

            myDatabase.host = tbEditDatabaseHost.Text;
            myDatabase.databaseName = tbEditDatabaseName.Text;
            myDatabase.user = tbEditDatabaseUser.Text;
            myDatabase.password = tbEditDatabasePassword.Text;
            myDatabase.cheminSauvegarde = tbEditDatabaseChemin.Text;
            myDatabase.idProjet = myProjet.id;
            myDatabase.libelle = tbEditDatabaseLibelle.Text;

            if (isModif) BaseDonneeManager.Update(myDatabase);
            else BaseDonneeManager.Insert(myDatabase);

            ListeBaseDonnees_Init();

            ResetDatabaseForm();

            btnAddDatabase.Enabled = true;
            pnlEditDatabase.Visible = false;

            // Sauvegarde
            upDatabase.Update();
        }
    }
 public static BaseDonnee Update(BaseDonnee myItem)
 {
     return(BaseDonneeDB.Update(myItem));
 }
 public static BaseDonnee Insert(BaseDonnee myItem)
 {
     return(BaseDonneeDB.Insert(myItem));
 }