Esempio n. 1
0
        protected void TextBox1_TextChanged(object sender, EventArgs e)
        {
            XmlDocument  xdoc = XmlDataSource2.GetXmlDocument();
            XmlNodeList  list = xdoc.GetElementsByTagName("User");
            XmlElement   feed;
            XmlElement   game  = null;
            XmlAttribute name  = null;
            XmlAttribute score = null;
            XmlElement   game1;

            if (Idplayer == "")
            {
                feed       = xdoc.CreateElement("User");
                name       = xdoc.CreateAttribute("id");
                name.Value = HttpContext.Current.User.Identity.Name.ToString();
                feed.Attributes.Append(name);

                game  = xdoc.CreateElement("Rating");
                name  = xdoc.CreateAttribute("idJogo");
                score = xdoc.CreateAttribute("Rating");

                name.Value = Request.QueryString["id"];
                TextBox textBox = sender as TextBox;
                score.Value = textBox.Text;
                game.Attributes.Append(name);
                game.Attributes.Append(score);
                feed.AppendChild(game);
            }
            else
            {
                feed = xdoc.SelectSingleNode("Ratings/User[@id='" + Idplayer + "']") as XmlElement;
                if (gameReviewed == false)
                {
                    game  = xdoc.CreateElement("Rating");
                    name  = xdoc.CreateAttribute("idJogo");
                    score = xdoc.CreateAttribute("Rating");

                    name.Value = Request.QueryString["id"];
                    TextBox textBox = sender as TextBox;
                    score.Value = textBox.Text;
                    game.Attributes.Append(name);
                    game.Attributes.Append(score);
                    feed.AppendChild(game);
                }
                else
                {
                    game1 = xdoc.SelectSingleNode("Ratings/User[@id='" + Idplayer + "']/Rating[@idJogo='" + Request.QueryString["id"] + "']") as XmlElement;
                    TextBox textBox = sender as TextBox;
                    game1.Attributes[1].Value = textBox.Text;
                    game1.Attributes[0].Value = Request.QueryString["id"];
                    feed.AppendChild(game1);
                }
            }



            xdoc.DocumentElement.AppendChild(feed);

            XmlDataSource2.Save();
        }
Esempio n. 2
0
        protected void Page_Load(object sender, EventArgs e)
        {
            XmlDocument xdoc = XmlDataSource2.GetXmlDocument();

            var feedList = xdoc.DocumentElement.SelectNodes("feed");


            XmlDocument all    = new XmlDocument();
            XmlElement  parent = all.CreateElement("all");

            all.AppendChild(parent);
            foreach (XmlNode node in feedList)
            {
                XmlDocument feed = new XmlDocument();
                feed.Load(node.Attributes["url"].Value);
                var nodes = feed.SelectNodes("rss/channel/item");

                foreach (XmlNode innerNode in nodes)
                {
                    var author = all.CreateElement("author");
                    author.InnerText = feed.SelectSingleNode("rss/channel/title").InnerText;
                    var importNode = all.ImportNode(innerNode, true);
                    importNode.AppendChild(author);
                    all.DocumentElement.AppendChild(importNode);
                }
            }

            list(order(all));
        }
Esempio n. 3
0
        protected void DropDownList1_SelectedIndexChanged(object sender, EventArgs e)
        {
            XmlDataSource4.DataFile = "~/" + DropDownList1.SelectedValue + "_feed.xml";
            XmlDataSource3.DataFile = "~/" + DropDownList1.SelectedValue + "_feed.xml";
            XmlDataSource2.DataFile = "~/" + DropDownList1.SelectedValue + "_feed.xml";

            XmlDocument xdoc     = XmlDataSource2.GetXmlDocument();
            XmlNodeList elemList = xdoc.GetElementsByTagName("channel");
        }
