public void UpdateSystemDLLs(string source, string tarjet) { string startup = Application.StartupPath; //altera o path //..\ITSolution\ITSolution.Admin\bin\Debug //..\ITE\ITE.Forms\bin\Debug\ if (string.IsNullOrEmpty(source)) { source = startup.Replace(@"\ITSolution\ITSolution.Admin", @"\ITE\ITE.Forms"); source = source.Replace(@"\ITE\ITE.Teste", @"\ITE\ITE.Forms"); } var files = FileManagerIts.ToFiles(source, new string[] { ".dll", ".pdb", ".exe" }); //vai o foreach normal mesmo foreach (var f in files) { string fileName = Path.GetFileName(f); if (fileName.StartsWith("ITE.") || fileName.StartsWith("ITSolution.")) { //gera o caminho do arquivo string newSource = Path.Combine(tarjet, fileName); //copia o arquivo para o diretorio ou sobreescreve se ele existir FileManagerIts.CopyFile(f, newSource); Console.WriteLine(fileName); } } }
public string GeneratePackageSystemDLLs() { string raiz = Application.StartupPath; //altera o path //..\ITSolution\ITSolution.Admin\bin\Debug //..\ITE\ITE.Forms\bin\Debug\ string resource = raiz.Replace(@"\ITSolution\ITSolution.Admin", @"\ITE\ITE.Forms"); var files = FileManagerIts.ToFiles(resource, new string[] { ".dll", ".pdb", ".exe" }); var dlls = new List <string>(); //vai o foreach normal mesmo foreach (var f in files) { string fileName = Path.GetFileName(f); if (fileName.StartsWith("ITE.") || fileName.StartsWith("ITSolution.")) { //gera o caminho do arquivo string newSource = Path.Combine(resource, fileName); dlls.Add(newSource); } } string dllsPackage = Path.Combine(Path.GetTempPath(), "System DLLs Package " + DateTime.Now.ToString("dd-MM-yyyy") + ".zip"); ZipUtil.CompressFileList(dlls, dllsPackage); return(dllsPackage); }
private static void InfoVersionDLLs() { //versao da dll var v = System.Reflection.Assembly.GetExecutingAssembly().GetName().Version; //nome do projeto var n = System.Reflection.Assembly.GetExecutingAssembly().GetName().Name; var forms = @"D:\Program Files\TFS\ITE\ITE.Forms\bin\Debug\"; var files = FileManagerIts.ToFiles(forms, new string[] { ".dll" }); var outversion = FileManagerIts.DeskTopPath + "\\out.txt"; foreach (var f in files) { if (Path.GetFileName(f).StartsWith("ITE.")) { Console.WriteLine(f); Console.WriteLine("=================================================================================="); var currentVersion = FileVersionInfo.GetVersionInfo(f); var oldVersion = FileVersionInfo.GetVersionInfo(f); FileManagerIts.AppendLines(outversion, "File:" + f); FileManagerIts.AppendLines(outversion, "File version:" + currentVersion.FileVersion); FileManagerIts.AppendLines(outversion, "Product version:" + currentVersion.ProductVersion); } } }
public void ClearCache() { var reports = FileManagerIts.ToFiles(_reportDir, new string[] { "", ".repx" }); foreach (var f in reports) { File.Delete(f); } }
/// <summary> /// Remove os dashboard criados no disco /// <br>Todos .xml será apagado</br> /// </summary> /// <param name="dashboardAnt"></param> public void ClearCache() { var dashs = FileManagerIts.ToFiles(_dashboardDir, new string[] { "", ".xml" }); foreach (var path in dashs) { FileManagerIts.DeleteFile(path); } }
private void barBtnSelectDir_ItemClick(object sender, ItemClickEventArgs e) { var op = fBrowserFileCs.ShowDialog(); if (op == DialogResult.OK) { this._fileClassList.Clear(); var files = FileManagerIts.ToFiles(fBrowserFileCs.SelectedPath, new string[] { ".cs" }); addFilecs(files); this.gridViewClasses.SelectAllRow(); } }
//OK Graças a Deus public void UpdateDLLsITSolution(string source, string tarjet) { var files = FileManagerIts.ToFiles(source, new string[] { ".dll", ".pdb", ".exe" }); //vai o foreach normal mesmo foreach (var f in files) { string fileName = Path.GetFileName(f); if (fileName != null && fileName.StartsWith("ITSolution.")) { //gera o caminho do arquivo string newSource = Path.Combine(tarjet, fileName); //copia o arquivo para o diretorio ou sobreescreve se ele existir FileManagerIts.CopyFile(f, newSource); } } }
private static void generateScriptToSkin() { //todos os arquivo sem extensao var skins = FileManagerIts.ToFiles(@"D:\Program Files\TFS\ITSolution\ITSolution.Framework\Resources", new string[] { "" }); //lista de temas do dev express var lista = new List <string>(); foreach (var f in skins) { var skinsData = FileManagerIts.GetDataFile(f); Console.WriteLine(f); Console.WriteLine("======================================================================================================="); foreach (var skin in skinsData) { Console.WriteLine("'" + skin + "',");//concatenar usando o excel posteriomente eh mais rapido } } }
private void XFrmDigitalizacaoAvancada_FormClosing(object sender, FormClosingEventArgs e) { var temp = Path.GetTempPath(); try { var files = FileManagerIts.ToFiles(temp, new String[] { ".jpg", ".jpeg", ".tmp" }); //files.ForEach(File.Delete); //usei o delegate pra lembra q ele existe files.ForEach(delegate(string file) { File.Delete(file); }); } catch { //Whatever apagando ou nao } }
private List <AnexoPackage> getQueriesSql() { var sqls = new List <AnexoPackage>(); if (Directory.Exists(_resourceDir)) { //de tudo .sql q esta la dentro var sqlFiles = FileManagerIts.ToFiles(_resourceDir, new string[] { ".sql" }, true); foreach (var item in sqlFiles) { sqls.Add(new AnexoPackage(item)); } } else { //se nao existe entao olhe pros anexos sqls = this._pacote.Anexos.Where(a => a.Extensao == ".sql") .ToList(); } return(sqls); }
//OK public void UpdateDLLsITE(string source, string tarjet) { var files = FileManagerIts.ToFiles(source, new string[] { ".dll", ".pdb", ".exe" }); //vai o foreach normal mesmo foreach (var f in files) { string fileName = Path.GetFileName(f); if (fileName != null && fileName.StartsWith("ITE.")) { //gera o caminho do arquivo string newSource = Path.Combine(tarjet, fileName); //copia o arquivo para o diretorio ou sobreescreve se ele existir FileManagerIts.CopyFile(f, newSource); } } //com lambda ficou foi mais complicado de entender posteriormente //FileManagerIts.ToFiles(temp) // .Where(f => f.ToString() != null && !f.StartsWith("ITE.")) // .ToList().ForEach(File.Delete); }
private static void InfoVersionDLLs() { var forms = @"D:\Program Files\TFS\ITE\ITE.Forms\bin\Debug\"; var files = FileManagerIts.ToFiles(forms, new string[] { ".dll" }); var outversion = FileManagerIts.DeskTopPath + "\\out.txt"; foreach (var f in files) { if (Path.GetFileName(f).StartsWith("ITE.")) { Console.WriteLine(f); Console.WriteLine("=================================================================================="); var currentVersion = FileVersionInfo.GetVersionInfo(f); var oldVersion = FileVersionInfo.GetVersionInfo(f); FileManagerIts.AppendLines(outversion, "File:" + f); FileManagerIts.AppendLines(outversion, "File version:" + currentVersion.FileVersion); FileManagerIts.AppendLines(outversion, "Product version:" + currentVersion.ProductVersion); } } }
private void loadPackage(Package pacote) { this._pacote = pacote; this.wizardControl1.SelectedPageIndex = 1; try { groupControlInfoPackage.Visible = true; if (pacote.DataPublicacao.HasValue) { lbDtPublish.Text = pacote.DataPublicacao.Value.ToShortDateString(); labelControl6.Text = pacote.NumeroPacote; memoEditDesc.Text = pacote.Descricao; if (pacote.Anexos.Any(a => a.Extensao == ".zip")) { var firstPkg = pacote.Anexos.FirstOrDefault(); string zipName = firstPkg.FileName; //crie um temporario para receber os dados do pacote this._resourceDir = Path.Combine(Path.GetTempPath(), Path.GetFileNameWithoutExtension(zipName)); FileManagerIts.DeleteDirectory(_resourceDir); FileManagerIts.CreateDirectory(_resourceDir); try { //arquivo zip string zipFile = Path.Combine(Path.GetTempPath(), zipName); //gera o zip em disco FileManagerIts.WriteBytesToFile(zipFile, firstPkg.DataFile); //extrai os dados pro temporario ZipUtil.ExtractToDirectory(zipFile, this._resourceDir); //todos os arquivos foreach (string item in FileManagerIts.ToFiles(this._resourceDir, new string[] { ".sql" }, true)) { if (item.EndsWith(".sql")) { _containsSql = true; } else if (item.EndsWith(".dll")) { _containsDll = true; } } //ja extrai o pacote e nao preciso dele no disco, os dados ja foram extraidos FileManagerIts.DeleteFile(zipFile); } catch (Exception ex) { string msg = "Falha na verificação de integridade do pacote."; XMessageIts.ExceptionMessageDetails(ex, msg); LoggerUtilIts.GenerateLogs(ex, msg); } } else { int countSql = pacote.Anexos.Count(a => a.Extensao == ".sql"); int countDll = pacote.Anexos.Count(a => a.Extensao == ".dll"); this._containsSql = countSql > 0; this._containsDll = countDll > 0; } this.pnlSql.Visible = _containsSql; if (_containsDll) { this.pnlDlls.Visible = true; detectInstallDir(); //this.groupControlInfoPackage.Location = new Point(17, 251); //this.groupControlInfoPackage.Size = new Size(806, 242); } else { this.pnlDlls.Visible = false; //this.groupControlInfoPackage.Location = new Point(17, 159); //this.groupControlInfoPackage.Size = new Size(806, 344); } wizardPage1.AllowNext = true; } else { XMessageIts.Erro("O pacote selecionado não foi publicado e não pode ser aplicado."); } } catch (Exception ex) { string msg = "O pacote de atualização informado é inválido!" + "\n\nContate o administrador para aplicar atualização."; XMessageIts.ExceptionMessageDetails(ex, msg, "Atenção"); LoggerUtilIts.GenerateLogs(ex, msg); } }
private void executeDDL() { using (TransactionScope ts = new TransactionScope(TransactionScopeOption.Required, new TransactionOptions() { IsolationLevel = IsolationLevel.ReadUncommitted })) { using (var cnn = createConnection()) { try { cnn.OpenConnection(); var connection = cnn.Connection; Dictionary <string, bool> statusScripts = new Dictionary <string, bool>(); List <SqlCommand> commands = new List <SqlCommand>(); //cria a transacao cnn.Transaction = connection.BeginTransaction(System.Data.IsolationLevel.ReadUncommitted, "myTransaction"); //de tudo .sql q esta la dentro var sqlFiles = FileManagerIts.ToFiles(_proceduresResource, new string[] { ".sql" }, true); /*var sqlFiles = new FileManagerIts().ToFilesRecursive(_proceduresResource); * var sqls = sqlFiles.Where(file => file.ToString().EndsWith(".sql"));*/ foreach (var sql in sqlFiles) { var sqlFileName = Path.GetFileName(sql); taskLogger("Executando script: " + sqlFileName); var sqlQuery = FileManagerIts.GetDataStringFile(sql); // split script on GO command IEnumerable <string> commandStrings = Regex.Split(sqlQuery, @"^\s*GO\s*$", RegexOptions.Multiline | RegexOptions.IgnoreCase); //executando cada script separado por GO foreach (string commandString in commandStrings) { try { if (commandString.Trim() != string.Empty) { var command = new SqlCommand(commandString, null); command.Transaction = cnn.Transaction; var result = cnn.ExecuteNonQuery(command); commands.Add(command); if (result.IsCompleted) //se executou o arquivo DDL.. { //taskLogger("Comando " + commandString + " executado com sucesso."); taskLogger("Instrução " + sqlFileName + " executado com sucesso."); taskLogger("============================================================================"); statusScripts.Add(commandString, true); } } } catch (SqlException sqlE) { taskLogger("Error: " + sqlE.Number + "Comando: \n" + commandString + " \nLine: " + sqlE.LineNumber + " Message:" + sqlE.Message); statusScripts.Add(commandString, false); } }//fim } //se a lista de scripts executados tiver mais de um item falso if (statusScripts.Where(s => s.Value == false).Count() == 0) { cnn.Transaction.Commit(); ts.Complete(); } else { cnn.Transaction.Rollback(); throw new TransactionAbortedException(); } } catch (TransactionAbortedException traCanc) { taskLogger("Ocorreram erros no processo. Todas as alterações serao desfeitas."); taskLogger("Erro: " + traCanc.Message); } catch (Exception ex) { taskLogger("Ocorreram erros no processo. Todas as alterações serao desfeitas."); taskLogger("Erro: " + ex.Message); } finally { cnn.CloseConnection(); } } } }