All pastes #2058526 Raw Edit

default.aspx.cs

public text v1 · immutable
#2058526 ·published 2011-05-13 18:19 UTC
rendered paste body
using System;
using System.Collections.Generic;
using System.Configuration;
using System.Data.SqlClient;
using System.Text;

public partial class _Default : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {

    }

    private int _lastid = 0;
    public int lastid
    {
        get
        {
            return _lastid;
        }
        private set
        {
            _lastid = value;
        }
    }

    public string URL;
    public string IMG;
    protected IEnumerable<string> GetMedia()
    {
        List<string> list = new List<string>();

        try
        {
            DatabaseAction.Execute(delegate(SqlConnection con)
            {
                // TOP nn * here means select up to nn entries from the returned row.
                string querystring = @"SELECT TOP 10 * FROM videos WHERE id > @LastId ORDER BY id DESC;";
                SqlCommand db = new SqlCommand(querystring, con);
                db.Parameters.AddWithValue("@LastId", lastid);
                SqlDataReader reader = db.ExecuteReader();
                
                while (reader.Read())
                {
                    StringBuilder sb = new StringBuilder(512);
                    
                    //not a pretty table
                    URL = reader["path"].ToString();
                    IMG = reader["image"].ToString();
                    sb.Append("<meta property=\"image\" content=\"http://www.survum.com/cack/image/" + IMG + "\" /><link rel=\"video_src\" content=\"http://www.survum.com/cack/videos/" + URL + "\" /><meta name=\"video_height\" content=\"200\" /><meta name=\"video_width\" content=\"300\" /><meta name=\"video_type\" content=\"application/x-shockwave-flash\" />"); //&nbsp;
                    sb.Append("<tr><td><table align=left border=0px style=\"border-color: #FFFFFF;padding-right:2px; padding-left:2px; padding-top:2px;\"><tr height=100px><td width=140px halign=right><table class=\"tableclass1\" style=\"border-width:4px;border-color: #FFFFFF;\" width=100% height=100%><tr><td><a href=\"Media.aspx?id=" + reader["id"].ToString() + "\">");
                    sb.Append("<span class=\"video-thumb ux-thumb-128 \">");
                    sb.Append("<span class=\"clip\"><table style=\"border: 2px solid #CCCCCC\"><tr><td><img onload=\"tn_load(1)\" src=\"http://www.survum.com/cack/image/" + IMG + "\" v-align=center height=90 width=150 class=\"imgclass1\"></td></tr></table></span></span></a></td></tr></table></td>");
                    sb.Append("<td valign=\"top\"><table height=100%><tr><td id=\"titles\" valign=\"top\" style=\"padding-right:0px; padding-left:8px; padding-top:4px;\" width=100%><a class=\"b\" href=\"Media.aspx?id=" + reader["id"].ToString());
                    sb.Append("\">" + reader["title"] + "</a></td></tr>");
                    sb.Append("<tr valign=\"top\"><td style=\"padding-right:0px; padding-left:4px; padding-top:12px; padding-bottom:0px;\"><script src=\"http://connect.facebook.net/en_US/all.js#xfbml=1\"></script><fb:like href=\"survum.com/Media.aspx?id=" + reader["id"].ToString() + "\" layout=\"button_count\" show_faces=\"false\" width=\"420\" font=\"segoe ui\" ref=\"vid" + reader["id"].ToString() + "\"></fb:like></td></tr></table></td></tr><tr><td colspan=2><img src=\"images/devider.jpg\" align=center ></table></tr></td>"); //<br/>&nbsp;
                    //sb.Append("");
                    list.Add(sb.ToString());
                    lastid = (int)reader["id"];
                }
            });
        }

            

        catch (Exception ex)
        {
            Response.Write(ex.Message);
        }
        
        return list;
    }
    // this is the video id code!!!!!!
    public string GetVideoId(string uri)
    {
        string link = (new Uri(uri)).Query;
        string id = "";
        int length = link.IndexOf('&');
        if (length == -1)
        {
            length = link.Length;
            id = link.Substring(link.IndexOf('=') + 1);
        }
        else
        {
            length = length - 3;
            id = link.Substring(link.IndexOf("=") + 1, length);
        }
        if (String.IsNullOrEmpty(id))
            throw new Exception("<p style=\"color:red;\">internal error parsing " + uri + "</p>");
                
        return id;
    }
    protected string GetPrevPage()
    {
        return "";
    }
    protected string GetNextPage()
    {
        return "";
    }
    protected void SearchBox_TextChanged(object sender, EventArgs e)
    {

    }
    public string GetEmbedCode(string PlaylistUrl)
    {
        StringBuilder sb = new StringBuilder(512);

        sb.Append("<div style='text-align: center; margin-left: auto; visibility:visible; margin-right: auto; width:452px;'><a href='http://www.survum.com'><img border=0 src='http://www.survum.com/images/survumbanner.jpg' /></a>");
        sb.Append("<object width='452' height='376'> <param name='movie' value='http://www.playlistproject.net/mc/mp3player_new.swf'></param>");
        sb.Append("<param name='allowscriptaccess' value='never'></param> <param name='wmode' value='transparent'></param>");
        sb.Append("<param name='flashvars' value='config=http%3A%2F%2Fwww.indimusic.us%2Fext%2Fpc%2Fskins%2Fconfig_white_noautostart.xml&amp;mywidth=450&amp;myheight=470&amp;playlist_url=http%3A%2F%2Fwww.playlistproject.net%2Fpl.php" + PlaylistUrl + "&amp;skinurl=http%3A%2F%2Fsurvum.com%2Fimages%2Funtitled.jpg&amp;wid=os'></param>");
        sb.Append("<embed style='width:452px visibility:visible; height:376px;' allowScriptAccess='never' src='http://www.playlistproject.net/mc/mp3player_new.swf' flashvars='config=http%3A%2F%2Fwww.indimusic.us%2Fext%2Fpc%2Fskins%2Fconfig_white.xml&amp;mywidth=435&amp;myheight=370&amp;playlist_url=http%3A%2F%2Fwww.playlistproject.net%2Fpl.php" + PlaylistUrl + "&amp;skinurl=http%3A%2F%2Fsurvum.com%2Fimages%2Funtitled.jpg&amp;wid=os' width='452' height='376' name='mp3player' wmode='transparent' type='application/x-shockwave-flash' border='0'/> </object>");
        return sb.ToString();
    }

 
}