Esempio n. 4
0
 protected void Page_Load(object sender, EventArgs e)
 {
     if (Request.QueryString["P"] != null && !IsPostBack)
     {
         XmlDocument xmlDoc  = XmlDataSource2.GetXmlDocument();
         XmlNodeList xmlNode = xmlDoc.SelectNodes("/AdminPost/Post[@id='" + Request.QueryString["P"] + "']");
         txtEditTitle.Text    = xmlNode[0].ChildNodes[0].InnerText;
         txtEditLoc.Text      = xmlNode[0].ChildNodes[1].InnerText;
         txtDescription.Value = xmlNode[0].ChildNodes[4].InnerText;
         txtEditTag.Text      = xmlNode[0].ChildNodes[5].InnerText;
     }
 }
Esempio n. 5
0
    protected void ASPxCallback1_Callback(object source, DevExpress.Web.ASPxCallback.CallbackEventArgs e)
    {
        string  xpath = string.Format("//items/item[@id='{0}']", e.Parameter);
        XmlNode node  = XmlDataSource2.GetXmlDocument().SelectSingleNode(xpath);

        if (node != null)
        {
            LargeImage.ImageUrl      = "Images/" + node.Attributes["FileName"].Value;
            LargeImage.AlternateText = node.Attributes["Text"].Value;
            LargeImageText.Text      = node.Attributes["Text"].Value;
        }
        e.Result = ASPxCallback.GetRenderResult(ImagePanel);
    }
Esempio n. 6
0
 protected void GridView1_RowCommand(object sender, GridViewCommandEventArgs e)
 {
     if (e.CommandName == "delete")
     {
         XmlDocument xmlDoc   = XmlDataSource2.GetXmlDocument();
         XmlNodeList xmlNodel = xmlDoc.SelectNodes("/AdminPost/Post[@id='" + Request.QueryString["P"] + "']");
         XmlNode     xmlNode  = xmlNodel[0];
         XmlNode     xParent  = xmlNode.ParentNode;
         xParent.RemoveChild(xmlNode);
         //Save File
         xmlDoc.Save(Server.MapPath("~/App_Data/AdminPost.xml"));
         Response.Redirect("ManagePost.aspx");
     }
 }
Esempio n. 7
0
        private void getTop()
        {
            string link = "http://localhost:49486/RSS/top";

            XmlReader   reader = XmlReader.Create(link);
            XmlDocument doc    = new XmlDocument();

            doc.Load(reader);
            reader.Close();

            XmlDataSource3.Data = doc.OuterXml;
            XmlDataSource3.DataBind();
            XmlDataSource3.XPath = "/rss/channel";

            XmlDataSource2.Data = doc.OuterXml;
            XmlDataSource2.DataBind();
            XmlDataSource2.XPath = "/channel";

            XmlDocument xdoc1    = XmlDataSource3.GetXmlDocument();
            XmlDocument xdoc2    = XmlDataSource2.GetXmlDocument();
            XmlNodeList channel  = xdoc1.SelectNodes("//channel");
            XmlNode     info     = channel[0];
            XmlNodeList noticias = xdoc2.SelectNodes("//item");

            top.InnerHtml = "<ul>";

            foreach (XmlNode i in noticias)
            {
                top.InnerHtml += "" +
                                 "<li>" +
                                 "<a href = \"/Movie?ID=" + i.Attributes["id"].Value + "\" >" +
                                 "<div class=\"thumb\">" +
                                 "<div class=\"img\" style=\"background-image: url('" + i.Attributes["poster"].Value + "');\"></div>" +
                                 "</div>" +
                                 "<div class=\"info\">" +
                                 "<div class=\"title\">" + i.Attributes["title"].Value + "</div>" +
                                 "<div class=\"infos\">" +
                                 "<div class=\"year\">" + i.Attributes["year"].Value + "</div>" +
                                 "<div class=\"imdb\">TMDB: " + i.Attributes["rating"].Value + "</div>" +
                                 "</div>" +
                                 "</div>" +
                                 "</a>" +
                                 "</li>";
            }
            top.InnerHtml += "</ul>";
        }
