Example #1
0
 protected void btnSubmit_Click(object sender, EventArgs e)
 {
     try
     {
         if (Label2.Text.Trim() == "")
         {
             Response.Write("<script>alert('照片不能为空!')</script>");
         }
         else
         {
             Models.Video video = new Models.Video();
             video.VideoID = Convert.ToInt32(Request.QueryString["VideoID"]);
             //news.AssID = 1;
             video.VideoName  = txtTitle.Text.Trim();
             video.VideoBrief = CKEditorControl1.Text.Trim();
             video.Images     = Label2.Text;
             video.VideoUrl   = Label1.Text;
             video.CreatTime  = DateTime.Now;
             int result = VideoService.Insert(video);
             if (result >= 1)
             {
                 Response.Write("<script>alert('发布成功!')</script>");
             }
         }
     }
     catch (Exception ex)
     {
         Response.Write("<script>alert('上传失败');</script> 原因是:" + ex);
     }
 }
Example #2
0
    protected void UploadFileButton_Click(object sender, EventArgs e)
    {
        string filePath = Server.MapPath(VideoUploader.PostedFile.FileName);
        string existingBucketName = "ccdem";
        string keyName = Membership.GetUser().ProviderUserKey.GetHashCode().ToString();
        string fileName = UtilityFunctions.GenerateChar() + VideoUploader.PostedFile.FileName;
        IAmazonS3 client;
        using (client = Amazon.AWSClientFactory.CreateAmazonS3Client(System.Web.Configuration.WebConfigurationManager.AppSettings[0].ToString(), System.Web.Configuration.WebConfigurationManager.AppSettings[1].ToString()))
        {

            var stream = VideoUploader.FileContent;

            stream.Position = 0;

            PutObjectRequest request = new PutObjectRequest();
            request.InputStream = stream;
            request.BucketName = existingBucketName;
            request.CannedACL = S3CannedACL.PublicRead;
            request.Key = keyName + "/" + fileName;
            PutObjectResponse response = client.PutObject(request);
        }

        string bucketUrl = "https://s3-us-west-2.amazonaws.com/" + existingBucketName + "/" + keyName + "/" + fileName;
        cloudFrontUrl = cloudFrontUrl + keyName + "/" + fileName;
        TranscoderUtility.Transcode(keyName + "/" + fileName, keyName + "/mob_" + fileName, existingBucketName);
           // lblPath.Text = "<br/>Successfully uploaded into S3:" + bucketUrl + "<br/> Cloudfront distribution url is " + cloudFrontUrl;
        Models.Video video = new Models.Video() { Url = cloudFrontUrl };
        int newVid = DAL.DataAccessLayer.AddVideo(video, (Guid)Membership.GetUser().ProviderUserKey);
        string vid=Request.QueryString["vid"].ToString();
        if(!vid.Equals(""))
            DAL.DataAccessLayer.AddResponseVideo(vid,newVid.ToString());
        RefreshPage();
    }
Example #3
0
        public static int AddVideo(Models.Video vid, Guid UserId)
        {
            int    newId       = -1;
            string queryString = "AddVideo";

            using (SqlConnection connection = new SqlConnection(connectionString))
            {
                SqlCommand command = new SqlCommand(queryString, connection);
                command.CommandType = System.Data.CommandType.StoredProcedure;
                command.Parameters.Add("@UserID", SqlDbType.UniqueIdentifier, 25);
                command.Parameters.Add("@URL", SqlDbType.Text);


                command.Parameters["@UserID"].Value = UserId;
                command.Parameters["@URL"].Value    = vid.Url;
                try
                {
                    connection.Open();
                    command.ExecuteNonQuery();
                    command.CommandText = "select @@Identity";
                    command.CommandType = CommandType.Text;
                    newId = Convert.ToInt32(command.ExecuteScalar().ToString());
                }
                catch (Exception ex)
                {
                    return(-1);
                }
            }
            return(newId);
        }
        private int AddToDatabase(Feed <Google.YouTube.Video> vids, int bikeModelID)
        {
            int entriesAdded = 0;

            foreach (var vid in vids.Entries)
            {
                int?checkVid = Beweb.BewebData.GetValueInt(new Sql("SELECT COUNT(VideoId) FROM Video WHERE VideoCode=", vid.VideoId.Sqlize_Text()));
                if (checkVid > 0)
                {
                    continue;                               // don't add one that already exists
                }
                Models.Video v = new Video();
                v.SourceWebsiteCode = "youtube";                   // actually all are from youtube
                v.VideoCode         = vid.VideoId;
                v.Title             = vid.Title.Left(150);
                v.VideoDescription  = vid.Description;
                v.Credit            = vid.Author;      //vid.Uploader;
                v.ViewCount         = vid.ViewCount;
                v.Status            = "New";
                v.VideoPostedDate   = Convert.ToDateTime(vid.YouTubeEntry.Published);
                v.DateAdded         = DateTime.Now;
                v.ThumbnailUrl      = vid.Thumbnails[0].Url;
                v.BikeModelID       = bikeModelID;
                v.IsAuto            = true;
                v.Save();
                entriesAdded++;
            }
            return(entriesAdded);
        }
