private void ligacoeList_SelectedIndexChanged(object sender, EventArgs e) { try { AutomatismosClass.Automatismo.Ficheiro.Consulta ligacao = ligacoeList.SelectedItem as AutomatismosClass.Automatismo.Ficheiro.Consulta; CKFtxt.Text = ligacao.Ok; FO_modtxt.Text = ligacao.FO_Mod; FO_transTxt.Text = ligacao.FO_Trans; DA_modtxt.Text = ligacao.DA_Mod; rngTxt.Text = ligacao.Range; if (ligacao.Image != null) { pictureBox1.Image = ligacao.Image; } else if (rngTxt.Text != "") { pictureBox1.Image = GetImageFromExcel(tempPath, rngTxt.Text); rngAl.Visible = false; ligacao.Image = pictureBox1.Image; ShowConn(); } else { ListaAlertas.Add(new Alertas() { Alerta = TipoAlerta.Valor_Falta, Campo = "Range", Ficheiro = "Consulta" + ligacao.Nome }); rngAl.Visible = true; ShowConn(); } } catch (Exception ex) { Console.WriteLine(ex.Message); } }
private void gravar_Click(object sender, EventArgs e) { AutomatismosClass.Automatismo tb = fileList.SelectedItem as AutomatismosClass.Automatismo; AutomatismosClass.Automatismo.Ficheiro f = tbfileslist.SelectedItem as AutomatismosClass.Automatismo.Ficheiro; AutomatismosClass.Automatismo.Ficheiro.Consulta c = ligacoeList.SelectedItem as AutomatismosClass.Automatismo.Ficheiro.Consulta; c.Range = rngTxt.Text; File.WriteAllText(@"Automatismo.xml", (string)ser.Serialize <AutomatismosClass>(autos)); }
private void RefreshAutos() { List <string> Folders = SearchFolder.GetDirectories(setts.MainFolder); foreach (var folder in Folders) { AutomatismosClass.Automatismo t = autos.Automatismos.Find(x => x.Path.Equals(folder)); if (t == null) { //Adicionar Nova pasta á strutura } else { foreach (var file in new DirectoryInfo(@"" + t.Path + "\\01. Script").GetFiles().Where(f => !f.Attributes.HasFlag(FileAttributes.Hidden))) { AutomatismosClass.Automatismo.Ficheiro f = t.Ficheiros.Find(x => x.Nome.Equals(file.Name)); if (f == null) { //Adicionar Ficheiro } else { ExcelLink teste = new ExcelLink(t.Path + "\\01. Script\\" + f.Nome); Range r = teste.GetRange("C6:E36", ""); foreach (Range item in r.Rows) { if (item.Cells[1, 3].Value == null) { break; } AutomatismosClass.Automatismo.Ficheiro.Consulta lig = f.Ligacoes.Find(l => l.Nome.Equals(item.Cells[1, 3].Value)); if (lig == null) { //Adicionar Consulta } else { lig.Nome = item.Cells[1, 3].Value; lig.Ok = item.Cells[1, 1].Value; lig.VOlBD_Export = item.Cells[1, 4].Value; lig.Seq_Data_Report = item.Cells[1, 5].Value; lig.DA_Mod = item.Cells[1, 9].Value.ToString("dd/MM/yyyy"); lig.FO_Mod = item.Cells[1, 15].Value; lig.FO_Trans = (item.Cells[1, 13].value == null ? "" : item.Cells[1, 13].Value.ToString("dd/MM/yyyy")); if (lig.Range != "") { lig.Image = teste.CopyImage(r, lig.Range); } teste.closeFile(false); } } } } } } }
private List <AutomatismosClass.Automatismo.Ficheiro.Consulta> GetLigacoesFromFile(string file) { ExcelLink Tb = new ExcelLink(file, true); List <AutomatismosClass.Automatismo.Ficheiro.Consulta> Ligs = new List <AutomatismosClass.Automatismo.Ficheiro.Consulta>(); Range r = Tb.GetRange("C6", "R25"); foreach (Range item in r.Rows) { try { if (item.Cells[1, 3].Value == null) { break; } AutomatismosClass.Automatismo.Ficheiro.Consulta Lig = new AutomatismosClass.Automatismo.Ficheiro.Consulta() { Nome = item.Cells[1, 3].Value, Ok = item.Cells[1, 1].Value, VOlBD_Export = item.Cells[1, 4].Value, Seq_Data_Report = item.Cells[1, 5].Value, Range = (autos.Automatismos.FirstOrDefault(x => x.Ficheiros.Contains(x.Ficheiros.FirstOrDefault(y => y.Ligacoes.Contains(y.Ligacoes.FirstOrDefault(z => z.Nome == item.Cells[1, 3].Value))))).Ficheiros.FirstOrDefault(x => x.Ligacoes.Contains(x.Ligacoes.FirstOrDefault(z => z.Nome == item.Cells[1, 3].Value))).Ligacoes.FirstOrDefault(x => x.Nome == item.Cells[1, 3].Value).Range), // Image = (Range != null ) DA_Mod = item.Cells[1, 9].Value.ToString("dd/MM/yyyy"), FO_Mod = item.Cells[1, 15].Value, FO_Trans = (item.Cells[1, 13].value == null ? "" : item.Cells[1, 13].Value.ToString("dd/MM/yyyy")) }; Ligs.Add(Lig); } catch (Exception) { //throw; } } Tb.closeFile(false); return(Ligs); }