Esempio n. 8
0
        protected void UpdateBtn_Click(object sender, EventArgs e)
        {
            XmlDocument xmlDoc  = XmlDataSource2.GetXmlDocument();
            XmlNodeList xmlNode = xmlDoc.SelectNodes("/AdminPost/Post[@id='" + Request.QueryString["P"] + "']");

            //Update Title
            xmlNode[0].ChildNodes[0].InnerText = txtEditTitle.Text;
            //Update Location
            xmlNode[0].ChildNodes[1].InnerText = txtEditLoc.Text;
            //Update desc
            xmlNode[0].ChildNodes[4].InnerText = txtDescription.Value;


            xmlDoc.Save(Server.MapPath("~/App_Data/AdminPost.xml"));

            Response.Redirect("ManagePost.aspx");
        }
Esempio n. 9
0
        protected void Button2_Click(object sender, EventArgs e)
        {
            Debug.WriteLine("dqwdqwdqw");
            XmlReader   reader = XmlReader.Create("http://www.omdbapi.com/?i=" + idInput.Value.ToString() + "&plot=full&r=xml");
            XmlDocument doc    = new XmlDocument();

            doc.Load(reader);
            reader.Close();

            XmlDataSource2.Data = doc.OuterXml;

            XmlDataSource2.DataBind();
            XmlDataSource2.XPath = "/root/movie";


            XmlDocument xdoc1 = XmlDataSource2.GetXmlDocument();
            XmlNode     info  = xdoc1.SelectSingleNode("/root/movie");

            String query = "INSERT INTO dbo.Movies (id,rating,year,poster,title) VALUES (@id,@rating, @year, @poster, @title)";

            using (SqlConnection connection = new SqlConnection("Data Source=localhost\\SQLEXPRESS;Initial Catalog=MoviesBS;Integrated Security=True;Pooling=False"))
                using (SqlCommand command = new SqlCommand(query, connection))
                {
                    //a shorter syntax to adding parameters
                    command.Parameters.Add("@id", SqlDbType.NChar).Value = idInput.Value.ToString();

                    command.Parameters.Add("@rating", SqlDbType.NChar).Value = info.Attributes["imdbRating"].Value;

                    command.Parameters.Add("@year", SqlDbType.NChar).Value = info.Attributes["year"].Value;

                    command.Parameters.Add("@poster", SqlDbType.NChar).Value = info.Attributes["poster"].Value;

                    command.Parameters.Add("@title", SqlDbType.NChar).Value = info.Attributes["title"].Value;

                    //make sure you open and close(after executing) the connection
                    connection.Open();
                    try
                    {
                        command.ExecuteNonQuery();
                    }
                    catch { }
                    connection.Close();
                }
            stats();
        }
Esempio n. 10
0
    protected void Page_Load(object sender, EventArgs e)
    {
        //מנקה את קובץ האקס-אמ-אל המיועד לעריכת שאלות
        xmlFakeDoc = XmlDataSource2.GetXmlDocument();
        xmlFakeDoc.SelectSingleNode("/tree").InnerXml = "";

        xmlRealDoc = XmlDataSource1.GetXmlDocument();
        xmlRealDoc.Load(Server.MapPath("tree/games.xml"));

        string path = (Server.MapPath("/uploadedFiles"));

        string[] files = Directory.GetFiles(path);

        foreach (string x in files)
        {
            string imageName = x.Substring((x.Length - x.LastIndexOf("'\'") + 2));

            if (xmlRealDoc.InnerText.Contains(Server.UrlEncode(imageName)) == false)
            {
                File.Delete(Server.MapPath("/uploadedFiles/" + imageName));
            }
        }
    }
