private void button1_Click(object sender, EventArgs e) { BD bd = new BD(); if (i == 1) { Projecto p = new Projecto(); p = constroiProjecto(); bd.actualizarProjecto(p); this.Close(); } else { if (textBox1.Text.Length == 0 || textBox2.Text.Length == 0 || textBox3.Text.Length == 0) MessageBox.Show("Preencha todos os campos!"); else { Projecto p = new Projecto(); p = constroiProjecto(); bd.gravarProjecto(p); this.Close(); } } constroiDefinicoes(); bd.gravarDefinicoes(def); }
public void actualizarProjecto(Projecto p) { string file, schema; file = getFicheiro(p.getNome()); if (file.Length == 0) { file = p.getNome() + ".xml"; schema = file.Remove(file.Length - 4) + ".xsd"; File.Copy("exemplo.xml", file); } else { schema = file.Remove(file.Length - 4) + ".xsd"; } DataSet ds = new DataSet(); FileStream finschema = new FileStream("exemplo.xsd", FileMode.OpenOrCreate, FileAccess.Read, FileShare.Read); ds.ReadXmlSchema(finschema); finschema.Close(); FileStream findata = new FileStream(file, FileMode.OpenOrCreate, FileAccess.Read, FileShare.ReadWrite); ds.ReadXml(findata); findata.Close(); foreach (DataRow dr in ds.Tables["projecto"].Rows) { dr["nome"] = p.getNome(); dr["data"] = DateTime.Now; dr["Filtros"] = p.getFiltros(); } foreach (DataRow dr in ds.Tables["Propriedades"].Rows) { dr["url"] = p.getUrlInicial(); } foreach (DataRow dr in ds.Tables["Propriedades"].Rows) { dr["pasta"] = p.getPasta(); dr["visualizacaolocal"] = p.getvisualizacaolocal(); dr["niveis"] = p.getNivel(); dr["imagensremotas"] = p.getImagensRemotas(); dr["aceitarrejeitar"] = p.getAceitarRejeitar(); } FileStream fout = new FileStream(file, FileMode.Truncate, FileAccess.Write, FileShare.ReadWrite); //Only write the Xml data to the stream ds.WriteXml(fout); //Close the Stream fout.Close(); }
public void criarProjecto(Projecto p) { DataSet ds = new DataSet(); FileStream finschema = new FileStream("projectos.xsd", FileMode.OpenOrCreate, FileAccess.Read, FileShare.Read); ds.ReadXmlSchema(finschema); finschema.Close(); FileStream findata = new FileStream("projectos.xml", FileMode.OpenOrCreate, FileAccess.Read, FileShare.ReadWrite); ds.ReadXml(findata); findata.Close(); DataRow newrow = ds.Tables["Projecto"].NewRow(); newrow["nome"] = p.getNome(); newrow["data"] = DateTime.Now; newrow["ficheiro"] = p.getNome() + ".xml"; ds.Tables["Projecto"].Rows.Add(newrow); FileStream fout = new FileStream("projectos.xml", FileMode.OpenOrCreate, FileAccess.Write, FileShare.ReadWrite); ds.WriteXml(fout); fout.Close(); }
public Motor(Projecto temp, RichTextBox r, int act, Label la1, Label la2, Label la3, Label la4) { log = r; r.Text = "Motor criado\n"; pasta = temp.getPasta(); fNivel = temp.getNivel(); p = temp; criarfiltro(p.getFiltros()); actualizar = act; l1 = la1; l2 = la2; l3 = la3; l4 = la4; l1.Text = "0"; l2.Text = "0"; l3.Text = "0"; l4.Text = "0"; l1.Visible = true; l2.Visible = true; l3.Visible = true; l4.Visible = true; }
public Projecto lerProjecto(string n) { Projecto p = new Projecto(); DataSet ds = new DataSet(); FileStream finschema = new FileStream("exemplo.xsd", FileMode.Open, FileAccess.Read, FileShare.Read); ds.ReadXmlSchema(finschema); finschema.Close(); FileStream findata = new FileStream(n + ".xml", FileMode.Open, FileAccess.Read, FileShare.ReadWrite); ds.ReadXml(findata); findata.Close(); foreach (DataRow dr in ds.Tables["Projecto"].Rows) { p.setNome((string)(dr["nome"])); p.setFiltros((string)(dr["Filtros"])); DateTimeConverter d = new DateTimeConverter(); DateTime da = new DateTime(); da = (DateTime)(d.ConvertFromString((string)(dr[1]))); p.setData(da); } foreach (DataRow dr in ds.Tables["propriedades"].Rows) { p.setPasta((string)(dr["pasta"])); p.setUrlInicial((string)(dr["url"])); p.setvisualizacaolocal(Convert.ToInt32(dr["visualizacaolocal"])); p.setNivel(Convert.ToInt32(dr["niveis"])); p.setImagensRemotas(Convert.ToInt32(dr["imagensremotas"])); p.setAceitarRejeitar(Convert.ToInt32(dr["aceitarrejeitar"])); } return p; }
private void run() { Projecto p = new Projecto(); BD bd = new BD(); p = bd.lerProjecto(listView3.Items[0].Text); if (toolStripButton4.Checked == true) m = new Motor(p, log, 1, label5, label6, label7, label8); else m = new Motor(p, log, 0, label5, label6, label7, label8); Url u = new Url(); u.setNome(p.getUrlInicial()); m.run(u); passaAoProximoProjecto(); }
private void mostraPropriedades() { if (listView1.SelectedItems.Count == 1) { BD bd = new BD(); Projecto temp = new Projecto(); temp = bd.lerProjecto(listView1.SelectedItems[0].Text); Proproj prop = new Proproj(temp); prop.ShowDialog(); } }
public Proproj(Projecto temp) { i = 1; p = temp; InitializeComponent(); }
private Projecto constroiProjecto() { Projecto p = new Projecto(); p.setNome(textBox1.Text); p.setUrlInicial(textBox2.Text); p.setNivel((int)(numericUpDown2.Value)); p.setPasta(textBox3.Text); if (radioButton3.Checked) p.setNivel(-1); if (radioButton4.Checked) p.setNivel((int)(numericUpDown2.Value)); if (radioButton5.Checked) p.setNivel(0); if (checkBox16.Checked) p.setImagensRemotas(1); else p.setImagensRemotas(0); if (radioButton1.Checked) p.setvisualizacaolocal(1); else p.setvisualizacaolocal(0); criar_string_filtros(); p.setFiltros(filtros); if (radioButton7.Checked) p.setAceitarRejeitar(0); else p.setAceitarRejeitar(1); return p; }