public string retornarVersaoDLL(string nomeAmbiente) { clsOperacoes op = new clsOperacoes(); Assembly assembly = Assembly.LoadFrom(string.Format(@"C:\totvs\{0}\{1}\RM.Lib.Interop.dll", nomeAmbiente, op.retornarNomeApp())); Version ver = assembly.GetName().Version; return(ver.ToString()); }
public void deletarDiretorio(string caminhoDeletar) { clsOperacoes operacoes = new clsOperacoes(); if (Directory.Exists(caminhoDeletar)) { operacoes.deletarDiretorio(caminhoDeletar, true); } }
public void criarArquivoConfig(string nomeAmbiente, bool aplicativo, bool versao12, TextBox txtArquivo) { clsRegraNegocio regra = new clsRegraNegocio(); clsOperacoes op = new clsOperacoes(); try { if (aplicativo == true) { string nomeArquivo = op.retornarNomeApp() + ".exe"; //string.Format("{0}.exe", regra.retornarAplicativo(txtArquivo.Text)); string nomePasta = op.retornarNomeApp(); //string.Format("{0}", regra.retornarAplicativo(txtArquivo.Text)); string caminhoApp = string.Format(@"C:\totvs\{0}\{1}\{2}.config ", nomeAmbiente, nomePasta, nomeArquivo); System.IO.FileStream fs = System.IO.File.OpenWrite(caminhoApp); fs.Close(); File.WriteAllText(caminhoApp, retornarArquivoConfig(nomeAmbiente)); } else { List <string> nomesArquivo = new List <string>(); if (versao12 == true) { nomesArquivo.Add("RM.AliasManager.exe"); nomesArquivo.Add("RM.exe"); nomesArquivo.Add("RM.Atualizador.exe.dll"); nomesArquivo.Add("RM.Atualizador.exe"); nomesArquivo.Add("RM.Host.exe"); nomesArquivo.Add("RM.Host.Service.exe"); nomesArquivo.Add("RM.Lib.Gerador.Execute.exe"); nomesArquivo.Add("RM.Script.Executor.exe"); nomesArquivo.Add("RM.TotvsSQLTools.exe"); nomesArquivo.Add("RM.Atualizador.LogViewer.exe"); nomesArquivo.Add("RMAgilis.exe"); nomesArquivo.Add("RMBiblios.exe"); nomesArquivo.Add("RMBis.exe"); nomesArquivo.Add("RMBonum.exe"); nomesArquivo.Add("RMChronus.exe"); nomesArquivo.Add("RMClass.exe"); nomesArquivo.Add("RMClassisF.exe"); nomesArquivo.Add("RMClassisNet.exe"); nomesArquivo.Add("RMFactor.exe"); nomesArquivo.Add("RMFluxus.exe"); nomesArquivo.Add("RMLabore.exe"); nomesArquivo.Add("RMLiber.exe"); nomesArquivo.Add("RMNucleus.exe"); nomesArquivo.Add("RMOfficina.exe"); nomesArquivo.Add("RMPortal.exe"); nomesArquivo.Add("RMSaldus.exe"); nomesArquivo.Add("RMSaude.exe"); nomesArquivo.Add("RMSGI.exe"); nomesArquivo.Add("RMSGI.exe"); nomesArquivo.Add("RMTestis.exe"); nomesArquivo.Add("RMVitae.exe"); nomesArquivo.Add("RMVitaeSMT.exe"); copiarArquivosV12(nomeAmbiente, "RM.Glb.PlanilhaNet.API.dll"); copiarArquivosV12(nomeAmbiente, "RM.TstExec.Executor.exe"); } else { nomesArquivo.Add("RM.AliasManager.exe"); nomesArquivo.Add("RM.exe"); nomesArquivo.Add("RM.Glb.PlanilhaNet.API.dll"); nomesArquivo.Add("RM.Host.exe"); nomesArquivo.Add("RM.Host.Service.exe"); nomesArquivo.Add("RM.Lib.Gerador.Execute.exe"); nomesArquivo.Add("RM.Script.Executor.exe"); nomesArquivo.Add("RM.TotvsSQLTools.exe"); nomesArquivo.Add("RM.TstExec.Executor.exe"); } for (int i = 0; i < nomesArquivo.Count; i++) { string caminhoTotal = string.Format(@"C:\totvs\{0}\RM.Net\{1}.config ", nomeAmbiente, nomesArquivo[i]); if (File.Exists(caminhoTotal)) { File.Delete(caminhoTotal); File.Copy(@"C:\Gerencia Ambiente\Ambiente\RM.exe.config", caminhoTotal); // File.Copy(@"\\BHD000000407\ambiente\RM.exe.config", caminhoTotal); // File.Create(@"C:\Users\Gustavo Giori\Desktop\PA\teste.config"); // File.CreateText(@"C:\Users\Gustavo Giori\Desktop\PA\teste.config"); // System.IO.FileStream fs = System.IO.File.OpenWrite(caminhoTotal); //fs.Close(); File.WriteAllText(caminhoTotal, retornarArquivoConfig(nomeAmbiente)); } else { File.Copy(@"C:\Gerencia Ambiente\Ambiente\RM.exe.config", caminhoTotal); // File.Copy(@"\\BHD000000407\ambiente\RM.exe.config", caminhoTotal); // File.Create(@"C:\Users\Gustavo Giori\Desktop\PA\teste.config"); // File.CreateText(@"C:\Users\Gustavo Giori\Desktop\PA\teste.config"); // System.IO.FileStream fs = System.IO.File.OpenWrite(caminhoTotal); //fs.Close(); File.WriteAllText(caminhoTotal, retornarArquivoConfig(nomeAmbiente)); } } } } catch (Exception ex) { throw new System.ArgumentException(ex.Message + "\n" + ex.InnerException); } }
public bool criarAmbiente(string produto) { bool criou = false; clsOperacoes operacoes = new clsOperacoes(progressBar1, lblTeste, checkVersao12.Checked); clsConfiguracao config = new clsConfiguracao(); bool versao12 = false; try { if (produto == "Biblioteca") { operacoes.setTxtDiretorio(txtBibliotecaCriar); operacoes.extrairInstalador(txtBibliotecaCriar.Text, @"c:\extrair"); versao12 = operacoes.verificarVersao12(string.Format(@"C:\extrair\WinRoot\totvs\CorporeRM\RM.Net\RM.Version.dll", txtNome.Text)); operacoes.DirectoryCopy(@"C:\extrair\WinRoot\totvs\CorporeRM", txtNome .Text, true, false); config.criarArquivoConfig(txtNome.Text, false, versao12, txtBibliotecaCriar); ambienteCriadoSucesso(); config.deletarBroker(txtNome.Text); } if (produto == "Aplicativo") { operacoes.setTxtDiretorio(txtBibliotecaCriar); if (Directory.Exists(@"C:\extrair")) { operacoes.deletarDiretorio(@"c:\extrair", true); } operacoes.extrairInstalador(txtLaboreCriar.Text, @"c:\extrair"); operacoes.DirectoryCopy(@"C:\extrair\WinRoot\totvs\CorporeRM", txtNome .Text, true, false); config.criarArquivoConfig(txtNome.Text, true, versao12, txtLaboreCriar); clsRegraNegocio regra = new clsRegraNegocio(); string aplicativo = regra.retornarAplicativo(txtLaboreCriar.Text); File.Copy(@"C:\Gerencia Ambiente\Ambiente\RM.Lib.Interop.dll", string.Format(@"C:\totvs\{0}\RM{1}\RM.Lib.Interop.dll ", txtNome.Text, aplicativo), true); ambienteCriadoSucesso(); } if (produto == "Portal") { operacoes.setTxtDiretorio(txtPortalCriar); if (Directory.Exists(@"C:\extrair")) { operacoes.deletarDiretorio(@"c:\extrair", true); } operacoes.extrairInstalador(txtPortalCriar.Text, @"c:\extrair"); operacoes.DirectoryCopy(@"C:\extrair\WinRoot\totvs\CorporeRM", txtNome .Text, true, false); config.criarArquivoConfig(txtNome.Text, false, checkVersao12.Checked, txtPortalCriar); config.deletarBroker(txtNome.Text); ambienteCriadoSucesso(); } criou = true; } catch (Exception ex) { criou = false; MessageBox.Show(ex.Message); } return(criou); }
atualizar(string nomeAmbiente, string caminhoArquivo, string tipoAtualizacao) { clsOperacoes operacoes = new clsOperacoes(progressBar1, lblTeste, checkVersao12.Checked); Util.clsUtil util = new Util.clsUtil(); try { string extension = Path.GetExtension(this.txtEspecificaBiblioteca.Text); string extension2 = Path.GetExtension(this.txtEspecificaLabore.Text); string extension3 = Path.GetExtension(this.txtEspecificaPortal.Text); clsConfiguracao clsConfiguracao = new clsConfiguracao(); util.mensagemAviso("Iniciando processo de atualização do patch"); if (Directory.Exists("C:\\{app}") && Directory.Exists("C:\\{temp}")) { operacoes.deletarDiretorio("C:\\{app}", true); operacoes.deletarDiretorio("C:\\{temp}", true); } if (tipoAtualizacao == "Labore") { operacoes.extrairInstalador(caminhoArquivo, "C:\\extrair\\Labore"); if (extension2 == ".msi") { operacoes.DirectoryCopy("C:\\extrair\\WinRoot\\totvs\\CorporeRM", nomeAmbiente, true, false); } else { operacoes.DirectoryCopy("C:\\extrair\\Labore\\{app}", nomeAmbiente, true, false); } } else if (tipoAtualizacao == "Portal") { if (!Directory.Exists("C:\\extrair\\Portal")) { Directory.CreateDirectory("C:\\extrair\\Portal"); } operacoes.extrairInstalador(caminhoArquivo, "C:\\extrair\\Portal"); if (Path.GetExtension(caminhoArquivo) == ".msi") { operacoes.DirectoryCopy("C:\\extrair\\Portal\\WinRoot\\totvs\\CorporeRM", nomeAmbiente, true, false); } else { if (!Directory.Exists("C:\\ex\\Corpore.Net")) { Directory.CreateDirectory("C:\\ex\\Corpore.Net"); } operacoes.DirectoryCopy("C:\\extrair\\Portal\\{app}", "C:\\ex\\Corpore.Net", true, true); operacoes.DirectoryCopy("C:\\ex\\Corpore.Net", nomeAmbiente, true, false); } } else { operacoes.extrairInstalador(caminhoArquivo, "C:\\extrair\\Biblioteca"); if (Path.GetExtension(caminhoArquivo) == ".msi") { operacoes.DirectoryCopy("C:\\extrair\\Biblioteca\\WinRoot\\totvs\\CorporeRM", nomeAmbiente, true, false); } else { operacoes.DirectoryCopy("C:\\extrair\\Biblioteca\\{app}", nomeAmbiente, true, false); } } if (tipoAtualizacao == "Biblioteca") { if (Directory.Exists("c:\\rep\\Biblioteca")) { operacoes.deletarDiretorio("c:\\rep\\Biblioteca", true); this.contador++; } } if (tipoAtualizacao == "Portal") { if (Directory.Exists("c:\\rep\\Portal")) { operacoes.deletarDiretorio("c:\\rep\\Portal", true); this.contador++; } } else if (tipoAtualizacao == "Labore") { if (Directory.Exists("c:\\rep\\Labore")) { operacoes.deletarDiretorio("c:\\rep\\Labore", true); this.contador++; } } clsConfiguracao.acertarRMVersion(nomeAmbiente); util.mensagemSucesso("Versão atualizada com sucesso!"); this.progressBar1.Value = 0; this.lblTeste.Text = ""; this.lblTeste.Update(); if (this.contador == this.retornarQuantidadeTextBox()) { if (Directory.Exists("C:/rep")) { operacoes.deletarDiretorio("C:/rep", true); this.contador = 0; } } } catch (Exception ex) { util.mensagemErro(ex.Message); } }
public void criarArquivoConfig(string nomeAmbiente, bool aplicativo, bool versao12, TextBox txtArquivo) { clsRegraNegocio regra = new clsRegraNegocio(); clsOperacoes op = new clsOperacoes(); try { if (aplicativo == true) { string nomeArquivo = op.retornarNomeApp() + ".exe"; //string.Format("{0}.exe", regra.retornarAplicativo(txtArquivo.Text)); string nomePasta = op.retornarNomeApp(); //string.Format("{0}", regra.retornarAplicativo(txtArquivo.Text)); string caminhoApp = string.Format(@"C:\totvs\{0}\{1}\{2}.config ", nomeAmbiente, nomePasta, nomeArquivo); System.IO.FileStream fs = System.IO.File.OpenWrite(caminhoApp); fs.Close(); File.WriteAllText(caminhoApp, retornarArquivoConfig(nomeAmbiente)); } else { List<string> nomesArquivo = new List<string>(); if (versao12 == true) { nomesArquivo.Add("RM.AliasManager.exe"); nomesArquivo.Add("RM.exe"); nomesArquivo.Add("RM.Atualizador.exe.dll"); nomesArquivo.Add("RM.Atualizador.exe"); nomesArquivo.Add("RM.Host.exe"); nomesArquivo.Add("RM.Host.Service.exe"); nomesArquivo.Add("RM.Lib.Gerador.Execute.exe"); nomesArquivo.Add("RM.Script.Executor.exe"); nomesArquivo.Add("RM.TotvsSQLTools.exe"); nomesArquivo.Add("RM.Atualizador.LogViewer.exe"); nomesArquivo.Add("RMAgilis.exe"); nomesArquivo.Add("RMBiblios.exe"); nomesArquivo.Add("RMBis.exe"); nomesArquivo.Add("RMBonum.exe"); nomesArquivo.Add("RMChronus.exe"); nomesArquivo.Add("RMClass.exe"); nomesArquivo.Add("RMClassisF.exe"); nomesArquivo.Add("RMClassisNet.exe"); nomesArquivo.Add("RMFactor.exe"); nomesArquivo.Add("RMFluxus.exe"); nomesArquivo.Add("RMLabore.exe"); nomesArquivo.Add("RMLiber.exe"); nomesArquivo.Add("RMNucleus.exe"); nomesArquivo.Add("RMOfficina.exe"); nomesArquivo.Add("RMPortal.exe"); nomesArquivo.Add("RMSaldus.exe"); nomesArquivo.Add("RMSaude.exe"); nomesArquivo.Add("RMSGI.exe"); nomesArquivo.Add("RMSGI.exe"); nomesArquivo.Add("RMTestis.exe"); nomesArquivo.Add("RMVitae.exe"); nomesArquivo.Add("RMVitaeSMT.exe"); copiarArquivosV12(nomeAmbiente, "RM.Glb.PlanilhaNet.API.dll"); copiarArquivosV12(nomeAmbiente, "RM.TstExec.Executor.exe"); } else { nomesArquivo.Add("RM.AliasManager.exe"); nomesArquivo.Add("RM.exe"); nomesArquivo.Add("RM.Glb.PlanilhaNet.API.dll"); nomesArquivo.Add("RM.Host.exe"); nomesArquivo.Add("RM.Host.Service.exe"); nomesArquivo.Add("RM.Lib.Gerador.Execute.exe"); nomesArquivo.Add("RM.Script.Executor.exe"); nomesArquivo.Add("RM.TotvsSQLTools.exe"); nomesArquivo.Add("RM.TstExec.Executor.exe"); } for (int i = 0; i < nomesArquivo.Count; i++) { string caminhoTotal = string.Format(@"C:\totvs\{0}\RM.Net\{1}.config ", nomeAmbiente, nomesArquivo[i]); if (File.Exists(caminhoTotal)) { File.Delete(caminhoTotal); File.Copy(@"C:\Gerencia Ambiente\Ambiente\RM.exe.config", caminhoTotal); // File.Copy(@"\\BHD000000407\ambiente\RM.exe.config", caminhoTotal); // File.Create(@"C:\Users\Gustavo Giori\Desktop\PA\teste.config"); // File.CreateText(@"C:\Users\Gustavo Giori\Desktop\PA\teste.config"); // System.IO.FileStream fs = System.IO.File.OpenWrite(caminhoTotal); //fs.Close(); File.WriteAllText(caminhoTotal, retornarArquivoConfig(nomeAmbiente)); } else { File.Copy(@"C:\Gerencia Ambiente\Ambiente\RM.exe.config", caminhoTotal); // File.Copy(@"\\BHD000000407\ambiente\RM.exe.config", caminhoTotal); // File.Create(@"C:\Users\Gustavo Giori\Desktop\PA\teste.config"); // File.CreateText(@"C:\Users\Gustavo Giori\Desktop\PA\teste.config"); // System.IO.FileStream fs = System.IO.File.OpenWrite(caminhoTotal); //fs.Close(); File.WriteAllText(caminhoTotal, retornarArquivoConfig(nomeAmbiente)); } } } } catch (Exception ex) { throw new System.ArgumentException(ex.Message + "\n" + ex.InnerException); } }
public string retornarVersaoDLL(string nomeAmbiente) { clsOperacoes op = new clsOperacoes(); Assembly assembly = Assembly.LoadFrom(string.Format(@"C:\totvs\{0}\{1}\RM.Lib.Interop.dll", nomeAmbiente,op.retornarNomeApp())); Version ver = assembly.GetName().Version; return ver.ToString(); }
public void atualizar(string nomeAmbiente, string caminhoArquivo, string tipoAtualizacao) { clsOperacoes operacoes = new clsOperacoes(progressBar1, lblTeste, checkVersao12.Checked); Util.clsUtil util = new Util.clsUtil(); try { string extension = Path.GetExtension(this.txtEspecificaBiblioteca.Text); string extension2 = Path.GetExtension(this.txtEspecificaLabore.Text); string extension3 = Path.GetExtension(this.txtEspecificaPortal.Text); clsConfiguracao clsConfiguracao = new clsConfiguracao(); util.mensagemAviso("Iniciando processo de atualização do patch"); if (Directory.Exists("C:\\{app}") && Directory.Exists("C:\\{temp}")) { operacoes.deletarDiretorio("C:\\{app}", true); operacoes.deletarDiretorio("C:\\{temp}", true); } if (tipoAtualizacao == "Labore") { operacoes.extrairInstalador(caminhoArquivo, "C:\\extrair\\Labore"); if (extension2 == ".msi") { operacoes.DirectoryCopy("C:\\extrair\\WinRoot\\totvs\\CorporeRM", nomeAmbiente, true, false); } else { operacoes.DirectoryCopy("C:\\extrair\\Labore\\{app}", nomeAmbiente, true, false); } } else if (tipoAtualizacao == "Portal") { if (!Directory.Exists("C:\\extrair\\Portal")) { Directory.CreateDirectory("C:\\extrair\\Portal"); } operacoes.extrairInstalador(caminhoArquivo, "C:\\extrair\\Portal"); if (Path.GetExtension(caminhoArquivo) == ".msi") { operacoes.DirectoryCopy("C:\\extrair\\Portal\\WinRoot\\totvs\\CorporeRM", nomeAmbiente, true, false); } else { if (!Directory.Exists("C:\\ex\\Corpore.Net")) { Directory.CreateDirectory("C:\\ex\\Corpore.Net"); } operacoes.DirectoryCopy("C:\\extrair\\Portal\\{app}", "C:\\ex\\Corpore.Net", true, true); operacoes.DirectoryCopy("C:\\ex\\Corpore.Net", nomeAmbiente, true, false); } } else { operacoes.extrairInstalador(caminhoArquivo, "C:\\extrair\\Biblioteca"); if (Path.GetExtension(caminhoArquivo) == ".msi") { operacoes.DirectoryCopy("C:\\extrair\\Biblioteca\\WinRoot\\totvs\\CorporeRM", nomeAmbiente, true, false); } else { operacoes.DirectoryCopy("C:\\extrair\\Biblioteca\\{app}", nomeAmbiente, true, false); } } if (tipoAtualizacao == "Biblioteca") { if (Directory.Exists("c:\\rep\\Biblioteca")) { operacoes.deletarDiretorio("c:\\rep\\Biblioteca", true); this.contador++; } } if (tipoAtualizacao == "Portal") { if (Directory.Exists("c:\\rep\\Portal")) { operacoes.deletarDiretorio("c:\\rep\\Portal", true); this.contador++; } } else if (tipoAtualizacao == "Labore") { if (Directory.Exists("c:\\rep\\Labore")) { operacoes.deletarDiretorio("c:\\rep\\Labore", true); this.contador++; } } clsConfiguracao.acertarRMVersion(nomeAmbiente); util.mensagemSucesso("Versão atualizada com sucesso!"); this.progressBar1.Value = 0; this.lblTeste.Text = ""; this.lblTeste.Update(); if (this.contador == this.retornarQuantidadeTextBox()) { if (Directory.Exists("C:/rep")) { operacoes.deletarDiretorio("C:/rep", true); this.contador = 0; } } } catch (Exception ex) { util.mensagemErro(ex.Message); } }
public bool criarAmbiente(string produto) { bool criou = false; clsOperacoes operacoes = new clsOperacoes(progressBar1, lblTeste, checkVersao12.Checked); clsConfiguracao config = new clsConfiguracao(); bool versao12 = false; try { if (produto == "Biblioteca") { operacoes.setTxtDiretorio(txtBibliotecaCriar); operacoes.extrairInstalador(txtBibliotecaCriar.Text, @"c:\extrair"); versao12 = operacoes.verificarVersao12(string.Format(@"C:\extrair\WinRoot\totvs\CorporeRM\RM.Net\RM.Version.dll", txtNome.Text)); operacoes.DirectoryCopy(@"C:\extrair\WinRoot\totvs\CorporeRM", txtNome .Text, true, false); config.criarArquivoConfig(txtNome.Text, false, versao12, txtBibliotecaCriar); ambienteCriadoSucesso(); config.deletarBroker(txtNome.Text); } if (produto == "Aplicativo") { operacoes.setTxtDiretorio(txtBibliotecaCriar); if (Directory.Exists(@"C:\extrair")) { operacoes.deletarDiretorio(@"c:\extrair", true); } operacoes.extrairInstalador(txtLaboreCriar.Text, @"c:\extrair"); operacoes.DirectoryCopy(@"C:\extrair\WinRoot\totvs\CorporeRM", txtNome .Text, true, false); config.criarArquivoConfig(txtNome.Text, true, versao12, txtLaboreCriar); clsRegraNegocio regra = new clsRegraNegocio(); string aplicativo = regra.retornarAplicativo(txtLaboreCriar.Text); File.Copy(@"C:\Gerencia Ambiente\Ambiente\RM.Lib.Interop.dll", string.Format(@"C:\totvs\{0}\RM{1}\RM.Lib.Interop.dll ", txtNome.Text,aplicativo), true); ambienteCriadoSucesso(); } if (produto == "Portal") { operacoes.setTxtDiretorio(txtPortalCriar); if (Directory.Exists(@"C:\extrair")) { operacoes.deletarDiretorio(@"c:\extrair", true); } operacoes.extrairInstalador(txtPortalCriar.Text, @"c:\extrair"); operacoes.DirectoryCopy(@"C:\extrair\WinRoot\totvs\CorporeRM", txtNome .Text, true, false); config.criarArquivoConfig(txtNome.Text, false, checkVersao12.Checked, txtPortalCriar); config.deletarBroker(txtNome.Text); ambienteCriadoSucesso(); } criou = true; } catch (Exception ex) { criou = false; MessageBox.Show(ex.Message); } return criou; }