public static void SaveAgentsToFile(string path, AgentDependency m)
 {
     XmlTextWriter	writer = new XmlTextWriter(path, System.Text.Encoding.UTF8);
     writer.Indentation = 4;
     writer.Formatting = Formatting.Indented;
     writer.Settings.NewLineHandling = NewLineHandling.Entitize;
     writer.Settings.NewLineOnAttributes = true;
     writer.WriteStartDocument();
     writer.WriteComment("This file is generated by Agents Plugin Editor (created by Peyman Abdi peyman[at]nemo-games[dot]com).");
     m.Write(writer);
     writer.Close();
     AssetDatabase.Refresh(ImportAssetOptions.ForceUpdate);
 }
 public static void SaveManifestToFile(string path, Manifest m)
 {
     if (!System.IO.Directory.Exists(Manifest.ManifestFolder))
         System.IO.Directory.CreateDirectory(Manifest.ManifestFolder);
     XmlTextWriter	writer = new XmlTextWriter(path, System.Text.Encoding.UTF8);
     writer.Indentation = 4;
     writer.Formatting = Formatting.Indented;
     writer.Settings.NewLineHandling = NewLineHandling.Entitize;
     writer.Settings.NewLineOnAttributes = true;
     writer.WriteStartDocument();
     writer.WriteComment("This file is generated by Android Manifest Editor (created by Peyman Abdi peyman[at]nemo-games[dot]com).");
     m.Write(writer);
     writer.Close();
     AssetDatabase.Refresh(ImportAssetOptions.ForceUpdate);
 }
