Exemplo n.º 1
0
 public void PlayVideo()
 {
     string ID = Request.QueryString["VideoID"].ToString();
     RegisterVideo rv = new RegisterVideo();
     rv.PKVideoID = Convert.ToInt32(ID);
     rv.GetVideoFromID();
     Response.Clear();
     Response.Buffer = true;
     Response.AddHeader("content-disposition", ("inline;filename=" + rv.VideoName));
     Response.ContentType = rv.Extension.ToString();
     Response.BinaryWrite(rv.Image);
     Response.Flush();
     Response.End();
 }
Exemplo n.º 2
0
    protected void Page_Load(object sender, EventArgs e)
    {
        string        ID = Request.QueryString["VideoID"].ToString();
        RegisterVideo rv = new RegisterVideo();

        rv.PKVideoID = Convert.ToInt32(ID);
        rv.GetVideoFromID();
        Response.Clear();
        Response.Buffer = true;
        Response.AddHeader("content-disposition", ("inline;filename=" + rv.VideoName));
        Response.ContentType = rv.Extension.ToString();
        Response.BinaryWrite(rv.Image);
        Response.Flush();
        Response.End();
    }
Exemplo n.º 3
0
    protected void gvVideos_RowDeleting(object sender, GridViewDeleteEventArgs e)
    {
        try
        {
            int           id = Int32.Parse(gvVideos.DataKeys[e.RowIndex].Value.ToString());
            RegisterVideo rv = new RegisterVideo();
            rv.PKVideoID = id;
            rv.DeleteVideo();

            BindGrid();
        }
        catch (System.Exception ex)
        {
            lblError.Text = ex.Message;
        }
    }
Exemplo n.º 4
0
    protected void btnsave_Click(object sender, EventArgs e)
    {
        SqlConnection con = new SqlConnection(ConfigurationManager.ConnectionStrings["VideoConnectionString"].ToString());
        try
        {
            System.Web.HttpPostedFile InputFile = fuVideo.PostedFile;
            int FileLength = InputFile.ContentLength;
            System.IO.Stream StreamObject = InputFile.InputStream;
            byte[] FileByteArray = new byte[FileLength];
            StreamObject.Read(FileByteArray, 0, FileLength);
            string VideoName = fuVideo.FileName.ToString();
               string ext;
                ext = VideoName.Substring((VideoName.Length - (VideoName.Length - (VideoName.LastIndexOf(".") + 1))));
                ext = ext.Trim();
                ext = ext.ToUpper();
                if (ext == "XLS" || ext == "MOV" || ext == "MP4" || ext == "WMV" || ext == "M2V" || ext == "M4V" || ext == "OGG" || ext == "WEBM" || ext == "AVI" || ext == "MPG" || ext == "MPEG")
                {
                    RegisterVideo rv = new RegisterVideo();
                    rv.VideoName = fuVideo.FileName.ToString();

                    rv.Image = FileByteArray;
                    rv.DateUploaded = Convert.ToDateTime(DateTime.Now.ToShortDateString());
                    rv.UserName = Session["UserName"].ToString();
                    // rv.InsertIntoVideos();

                    string FileSize = GetFileSize(FileLength);
                    rv.FileSize = FileSize;
                    int cnt = rv.CheckVideo();

                    if (cnt == 0)
                    {
                        SqlCommand com = new SqlCommand();
                        com.CommandText = "spInsertIntoVideos";
                        com.CommandType = CommandType.StoredProcedure;
                        com.Connection = con;
                        con.Open();

                        com.Parameters.Add(new SqlParameter("@VideoName", rv.VideoName));
                        com.Parameters.Add(new SqlParameter("@Image", rv.Image));
                        com.Parameters.Add(new SqlParameter("@DateUploaded", rv.DateUploaded));
                        com.Parameters.Add(new SqlParameter("@UserName", rv.UserName));
                        com.Parameters.Add(new SqlParameter("@FileSize", FileSize));
                        com.ExecuteNonQuery();

                        lblError.Text = "Video Uploaded Successfully";
                    }
                    else
                    {
                        lblError.Text = "File already exists";
                    }
                    BindGrid();
                }
                else
                {
                    lblError.Text = "File format not supported";
                }
        }
        catch (System.Exception ex)
        {
            lblError.Text = ex.Message;
        }
        finally
        {
            con.Close();
        }
    }
Exemplo n.º 5
0
    protected void gvVideos_RowDeleting(object sender, GridViewDeleteEventArgs e)
    {
        try
        {
            int id = Int32.Parse(gvVideos.DataKeys[e.RowIndex].Value.ToString());
            RegisterVideo rv = new RegisterVideo();
            rv.PKVideoID = id;
            rv.DeleteVideo();

            BindGrid();
        }
        catch (System.Exception ex)
        {
            lblError.Text = ex.Message;
        }
    }
Exemplo n.º 6
0
    protected void btnsave_Click(object sender, EventArgs e)
    {
        SqlConnection con = new SqlConnection(ConfigurationManager.ConnectionStrings["VideoConnectionString"].ToString());

        try
        {
            System.Web.HttpPostedFile InputFile = fuVideo.PostedFile;
            int FileLength = InputFile.ContentLength;
            System.IO.Stream StreamObject  = InputFile.InputStream;
            byte[]           FileByteArray = new byte[FileLength];
            StreamObject.Read(FileByteArray, 0, FileLength);
            string VideoName = fuVideo.FileName.ToString();
            string ext;
            ext = VideoName.Substring((VideoName.Length - (VideoName.Length - (VideoName.LastIndexOf(".") + 1))));
            ext = ext.Trim();
            ext = ext.ToUpper();
            if (ext == "XLS" || ext == "MOV" || ext == "MP4" || ext == "WMV" || ext == "M2V" || ext == "M4V" || ext == "OGG" || ext == "WEBM" || ext == "AVI" || ext == "MPG" || ext == "MPEG")
            {
                RegisterVideo rv = new RegisterVideo();
                rv.VideoName = fuVideo.FileName.ToString();


                rv.Image        = FileByteArray;
                rv.DateUploaded = Convert.ToDateTime(DateTime.Now.ToShortDateString());
                rv.UserName     = Session["UserName"].ToString();
                // rv.InsertIntoVideos();

                string FileSize = GetFileSize(FileLength);
                rv.FileSize = FileSize;
                int cnt = rv.CheckVideo();

                if (cnt == 0)
                {
                    SqlCommand com = new SqlCommand();
                    com.CommandText = "spInsertIntoVideos";
                    com.CommandType = CommandType.StoredProcedure;
                    com.Connection  = con;
                    con.Open();

                    com.Parameters.Add(new SqlParameter("@VideoName", rv.VideoName));
                    com.Parameters.Add(new SqlParameter("@Image", rv.Image));
                    com.Parameters.Add(new SqlParameter("@DateUploaded", rv.DateUploaded));
                    com.Parameters.Add(new SqlParameter("@UserName", rv.UserName));
                    com.Parameters.Add(new SqlParameter("@FileSize", FileSize));
                    com.ExecuteNonQuery();

                    lblError.Text = "Video Uploaded Successfully";
                }
                else
                {
                    lblError.Text = "File already exists";
                }
                BindGrid();
            }
            else
            {
                lblError.Text = "File format not supported";
            }
        }
        catch (System.Exception ex)
        {
            lblError.Text = ex.Message;
        }
        finally
        {
            con.Close();
        }
    }