private void ButtonNext_Click(object sender, EventArgs e) { try { InstallInfos.InstallWebApp(Path.Combine(InstallInfos.tomcatBinPath, @"..\webapps" /*\SuiviAtelier.war"*/), false); Form7InstallDone f7 = new Form7InstallDone(); f7.Show(); this.Hide(); } catch (Exception) { labelError.Text = "Impossible d'installer l'application web dans le répertoire webapps, vérifiez dans un premier temps vos droits d'utilisateur."; labelError.ForeColor = Color.Green; throw; } }
private void buttonUpdate_Click(object sender, EventArgs e) { InstallInfos.tomcatBinPath = Path.Combine(textBoxEmplacement.Text, @"\bin"); String tomcatPath = textBoxEmplacement.Text; //Vérifier le chemin if (Directory.Exists(textBoxEmplacement.Text)) { //Vérifier l'existence de Tomcat/WebApps if (Directory.Exists(Path.Combine(textBoxEmplacement.Text, @"webapps"))) { String webAppsPath = Path.Combine(textBoxEmplacement.Text, @"webapps"); //Vérifier l'existence du .war dedans string[] files = System.IO.Directory.GetFiles(webAppsPath, "*.war", System.IO.SearchOption.TopDirectoryOnly); //if (files.Length > 0) //{ //file exist //(supprimer l'ancienne archivee web préssente) if (files.Length > 0) { //SI on a deja un .war on le supprime File.Delete(files[0]); } //STOP LE SERVICE!!!! String svcName = AskServiceName(); SvcManager.StopService(svcName, 15000); Trace.WriteLine("Svc name = " + svcName); //Suppression de l'ancien répertoire de l'appli web try { Directory.Delete(Path.Combine(tomcatPath, @"webapps\SuiviAtelier"), true); } catch { //Le service tomcat le gèrera la suppression } //mettre les logs dans un old String logPath = Path.Combine(tomcatPath, "logs"); string[] logs = Directory.GetFiles(logPath); if (!Directory.Exists(Path.Combine(logPath, "old_logs"))) { Directory.CreateDirectory(Path.Combine(logPath, "old_logs")); //attention si on a deja fait une maj ? } foreach (String oneLog in logs) { String fileName = Path.GetFileName(oneLog); String destination = Path.Combine(logPath, "old_logs", fileName); try { File.Move(oneLog, destination); } catch { //Le log est utilisé par un processus, on le laisse dans ce fichier Trace.WriteLine("its ok just a log because service is mal éteint"); } } //mettre archivweb //Dans le rep Source AVEC LE NUM DE VERSION if (!Directory.Exists(Path.Combine(tomcatPath, @"..\Sources"))) { Directory.CreateDirectory(Path.Combine(tomcatPath, @"..\Sources")); } InstallInfos.InstallWebApp(Path.Combine(tomcatPath, @"..\Sources"), true); //Sans la version (suivi atelier) dans webapps InstallInfos.InstallWebApp(webAppsPath, false); //LANCER LE SERVICE SvcManager.StartService(svcName, 15000); //} //else //{ // setErreurOn("ERREUR - Pas de fichier .war dans le répertoire webapps de tomcat"); // throw new Exception("ERREUR - Pas de fichier .war dans le répertoire webapps de tomcat"); // //ERROR MESSAGE // //Pas d'application .war //} } else { setErreurOn("ERREUR - Le répertoire webapps n'a pas été trouvé"); //ERROR MESSAGE //Pas de repertoire webapps throw new Exception("ERREUR - Le répertoire webapps n'a pas été trouvé"); } } else { setErreurOn("ERREUR - Le répertoire d'installation renseigné n'a pas été trouvé."); //ERROR MESSAGE //répertoire d'install tomcat introuvable throw new Exception("ERREUR - Le répertoire d'installation renseigné n'a pas été trouvé."); } labelError.Text = "MISE A JOUR TERMINEE"; labelError.ForeColor = System.Drawing.Color.Green; Form8UpdateDone form = new Form8UpdateDone(); this.Hide(); form.Show(); }