Exemple #3
0
 public static void Main() {
 StringWriter w = new StringWriter();
 XmlTextWriter x = new XmlTextWriter(w);
 x.Formatting = Formatting.Indented;
 x.WriteStartDocument();
 x.WriteComment("a simple test");
 x.WriteStartElement("message");
 x.WriteStartAttribute("project", "");
 x.WriteString("Rotor");
 x.WriteEndAttribute();
 x.WriteString("Hello world!");
 x.WriteEndElement();
 x.WriteEndDocument();
 x.Flush();
 Console.WriteLine(w.ToString());
 }
    protected void Matricularse_Click(object sender, EventArgs e)
    {
        SqlConnection con = new SqlConnection(connectionString);

        int codigo = 0;
        if (Nombre.Text == "" || Apellido.Text == "" || DNI.Text == "" || Direccion.Text == "" || Telefono.Text == "" || Celular.Text == "" || Correo_electronico.Text == "")
        {
            registro.Style["color"] = "Red";
            registro.Text = "MATRICULA NO REGISTRADA, llene todos los campos...";
        }
        else
        {
            codigo = codigo + 1;
            //byte[] photo=GetPhoto(Foto_alumno.ImageUrl);

            SqlCommand cmd = new SqlCommand();

            cmd.Connection = con;
            cmd.CommandText = "INSERT INTO Salud VALUES (@codigo, @nombre, @apellidos, @DNI, @fechanac,@genero,@nivel,@seccion,@escuela,@region,@distrito,@direccion,@telefono,@celular,@email)";
            cmd.Parameters.Add("@codigo", System.Data.SqlDbType.Int);
            cmd.Parameters.Add("@nombre", System.Data.SqlDbType.NVarChar);
            cmd.Parameters.Add("@apellidos", System.Data.SqlDbType.NVarChar);
            cmd.Parameters.Add("@DNI", System.Data.SqlDbType.Int);
            cmd.Parameters.Add("@fechanac", System.Data.SqlDbType.Date);
            cmd.Parameters.Add("@genero", System.Data.SqlDbType.NChar);
            cmd.Parameters.Add("@nivel", System.Data.SqlDbType.NChar);
            cmd.Parameters.Add("@seccion", System.Data.SqlDbType.NChar);
            cmd.Parameters.Add("@escuela", System.Data.SqlDbType.NVarChar);
            cmd.Parameters.Add("@region", System.Data.SqlDbType.NVarChar);
            cmd.Parameters.Add("@distrito", System.Data.SqlDbType.NVarChar);
            cmd.Parameters.Add("@direccion", System.Data.SqlDbType.NVarChar);
            cmd.Parameters.Add("@telefono", System.Data.SqlDbType.Int);
            cmd.Parameters.Add("@celular", System.Data.SqlDbType.Int);
            cmd.Parameters.Add("@email", System.Data.SqlDbType.NVarChar);
            //cmd.Parameters.Add("@foto", System.Data.SqlDbType.Image).Value=photo;

            cmd.Parameters["@codigo"].Value = codigo;
            cmd.Parameters["@nombre"].Value = Nombre.Text;
            cmd.Parameters["@apellidos"].Value = Apellido.Text;
            cmd.Parameters["@DNI"].Value = Int32.Parse(DNI.Text); ;
            cmd.Parameters["@fechanac"].Value = Dias.Text + "-" + Meses.Text + "-" + Años.Text;
            cmd.Parameters["@genero"].Value = genero.SelectedItem.Text;
            cmd.Parameters["@nivel"].Value = Grado1.SelectedItem.Text;
            cmd.Parameters["@seccion"].Value = Seccion1.SelectedItem.Text;
            cmd.Parameters["@escuela"].Value = Escuela1.SelectedItem.Text;
            cmd.Parameters["@region"].Value = Region.SelectedItem.Text;
            cmd.Parameters["@distrito"].Value = Distrito.SelectedItem.Text;
            cmd.Parameters["@direccion"].Value = Direccion.Text;
            cmd.Parameters["@telefono"].Value = Int32.Parse(Telefono.Text);
            cmd.Parameters["@celular"].Value = Int32.Parse(Celular.Text);
            cmd.Parameters["@email"].Value = Correo_electronico.Text;

            try
            {
                con.Open();
                cmd.ExecuteNonQuery();
                registro.Style["color"] = "green";
                registro.Text = "MATRICULA REGISTRADA";
                con.Close();

            }
            catch (Exception err)
            {
                registro.Text = "Error al registrar alumno";
                registro.Text += err.Message;
            }

              Cursos1.Visible = true;
              FileStream fs = new FileStream(@"F:\SuperProProductList.xml",
                           FileMode.Create);
              XmlTextWriter w = new XmlTextWriter(fs, null);

              w.WriteStartDocument();
              w.WriteStartElement("SuperProProductList");
              w.WriteComment("This file generated by the XmlTextWriter class.");

              w.WriteStartElement("Lista_Utiles");
              w.WriteAttributeString("Codigo", "", "1");
              w.WriteAttributeString("Curso", "", "BIOQUIMICA MEDICA");

              w.WriteStartElement("Creditos");
              w.WriteString("5");
              w.WriteEndElement();

              w.WriteEndElement();

              w.WriteStartElement("Lista_Utiles");
              w.WriteAttributeString("Codigo", "", "2");
              w.WriteAttributeString("Curso", "", "INGLES MEDICO");

              w.WriteStartElement("Creditos");
              w.WriteString("2");
              w.WriteEndElement();

              w.WriteEndElement();

              w.WriteStartElement("Lista_Utiles");
              w.WriteAttributeString("Codigo", "", "3");
              w.WriteAttributeString("Curso", "", "DOCTRINA SOCIAL DE LA IGLESIA");

              w.WriteStartElement("Creditos");
              w.WriteString("2");
              w.WriteEndElement();

              w.WriteEndElement();

              w.WriteStartElement("Lista_Utiles");
              w.WriteAttributeString("Codigo", "", "4");
              w.WriteAttributeString("Curso", "", "BIOLOGIA CELULAR");

              w.WriteStartElement("Creditos");
              w.WriteString("4");
              w.WriteEndElement();

              w.WriteEndElement();
              w.WriteStartElement("Lista_Utiles");
              w.WriteAttributeString("Codigo", "", "5");
              w.WriteAttributeString("Curso", "", "LOGICO MATEMATICA");

              w.WriteStartElement("Creditos");
              w.WriteString("3");
              w.WriteEndElement();

              w.WriteEndElement();

              w.WriteStartElement("Lista_Utiles");
              w.WriteAttributeString("Codigo", "", "6");
              w.WriteAttributeString("Curso", "", "COMUNICACION, REDACCION Y ORATORIA");

              w.WriteStartElement("Creditos");
              w.WriteString("3");
              w.WriteEndElement();

              w.WriteEndElement();

              w.WriteStartElement("Lista_Utiles");
              w.WriteAttributeString("Codigo", "", "7");
              w.WriteAttributeString("Curso", "", "HISTOLOGIA");

              w.WriteStartElement("Creditos");
              w.WriteString("5");
              w.WriteEndElement();

              w.WriteEndElement();

              w.WriteStartElement("Lista_Utiles");
              w.WriteAttributeString("Codigo", "", "8");
              w.WriteAttributeString("Curso", "", "BIOQUIMICA MEDICA II");

              w.WriteStartElement("Creditos");
              w.WriteString("5");
              w.WriteEndElement();

              w.WriteEndElement();

              w.WriteEndElement();
              w.WriteEndDocument();
              w.Close();

              Limpiar.Visible = false;
        }
    }
    protected void Matricularse2_Click(object sender, EventArgs e)
    {
        SqlConnection con = new SqlConnection(connectionString);

        if (Nombre2.Text == "" || Apellido2.Text == "" || DNI2.Text == "" || Direccion2.Text == "" || Telefono2.Text == "" || Celular2.Text == "" || Correo_electronico2.Text == "")
        {
            registro2.Style["color"] = "Red";
            registro2.Text = "MATRICULA NO REGISTRADA, llene todos los campos...";
        }
        else
        {

            SqlCommand cmd = new SqlCommand();

            cmd.Connection = con;
            cmd.CommandText = "INSERT INTO Sociales VALUES (@nombre, @apellidos, @DNI, @fechanac,@genero,@grado,@seccion,@escuela,@region,@distrito,@direccion,@telefono,@celular,@email)";
            cmd.Parameters.Add("@nombre", System.Data.SqlDbType.NVarChar);
            cmd.Parameters.Add("@apellidos", System.Data.SqlDbType.NVarChar);
            cmd.Parameters.Add("@DNI", System.Data.SqlDbType.Int);
            cmd.Parameters.Add("@fechanac", System.Data.SqlDbType.Date);
            cmd.Parameters.Add("@genero", System.Data.SqlDbType.NChar);
            cmd.Parameters.Add("@grado", System.Data.SqlDbType.NChar);
            cmd.Parameters.Add("@seccion", System.Data.SqlDbType.NChar);
            cmd.Parameters.Add("@escuela", System.Data.SqlDbType.NVarChar);
            cmd.Parameters.Add("@region", System.Data.SqlDbType.NVarChar);
            cmd.Parameters.Add("@distrito", System.Data.SqlDbType.NVarChar);
            cmd.Parameters.Add("@direccion", System.Data.SqlDbType.NVarChar);
            cmd.Parameters.Add("@telefono", System.Data.SqlDbType.Int);
            cmd.Parameters.Add("@celular", System.Data.SqlDbType.Int);
            cmd.Parameters.Add("@email", System.Data.SqlDbType.NVarChar);
            //cmd.Parameters.Add("@foto", System.Data.SqlDbType.Image).Value=photo;

            cmd.Parameters["@nombre"].Value = Nombre2.Text;
            cmd.Parameters["@apellidos"].Value = Apellido2.Text;
            cmd.Parameters["@DNI"].Value = Int32.Parse(DNI2.Text); ;
            cmd.Parameters["@fechanac"].Value = Dias2.Text + "-" + Meses2.Text + "-" + Años2.Text;
            cmd.Parameters["@genero"].Value = genero.Text;
            cmd.Parameters["@grado"].Value = Grado2.SelectedItem.Text;
            cmd.Parameters["@seccion"].Value = Seccion2.SelectedItem.Text;
            cmd.Parameters["@escuela"].Value = Escuela2.SelectedItem.Text;
            cmd.Parameters["@region"].Value = Region2.SelectedItem.Text;
            cmd.Parameters["@distrito"].Value = Distrito2.SelectedItem.Text;
            cmd.Parameters["@direccion"].Value = Direccion2.Text;
            cmd.Parameters["@telefono"].Value = Int32.Parse(Telefono2.Text);
            cmd.Parameters["@celular"].Value = Int32.Parse(Celular2.Text);
            cmd.Parameters["@email"].Value = Correo_electronico2.Text;

            try
            {
                con.Open();
                cmd.ExecuteNonQuery();
                registro2.Style["color"] = "Blue";
                registro2.Text = "MATRICULA REGISTRADA";
                con.Close();

            }
            catch (Exception err)
            {
                registro2.Text = "Error al registrar alumno";
                registro2.Text += err.Message;
            }
            Cursos0.Visible = true;
            FileStream fs = new FileStream(@"F:\SuperProProductList.xml",
                        FileMode.Create);
            XmlTextWriter w = new XmlTextWriter(fs, null);

            w.WriteStartDocument();
            w.WriteStartElement("SuperProProductList");
            w.WriteComment("This file generated by the XmlTextWriter class.");

            w.WriteStartElement("Lista_Utiles");
            w.WriteAttributeString("Codigo", "", "1");
            w.WriteAttributeString("Nombre_Utiles", "", "Psicología");

            w.WriteStartElement("Creditos");
            w.WriteString("3");
            w.WriteEndElement();

            w.WriteEndElement();

            w.WriteStartElement("Lista_Utiles");
            w.WriteAttributeString("Codigo", "", "2");
            w.WriteAttributeString("Nombre_Utiles", "", "Propedeútica del Trabajo");

            w.WriteStartElement("Creditos");
            w.WriteString("3");
            w.WriteEndElement();

            w.WriteEndElement();

            w.WriteStartElement("Lista_Utiles");
            w.WriteAttributeString("Codigo", "", "3");
            w.WriteAttributeString("Nombre_Utiles", "", "Comu. Oral y Escrit");

            w.WriteStartElement("Creditos");
            w.WriteString("3");
            w.WriteEndElement();

            w.WriteEndElement();

            w.WriteStartElement("Lista_Utiles");
            w.WriteAttributeString("Codigo", "", "4");
            w.WriteAttributeString("Nombre_Utiles", "", "Matemática y Estadística");

            w.WriteStartElement("Creditos");
            w.WriteString("3");
            w.WriteEndElement();

            w.WriteEndElement();
            w.WriteStartElement("Lista_Utiles");
            w.WriteAttributeString("id", "", "5");
            w.WriteAttributeString("Nombre_Utiles", "", "Realidad Nacional");

            w.WriteStartElement("Creditos");
            w.WriteString("3");
            w.WriteEndElement();

            w.WriteEndElement();

            w.WriteStartElement("Lista_Utiles");
            w.WriteAttributeString("id", "", "6");
            w.WriteAttributeString("Nombre_Utiles", "", "D. Social de la Iglesia");

            w.WriteStartElement("Creditos");
            w.WriteString("4");
            w.WriteEndElement();

            w.WriteEndElement();

            w.WriteStartElement("Lista_Utiles");
            w.WriteAttributeString("id", "", "7");
            w.WriteAttributeString("Nombre_Utiles", "", "Desarrollo Humano");

            w.WriteStartElement("Creditos");
            w.WriteString("3");
            w.WriteEndElement();

            w.WriteEndElement();

            w.WriteStartElement("Lista_Utiles");
            w.WriteAttributeString("id", "", "8");
            w.WriteAttributeString("Nombre_Utiles", "", "M. de la Investigación");

            w.WriteStartElement("Creditos");
            w.WriteString("3");
            w.WriteEndElement();

            w.WriteEndElement();
            w.WriteStartElement("Lista_Utiles");
            w.WriteAttributeString("id", "", "9");
            w.WriteAttributeString("Nombre_Utiles", "", "Principios de Economía");

            w.WriteStartElement("Creditos");
            w.WriteString("3");
            w.WriteEndElement();

            w.WriteEndElement();

            w.WriteStartElement("Lista_Utiles");
            w.WriteAttributeString("id", "", "10");
            w.WriteAttributeString("Nombre_Utiles", "", "Fund. de Contabilidad");

            w.WriteStartElement("Creditos");
            w.WriteString("3");
            w.WriteEndElement();

            w.WriteEndElement();
            w.WriteStartElement("Lista_Utiles");
            w.WriteAttributeString("id", "", "11");
            w.WriteAttributeString("Nombre_Utiles", "", "Lógica Jurídica");

            w.WriteStartElement("Creditos");
            w.WriteString("3");
            w.WriteEndElement();

            w.WriteEndElement();
            w.WriteStartElement("Lista_Utiles");
            w.WriteAttributeString("id", "", "12");
            w.WriteAttributeString("Nombre_Utiles", "", "Derecho Romano");

            w.WriteStartElement("Creditos");
            w.WriteString("4");
            w.WriteEndElement();

            w.WriteEndElement();
            w.WriteEndDocument();
            w.Close();

            Limpiar1.Visible = false;
        }
    }
    protected void Matricularse0_Click(object sender, EventArgs e)
    {
        SqlConnection con = new SqlConnection(connectionString);

        if (Nombre0.Text == "" || Apellido0.Text == "" || DNI0.Text == "" || Direccion0.Text == "" || Telefono0.Text == "" || Celular0.Text == "" || Correo_electronico0.Text == "")
        {
            registro0.Style["color"] = "Red";
            registro0.Text = "MATRICULA NO REGISTRADA, llene todos los campos...";
        }
        else
        {
            SqlCommand cmd = new SqlCommand();

            cmd.Connection = con;
            cmd.CommandText = "INSERT INTO Ingenierias VALUES (@nombre, @apellidos, @DNI, @fechanac,@genero,@grado,@seccion,@escuela,@region,@distrito,@direccion,@telefono,@celular,@email)";
            cmd.Parameters.Add("@nombre", System.Data.SqlDbType.NVarChar);
            cmd.Parameters.Add("@apellidos", System.Data.SqlDbType.NVarChar);
            cmd.Parameters.Add("@DNI", System.Data.SqlDbType.Int);
            cmd.Parameters.Add("@fechanac", System.Data.SqlDbType.Date);
            cmd.Parameters.Add("@genero", System.Data.SqlDbType.NChar);
            cmd.Parameters.Add("@grado", System.Data.SqlDbType.NChar);
            cmd.Parameters.Add("@seccion", System.Data.SqlDbType.NChar);
            cmd.Parameters.Add("@escuela", System.Data.SqlDbType.NVarChar);
            cmd.Parameters.Add("@region", System.Data.SqlDbType.NVarChar);
            cmd.Parameters.Add("@distrito", System.Data.SqlDbType.NVarChar);
            cmd.Parameters.Add("@direccion", System.Data.SqlDbType.NVarChar);
            cmd.Parameters.Add("@telefono", System.Data.SqlDbType.Int);
            cmd.Parameters.Add("@celular", System.Data.SqlDbType.Int);
            cmd.Parameters.Add("@email", System.Data.SqlDbType.NVarChar);
            //cmd.Parameters.Add("@foto", System.Data.SqlDbType.Image).Value=photo;

            cmd.Parameters["@nombre"].Value = Nombre0.Text;
            cmd.Parameters["@apellidos"].Value = Apellido0.Text;
            cmd.Parameters["@DNI"].Value = Int32.Parse(DNI0.Text); ;
            cmd.Parameters["@fechanac"].Value = Dias0.Text + "-" + Meses0.Text + "-" + Años0.Text;
            cmd.Parameters["@genero"].Value = genero0.SelectedItem.Text;
            cmd.Parameters["@grado"].Value = Grado.SelectedItem.Text;
            cmd.Parameters["@seccion"].Value = Seccion.SelectedItem.Text;
            cmd.Parameters["@escuela"].Value = Escuela.SelectedItem.Text;
            cmd.Parameters["@region"].Value = Region0.SelectedItem.Text;
            cmd.Parameters["@distrito"].Value = Distrito0.SelectedItem.Text;
            cmd.Parameters["@direccion"].Value = Direccion0.Text;
            cmd.Parameters["@telefono"].Value = Int32.Parse(Telefono0.Text);
            cmd.Parameters["@celular"].Value = Int32.Parse(Celular0.Text);
            cmd.Parameters["@email"].Value = Correo_electronico0.Text;

            try
            {
                con.Open();
                cmd.ExecuteNonQuery();
                registro0.Style["color"] = "Blue";
                registro0.Text = "MATRICULA REGISTRADA";
                con.Close();

            }
            catch (Exception err)
            {
                registro0.Text = "Error al registrar alumno";
                registro0.Text += err.Message;
            }

            Cursos.Visible = true;
            FileStream fs = new FileStream(@"F:\SuperProProductList.xml",
                         FileMode.Create);
            XmlTextWriter w = new XmlTextWriter(fs, null);

            w.WriteStartDocument();
            w.WriteStartElement("SuperProProductList");
            w.WriteComment("This file generated by the XmlTextWriter class.");

            w.WriteStartElement("Lista_Utiles");
            w.WriteAttributeString("id", "", "1");
            w.WriteAttributeString("Curso", "", "ALGEBRA Y GEOMETRIA");

            w.WriteStartElement("Creditos");
            w.WriteString("4");
            w.WriteEndElement();

            w.WriteEndElement();

            w.WriteStartElement("Lista_Utiles");
            w.WriteAttributeString("id", "", "2");
            w.WriteAttributeString("Curso", "", "INGENIERIA DE SISTEMAS");

            w.WriteStartElement("Creditos");
            w.WriteString("4");
            w.WriteEndElement();

            w.WriteEndElement();

            w.WriteStartElement("Lista_Utiles");
            w.WriteAttributeString("id", "", "3");
            w.WriteAttributeString("Curso", "", "PROPEDEUTICA");

            w.WriteStartElement("Creditos");
            w.WriteString("2");
            w.WriteEndElement();

            w.WriteEndElement();

            w.WriteStartElement("Lista_Utiles");
            w.WriteAttributeString("id", "", "4");
            w.WriteAttributeString("Curso", "", "SOCIOLOGIA");

            w.WriteStartElement("Creditos");
            w.WriteString("2");
            w.WriteEndElement();

            w.WriteEndElement();
            w.WriteStartElement("Lista_Utiles");
            w.WriteAttributeString("id", "", "5");
            w.WriteAttributeString("Curso", "", "M. DE LA PROGRAMACION");

            w.WriteStartElement("Creditos");
            w.WriteString("5");
            w.WriteEndElement();

            w.WriteEndElement();

            w.WriteStartElement("Lista_Utiles");
            w.WriteAttributeString("id", "", "6");
            w.WriteAttributeString("Curso", "", "D.SOCIAL DE LA IGLESIA");

            w.WriteStartElement("Creditos");
            w.WriteString("2");
            w.WriteEndElement();

            w.WriteEndElement();

            w.WriteStartElement("Lista_Utiles");
            w.WriteAttributeString("id", "", "7");
            w.WriteAttributeString("Curso", "", "CALCULO DIFERENCIAL");

            w.WriteStartElement("Creditos");
            w.WriteString("4");
            w.WriteEndElement();

            w.WriteEndElement();

            w.WriteStartElement("Lista_Utiles");
            w.WriteAttributeString("id", "", "8");
            w.WriteAttributeString("Curso", "", "DESARROLLO HUMANO");

            w.WriteStartElement("Creditos");
            w.WriteString("2");
            w.WriteEndElement();

            w.WriteEndElement();
            w.WriteStartElement("Lista_Utiles");
            w.WriteAttributeString("id", "", "9");
            w.WriteAttributeString("Curso", "", "COMU. ORAL Y ESCRITA");

            w.WriteStartElement("Creditos");
            w.WriteString("2");
            w.WriteEndElement();

            w.WriteEndElement();

            w.WriteStartElement("Lista_Utiles");
            w.WriteAttributeString("id", "", "10");
            w.WriteAttributeString("Curso", "", "F.DE PROGRAMACION");

            w.WriteStartElement("Creditos");
            w.WriteString("4");
            w.WriteEndElement();

            w.WriteEndElement();
            w.WriteStartElement("Lista_Utiles");
            w.WriteAttributeString("id", "", "11");
            w.WriteAttributeString("Curso", "", "PROGRAMACION I");

            w.WriteStartElement("Creditos");
            w.WriteString("5");
            w.WriteEndElement();

            w.WriteEndElement();
            w.WriteStartElement("Lista_Utiles");
            w.WriteAttributeString("id", "", "12");
            w.WriteAttributeString("Curso", "", "ESTRUCTURAS DISCRETAS I");

            w.WriteStartElement("Creditos");
            w.WriteString("4");
            w.WriteEndElement();

            w.WriteEndElement();
            w.WriteStartElement("Lista_Utiles");
            w.WriteAttributeString("id", "", "13");
            w.WriteAttributeString("Curso", "", "FISICA I");

            w.WriteStartElement("Creditos");
            w.WriteString("4");
            w.WriteEndElement();

            w.WriteEndElement();
            w.WriteStartElement("Lista_Utiles");
            w.WriteAttributeString("id", "", "14");
            w.WriteAttributeString("Curso", "", "CALCULO INTEGRAL");

            w.WriteStartElement("Creditos");
            w.WriteString("4");
            w.WriteEndElement();

            w.WriteEndElement();

            w.WriteStartElement("Lista_Utiles");
            w.WriteAttributeString("id", "", "15");
            w.WriteAttributeString("Curso", "", "T. GENERAL DE SISTEMAS");

            w.WriteStartElement("Creditos");
            w.WriteString("2");
            w.WriteEndElement();

            w.WriteEndElement();

            w.WriteEndElement();
            w.WriteEndDocument();
            w.Close();

            Limpiar0.Visible = false;
        }
    }
	private void WriteXML()
	{
		string xmlFile = Server.MapPath("DvdList.xml");

		// Create the writer.
		XmlTextWriter writer = new XmlTextWriter(xmlFile, null);
		writer.Formatting = Formatting.Indented;
		writer.Indentation = 3;

		// Start the document and write a comment.
		writer.WriteStartDocument();
		writer.WriteComment("Created: " + DateTime.Now.ToString());

		// Write the <DvdList> element.
		writer.WriteStartElement("DvdList");

		// Write the <DVD> element for "The Matrix"
		writer.WriteStartElement("DVD");
		// Write a couple of attributes to the <DVD> element.
		writer.WriteAttributeString("ID", "1");
		writer.WriteAttributeString("Category", "Science Fiction");
		// Write some simple elements.
		writer.WriteElementString("Title", "The Matrix");
		writer.WriteElementString("Director", "Larry Wachowski");
		writer.WriteElementString("Price", "18.74");
		// Open the <Starring> element.
		writer.WriteStartElement("Starring");
		// Write two elements.
		writer.WriteElementString("Star", "Keanu Reeves");
		writer.WriteElementString("Star", "Laurence Fishburne");
		// Close the <Starring> element.
		writer.WriteEndElement();
		// Close the <DVD> element.
		writer.WriteEndElement();

		// Write the <DVD> element for "Forrest Gump"
		writer.WriteStartElement("DVD");

		writer.WriteAttributeString("ID", "2");
		writer.WriteAttributeString("Category", "Drama");

		writer.WriteElementString("Title", "Forrest Gump");
		writer.WriteElementString("Director", "Robert Zemeckis");
		writer.WriteElementString("Price", "23.99");

		writer.WriteStartElement("Starring");

		writer.WriteElementString("Star", "Tom Hanks");
		writer.WriteElementString("Star", "Robin Wright");

		writer.WriteEndElement();
		// close the <DVD> element
		writer.WriteEndElement();

		// Write the <DVD> element for "The Others"
		writer.WriteStartElement("DVD");

		writer.WriteAttributeString("ID", "3");
		writer.WriteAttributeString("Category", "Horror");

		writer.WriteElementString("Title", "The Others");
		writer.WriteElementString("Director", "Alejandro Amenábar");
		writer.WriteElementString("Price", "22.49");

		writer.WriteStartElement("Starring");

		writer.WriteElementString("Star", "Nicole Kidman");
		writer.WriteElementString("Star", "Christopher Eccleston");

		writer.WriteEndElement();
		// Close the <DVD> element.
		writer.WriteEndElement();

		// Write the <DVD> element for "Mulholland Drive"
		writer.WriteStartElement("DVD");

		writer.WriteAttributeString("ID", "4");
		writer.WriteAttributeString("Category", "Mystery");

		writer.WriteElementString("Title", "Mulholland Drive");
		writer.WriteElementString("Director", "David Lynch");
		writer.WriteElementString("Price", "25.74");

		writer.WriteStartElement("Starring");

		writer.WriteElementString("Star", "Laura Harring");

		writer.WriteEndElement();
		// close the <DVD> element.
		writer.WriteEndElement();

		// Write the <DVD> element for "A.I. Artificial Intelligence"
		writer.WriteStartElement("DVD");

		writer.WriteAttributeString("ID", "5");
		writer.WriteAttributeString("Category", "Science Fiction");

		writer.WriteElementString("Title", "A.I. Artificial Intelligence");
		writer.WriteElementString("Director", "Steven Spielberg");
		writer.WriteElementString("Price", "23.99");

		writer.WriteStartElement("Starring");

		writer.WriteElementString("Star", "Haley Joel Osment");
		writer.WriteElementString("Star", "Jude Law");

		writer.WriteEndElement();
		// Close the <DVD> element.
		writer.WriteEndElement();


		// Close the <DvdList> element.
		writer.WriteEndElement();

		// Close the writer.
		writer.Close();
	}