Esempio n. 11
0
        protected void CommentBtn_Click(object sender, EventArgs e)
        {
            XmlDocument doc      = XmlDataSource2.GetXmlDocument();
            XmlNodeList nodelist = doc.SelectNodes("//Response[last()]");

            String oldFeedbackID = nodelist[0].Attributes[0].Value.ToString();
            int    feedback      = int.Parse(oldFeedbackID.Substring(1));

            feedback++;
            String newFeedbackID = "F" + feedback;

            XmlNode node    = doc.SelectNodes("/Feedback/Response")[0];
            XmlNode newnode = node.CloneNode(true);

            // update element values for the new node
            newnode.Attributes[0].Value = newFeedbackID;
            newnode.Attributes[1].Value = Request.QueryString["P"];
            newnode.SelectSingleNode("Name").InnerText    = txtNameFeedback.Text;
            newnode.SelectSingleNode("Message").InnerText = txtMessageFeedback.Text;

            // append the new node to the document
            doc.DocumentElement.AppendChild(newnode);
            doc.Save(Server.MapPath("~/App_Data/Feedback.xml"));
        }
Esempio n. 12
0
        protected void FormView1_ItemInserting(object sender, FormViewInsertEventArgs e)
        {
            //verificar se os campos estao todos preenchidos
            DateTime datavelha = DateTime.Now;
            string   script    = "<script language=\"javascript\">\n" + "alert (\"Preencha todos os campos\");\n" + "</script>";

            if (e.Values["nif"].ToString().Length == 0 || e.Values["fname"].ToString().Length == 0 || e.Values["lname"].ToString().Length == 0 || e.Values["pdate"].ToString().Length == 0)
            {
                ClientScript.RegisterStartupScript(script.GetType(), "Error", script);
                e.Cancel = true;
            }
            else
            {
                //verificar se o nif foi corretamente preenchido
                UInt32 n;
                if (UInt32.TryParse(e.Values["nif"].ToString(), out n) && e.Values["nif"].ToString().Length == 9)
                {
                    //verificar se a data e valida
                    DateTime d;
                    if (DateTime.TryParse(e.Values["pdate"].ToString(), out d))
                    {
                        XmlDocument xdoc = XmlDataSource2.GetXmlDocument();
                        //verificar se a propriedade selecionada ja possui dono
                        XmlElement propSelecionada = xdoc.SelectSingleNode("properties/property[@id='" + DropDownList1.SelectedValue + "']") as XmlElement;
                        XmlElement dono            = propSelecionada.SelectSingleNode("owner") as XmlElement;
                        if (dono == null)
                        {
                            dono = xdoc.CreateElement("owner");

                            XmlAttribute nif   = xdoc.CreateAttribute("nif");
                            XmlAttribute fname = xdoc.CreateAttribute("fname");
                            XmlAttribute lname = xdoc.CreateAttribute("lname");
                            XmlAttribute pdate = xdoc.CreateAttribute("pdate");

                            nif.Value   = e.Values["nif"].ToString();
                            fname.Value = e.Values["fname"].ToString();
                            lname.Value = e.Values["lname"].ToString();
                            pdate.Value = e.Values["pdate"].ToString();

                            dono.Attributes.Append(nif);
                            dono.Attributes.Append(fname);
                            dono.Attributes.Append(lname);
                            dono.Attributes.Append(pdate);

                            propSelecionada.AppendChild(dono);

                            XmlDataSource2.Save();
                            e.Cancel = true;

                            script = "<script language=\"javascript\">\n" + "alert (\"Criação de dono bem sucedida!\");\n" + "</script>";
                            ClientScript.RegisterStartupScript(script.GetType(), "Success", script);

                            Response.Redirect("Owners.aspx");
                        }
                        else
                        {
                            datavelha = Convert.ToDateTime(dono.GetAttribute("pdate").ToString());


                            if (datavelha < d)
                            {
                                dono.RemoveAllAttributes();
                                XmlAttribute nif   = xdoc.CreateAttribute("nif");
                                XmlAttribute fname = xdoc.CreateAttribute("fname");
                                XmlAttribute lname = xdoc.CreateAttribute("lname");
                                XmlAttribute pdate = xdoc.CreateAttribute("pdate");

                                nif.Value   = e.Values["nif"].ToString();
                                fname.Value = e.Values["fname"].ToString();
                                lname.Value = e.Values["lname"].ToString();
                                pdate.Value = e.Values["pdate"].ToString();

                                dono.Attributes.Append(nif);
                                dono.Attributes.Append(fname);
                                dono.Attributes.Append(lname);
                                dono.Attributes.Append(pdate);

                                propSelecionada.AppendChild(dono);
                                XmlDataSource2.Save();
                                e.Cancel = true;

                                script = "<script language=\"javascript\">\n" + "alert (\"Alteração de dono bem sucedida!\");\n" + "</script>";
                                ClientScript.RegisterStartupScript(script.GetType(), "Success", script);

                                Response.Redirect("propriedades.aspx");
                            }
                            else
                            {
                                script = "<script language=\"javascript\">\n" + "alert (\"a data de compra nao pode ser mais antiga que a do dono anterior\");\n" + "</script>";
                                ClientScript.RegisterStartupScript(script.GetType(), "Error", script);
                                e.Cancel = true;
                            }
                        }
                    }
                    else
                    {
                        script = "<script language=\"javascript\">\n" + "alert (\"a data não é válida\");\n" + "</script>";
                        ClientScript.RegisterStartupScript(script.GetType(), "Error", script);
                        e.Cancel = true;
                    }
                }
                else
                {
                    script = "<script language=\"javascript\">\n" + "alert (\"O nif nao foi bem preenchido\");\n" + "</script>";
                    ClientScript.RegisterStartupScript(script.GetType(), "Error", script);
                    e.Cancel = true;
                }
            }
        }
