Exemple #1
0
    public static void ConvertUrlsToInData(string url)
    {
        WebService.LinkDetails wss = new WebService.LinkDetails();
        WebService             ws  = new WebService();

        wss = ws.GetDetails(url);
        string imgurl = "";

        if (wss.Image != null)
        {
            imgurl = wss.Image.Url;
        }
        else if (wss.Images != null)
        {
            if (wss.Images.Count > 0)
            {
                imgurl = wss.Images[0].Url;
            }
        }
        URL_data urld = new URL_data();

        urld.url = wss.Url;
        if (wss.Title != null)
        {
            urld.title = wss.Title;
        }
        if (wss.Description != null)
        {
            urld.des = wss.Description;
        }

        if (imgurl != "")
        {
            if (UrlExists(imgurl))
            {
                urld.image_url = imgurl;
            }
        }


        GCP_MYSQL gc1    = new GCP_MYSQL();
        string    Query1 = "insert into status_messages_link_info(link,image_url,title,des,update_time)";

        Query1 += " values('" + url + "','" + urld.image_url + "','" + urld.title + "','" + urld.des + "',NOW());";
        string resin1 = gc1.insert_cmd(Query1);
    }
    protected void Page_Load(object sender, EventArgs e)
    {
        if (Session["seak_URLinfo"] != null)
        {
            if (Session["seak_URLinfo"].ToString() == "true")
            {
                ListBox1.Items.Clear();
                ListBox2.Items.Clear();
                ListBox3.Items.Clear();
                ListBox4.Items.Clear();
                ListBox5.Items.Clear();
                ListBox6.Items.Clear();

                gc = new GCP_MYSQL();


                Query = "select *,TIMESTAMPDIFF(minute, update_time, NOW()) as difftime from status_messages_link_info order by difftime DESC LIMIT 50;";

                DataView ict2     = gc.select_cmd(Query);
                URL_data URL_info = new URL_data();
                if (ict2.Count > 0)
                {
                    for (int i = 0; i < ict2.Count; i++)
                    {
                        if (Convert.ToInt32(ict2.Table.Rows[i]["difftime"].ToString()) > 30)
                        {
                            URL_info = new URL_data();
                            URL_info = ConvertUrlsToDIV(ict2.Table.Rows[i]["link"].ToString());

                            Query      = "update status_messages_link_info set image_url='" + URL_info.image_url + "',title='" + URL_info.title + "'";
                            Query     += ",des='" + URL_info.des + "',update_time=NOW() where id='" + ict2.Table.Rows[i]["id"].ToString() + "';";
                            result_cmd = gc.update_cmd(Query);

                            ListBox1.Items.Add(URL_info.url);
                            ListBox2.Items.Add(URL_info.title);
                            ListBox3.Items.Add(URL_info.des);
                            ListBox4.Items.Add(URL_info.image_url);
                            ListBox6.Items.Add(URL_info.update_time);
                        }
                    }
                }
            }
        }
    }
    public static URL_data ConvertUrlsToDIV(string url)
    {
        WebService.LinkDetails wss = new WebService.LinkDetails();
        WebService             ws  = new WebService();

        wss = ws.GetDetails(url);
        string imgurl = "";

        if (wss.Image != null)
        {
            imgurl = wss.Image.Url;
        }
        else if (wss.Images != null)
        {
            if (wss.Images.Count > 0)
            {
                imgurl = wss.Images[0].Url;
            }
        }
        URL_data urld = new URL_data();

        urld.url = url;
        if (wss.Title != null)
        {
            urld.title = wss.Title;
        }
        if (wss.Description != null)
        {
            urld.des = wss.Description;
        }

        if (imgurl != "")
        {
            if (UrlExists(imgurl))
            {
                urld.image_url = imgurl;
            }
        }

        return(urld);
    }