Exemple #8
0
    public void saveSetting(string vsSettingsFile)
    {
        if (vsSettingsFile == null) return;

        string fullDirPath = Path.GetDirectoryName(vsSettingsFile);
        if (!Directory.Exists(fullDirPath)) Directory.CreateDirectory(fullDirPath);


        // open file
        FileStream fs = new FileStream(vsSettingsFile, FileMode.Create);
        // create XML writer
        XmlTextWriter xmlOut = new XmlTextWriter(fs, Encoding.UTF8);

        // use indenting for readability
        xmlOut.Formatting = Formatting.Indented;

        // start document
        xmlOut.WriteStartDocument();
        xmlOut.WriteComment("Visual Surveillance System configuration file");

        // main node
        xmlOut.WriteStartElement("appSettings");
        {
            foreach (KeyValuePair<string, string> kv in data)
            {
                xmlOut.WriteStartElement("add");
                {
                    xmlOut.WriteAttributeString("key", kv.Key);
                    xmlOut.WriteAttributeString("value", kv.Value);

                }
                xmlOut.WriteEndElement();
            }
        }
        xmlOut.WriteEndElement();

        // close file
        xmlOut.Close();
        fs.Close();
    }
        public static Stream Format(Stream input)
        {
            int t1 = Environment.TickCount;

            var r = new XmlTextReader(input)
            {
                DtdProcessing      = DtdProcessing.Ignore,
                WhitespaceHandling = WhitespaceHandling.None
            };
            XmlNamespaceManager nsmgr = XmlNamespaces.GetNamespaceManager(r.NameTable);

            var m = new MemoryStream();
            var w = new XmlTextWriter(m, Encoding.UTF8)
            {
                Formatting  = Formatting.Indented,
                Indentation = 2
            };

            w.WriteStartDocument();

            while (r.Read())
            {
                switch (r.NodeType)
                {
                case XmlNodeType.Element:
                    w.WriteStartElement(r.Prefix, r.LocalName, r.NamespaceURI);
                    if (r.HasAttributes)
                    {
                        string elementQName = XmlUtil.GetQName(r, nsmgr);
                        for (int i = 0; i < r.AttributeCount; ++i)
                        {
                            r.MoveToAttribute(i);
                            string attributeQName = XmlUtil.GetQName(r, nsmgr);
                            string xpath          = elementQName + "/@" + attributeQName;
                            // Filter out language="*"
                            if ((xpath.Equals(XPaths.languageAttribute1, StringComparison.Ordinal) || xpath.Equals(
                                     XPaths.languageAttribute2,
                                     StringComparison.Ordinal)) && String.Equals(
                                    r.Value,
                                    "*",
                                    StringComparison.Ordinal))
                            {
                                continue;
                            }
                            // Filter out attributes with empty values if attribute is on the list...
                            if (String.IsNullOrEmpty(r.Value) &&
                                Array.BinarySearch(XPaths.emptyAttributeList, xpath) >= 0)
                            {
                                continue;
                            }
                            w.WriteAttributeString(r.Prefix, r.LocalName, r.NamespaceURI, r.Value);
                        }

                        r.MoveToElement();     //Moves the reader back to the element node.
                    }

                    if (r.IsEmptyElement)
                    {
                        w.WriteEndElement();
                    }

                    break;

                case XmlNodeType.EndElement:
                    w.WriteEndElement();
                    break;

                case XmlNodeType.Comment:
                    w.WriteComment(r.Value);
                    break;

                case XmlNodeType.CDATA:
                    w.WriteCData(r.Value);
                    break;

                case XmlNodeType.Text:
                    w.WriteString(r.Value);
                    break;
                }
            }

            w.WriteEndDocument();
            w.Flush();
            m.Position = 0;
            Util.WriteLog(String.Format(CultureInfo.CurrentCulture, "ManifestWriter.Format t={0}", Environment.TickCount - t1));
            return(m);
        }