Esempio n. 13
0
        protected void doLoad()
        {
            System.Diagnostics.Debug.WriteLine("USER NOT AUTHENTICATED!!!");

            if (!HttpContext.Current.User.Identity.IsAuthenticated)
            {
                System.Diagnostics.Debug.WriteLine("USER NOT AUTHENTICATED!!!");
                Rating1.Visible      = false;
                RadioButton1.Visible = false;
                Label1.Visible       = false;
                Label3.Visible       = false;
                Label4.Visible       = true;
                Label2.Visible       = false;
                ola.Visible          = false;
                TextBox1.Visible     = false;
                Button1.Visible      = false;
            }
            else
            {
                Rating1.Visible      = true;
                RadioButton1.Visible = true;
                Label1.Visible       = true;
                Label3.Visible       = true;
                Label4.Visible       = false;
                Label2.Visible       = true;
                TextBox1.Visible     = true;
                Button1.Visible      = true;
                ola.Visible          = true;
            }

            Label2.Text = Auxiliar.GetAvgScore(Int32.Parse(Request.QueryString["id"])).ToString();

            int score = Auxiliar.GetScore(HttpContext.Current.User.Identity.Name.ToString(), Int32.Parse(Request.QueryString["id"]));

            System.Diagnostics.Debug.WriteLine(score);
            int playedTrue = Auxiliar.Playing(HttpContext.Current.User.Identity.Name.ToString(), Int32.Parse(Request.QueryString["id"]));

            RadioButton1.Checked = false;
            if (playedTrue == 1)
            {
                RadioButton1.Checked = true;
            }


            if (score != 0)
            {
                Rating1.CurrentRating = score;
            }

            if (RadioButton1.Checked == true)
            {
                Rating1.Visible  = true;
                TextBox1.Visible = true;
                Button1.Visible  = true;
            }
            else
            {
                Rating1.Visible  = false;
                TextBox1.Visible = false;
                Button1.Visible  = false;
            }

            Button1.Visible = true;

            XmlDocument asfvafaw      = new XmlDocument();
            String      xsltFileName1 = Server.MapPath("~/XML/Reviews.xml");

            asfvafaw.Load(xsltFileName1);

            XmlDataSource3.Data  = asfvafaw.OuterXml;
            GridView1.DataSource = XmlDataSource3;
            GridView1.DataBind();


            try
            {
                XmlDocument reviews = Auxiliar.getReviews(Int32.Parse(Request.QueryString["id"]));

                GridView1.DataSource = null;
                GridView1.DataBind();

                DataSet xmlData    = new DataSet();
                var     xmlReader1 = new XmlNodeReader(reviews);
                xmlData.ReadXml(xmlReader1);

                GridView1.DataSource = xmlData;
                GridView1.DataBind();
            }
            catch
            {
            }

            XmlDocument Games = Auxiliar.GamesInfoPush(Int32.Parse(Request.QueryString["id"]));
            //XmlDocument Games = Auxiliar.GamesInfo(Int32.Parse(Request.QueryString["id"]));
            var trans = new XslTransform();

            String xsltFileName = Server.MapPath("~/XSLT/infoGame.xslt");

            trans.Load(xsltFileName);

            var reader         = trans.Transform(Games, null, (XmlResolver)null);
            var transformedDoc = new XmlDocument();

            transformedDoc.Load(reader);
            System.Diagnostics.Debug.WriteLine("olaaaaaaaaaaaaaaaaaaaa");

            var ds        = new DataSet();
            var xmlReader = new XmlNodeReader(transformedDoc);

            ds.ReadXml(xmlReader);
            SeriesDetailsView.DataSource = ds;
            SeriesDetailsView.FieldHeaderStyle.Font.Bold     = true;
            SeriesDetailsView.RowStyle.BackColor             = System.Drawing.Color.White;
            SeriesDetailsView.FieldHeaderStyle.BackColor     = System.Drawing.Color.LightGray;
            SeriesDetailsView.FieldHeaderStyle.BorderColor   = System.Drawing.Color.Black;
            SeriesDetailsView.FieldHeaderStyle.Width         = 90;
            SeriesDetailsView.FieldHeaderStyle.VerticalAlign = VerticalAlign.Middle;
            System.Diagnostics.Debug.WriteLine("olaaaaaaaaaaaaaaaaaaaa");

            SeriesDetailsView.DataBind();

            System.Diagnostics.Debug.WriteLine("olaaaaaaaaaaaaaaaaaaaa");

            for (int i = 0; i < 4; i++)
            {
                SeriesDetailsView.Rows[i].Visible = false;
                System.Diagnostics.Debug.WriteLine(SeriesDetailsView.Rows[i].Visible);
            }

            SeriesDetailsView.Rows[0].Enabled = false;


            Image[]     image     = new Image[transformedDoc.SelectNodes("//Similar").Count];
            Label[]     label     = new Label[transformedDoc.SelectNodes("//Similar").Count];
            HyperLink[] hyperlink = new HyperLink[transformedDoc.SelectNodes("//Similar").Count];

            for (int i = 0; i < transformedDoc.SelectNodes("//Similar").Count; i++)
            {
                label[i] = new Label();

                image[i] = new Image();
                image[i].Attributes.Add("class", "img-responsive center-block");
                image[i].Attributes.Add("style", "height:200px");

                XmlDocument x = new XmlDocument();
                x.Load("http://thegamesdb.net/api/GetArt.php?id=" + transformedDoc.SelectNodes("//Similar/@idJogo").Item(i).InnerText);
                image[i].ImageUrl = "http://thegamesdb.net/banners/" + x.SelectNodes("//Images/boxart[@side='front']").Item(0).InnerText;

                HtmlGenericControl createDiv = new HtmlGenericControl("DIV");
                createDiv.Attributes.Add("class", "grid-item col-md-3 col-sm-8 sortable");
                createDiv.Attributes.Add("style", "margin-top: 20px;");

                this.SimilarGames.Controls.Add(createDiv);
                createDiv.Controls.Add(image[i]);
                label[i] = new Label();
                HtmlGenericControl createDivText = new HtmlGenericControl("DIV");
                createDivText.Attributes.Add("class", "titles");
                createDivText.Attributes.Add("style", "text-align: center; margin-top: 5px;");
                createDiv.Controls.Add(createDivText);
                hyperlink[i]             = new HyperLink();
                hyperlink[i].NavigateUrl = String.Format("videoGameInfo.aspx?id={0}", transformedDoc.SelectNodes("//Similar/@idJogo").Item(i).InnerText);

                x.Load("http://thegamesdb.net/api/GetGame.php?id=" + transformedDoc.SelectNodes("//Similar/@idJogo").Item(i).InnerText);
                hyperlink[i].Text = x.SelectNodes("//Game/GameTitle").Item(0).InnerText;

                label[i].Controls.Add(hyperlink[i]);
                createDivText.Controls.Add(label[i]);
            }


            Label1.Text = SeriesDetailsView.Rows[2].Cells[1].Text;
            //System.Diagnostics.Debug.WriteLine(SeriesDetailsView.Rows[9].Cells[0].Text);
            channelImage.Src = "http://thegamesdb.net/banners/" + SeriesDetailsView.Rows[7].Cells[1].Text;
            channelImage.DataBind();
            XmlDocument xdoc  = XmlDataSource2.GetXmlDocument();
            XmlNodeList list4 = xdoc.GetElementsByTagName("User");

            foreach (XmlNode x in list4)
            {
                if (x.Attributes["id"].Value == HttpContext.Current.User.Identity.Name.ToString())
                {
                    Idplayer = x.Attributes["id"].Value;
                    XmlNodeList list3 = x.ChildNodes;
                    foreach (XmlNode c in list3)
                    {
                        if (c.Attributes["idJogo"].Value == Request.QueryString["id"])
                        {
                            gameReviewed = true;
                        }
                    }
                }
            }
            lastVal = -1;
        }