Example #5
0
        /// <summary>
        /// Populates defaults and opens edit form to add new record
        /// GET: /Admin/Video/Create
        /// </summary>
        public ActionResult Create()
        {
            Breadcrumbs.Current.AddBreadcrumb(3, "Add Video");
            var record = new Models.Video();

            // any default values can be set here or in partial class Video.InitDefaults()
            return(View("VideoEdit", record));
        }
Example #6
0
 private void Save(Models.Video record, bool isNew)
 {
     // add any code to update other fields/tables here
     if (isNew)
     {
         record.VideoCode = ParseVideoUrl("YouTube", Request["VideoURL"]);
     }
     record.ThumbnailUrl = "http://i.ytimg.com/vi/" + record.VideoCode + "/default.jpg";
     record.Save();
 }
Example #7
0
        public string ApproveVid()
        {
            int  vid      = Request["VID"].ToInt();
            bool approved = Request["Approved"].ConvertToBool();

            Models.Video v = Models.Video.LoadByVideoID(vid);
            if (approved)
            {
                v.Status = "Approved";
            }
            else
            {
                v.Status = "Rejected";
            }
            v.Save();

            return(vid.ToString());
        }
Example #8
0
    protected void UploadFileButton_Click(object sender, EventArgs e)
    {
        string    filePath           = Server.MapPath(VideoUploader.PostedFile.FileName);
        string    existingBucketName = "ccdem";
        string    keyName            = Membership.GetUser().ProviderUserKey.GetHashCode().ToString();
        string    fileName           = UtilityFunctions.GenerateChar() + VideoUploader.PostedFile.FileName;
        IAmazonS3 client;

        using (client = Amazon.AWSClientFactory.CreateAmazonS3Client(System.Web.Configuration.WebConfigurationManager.AppSettings[0].ToString(), System.Web.Configuration.WebConfigurationManager.AppSettings[1].ToString()))
        {
            var stream = VideoUploader.FileContent;

            stream.Position = 0;

            PutObjectRequest request = new PutObjectRequest();
            request.InputStream = stream;
            request.BucketName  = existingBucketName;
            request.CannedACL   = S3CannedACL.PublicRead;
            request.Key         = keyName + "/" + fileName;
            PutObjectResponse response = client.PutObject(request);
        }

        string bucketUrl = "https://s3-us-west-2.amazonaws.com/" + existingBucketName + "/" + keyName + "/" + fileName;

        cloudFrontUrl = cloudFrontUrl + keyName + "/" + fileName;
        TranscoderUtility.Transcode(keyName + "/" + fileName, keyName + "/mob_" + fileName, existingBucketName);
        // lblPath.Text = "<br/>Successfully uploaded into S3:" + bucketUrl + "<br/> Cloudfront distribution url is " + cloudFrontUrl;
        Models.Video video = new Models.Video()
        {
            Url = cloudFrontUrl
        };
        int    newVid = DAL.DataAccessLayer.AddVideo(video, (Guid)Membership.GetUser().ProviderUserKey);
        string vid    = Request.QueryString["vid"].ToString();

        if (!vid.Equals(""))
        {
            DAL.DataAccessLayer.AddResponseVideo(vid, newVid.ToString());
        }
        RefreshPage();
    }
Example #9
0
        protected ActionResult ProcessForm(Models.Video record)
        {
            try {
                record.UpdateFromRequest();
                Validate(record);
                if (ModelState.IsValid)
                {
                    Save(record, record.IsNewRecord);
                    TempData["info"] = "Video " + record.GetName() + " saved.";
                }
            } catch (UserErrorException e) {
                ModelState.AddModelError("Record", e.Message);
            }

            if (!ModelState.IsValid)
            {
                // invalid so redisplay form with validation message(s)
                return(View("VideoEdit", record));
            }
            else if (Web.Request["SaveAndRefreshButton"] != null)
            {
                return(RedirectToEdit(record.ID));
            }
            else if (Web.Request["DuplicateButton"] != null)
            {
                var newRecord = new Models.Video();
                newRecord.UpdateFrom(record);
                newRecord.Save();
                TempData["info"] = "Copy of Video " + record.GetName() + " created. You are now editing the new copy.";
                return(RedirectToEdit(newRecord.ID));
            }
            else
            {
                return(RedirectToReturnPage());
            }
        }
Example #10
0
 private void Validate(Models.Video record)
 {
     // add any code to check for validity
     //ModelState.AddModelError("Record", "Suchandsuch cannot be whatever.");
 }