Exemple #10
0
        internal bool ParseReaderNode()
        {
            if (reader.Depth > markupDepth)
            {
                if (writer != null)   // ProcessMarkup
                {
                    switch (reader.NodeType)
                    {
                    case XmlNodeType.Element:
                        writer.WriteStartElement(reader.Prefix, reader.LocalName, reader.NamespaceURI);
                        writer.WriteAttributes(reader, false);
                        if (reader.IsEmptyElement)
                        {
                            writer.WriteEndElement();
                        }
                        break;

                    case XmlNodeType.Text:
                        writer.WriteString(reader.Value);
                        break;

                    case XmlNodeType.SignificantWhitespace:
                        writer.WriteWhitespace(reader.Value);
                        break;

                    case XmlNodeType.CDATA:
                        writer.WriteCData(reader.Value);
                        break;

                    case XmlNodeType.EntityReference:
                        writer.WriteEntityRef(reader.Name);
                        break;

                    case XmlNodeType.Comment:
                        writer.WriteComment(reader.Value);
                        break;

                    case XmlNodeType.EndElement:
                        writer.WriteFullEndElement();
                        break;
                    }
                }
                return(true);
            }
            if (reader.NodeType == XmlNodeType.Element)
            {
                if (builder.ProcessElement(reader.Prefix, reader.LocalName, reader.NamespaceURI))
                {
                    namespaceManager.PushScope();
                    if (reader.MoveToFirstAttribute())
                    {
                        do
                        {
                            builder.ProcessAttribute(reader.Prefix, reader.LocalName, reader.NamespaceURI, reader.Value);
                            if (Ref.Equal(reader.NamespaceURI, schemaNames.NsXmlNs) && isProcessNamespaces)
                            {
                                namespaceManager.AddNamespace(reader.Prefix == string.Empty ? string.Empty : reader.LocalName, reader.Value);
                            }
                        }while (reader.MoveToNextAttribute());
                        reader.MoveToElement(); // get back to the element
                    }
                    builder.StartChildren();
                    if (reader.IsEmptyElement)
                    {
                        namespaceManager.PopScope();
                        builder.EndChildren();
                    }
                    else if (!builder.IsContentParsed())
                    {
                        markupDepth  = reader.Depth;
                        stringWriter = new StringWriter();
                        writer       = new XmlTextWriter(stringWriter);
                        writer.WriteStartElement(reader.LocalName);
                    }
                }
                else if (!reader.IsEmptyElement)
                {
                    markupDepth = reader.Depth;
                    writer      = null;
                }
            }
            else if (reader.NodeType == XmlNodeType.Text ||
                     reader.NodeType == XmlNodeType.EntityReference ||
                     reader.NodeType == XmlNodeType.SignificantWhitespace ||
                     reader.NodeType == XmlNodeType.CDATA)
            {
                builder.ProcessCData(reader.Value);
            }
            else if (reader.NodeType == XmlNodeType.EndElement)
            {
                if (reader.Depth == markupDepth)
                {
                    if (writer != null)   // processUnparsedContent
                    {
                        writer.WriteEndElement();
                        writer.Close();
                        writer = null;
                        XmlDocument doc = new XmlDocument();
                        doc.Load(new XmlTextReader(new StringReader(stringWriter.ToString())));
                        XmlNodeList list   = doc.DocumentElement.ChildNodes;
                        XmlNode[]   markup = new XmlNode[list.Count];
                        for (int i = 0; i < list.Count; i++)
                        {
                            markup[i] = list[i];
                        }
                        builder.ProcessMarkup(markup);
                        namespaceManager.PopScope();
                        builder.EndChildren();
                    }
                    markupDepth = int.MaxValue;
                }
                else
                {
                    namespaceManager.PopScope();
                    builder.EndChildren();
                }
                if (reader.Depth == schemaXmlDepth)
                {
                    return(false); // done
                }
            }
            return(true);
        }