Esempio n. 14
0
        protected void Page_Load(object sender, EventArgs e)
        {
            XmlDocument xdoc = XmlDataSource2.GetXmlDocument();

            Image[]     image     = new Image[10];
            Label[]     label     = new Label[10];
            HyperLink[] hyperlink = new HyperLink[10];
            GridView1.Visible = false;
            int x4;

            if (GridView1.Rows.Count > 0)
            {
                if (GridView1.Rows.Count <= 9)
                {
                    x4 = GridView1.Rows.Count;
                }
                else
                {
                    x4 = 9;
                }
                for (int i = 1; i < x4; i++)
                {
                    label[i] = new Label();

                    image[i] = new Image();
                    image[i].Attributes.Add("height", "150px");

                    XmlDocument x = new XmlDocument();
                    x.Load("http://thegamesdb.net/api/GetArt.php?id=" + GridView1.Rows[i].Cells[0].Text);

                    image[i].ImageUrl = "http://thegamesdb.net/banners/" + x.SelectNodes("//Images/boxart[@side='front']").Item(0).InnerText;
                    HtmlGenericControl createDiv = new HtmlGenericControl("DIV");
                    createDiv.Attributes.Add("class", "grid-item col-md-5 col-sm-12 sortable");
                    createDiv.Attributes.Add("style", "margin-top: 30px;margin-left:30px;");

                    //Centrar image na div
                    image[i].Attributes.Add("class", "img-responsive center-block");
                    image[i].Attributes.Add("style", "height:250px");

                    this.SimilarGames.Controls.Add(createDiv);
                    createDiv.Controls.Add(image[i]);
                    label[i] = new Label();
                    HtmlGenericControl createDivText = new HtmlGenericControl("DIV");
                    createDivText.Attributes.Add("class", "titles");
                    createDivText.Attributes.Add("style", "text-align: center;");
                    createDiv.Controls.Add(createDivText);

                    hyperlink[i] = new HyperLink();
                    XmlDocument xml = new XmlDocument();
                    xml.Load("http://thegamesdb.net/api/GetGame.php?id=" + GridView1.Rows[i].Cells[0].Text);

                    hyperlink[i].Text        = xml.SelectNodes("//Game/GameTitle").Item(0).InnerText;
                    hyperlink[i].NavigateUrl = String.Format("videoGameInfo.aspx?id={0}", xml.SelectNodes("//Game/id").Item(0).InnerText);

                    label[i].Controls.Add(hyperlink[i]);
                    createDivText.Controls.Add(label[i]);
                }
            }

            var         feedList = xdoc.DocumentElement.SelectNodes("feed");
            XmlDocument all      = new XmlDocument();
            XmlElement  parent   = all.CreateElement("all");

            all.AppendChild(parent);
            foreach (XmlNode node in feedList)
            {
                XmlDocument feed = new XmlDocument();
                feed.Load(node.Attributes["url"].Value);
                var nodes = feed.SelectNodes("rss/channel/item");

                foreach (XmlNode innerNode in nodes)
                {
                    var author = all.CreateElement("author");
                    author.InnerText = feed.SelectSingleNode("rss/channel/title").InnerText;
                    var importNode = all.ImportNode(innerNode, true);
                    importNode.AppendChild(author);
                    all.DocumentElement.AppendChild(importNode);
                }
            }

            list(order(all));
        }
Esempio n. 15
0
        protected void Page_Load(object sender, EventArgs e)
        {
            XmlDocument xdoc = XmlDataSource2.GetXmlDocument();

            XmlNodeList elemList = xdoc.GetElementsByTagName("feed");


            for (int i = 0; i < elemList.Count; i++)
            {
                if (elemList[i].Attributes["nome"].Value == DropDownList1.SelectedValue)
                {
                    string      attrVal = elemList[i].Attributes["url"].Value;
                    XmlReader   reader  = XmlReader.Create(attrVal);
                    XmlDocument doc     = new XmlDocument();
                    doc.Load(reader);
                    reader.Close();

                    doc.Save("C:/Users/JotaP/Desktop/UA/EDC/TP3/TP3/TP3/XML/" + elemList[i].Attributes["nome"].Value + "_feed.xml");
                    XmlDataSource6.DataFile = "~/XML/" + elemList[i].Attributes["nome"].Value + "_feed.xml";
                }
            }

            XmlDocument xdoc1 = XmlDataSource6.GetXmlDocument();

            elemList = xdoc1.GetElementsByTagName("url");
            if (elemList.Count > 0)
            {
                XmlNode x1 = elemList[0].ChildNodes.Item(0);
                Image2.Src = x1.InnerText;
            }
            else
            {
                Image2.Src = "default-placeholder.png";
            }


            XmlNodeList nodes_items = xdoc1.SelectNodes("rss/channel/item");
            XmlNode     nodeTitle   = xdoc1.SelectSingleNode("rss/channel/item/title");
            XmlNode     nodeCat     = xdoc1.SelectSingleNode("rss/channel/item/category");
            XmlNode     nodeDate    = xdoc1.SelectSingleNode("rss/channel/item/date");
            XmlNode     nodeDesc    = xdoc1.SelectSingleNode("rss/channel/item/description");
            XmlNode     nodeLink    = xdoc1.SelectSingleNode("rss/channel/item/link");


            String innerHtml = "";

            foreach (XmlNode node in nodes_items)
            {
                nodeTitle = node.SelectSingleNode("title");
                nodeCat   = node.SelectSingleNode("category");
                nodeDate  = node.SelectSingleNode("pubDate");
                nodeDesc  = node.SelectSingleNode("description");
                nodeLink  = node.SelectSingleNode("link");
                if (nodeCat == null)
                {
                    nodeCat           = nodeTitle.Clone();
                    nodeCat.InnerText = "";
                }
                //System.Diagnostics.Debug.WriteLine(elemList[0].InnerText);
                String node_html = "<div class=\"col-xs-12 col-md-6 col-lg-4\"> <div class=\"well\" style=\"min-height: 300px\"> <div class=\"media\"> <div class=\"media-body\"> <h4 class=\"media-heading\"><a target=\"_blank\" href=\"" + nodeLink.InnerText + "\">" + nodeTitle.InnerText + "</a></h4> <div class=\"row\"><div class=\"col-md-6\"><small><i class=\"fa fa-tag\"></i> " + nodeCat.InnerText + "</small></div><div class=\"col-md-6\" style=\"text-align: right\"><small><i class=\"fa fa-calendar - check - o\"></i> " + nodeDate.InnerText + "</small></div></div><p>" + nodeDesc.InnerText + "</p></div></div></div></div>";
                innerHtml += node_html;
            }

            news.InnerHtml = innerHtml;
        }