Exemple #11
0
        private void RenderRss(int moduleId)
        {
            /*
             *
             * For more info on RSS 2.0
             * http://www.feedvalidator.org/docs/rss2.html
             *
             * Fields not implemented yet:
             * <blogChannel:blogRoll>http://radio.weblogs.com/0001015/userland/scriptingNewsLeftLinks.opml</blogChannel:blogRoll>
             * <blogChannel:mySubscriptions>http://radio.weblogs.com/0001015/gems/mySubscriptions.opml</blogChannel:mySubscriptions>
             * <blogChannel:blink>http://diveintomark.org/</blogChannel:blink>
             * <lastBuildDate>Mon, 30 Sep 2002 11:00:00 GMT</lastBuildDate>
             * <docs>http://backend.userland.com/rss</docs>
             *
             */



            Response.Cache.SetExpires(DateTime.Now.AddMinutes(30));
            Response.Cache.SetCacheability(HttpCacheability.Public);
            //Response.Cache.VaryByParams["g"] = true;

            Response.ContentType = "application/xml";

            moduleSettings = ModuleSettings.GetModuleSettings(moduleId);

            addSignature = WebUtils.ParseBoolFromHashtable(
                moduleSettings, "RSSAddSignature", false);

            ShowPostAuthorSetting = WebUtils.ParseBoolFromHashtable(
                moduleSettings, "ShowPostAuthorSetting", ShowPostAuthorSetting);

            addCommentsLink = WebUtils.ParseBoolFromHashtable(
                moduleSettings, "RSSAddCommentsLink", false);

            feedIsDisabled = WebUtils.ParseBoolFromHashtable(
                moduleSettings, "BlogDisableFeedSetting", feedIsDisabled);

            useExcerptInFeed = WebUtils.ParseBoolFromHashtable(
                moduleSettings, "UseExcerptInFeedSetting", useExcerptInFeed);

            excerptLength = WebUtils.ParseInt32FromHashtable(
                moduleSettings, "BlogExcerptLengthSetting", excerptLength);

            if (moduleSettings.Contains("BlogExcerptSuffixSetting"))
            {
                ExcerptSuffix = moduleSettings["BlogExcerptSuffixSetting"].ToString();
            }

            if (moduleSettings.Contains("BlogMoreLinkText"))
            {
                MoreLinkText = moduleSettings["BlogMoreLinkText"].ToString();
            }

            Response.ContentEncoding = Encoding.UTF8;

            using (XmlTextWriter xmlTextWriter = new XmlTextWriter(Response.OutputStream, Encoding.UTF8))
            {
                xmlTextWriter.Formatting = Formatting.Indented;

                xmlTextWriter.WriteStartDocument();


                //////////////////
                // style for RSS Feed viewed in browsers
                if (ConfigurationManager.AppSettings["RSSCSS"] != null)
                {
                    string rssCss = ConfigurationManager.AppSettings["RSSCSS"].ToString();
                    xmlTextWriter.WriteWhitespace(" ");
                    xmlTextWriter.WriteRaw(String.Format("<?xml-stylesheet type=\"text/css\" href=\"{0}{1}\" ?>", cssBaseUrl, rssCss));
                }

                if (ConfigurationManager.AppSettings["RSSXsl"] != null)
                {
                    string rssXsl = ConfigurationManager.AppSettings["RSSXsl"].ToString();
                    xmlTextWriter.WriteWhitespace(" ");
                    xmlTextWriter.WriteRaw(String.Format("<?xml-stylesheet type=\"text/xsl\" href=\"{0}{1}\" ?>", cssBaseUrl, rssXsl));
                }
                ///////////////////////////


                xmlTextWriter.WriteComment(String.Format("RSS generated by Cynthia Blog Module V 1.0 on {0}", DateTime.Now.ToLongDateString()));

                xmlTextWriter.WriteStartElement("rss");

                xmlTextWriter.WriteStartAttribute("version", "");
                xmlTextWriter.WriteString("2.0");
                xmlTextWriter.WriteEndAttribute();

                xmlTextWriter.WriteStartElement("channel");

                /*
                 *  RSS 2.0
                 *  Required elements for channel are title link and description
                 */

                xmlTextWriter.WriteStartElement("title");
                xmlTextWriter.WriteString(module.ModuleTitle);
                xmlTextWriter.WriteEndElement();

                // this assumes a valid pageid passed in url
                string blogUrl = SiteUtils.GetCurrentPageUrl();

                xmlTextWriter.WriteStartElement("link");
                xmlTextWriter.WriteString(blogUrl);
                xmlTextWriter.WriteEndElement();

                xmlTextWriter.WriteStartElement("description");
                xmlTextWriter.WriteString(moduleSettings["BlogDescriptionSetting"].ToString());
                xmlTextWriter.WriteEndElement();

                xmlTextWriter.WriteStartElement("copyright");
                xmlTextWriter.WriteString(moduleSettings["BlogCopyrightSetting"].ToString());
                xmlTextWriter.WriteEndElement();

                // begin optional RSS 2.0 fields

                //ttl = time to live in minutes, how long a channel can be cached before refreshing from the source
                xmlTextWriter.WriteStartElement("ttl");
                xmlTextWriter.WriteString(moduleSettings["BlogRSSCacheTimeSetting"].ToString());
                xmlTextWriter.WriteEndElement();

                //protection from scrapers wnating to add you to the spam list
                string authorEmail = moduleSettings["BlogAuthorEmailSetting"].ToString().Replace("@", "@nospam");

                xmlTextWriter.WriteStartElement("managingEditor");
                xmlTextWriter.WriteString(authorEmail);
                xmlTextWriter.WriteEndElement();

                xmlTextWriter.WriteStartElement("generator");
                xmlTextWriter.WriteString("Cynthia Blog Module V 1.0");
                xmlTextWriter.WriteEndElement();

                // check if the user has page view permission

                if (
                    (!feedIsDisabled) &&
                    (currentPage.ContainsModule(moduleId)) &&
                    ((bypassPageSecurity) || (WebUser.IsInRoles(currentPage.AuthorizedRoles)))
                    )
                {
                    RenderItems(xmlTextWriter);
                }
                else
                {
                    //beginning of blog entry
                    xmlTextWriter.WriteStartElement("item");
                    xmlTextWriter.WriteStartElement("title");
                    xmlTextWriter.WriteString("this feed is not available");
                    xmlTextWriter.WriteEndElement();

                    xmlTextWriter.WriteStartElement("link");
                    xmlTextWriter.WriteString(navigationSiteRoot);
                    xmlTextWriter.WriteEndElement();

                    xmlTextWriter.WriteStartElement("pubDate");
                    xmlTextWriter.WriteString(DateTime.UtcNow.ToString("r"));
                    xmlTextWriter.WriteEndElement();

                    xmlTextWriter.WriteStartElement("guid");
                    xmlTextWriter.WriteString(navigationSiteRoot);
                    xmlTextWriter.WriteEndElement();

                    //end blog entry
                    xmlTextWriter.WriteEndElement();
                }


                //end of document
                xmlTextWriter.WriteEndElement();
            }
        }