/// <summary>
 /// It Adds Data into the Database
 /// </summary>
 /// <param name="video"></param>
 /// <returns>If Data Added Successfully return true else false or Exception</returns>
 public bool AddVideo(VideoRequest video)
 {
     try
     {
         using (SqlConnection conn = new SqlConnection(sqlConnectionString))
         {
             using (SqlCommand cmd = new SqlCommand("spAddVideo", conn))
             {
                 cmd.CommandType = System.Data.CommandType.StoredProcedure;
                 cmd.Parameters.AddWithValue("@VideoPath", video.VideoPath);
                 cmd.Parameters.AddWithValue("@CreatedDate", DateTime.Now);
                 cmd.Parameters.AddWithValue("@ModifiedDate", DateTime.Now);
                 conn.Open();
                 int count = cmd.ExecuteNonQuery();
                 if (count > 0)
                 {
                     return(true);
                 }
             }
         }
         return(false);
     }
     catch (Exception ex)
     {
         throw new Exception(ex.Message);
     }
 }
Exemple #2
0
        public StatusResponse Update(VideoRequest videoRequest)
        {
            if (videoRequest == null)
            {
                _statusResponse.AddErrorMessage("O objeto não está correto");
                return(_statusResponse);
            }

            var video = MontaVideo(videoRequest);

            if (video.IsFailure)
            {
                _statusResponse.AddErrorsMessages(video.Errors);
                return(_statusResponse);
            }

            if (!_context.Videos.Any(x => x.Id == video.Id))
            {
                _statusResponse.AddErrorMessage("Vídeo não encontrado");
                return(_statusResponse);
            }

            _context.Videos.Update(video);
            _context.SaveChanges();

            return(_statusResponse);
        }
Exemple #3
0
        public async Task <ActionResult <Video> > Add(VideoRequest request)
        {
            try
            {
                var date = this.TimestampToDate(request.Timestamp);

                //Transforma o timestamp em DateTime e verifica se é valido
                if (date != null)
                {
                    //Verifica se a diferença do timestamp de postagem do video é menor que 60 segundos
                    var difference = (DateTime.Now - date).TotalSeconds;
                    if (difference <= 60)
                    {
                        var video = new Video()
                        {
                            Title     = request.Title,
                            Duration  = request.Duration,
                            Timestamp = request.Timestamp
                        };

                        _repository.Videos.Add(video);
                        await _repository.SaveChangesAsync();

                        return(CreatedAtAction(nameof(GetById), new { id = video.Id }, video));
                    }
                    return(NoContent());
                }
                return(NoContent());
            } catch (MissingFieldException ex)
            {
                throw ex;
            }
        }
        public async Task <IActionResult> UploadPoster(IFormFile fileUpload, int idVideo)
        {
            if (fileUpload != null && idVideo != 0)
            {
                var video = await _videoService.FinVideoAsync(idVideo);

                System.IO.File.Delete("wwwroot/Client/imgPoster/" + video.PosterImg);
                var filename = fileUpload.FileName.Split('.');
                var name     = video.Id.ToString() + "." + filename[filename.Length - 1].ToLower();
                video.PosterImg = name;
                using (var fileStream = new FileStream(Path.Combine("wwwroot/Client/imgPoster", name),
                                                       FileMode.Create, FileAccess.Write))
                {
                    fileUpload.CopyTo(fileStream);
                }
                var videoRequest = new VideoRequest();
                videoRequest.PosterVideo = video.PosterImg;
                videoRequest.Description = "";
                videoRequest.Name        = "";
                videoRequest.Id          = idVideo;
                var result = await _videoService.Update(videoRequest);

                if (result != -1)
                {
                    return(Redirect("MyChannel"));
                }
            }

            return(Content("Error"));
        }
Exemple #5
0
        public async Task <IActionResult> AddVideo([FromBody] VideoRequest videoRequest)
        {
            if (!await _genreManager.IsGenresIdValid(videoRequest.GenresId))
            {
                return(BadRequest("Genres is Invalid"));
            }

            if (!await IsUser())
            {
                return(Forbid());
            }

            var video = _mapper.Map <Video>(videoRequest);

            video.LastUpdated = DateTime.Now;
            var author = await _authorManager.GetAuthor(videoRequest.AuthorId);

            if (author == null)
            {
                return(BadRequest("Author is Invalid"));
            }

            video.UserId   = _userManager.GetUserId(HttpContext.User);
            video.AuthorId = author.Id;
            _videoManager.AddVideo(video);
            await _videoManager.SaveChangesAsync();

            var response = _mapper.Map <VideoResponse>(video);

            return(CreatedAtAction(nameof(GetVideoById), new { id = video.Id }, response));
        }
Exemple #6
0
        public VideoRequest ToModel(Customer customer)
        {
            VideoRequest model = new VideoRequest()
            {
                Customer = customer,
                //Email = this.Email,
                //From = this.from,
                Instructions = this.instructions,
                IsNotPublic  = this.is_not_public,
                Price        = this.price,
                To           = this.to,
                TalentID     = this.talent_id,
                TypeID       = this.type_id
            };

            if (type_id == (int)VideoRequestTypeEnum.someone)
            {
                model.From = from;
            }
            else
            {
                model.From = null;
            }

            return(model);
        }
Exemple #7
0
        //public string CreateJobForVideoRequestAnswerDeadline(VideoRequest request, string userID)
        //{
        //    string jobID = BackgroundJob.Schedule(() =>
        //        AnswerDeadlineReaches(request.ID, userID),
        //        new DateTimeOffset(request.RequestAnswerDeadline));

        //    return jobID;
        //}

        //public void AnswerDeadlineReaches(int videoRequestID, string userID)
        //{
        //    //try
        //    //{
        //        VideoRequest request = VideoRequestService.GetActiveSingleDetailsWithRelatedDataByID(videoRequestID);
        //        VideoRequestService.AnswerDeadlineReaches(request, userID);
        //    //}
        //    //catch (Exception ex)
        //    //{ }
        //}

//        public void CreateJobForPaymentReminder(VideoRequest request, string userID)
//        {
//#if DEBUG
//            DateTime reminderDeadline = DateTime.Now.AddMinutes(2);
//#else
//            DateTime reminderDeadline = DateTime.Now.AddDays(1);
//#endif
//            request.PaymentReminderJobID = BackgroundJob.Schedule(() =>
//                PaymentReminderReaches(request.ID, userID),
//                new DateTimeOffset(reminderDeadline));

//            VideoRequestService.Update(request, userID);
//        }

//        public void PaymentReminderReaches(int videoRequestID, string userID)
//        {
//            try
//            {
//                VideoRequest request = VideoRequestService.GetActiveSingleDetailsWithRelatedDataByID(videoRequestID);
//                VideoRequestService.SendEmailOnceVideoConfirmed(request);

//                CreateJobForPaymentReminder(request, userID);
//            }
//            catch (Exception ex)
//            { }
//        }

        public string CreateJobForVideoRequestVideoDeadline(VideoRequest request, string userID)
        {
            string jobID = BackgroundJob.Schedule(() =>
                                                  VideoDeadlineReaches(request.ID, userID),
                                                  new DateTimeOffset(request.VideoDeadline.Value));

            return(jobID);
        }
Exemple #8
0
        public async Task <VideoRequest> CreateRequestAsync(VideoRequest request)
        {
            request.CreateDate = request.ModifyDate = DateTime.UtcNow;

            await _dbContext.AddAsync(request);

            await _dbContext.SaveChangesWithTimesAsync();

            return(request);
        }
Exemple #9
0
 public static YoutubeDLRequest From(VideoRequest request)
 {
     return(new YoutubeDLRequest
     {
         AudioOnly = request.AudioOnly,
         Type = request.Type,
         OutputLocation = request.OutputLocation,
         ContentID = request.ContentID
     });
 }
Exemple #10
0
        public VideoRequestDetailsForCustomerVM(VideoRequest model)
            : base(model)
        {
            if (model == null)
            {
                return;
            }

            //is_credit_card_info_visible = true;
        }
        public async Task <IActionResult> Create([FromForm] VideoRequest request, List <IFormFile> file)
        {
            var result = await _videoService.Create(request, file);

            if (result != null)
            {
                return(Ok(result));
            }
            return(BadRequest("Create No Success"));
        }
        public async Task <IActionResult> Update([FromBody] VideoRequest request)
        {
            var result = await _videoService.Update(request);

            if (result > 0)
            {
                return(Ok());
            }
            return(BadRequest("Update No Success"));
        }
        public async Task <ActionResult <VideoResponse> > Create(VideoRequest model)
        {
            var response = await _service.CreateVideoResponse(User, model);

            if (!response.Success)
            {
                return(Conflict(response.Message));
            }

            return(CreatedAtAction("GetById", new { id = response.Data.Id }, response.Data));
        }
Exemple #14
0
        public VideoRequestListItemForTalentVM(VideoRequest model)
            : base(model)
        {
            if (model == null)
            {
                return;
            }

            person = new CustomerShortInfoVM(model.Customer);
            viewed = model.ViewedByTalent;
        }
Exemple #15
0
        public VideoRequestListItemForCustomerVM(VideoRequest model)
            : base(model)
        {
            if (model == null)
            {
                return;
            }

            person = new TalentShortInfoVM(model.Talent);
            viewed = model.ViewedByCustomer;
        }
Exemple #16
0
        public VideoRequestDetailsForTalentVM(VideoRequest model)
            : base(model)
        {
            if (model == null)
            {
                return;
            }

            //video = new AttachmentDetailsVM(model.Video);
            video = AttachmentDetailsVM.ToVM(model.Video);
        }
Exemple #17
0
        public VideoRequestListItemVM(VideoRequest model /*, string curUserType*/)
        {
            if (model == null)
            {
                return;
            }

            id = model.ID;
            //customer = new CustomerShortInfoVM(model.Customer);
            //talent = new TalentShortInfoVM(model.Talent);

            //if (curUserType == UserTypesEnum.customer.ToString())
            //    person = talent;
            //else
            //    person = customer;

            string dateTextViewStringFormat = AppData.Configuration.DateTextViewStringFormat;

            if (model.PaymentConfirmationDeadline.HasValue)
            {
                deadline = model.PaymentConfirmationDeadline.Value.ToString(dateTextViewStringFormat);
            }
            else if (model.VideoDeadline.HasValue)
            {
                deadline = model.VideoDeadline.Value.ToString(dateTextViewStringFormat);
            }
            else
            {
                deadline = model.RequestAnswerDeadline.ToString(dateTextViewStringFormat);
            }

            //DateTime now = DateTime.Now;
            //DateTime deadlineTmp = DateTime.MinValue;
            //if (model.RequestAnswerDeadline >= now)
            //{
            //    deadlineTmp = model.RequestAnswerDeadline;
            //    deadline_text = "Ожидает ответа (до " + deadlineTmp.ToShortDateString() + " " + deadlineTmp.ToShortTimeString() + ")";
            //}
            //else
            //    deadline_text = "Завершено";

            //if (model.VideoDeadline.HasValue && model.VideoDeadline.Value >= now)
            //{
            //    deadlineTmp = model.VideoDeadline.Value;
            //    deadline_text = "Ожидает видео";
            //}
            //else
            //    deadline_text = "Завершено";

            //if (deadlineTmp != DateTime.MinValue)
            //    deadline = deadlineTmp.ToShortDateString() + " " + deadlineTmp.ToShortTimeString();

            status = new BaseDropdownableDetailsVM(model.RequestStatus);
        }
Exemple #18
0
        protected void btnReject_Click(object sender, EventArgs e)
        {
            if (!string.IsNullOrEmpty(hfVideoRequestID.Value))
            {
                vidreq = new VideoRequest(Convert.ToInt32(hfVideoRequestID.Value));
                vidreq.StatusType = 'R';
                vidreq.Update();
                lblStatus.Text = "Video rejected";

                LoadGrid();
            }
        }
 private Video CreateVideo(string userId, VideoRequest model, VideoCategory videoCategory)
 {
     return(new Video
     {
         Id = Guid.NewGuid().ToString(),
         UserId = userId,
         Name = model.Name,
         Description = model.Description,
         VideoCategoryId = videoCategory.Id,
         UrlAddress = model.VideoPath
     });
 }
Exemple #20
0
        public ActionResult <VideoRequestDetailsForCustomerVM> Details(int id)
        {
            try
            {
                var          curUser = accountUtil.GetCurrentUser(User);
                VideoRequest request = VideoRequestService.GetActiveSingleDetailsWithRelatedDataByID(id);

                if (request == null || !VideoRequestService.BelongsToCustomer(request, curUser.ID))
                {
                    throw new Exception("Ваш заказ не найден");
                }

                if (request.ViewedByCustomer == false)
                {
                    request.ViewedByCustomer = true;
                    VideoRequestService.Update(request, curUser.ID);
                }

                var requestVM = new VideoRequestDetailsForCustomerVM(request);
                requestVM.edit_btn_is_available   = VideoRequestService.IsEditable(request);
                requestVM.cancel_btn_is_available = VideoRequestService.IsCancelable(request);

                //requestVM.request_price = VideoRequestPriceCalculationsService.CalculateRequestPrice(request);
                //requestVM.RequestPriceToStr();

                //requestVM.remaining_price = VideoRequestPriceCalculationsService.CalculateRemainingPrice(request.Price, request.WebsiteCommission);
                //requestVM.RemainingPriceToStr();

                requestVM.video_is_confirmed = VideoRequestService.IsVideoConfirmed(request);
                //requestVM.payment_screenshot_is_uploaded = VideoRequestService.IsPaymentScreenshotUploaded(request);

                //requestVM.payment_is_confirmed = VideoRequestService.IsPaymentConfirmed(request);
                if (requestVM.video_is_confirmed)
                {
                    //requestVM.video = new AttachmentDetailsVM(request.Video);
                    requestVM.video = AttachmentDetailsVM.ToVM(request.Video);
                }

                if (requestVM.edit_btn_is_available)
                {
                    requestVM.video_request_edit_vm = new VideoRequestEditVM(request);
                    requestVM.video_request_edit_vm.video_request_types = VideoRequestTypeService.GetAsSelectList();
                }

                //VideoRequestEditVM editModelVM = new VideoRequestEditVM(request);

                return(requestVM);
            }
            catch (Exception ex)
            {
                return(CustomBadRequest(ex));
            }
        }
Exemple #21
0
        public IActionResult Edit(int id, [FromBody] VideoRequestEditVM modelVM)
        {
            try
            {
                var curUser = accountUtil.GetCurrentUser(User);

                VideoRequest request = VideoRequestService.GetActiveSingleDetailsWithRelatedDataByID(id);
                if (request == null || !VideoRequestService.BelongsToCustomer(request, curUser.ID))
                {
                    //return NotFound();
                    throw new Exception("Заказ не найден");
                }

                if (!VideoRequestService.IsEditable(request))
                {
                    throw new Exception("Данный запрос нельзя редактировать");
                }

                if (ModelState.IsValid)
                {
                    if (ValidateFromProperty(modelVM.from, modelVM.type_id))
                    {
                        try
                        {
                            modelVM.UpdateModel(request);

                            VideoRequestService.Edit(request, curUser.ID);

                            return(Ok());
                        }
                        catch (Exception ex)
                        {
                            //ModelState.AddModelError("", ex.Message);
                            return(CustomBadRequest(ex));
                        }
                    }
                    else
                    {
                        //ModelState.AddModelError("From", "Укажите от кого");
                        throw new Exception("Укажите от кого");
                    }
                }
                else
                {
                    //ModelState.AddModelError("", "Указаны некорректные данные");
                    throw new Exception("Указаны некорректные данные");
                }
            }
            catch (Exception ex)
            {
                return(CustomBadRequest(ex));
            }
        }
Exemple #22
0
 public void VideoDeadlineReaches(int videoRequestID, string userID)
 {
     try
     {
         VideoRequest request = VideoRequestService.GetActiveSingleDetailsWithRelatedDataByID(videoRequestID);
         VideoRequestService.VideoDeadlineReaches(request, userID);
     }
     catch (Exception ex)
     {
         string origin = "Video deadline reached exception";
         TelegramBotService.SendMessage(ex.Message, origin);
     }
 }
Exemple #23
0
 private static bool SelectCache(VideoRequest request, out RequestLatency <DataCache> cacheRequest)
 {
     cacheRequest =
         request.EndPoint.CacheLatency.Where(
             c => c.Publisher.AcceptVideo(request.Video) && !c.Publisher.Videos.Contains(request.Video))
         .OrderBy(r => r.Time).FirstOrDefault();
     //cacheRequest = cacheRequests.OrderBy(c => c.Publisher.Usage).FirstOrDefault();
     if (cacheRequest == null)
     {
         return(false);
     }
     return(true);
 }
 public static RequestListItemViewModel From(VideoRequest request)
 {
     return(new RequestListItemViewModel
     {
         Id = request.Id,
         ContentId = request.ContentID,
         CreateDate = request.CreateDate,
         ModifyDate = request.ModifyDate,
         OutputLocation = request.OutputLocation,
         Status = request.Status,
         Type = request.Type
     });
 }
        public async Task UpdateRequestStatusAsync(VideoRequest req)
        {
            using (var client = new HttpClient())
            {
                var json = JsonSerializer.Serialize(req);
                var stringContent = new StringContent(json, Encoding.UTF8, "application/json");

                var response = await client.PostAsync(_apiUrl + "updatestatus", stringContent);

                response.EnsureSuccessStatusCode();
            }

        }
Exemple #26
0
        public VideoDetailsVM(VideoRequest model)
        {
            if (model == null)
            {
                return;
            }

            request_id = model.ID;
            //video = new AttachmentDetailsVM(model.Video);
            video  = AttachmentDetailsVM.ToVM(model.Video);
            to     = model.To;
            from   = model.From;
            talent = new TalentShortInfoForVideoPageVM(model.Talent);
        }
Exemple #27
0
        private Video MontaVideo(VideoRequest videoRequest)
        {
            var video = new Video(videoRequest.Id, videoRequest?.Titulo, videoRequest?.UrlDoVideo);

            if (video.IsFailure)
            {
                return(video);
            }

            video.SetDescricao(videoRequest?.Descricao);
            video.SetUrlDaImagem(videoRequest?.UrlDaImagem);

            return(video);
        }
Exemple #28
0
        public async Task <Video> Create(VideoRequest videoRequest, List <IFormFile> listPost)
        {
            var video = new Video();

            if (videoRequest != null)
            {
                video.Name        = videoRequest.Name;
                video.Description = videoRequest.Description;
                video.AppUserId   = videoRequest.AppUserId;
                video.CreateDate  = new GetDateNow().DateNow;
                video.HidenVideo  = videoRequest.HidenVideo;
                video.CategorysId = videoRequest.CategorysId;
                _context.Video.Add(video);
                _context.SaveChanges();
                var findVideo = _context.Video.OrderByDescending(x => x.Id).FirstOrDefault(x => x.Name.Contains(videoRequest.Name));
                if (listPost.Count > 0)
                {
                    var paths = "";
                    foreach (var item in listPost)
                    {
                        var filename = item.FileName.Split('.');
                        var name     = filename[filename.Length - 1].ToLower();
                        if (name.Contains("mp4"))
                        {
                            name  = findVideo.Id.ToString() + "." + filename[filename.Length - 1].ToLower();
                            paths = "wwwroot/Client/video";
                            findVideo.LinkVideo = name;
                        }
                        else
                        {
                            name = findVideo.Id.ToString() + "." + filename[filename.Length - 1].ToLower();
                            findVideo.PosterImg = name;
                            paths = "wwwroot/Client/imgPoster";
                        }
                        using (var fileStream = new FileStream(Path.Combine(paths, name),
                                                               FileMode.Create, FileAccess.Write))
                        {
                            item.CopyTo(fileStream);
                        }
                    }
                    _context.Update(findVideo);
                    await _context.SaveChangesAsync();

                    return(findVideo);
                }
            }
            return(null);
        }
Exemple #29
0
        public VideoRequestEditVM(VideoRequest model)
        {
            if (model == null)
            {
                return;
            }

            type_id      = model.TypeID;
            to           = model.To;
            from         = model.From;
            instructions = model.Instructions;
            //Email = model.Email;
            is_not_public = model.IsNotPublic;
            price         = model.Price;
            talent_id     = model.TalentID;
        }
Exemple #30
0
        public async Task <int> Update(VideoRequest videoRequest)
        {
            var video = await FinVideoAsync(videoRequest.Id);

            if (video != null)
            {
                videoRequest.Name        = videoRequest.Name == "" ? video.Name : videoRequest.Name;
                videoRequest.Description = videoRequest.Description == "" ? video.Description : videoRequest.Description;
                videoRequest.PosterVideo = videoRequest.PosterVideo == "" ? video.PosterImg : videoRequest.PosterVideo;
                video.Name        = videoRequest.Name;
                video.HidenVideo  = videoRequest.HidenVideo;
                video.Description = videoRequest.Description;
                return(await _context.SaveChangesAsync());
            }
            return(-1);
        }
Exemple #31
0
        public void UpdateModel(VideoRequest model)
        {
            model.TypeID = type_id;
            model.To     = to;

            if (type_id == (int)VideoRequestTypeEnum.someone)
            {
                model.From = from;
            }
            else
            {
                model.From = null;
            }
            model.Instructions = instructions;
            //model.Email = Email;
            model.IsNotPublic = is_not_public;
        }
Exemple #32
0
        protected void btnSubmit_Click(object sender, EventArgs e)
        {
            try
            {
                var allartsis = new Artists();
                allartsis.RemoveCache();

                if (gvwRequestedVideos.SelectedDataKey != null)
                {
                    vidreq = new VideoRequest(Convert.ToInt32(gvwRequestedVideos.SelectedDataKey.Value))
                    {
                        StatusType = 'A'
                    };
                    vidreq.Update();
                }

                vid = new Video("YT", txtVideoKey.Text)
                {
                    Duration = (float) Convert.ToDouble(txtDuration.Text),
                    Intro = (float) Convert.ToDouble(txtSecondsIn.Text),
                    LengthFromStart = (float) Convert.ToDouble(txtElasedEnd.Text),
                    ProviderCode = ddlVideoProvider.SelectedValue,
                    ProviderUserKey = txtUserName.Text,
                    VolumeLevel = Convert.ToInt32(ddlVolumeLevel.SelectedValue),
                    IsEnabled = chkEnabled.Checked,
                    EnableTrim = chkEnabled.Checked
                };

                // vid.IsHidden = chkHidden.Checked;

                /// publish date
                var yousettings = new YouTubeRequestSettings("Das Klub", devkey);
                var yourequest = new YouTubeRequest(yousettings);
                var Url = new Uri("http://gdata.youtube.com/feeds/api/videos/" + vid.ProviderKey);
                var video = new Google.YouTube.Video();
                video = yourequest.Retrieve<Google.YouTube.Video>(Url);
                vid.PublishDate = video.YouTubeEntry.Published;

                if (vid.VideoID == 0)
                {
                    vid.Create();
                }
                else
                    vid.Update();

                // if there is a contest, add it now since there is an id
                if (ddlContest.SelectedValue != unknownValue)
                {
                    //TODO: check if it already is in the contest

                    ContestVideo.DeleteVideoFromAllContests(vid.VideoID);

                    var cv = new ContestVideo();

                    cv.ContestID = Convert.ToInt32(ddlContest.SelectedValue);
                    cv.VideoID = vid.VideoID;
                    cv.Create();
                }
                else
                {
                    // TODO: JUST REMOVE FROM CURRENT CONTEST, NOT ALL
                    ContestVideo.DeleteVideoFromAllContests(vid.VideoID);
                }

                // vid type
                if (!string.IsNullOrWhiteSpace(ddlVideoType.SelectedValue)
                    && ddlVideoType.SelectedValue != selectText)
                {
                    propTyp = new PropertyType(SiteEnums.PropertyTypeCode.VIDTP);
                    mp = new MultiProperty(vid.VideoID, propTyp.PropertyTypeID, SiteEnums.MultiPropertyType.VIDEO);
                    MultiPropertyVideo.DeleteMultiPropertyVideo(mp.MultiPropertyID, vid.VideoID);
                    mp.RemoveCache();
                    MultiPropertyVideo.AddMultiPropertyVideo(
                        Convert.ToInt32(
                            ddlVideoType.SelectedValue), vid.VideoID);
                }

                // human
                if (!string.IsNullOrWhiteSpace(ddlHumanType.SelectedValue)
                    && ddlHumanType.SelectedValue != selectText)
                {
                    propTyp = new PropertyType(SiteEnums.PropertyTypeCode.HUMAN);
                    mp = new MultiProperty(vid.VideoID, propTyp.PropertyTypeID, SiteEnums.MultiPropertyType.VIDEO);
                    MultiPropertyVideo.DeleteMultiPropertyVideo(mp.MultiPropertyID, vid.VideoID);
                    mp.RemoveCache();
                    MultiPropertyVideo.AddMultiPropertyVideo(
                        Convert.ToInt32(
                            ddlHumanType.SelectedValue), vid.VideoID);
                }

                // footage
                if (!string.IsNullOrWhiteSpace(ddlFootageType.SelectedValue)
                    && ddlFootageType.SelectedValue != selectText)
                {
                    propTyp = new PropertyType(SiteEnums.PropertyTypeCode.FOOTG);
                    mp = new MultiProperty(vid.VideoID, propTyp.PropertyTypeID, SiteEnums.MultiPropertyType.VIDEO);
                    MultiPropertyVideo.DeleteMultiPropertyVideo(mp.MultiPropertyID, vid.VideoID);
                    mp.RemoveCache();
                    MultiPropertyVideo.AddMultiPropertyVideo(
                        Convert.ToInt32(
                            ddlFootageType.SelectedValue), vid.VideoID);
                }

                VideoSong.DeleteSongsForVideo(vid.VideoID);

                // song 1

                artst = string.IsNullOrEmpty(txtArtist1.Text.Trim())
                    ? new Artist(ddlArtist1.SelectedValue)
                    : new Artist(txtArtist1.Text);

                if (artst.ArtistID == 0)
                {
                    artst.AltName = FromString.UrlKey(artst.Name);
                    artst.Create();
                }

                if (string.IsNullOrEmpty(txtArtistSong1.Text))
                {
                    sng = new Song(artst.ArtistID, ddlArtistSongs1.SelectedValue);
                }
                else
                {
                    sng = new Song(artst.ArtistID, txtArtistSong1.Text);
                }

                if (sng.SongID == 0)
                {
                    sng.SongKey = FromString.UrlKey(sng.Name);
                    sng.Create();
                }

                VideoSong.AddVideoSong(sng.SongID, vid.VideoID, 1);

                // song 2

                if ((ddlArtist2.SelectedValue != unknownValue && !string.IsNullOrEmpty(ddlArtist2.SelectedValue)) ||
                    !string.IsNullOrEmpty(txtArtist2.Text))
                {
                    artst = null;
                    sng = null;

                    if (string.IsNullOrEmpty(txtArtist2.Text.Trim()))
                    {
                        artst = new Artist(ddlArtist2.SelectedValue);
                    }
                    else
                    {
                        artst = new Artist(txtArtist2.Text);
                    }

                    if (artst.ArtistID == 0)
                    {
                        artst.AltName = FromString.UrlKey(artst.Name);
                        artst.Create();
                    }

                    if (string.IsNullOrEmpty(txtArtistSong2.Text))
                    {
                        sng = new Song(artst.ArtistID, ddlArtistSongs2.SelectedValue);
                    }
                    else
                    {
                        sng = new Song(artst.ArtistID, txtArtistSong2.Text);
                    }

                    if (sng.SongID == 0)
                    {
                        sng.SongKey = FromString.UrlKey(sng.Name);
                        sng.Create();
                    }

                    VideoSong.AddVideoSong(sng.SongID, vid.VideoID, 2);

                    if ((ddlArtist3.SelectedValue != unknownValue && !string.IsNullOrEmpty(ddlArtist3.SelectedValue)) ||
                        !string.IsNullOrEmpty(txtArtist3.Text))
                    {
                        // song 3

                        artst = null;
                        sng = null;

                        if (string.IsNullOrEmpty(txtArtist3.Text))
                        {
                            artst = new Artist(ddlArtist3.SelectedValue);
                        }
                        else
                        {
                            artst = new Artist(txtArtist3.Text);
                        }

                        if (artst.ArtistID == 0)
                        {
                            artst.AltName = FromString.UrlKey(artst.Name);
                            artst.Create();
                        }

                        if (string.IsNullOrEmpty(txtArtistSong3.Text))
                        {
                            sng = new Song(artst.ArtistID, ddlArtistSongs3.SelectedValue);
                        }
                        else
                        {
                            sng = new Song(artst.ArtistID, txtArtistSong3.Text);
                        }

                        if (sng.SongID == 0)
                        {
                            sng.SongKey = FromString.UrlKey(sng.Name);
                            sng.Create();
                        }

                        VideoSong.AddVideoSong(sng.SongID, vid.VideoID, 3);

                        if ((ddlArtist4.SelectedValue != unknownValue && !string.IsNullOrEmpty(ddlArtist4.SelectedValue)) ||
                            !string.IsNullOrEmpty(txtArtist4.Text))
                        {
                            // song 4

                            artst = null;
                            sng = null;

                            if (string.IsNullOrEmpty(txtArtist4.Text))
                            {
                                artst = new Artist(ddlArtist4.SelectedValue);
                            }
                            else
                            {
                                artst = new Artist(txtArtist4.Text);
                            }

                            if (artst.ArtistID == 0)
                            {
                                artst.AltName = FromString.UrlKey(artst.Name);
                                artst.Create();
                            }

                            if (string.IsNullOrEmpty(txtArtistSong4.Text))
                            {
                                sng = new Song(artst.ArtistID, ddlArtistSongs4.SelectedValue);
                            }
                            else
                            {
                                sng = new Song(artst.ArtistID, txtArtistSong4.Text);
                            }

                            if (sng.SongID == 0)
                            {
                                sng.SongKey = FromString.UrlKey(sng.Name);
                                sng.Create();
                            }

                            VideoSong.AddVideoSong(sng.SongID, vid.VideoID, 4);

                            if ((ddlArtist5.SelectedValue != unknownValue &&
                                 !string.IsNullOrEmpty(ddlArtist5.SelectedValue)) ||
                                !string.IsNullOrEmpty(txtArtist5.Text))
                            {
                                // song 5

                                artst = null;
                                sng = null;

                                if (string.IsNullOrEmpty(txtArtist5.Text))
                                {
                                    artst = new Artist(ddlArtist5.SelectedValue);
                                }
                                else
                                {
                                    artst = new Artist(txtArtist5.Text);
                                }

                                if (artst.ArtistID == 0)
                                {
                                    artst.AltName = FromString.UrlKey(artst.Name);
                                    artst.Create();
                                }

                                if (string.IsNullOrEmpty(txtArtistSong5.Text))
                                {
                                    sng = new Song(artst.ArtistID, ddlArtistSongs5.SelectedValue);
                                }
                                else
                                {
                                    sng = new Song(artst.ArtistID, txtArtistSong5.Text);
                                }

                                if (sng.SongID == 0)
                                {
                                    sng.SongKey = FromString.UrlKey(sng.Name);
                                    sng.Create();
                                }

                                VideoSong.AddVideoSong(sng.SongID, vid.VideoID, 5);

                                if ((ddlArtist6.SelectedValue != unknownValue &&
                                     !string.IsNullOrEmpty(ddlArtist6.SelectedValue)) ||
                                    !string.IsNullOrEmpty(txtArtist6.Text))
                                {
                                    // song 6

                                    artst = null;
                                    sng = null;

                                    if (string.IsNullOrEmpty(txtArtist6.Text))
                                    {
                                        artst = new Artist(ddlArtist6.SelectedValue);
                                    }
                                    else
                                    {
                                        artst = new Artist(txtArtist6.Text);
                                    }

                                    if (artst.ArtistID == 0)
                                    {
                                        artst.AltName = FromString.UrlKey(artst.Name);
                                        artst.Create();
                                    }

                                    if (string.IsNullOrEmpty(txtArtistSong6.Text))
                                    {
                                        sng = new Song(artst.ArtistID, ddlArtistSongs6.SelectedValue);
                                    }
                                    else
                                    {
                                        sng = new Song(artst.ArtistID, txtArtistSong6.Text);
                                    }

                                    if (sng.SongID == 0)
                                    {
                                        sng.SongKey = FromString.UrlKey(sng.Name);
                                        sng.Create();
                                    }

                                    VideoSong.AddVideoSong(sng.SongID, vid.VideoID, 6);
                                }
                            }
                        }
                    }
                }

                //  RefreshLists();

                lblStatus.Text = "OK";
            }
            catch (Exception ex)
            {
                lblStatus.Text = ex.Message;
            }

            LoadGrid();
        }
Exemple #33
0
        protected void btnSubmit_Click(object sender, EventArgs e)
        {
            try
            {

                //IDictionaryEnumerator enumerator = HttpContext.Current.Cache.GetEnumerator();

                //while (enumerator.MoveNext())
                //{

                //    HttpContext.Current.Cache.Remove(enumerator.Key.ToString());

                //}

                Artists allartsis = new Artists();
                allartsis.RemoveCache();

                if (gvwRequestedVideos.SelectedDataKey != null)
                {
                    vidreq = new VideoRequest(Convert.ToInt32(gvwRequestedVideos.SelectedDataKey.Value));
                    vidreq.StatusType = 'A';
                    vidreq.Update();
                }

                vid = new BootBaronLib.AppSpec.DasKlub.BOL.Video("YT", txtVideoKey.Text);

                vid.Duration = (float)Convert.ToDouble(txtDuration.Text);
                vid.Intro = (float)Convert.ToDouble(txtSecondsIn.Text);
                vid.LengthFromStart = (float)Convert.ToDouble(txtElasedEnd.Text);
                vid.ProviderCode = ddlVideoProvider.SelectedValue;
                vid.ProviderUserKey = txtUserName.Text;
                vid.VolumeLevel = Convert.ToInt32(ddlVolumeLevel.SelectedValue);
                vid.IsEnabled = chkEnabled.Checked;
                // vid.IsHidden = chkHidden.Checked;
                vid.EnableTrim = chkEnabled.Checked;

                /// publish date
                YouTubeRequestSettings yousettings =
                    new YouTubeRequestSettings("You Manager", devkey, username, password);
                YouTubeRequest yourequest;
                Uri Url;
                Google.YouTube.Video video;

                yourequest = new YouTubeRequest(yousettings);
                Url = new Uri("http://gdata.youtube.com/feeds/api/videos/" + vid.ProviderKey);
                video = new Google.YouTube.Video();
                video = yourequest.Retrieve<Google.YouTube.Video>(Url);
                vid.PublishDate = video.YouTubeEntry.Published;

                if (vid.VideoID == 0)
                {
                    vid.Create();
                }
                else
                    vid.Update();

                // if there is a contest, add it now since there is an id
                if (ddlContest.SelectedValue != unknownValue)
                {
                    //TODO: check if it already is in the contest

                    ContestVideo.DeleteVideoFromAllContests(vid.VideoID);

                    ContestVideo cv = new ContestVideo();

                    cv.ContestID = Convert.ToInt32(ddlContest.SelectedValue);
                    cv.VideoID = vid.VideoID;
                    cv.Create();
                }
                else
                {
                    // TODO: JUST REMOVE FROM CURRENT CONTEST, NOT ALL
                    ContestVideo.DeleteVideoFromAllContests(vid.VideoID);
                }

                // vid type
                if (!string.IsNullOrWhiteSpace(this.ddlVideoType.SelectedValue)
                    && this.ddlVideoType.SelectedValue != selectText)
                {
                    propTyp = new PropertyType(SiteEnums.PropertyTypeCode.VIDTP);
                    mp = new MultiProperty(vid.VideoID, propTyp.PropertyTypeID, SiteEnums.MultiPropertyType.VIDEO);
                    MultiPropertyVideo.DeleteMultiPropertyVideo(mp.MultiPropertyID, vid.VideoID);
                    mp.RemoveCache();
                    MultiPropertyVideo.AddMultiPropertyVideo(
                        Convert.ToInt32(
                        ddlVideoType.SelectedValue), vid.VideoID);
                }

                // human
                if (!string.IsNullOrWhiteSpace(this.ddlHumanType.SelectedValue)
                    && this.ddlHumanType.SelectedValue != selectText)
                {
                    propTyp = new PropertyType(SiteEnums.PropertyTypeCode.HUMAN);
                    mp = new MultiProperty(vid.VideoID, propTyp.PropertyTypeID, SiteEnums.MultiPropertyType.VIDEO);
                    MultiPropertyVideo.DeleteMultiPropertyVideo(mp.MultiPropertyID, vid.VideoID);
                    mp.RemoveCache();
                    MultiPropertyVideo.AddMultiPropertyVideo(
                        Convert.ToInt32(
                        ddlHumanType.SelectedValue), vid.VideoID);
                }

                // footage
                if (!string.IsNullOrWhiteSpace(this.ddlFootageType.SelectedValue)
                    && this.ddlFootageType.SelectedValue != selectText)
                {
                    propTyp = new PropertyType(SiteEnums.PropertyTypeCode.FOOTG);
                    mp = new MultiProperty(vid.VideoID, propTyp.PropertyTypeID, SiteEnums.MultiPropertyType.VIDEO);
                    MultiPropertyVideo.DeleteMultiPropertyVideo(mp.MultiPropertyID, vid.VideoID);
                    mp.RemoveCache();
                    MultiPropertyVideo.AddMultiPropertyVideo(
                        Convert.ToInt32(
                        ddlFootageType.SelectedValue), vid.VideoID);
                }

                //// guitar
                //if (!string.IsNullOrWhiteSpace(this.ddlGuitarType.SelectedValue)
                //    && this.ddlGuitarType.SelectedValue != selectText)
                //{
                //    propTyp = new PropertyType(SiteEnums.PropertyTypeCode.GUITR);
                //    mp = new MultiProperty(vid.VideoID, propTyp.PropertyTypeID, SiteEnums.MultiPropertyType.VIDEO);
                //    MultiPropertyVideo.DeleteMultiPropertyVideo(mp.MultiPropertyID, vid.VideoID);
                //    mp.RemoveCache();
                //    MultiPropertyVideo.AddMultiPropertyVideo(
                //        Convert.ToInt32(ddlGuitarType.SelectedValue), vid.VideoID);
                //}

                //// Language
                //if (!string.IsNullOrWhiteSpace(this.ddlLanguage.SelectedValue)
                //    && this.ddlLanguage.SelectedValue != selectText)
                //{
                //    propTyp = new PropertyType(SiteEnums.PropertyTypeCode.LANGE);
                //    mp = new MultiProperty(vid.VideoID, propTyp.PropertyTypeID, SiteEnums.MultiPropertyType.VIDEO);
                //    MultiPropertyVideo.DeleteMultiPropertyVideo(mp.MultiPropertyID, vid.VideoID);
                //    mp.RemoveCache();
                //    MultiPropertyVideo.AddMultiPropertyVideo(
                //        Convert.ToInt32(ddlLanguage.SelectedValue), vid.VideoID);
                //}

                //// genre
                //if (!string.IsNullOrWhiteSpace(this.ddlGenre.SelectedValue)
                //    && this.ddlGenre.SelectedValue != selectText)
                //{
                //    propTyp = new PropertyType(SiteEnums.PropertyTypeCode.GENRE);
                //    mp = new MultiProperty(vid.VideoID, propTyp.PropertyTypeID, SiteEnums.MultiPropertyType.VIDEO);
                //    MultiPropertyVideo.DeleteMultiPropertyVideo(mp.MultiPropertyID, vid.VideoID);
                //    mp.RemoveCache();
                //    MultiPropertyVideo.AddMultiPropertyVideo(
                //        Convert.ToInt32(ddlGenre.SelectedValue), vid.VideoID);
                //}

                //// difficulty
                //if (!string.IsNullOrWhiteSpace(this.ddlDifficultyLevel.SelectedValue)
                //    && this.ddlDifficultyLevel.SelectedValue != selectText)
                //{
                //    propTyp = new PropertyType(SiteEnums.PropertyTypeCode.DIFFC);
                //    mp = new MultiProperty(vid.VideoID, propTyp.PropertyTypeID, SiteEnums.MultiPropertyType.VIDEO);
                //    MultiPropertyVideo.DeleteMultiPropertyVideo(mp.MultiPropertyID, vid.VideoID);
                //    mp.RemoveCache();
                //    MultiPropertyVideo.AddMultiPropertyVideo(
                //        Convert.ToInt32(this.ddlDifficultyLevel.SelectedValue), vid.VideoID);
                //}

                VideoSong.DeleteSongsForVideo(vid.VideoID);

                // song 1

                if (string.IsNullOrEmpty(txtArtist1.Text.Trim()))
                {
                    artst = new Artist(ddlArtist1.SelectedValue);
                }
                else
                {
                    artst = new Artist(txtArtist1.Text);
                }

                if (artst.ArtistID == 0)
                {
                    artst.AltName = FromString.URLKey(artst.Name);
                    artst.Create();
                }

                if (string.IsNullOrEmpty(txtArtistSong1.Text))
                {
                    sng = new Song(artst.ArtistID, ddlArtistSongs1.SelectedValue);
                }
                else
                {
                    sng = new Song(artst.ArtistID, txtArtistSong1.Text);
                }

                if (sng.SongID == 0)
                {
                    sng.SongKey = FromString.URLKey(sng.Name);
                    sng.Create();
                }

                VideoSong.AddVideoSong(sng.SongID, vid.VideoID, 1);

                // song 2

                if ((ddlArtist2.SelectedValue != unknownValue && !string.IsNullOrEmpty(ddlArtist2.SelectedValue)) ||
                    !string.IsNullOrEmpty(txtArtist2.Text))
                {
                    artst = null;
                    sng = null;

                    if (string.IsNullOrEmpty(txtArtist2.Text.Trim()))
                    {
                        artst = new Artist(ddlArtist2.SelectedValue);
                    }
                    else
                    {
                        artst = new Artist(txtArtist2.Text);
                    }

                    if (artst.ArtistID == 0)
                    {
                        artst.AltName = FromString.URLKey(artst.Name);
                        artst.Create();
                    }

                    if (string.IsNullOrEmpty(txtArtistSong2.Text))
                    {
                        sng = new Song(artst.ArtistID, ddlArtistSongs2.SelectedValue);
                    }
                    else
                    {
                        sng = new Song(artst.ArtistID, txtArtistSong2.Text);
                    }

                    if (sng.SongID == 0)
                    {
                        sng.SongKey = FromString.URLKey(sng.Name);
                        sng.Create();
                    }

                    VideoSong.AddVideoSong(sng.SongID, vid.VideoID, 2);

                    if ((ddlArtist3.SelectedValue != unknownValue && !string.IsNullOrEmpty(ddlArtist3.SelectedValue)) ||
                        !string.IsNullOrEmpty(txtArtist3.Text))
                    {

                        // song 3

                        artst = null;
                        sng = null;

                        if (string.IsNullOrEmpty(txtArtist3.Text))
                        {
                            artst = new Artist(ddlArtist3.SelectedValue);
                        }
                        else
                        {
                            artst = new Artist(txtArtist3.Text);
                        }

                        if (artst.ArtistID == 0)
                        {
                            artst.AltName = FromString.URLKey(artst.Name);
                            artst.Create();
                        }

                        if (string.IsNullOrEmpty(txtArtistSong3.Text))
                        {
                            sng = new Song(artst.ArtistID, ddlArtistSongs3.SelectedValue);
                        }
                        else
                        {
                            sng = new Song(artst.ArtistID, txtArtistSong3.Text);
                        }

                        if (sng.SongID == 0)
                        {
                            sng.SongKey = FromString.URLKey(sng.Name);
                            sng.Create();
                        }

                        VideoSong.AddVideoSong(sng.SongID, vid.VideoID, 3);

                        if ((ddlArtist4.SelectedValue != unknownValue && !string.IsNullOrEmpty(ddlArtist4.SelectedValue)) ||
                            !string.IsNullOrEmpty(txtArtist4.Text))
                        {

                            // song 4

                            artst = null;
                            sng = null;

                            if (string.IsNullOrEmpty(txtArtist4.Text))
                            {
                                artst = new Artist(ddlArtist4.SelectedValue);
                            }
                            else
                            {
                                artst = new Artist(txtArtist4.Text);
                            }

                            if (artst.ArtistID == 0)
                            {
                                artst.AltName = FromString.URLKey(artst.Name);
                                artst.Create();
                            }

                            if (string.IsNullOrEmpty(txtArtistSong4.Text))
                            {
                                sng = new Song(artst.ArtistID, ddlArtistSongs4.SelectedValue);
                            }
                            else
                            {
                                sng = new Song(artst.ArtistID, txtArtistSong4.Text);
                            }

                            if (sng.SongID == 0)
                            {
                                sng.SongKey = FromString.URLKey(sng.Name);
                                sng.Create();
                            }

                            VideoSong.AddVideoSong(sng.SongID, vid.VideoID, 4);

                            if ((ddlArtist5.SelectedValue != unknownValue && !string.IsNullOrEmpty(ddlArtist5.SelectedValue)) ||
                                !string.IsNullOrEmpty(txtArtist5.Text))
                            {

                                // song 5

                                artst = null;
                                sng = null;

                                if (string.IsNullOrEmpty(txtArtist5.Text))
                                {
                                    artst = new Artist(ddlArtist5.SelectedValue);
                                }
                                else
                                {
                                    artst = new Artist(txtArtist5.Text);
                                }

                                if (artst.ArtistID == 0)
                                {
                                    artst.AltName = FromString.URLKey(artst.Name);
                                    artst.Create();
                                }

                                if (string.IsNullOrEmpty(txtArtistSong5.Text))
                                {
                                    sng = new Song(artst.ArtistID, ddlArtistSongs5.SelectedValue);
                                }
                                else
                                {
                                    sng = new Song(artst.ArtistID, txtArtistSong5.Text);
                                }

                                if (sng.SongID == 0)
                                {
                                    sng.SongKey = FromString.URLKey(sng.Name);
                                    sng.Create();
                                }

                                VideoSong.AddVideoSong(sng.SongID, vid.VideoID, 5);

                                if ((ddlArtist6.SelectedValue != unknownValue && !string.IsNullOrEmpty(ddlArtist6.SelectedValue)) ||
                            !string.IsNullOrEmpty(txtArtist6.Text))
                                {

                                    // song 6

                                    artst = null;
                                    sng = null;

                                    if (string.IsNullOrEmpty(txtArtist6.Text))
                                    {
                                        artst = new Artist(ddlArtist6.SelectedValue);
                                    }
                                    else
                                    {
                                        artst = new Artist(txtArtist6.Text);
                                    }

                                    if (artst.ArtistID == 0)
                                    {
                                        artst.AltName = FromString.URLKey(artst.Name);
                                        artst.Create();
                                    }

                                    if (string.IsNullOrEmpty(txtArtistSong6.Text))
                                    {
                                        sng = new Song(artst.ArtistID, ddlArtistSongs6.SelectedValue);
                                    }
                                    else
                                    {
                                        sng = new Song(artst.ArtistID, txtArtistSong6.Text);
                                    }

                                    if (sng.SongID == 0)
                                    {
                                        sng.SongKey = FromString.URLKey(sng.Name);
                                        sng.Create();
                                    }

                                    VideoSong.AddVideoSong(sng.SongID, vid.VideoID, 6);
                                }

                            }

                        }

                    }
                }

                //  RefreshLists();

                lblStatus.Text = "OK";
            }
            catch (Exception ex)
            {
                lblStatus.Text = ex.Message;
            }

            LoadGrid();
        }
Exemple #34
0
        protected void gvwRequestedVideos_SelectedIndexChanged(object sender, EventArgs e)
        {
            int selected = Convert.ToInt32(gvwRequestedVideos.SelectedDataKey.Value);

            if (selected > 0)
            {
                btnReject.Enabled = true;
                hfVideoRequestID.Value = selected.ToString();
                vidreq = new VideoRequest(selected);
                txtURL.Text = vidreq.RequestURL;
                LoadVideoFromURL(vidreq.RequestURL);
            }
        }
Exemple #35
0
        public ActionResult VideoSubmit(string video,
            string videoType,
            string personType,
            string footageType,
            string band,
            string song,
            string contestID)
        {
            string invalidSubmissionLink = string.Concat("~/videosubmission.aspx?statustype=", InvalidStatus.ToString());

            if (string.IsNullOrWhiteSpace(video))
            {
                Response.Redirect(invalidSubmissionLink);
                return new EmptyResult();
            }
            var vir = new VideoRequest {RequestURL = video};

            string vidKey = Utilities.ExtractYouTubeVideoKey(video);
            vir.RequestURL = vir.RequestURL;
            vir.VideoKey = vidKey;

            if (string.IsNullOrWhiteSpace(vir.VideoKey))
            {
                vir.StatusType = InvalidStatus;
                Response.Redirect(invalidSubmissionLink);
                return new EmptyResult();
            }

            if (string.IsNullOrWhiteSpace(videoType) ||
                string.IsNullOrWhiteSpace(personType) ||
                string.IsNullOrWhiteSpace(footageType) ||
                string.IsNullOrWhiteSpace(band) ||
                string.IsNullOrWhiteSpace(song))
            {
                vir.StatusType = 'P';
                Response.Redirect("~/videosubmission.aspx?statustype=P");
                return new EmptyResult();
            }

            var vid = new Lib.BOL.Video(Provider, vidKey) {ProviderCode = Provider};

            try
            {
                var youTubeVideo = GetYouTubeVideo(vidKey);
                TimeSpan ts = XmlConvert.ToTimeSpan(youTubeVideo.ContentDetails.Duration);
                vid.Duration = (float) Convert.ToDouble(ts.TotalSeconds);
                vid.ProviderUserKey = youTubeVideo.Snippet.ChannelId;
                vid.PublishDate = Convert.ToDateTime(youTubeVideo.Snippet.PublishedAtRaw);
            }
            catch (GDataRequestException gdex)
            {
                vid.IsEnabled = false;
                vid.Update();
                vir.StatusType = InvalidStatus;
                Response.Redirect(invalidSubmissionLink);
                return new EmptyResult();
            }
            catch (ClientFeedException)
            {
                vir.StatusType = InvalidStatus;
                Response.Redirect(invalidSubmissionLink);
                return new EmptyResult();
            }
            catch (Exception ex)
            {
                vir.StatusType = InvalidStatus;
                Response.Redirect(invalidSubmissionLink);
                return new EmptyResult();
            }

            vid.VolumeLevel = 5;

            if (string.IsNullOrWhiteSpace(vid.ProviderKey))
            {
                // invalid
                vir.StatusType = InvalidStatus;
                Response.Redirect(invalidSubmissionLink);
                return new EmptyResult();
            }

            if (vid.VideoID == 0)
            {
                vid.IsHidden = false;
                vid.IsEnabled = true;
                vid.Create();
            }
            else
            {
                // just go to the video...
                vid.Update();
                Response.Redirect(vid.VideoURL);
            }

            // if there is a contest, add it now since there is an id
            int subContestId;

            if (!string.IsNullOrWhiteSpace(contestID) &&
                int.TryParse(contestID, out subContestId) &&
                subContestId > 0)
            {
                //TODO: check if it already is in the contest

                ContestVideo.DeleteVideoFromAllContests(vid.VideoID);

                var cv = new ContestVideo {ContestID = subContestId, VideoID = vid.VideoID};

                cv.Create();
            }
            else
            {
                // TODO: JUST REMOVE FROM CURRENT CONTEST, NOT ALL
                ContestVideo.DeleteVideoFromAllContests(vid.VideoID);
            }

            // vid type
            var propTyp = new PropertyType(SiteEnums.PropertyTypeCode.VIDTP);
            var mp = new MultiProperty(vid.VideoID, propTyp.PropertyTypeID, SiteEnums.MultiPropertyType.VIDEO);
            MultiPropertyVideo.DeleteMultiPropertyVideo(mp.MultiPropertyID, vid.VideoID);
            mp.RemoveCache();
            MultiPropertyVideo.AddMultiPropertyVideo(Convert.ToInt32(videoType), vid.VideoID);

            // human
            propTyp = new PropertyType(SiteEnums.PropertyTypeCode.HUMAN);
            mp = new MultiProperty(vid.VideoID, propTyp.PropertyTypeID, SiteEnums.MultiPropertyType.VIDEO);
            MultiPropertyVideo.DeleteMultiPropertyVideo(mp.MultiPropertyID, vid.VideoID);
            mp.RemoveCache();
            MultiPropertyVideo.AddMultiPropertyVideo(Convert.ToInt32(personType), vid.VideoID);

            // footage
            propTyp = new PropertyType(SiteEnums.PropertyTypeCode.FOOTG);
            mp = new MultiProperty(vid.VideoID, propTyp.PropertyTypeID, SiteEnums.MultiPropertyType.VIDEO);
            MultiPropertyVideo.DeleteMultiPropertyVideo(mp.MultiPropertyID, vid.VideoID);
            mp.RemoveCache();
            MultiPropertyVideo.AddMultiPropertyVideo(Convert.ToInt32(footageType), vid.VideoID);

            // song 1
            var artst = new Artist(band.Trim());

            if (artst.ArtistID == 0)
            {
                artst.GetArtistByAltname(band.Trim());
            }

            if (artst.ArtistID == 0)
            {
                artst.Name = band.Trim();
                artst.AltName = FromString.UrlKey(artst.Name);
                artst.Create();
            }

            var sng = new Song(artst.ArtistID, song.Trim());

            if (sng.SongID == 0)
            {
                sng.Name = sng.Name.Trim();
                sng.SongKey = FromString.UrlKey(sng.Name);
                sng.Create();
            }

            // BUG: DON'T ADD 2X
            VideoSong.AddVideoSong(sng.SongID, vid.VideoID, 1);

            if (vid.VideoID > 0)
            {
                Response.Redirect(vid.VideoURL); // just send them to it
            }

            return new EmptyResult();
        }
Exemple #36
0
        public ActionResult VideoSubmit(string video, string videoType, string personType,
            string footageType, string band, string song, string contestID)
        {
            if (string.IsNullOrWhiteSpace(video))
            {
                Response.Redirect("~/videosubmission.aspx?statustype=I");
                return new EmptyResult();
            }
            VideoRequest vir = new VideoRequest();

            vir.RequestURL = video;

            string vidKey = string.Empty;

            vir.RequestURL = vir.RequestURL.Replace("https", "http");

            if (vir.RequestURL.Contains("http://youtu.be/"))
            {
                vir.VideoKey = vir.RequestURL.Replace("http://youtu.be/", string.Empty);
            }
            else if (vir.RequestURL.Contains("http://www.youtube.com/watch?"))
            {
                NameValueCollection nvcKey = System.Web.HttpUtility.ParseQueryString(vir.RequestURL.Replace("http://www.youtube.com/watch?", string.Empty));

                vir.VideoKey = nvcKey["v"];
                vidKey = nvcKey["v"];
            }
            else
            {
                // invalid
                vir.StatusType = 'I';
                Response.Redirect("~/videosubmission.aspx?statustype=I");
                return new EmptyResult();
            }

            if (string.IsNullOrWhiteSpace(videoType) ||
                string.IsNullOrWhiteSpace(personType) ||
                string.IsNullOrWhiteSpace(footageType) ||
                string.IsNullOrWhiteSpace(band) ||
                string.IsNullOrWhiteSpace(song))
            {
                // invalid
                vir.StatusType = 'P';
                Response.Redirect("~/videosubmission.aspx?statustype=P");
                return new EmptyResult();
            }

            try
            {

                //IDictionaryEnumerator enumerator = HttpContext.Current.Cache.GetEnumerator();

                //while (enumerator.MoveNext())
                //{

                //    HttpContext.Current.Cache.Remove(enumerator.Key.ToString());

                //}

                //Artists allartsis = new Artists();
                //allartsis.RemoveCache();

                //if (gvwRequestedVideos.SelectedDataKey != null)
                //{
                //    vidreq = new VideoRequest(Convert.ToInt32(gvwRequestedVideos.SelectedDataKey.Value));
                //    vidreq.StatusType = 'A';
                //    vidreq.Update();
                //}

                BootBaronLib.AppSpec.DasKlub.BOL.Video vid = new BootBaronLib.AppSpec.DasKlub.BOL.Video("YT", vidKey);

                vid.ProviderCode = "YT";

                Google.YouTube.Video video2;
                video2 = new Google.YouTube.Video();

                try
                {
                    YouTubeRequestSettings yousettings = new YouTubeRequestSettings("You Manager", devkey, username, password);
                    YouTubeRequest yourequest;
                    Uri Url;

                    yourequest = new YouTubeRequest(yousettings);
                    Url = new Uri("http://gdata.youtube.com/feeds/api/videos/" + vidKey);

                    video2 = yourequest.Retrieve<Google.YouTube.Video>(Url);
                    vid.Duration = (float)Convert.ToDouble(video2.YouTubeEntry.Duration.Seconds);
                    vid.ProviderUserKey = video2.Uploader;
                    vid.PublishDate = video2.YouTubeEntry.Published;
                }
                catch (GDataRequestException)
                {
                    vid.IsEnabled = false;
                    vid.Update();
                    //litVideo.Text = string.Empty;
                    // return;

                    // invalid
                    vir.StatusType = 'I';
                    Response.Redirect("~/videosubmission.aspx?statustype=I");
                    return new EmptyResult();
                }

                vid.VolumeLevel = 5;
                // vid.HumanType = personType;

                //    t(string video, string videoType, string personType,
                //string footageType, string band, string song, string contestID)

                //  vid.VideoType = videoType;

                //vid.Duration = (float)Convert.ToDouble(txtDuration.Text);
                //vid.Intro = (float)Convert.ToDouble(txtSecondsIn.Text);
                //vid.LengthFromStart = (float)Convert.ToDouble(txtElasedEnd.Text);
                //vid.ProviderCode = ddlVideoProvider.SelectedValue;
                //vid.ProviderUserKey = txtUserName.Text;
                //vid.VolumeLevel = Convert.ToInt32(ddlVolumeLevel.SelectedValue);
                //vid.IsEnabled = chkEnabled.Checked;
                //// vid.IsHidden = chkHidden.Checked;
                //vid.EnableTrim = chkEnabled.Checked;

                ///// publish date
                //YouTubeRequestSettings yousettings =
                //    new YouTubeRequestSettings("You Manager", devkey, username, password);
                //YouTubeRequest yourequest;
                //Uri Url;

                //yourequest = new YouTubeRequest(yousettings);
                //Url = new Uri("http://gdata.youtube.com/feeds/api/videos/" + vid.ProviderKey);
                //video = new Google.YouTube.Video();
                //video = yourequest.Retrieve<Google.YouTube.Video>(Url);
                //vid.PublishDate = video.YouTubeEntry.Published;

                if (string.IsNullOrWhiteSpace(vid.ProviderKey))
                {
                    // invalid
                    vir.StatusType = 'I';
                    Response.Redirect("~/videosubmission.aspx?statustype=I");
                    return new EmptyResult();
                }

                if (vid.VideoID == 0)
                {
                    vid.IsHidden = false;
                    vid.IsEnabled = true;
                    vid.Create();
                }
                else
                {
                    vid.Update();
                }

                // if there is a contest, add it now since there is an id
                int subContestID = 0;
                if (!string.IsNullOrWhiteSpace(contestID) && int.TryParse(contestID, out subContestID) && subContestID > 0)
                {
                    //TODO: check if it already is in the contest

                    ContestVideo.DeleteVideoFromAllContests(vid.VideoID);

                    ContestVideo cv = new ContestVideo();

                    cv.ContestID = subContestID;
                    cv.VideoID = vid.VideoID;
                    cv.Create();
                }
                else
                {
                    // TODO: JUST REMOVE FROM CURRENT CONTEST, NOT ALL
                    ContestVideo.DeleteVideoFromAllContests(vid.VideoID);
                }

                PropertyType propTyp = null;
                MultiProperty mp = null;

                // vid type

                propTyp = new PropertyType(SiteEnums.PropertyTypeCode.VIDTP);
                mp = new MultiProperty(vid.VideoID, propTyp.PropertyTypeID, SiteEnums.MultiPropertyType.VIDEO);
                MultiPropertyVideo.DeleteMultiPropertyVideo(mp.MultiPropertyID, vid.VideoID);
                mp.RemoveCache();
                MultiPropertyVideo.AddMultiPropertyVideo(Convert.ToInt32(videoType), vid.VideoID);

                // human

                propTyp = new PropertyType(SiteEnums.PropertyTypeCode.HUMAN);
                mp = new MultiProperty(vid.VideoID, propTyp.PropertyTypeID, SiteEnums.MultiPropertyType.VIDEO);
                MultiPropertyVideo.DeleteMultiPropertyVideo(mp.MultiPropertyID, vid.VideoID);
                mp.RemoveCache();
                MultiPropertyVideo.AddMultiPropertyVideo(Convert.ToInt32(personType), vid.VideoID);

                // footage

                propTyp = new PropertyType(SiteEnums.PropertyTypeCode.FOOTG);
                mp = new MultiProperty(vid.VideoID, propTyp.PropertyTypeID, SiteEnums.MultiPropertyType.VIDEO);
                MultiPropertyVideo.DeleteMultiPropertyVideo(mp.MultiPropertyID, vid.VideoID);
                mp.RemoveCache();
                MultiPropertyVideo.AddMultiPropertyVideo(Convert.ToInt32(footageType), vid.VideoID);

                //// guitar
                //if (!string.IsNullOrWhiteSpace(this.ddlGuitarType.SelectedValue)
                //    && this.ddlGuitarType.SelectedValue != selectText)
                //{
                //    propTyp = new PropertyType(SiteEnums.PropertyTypeCode.GUITR);
                //    mp = new MultiProperty(vid.VideoID, propTyp.PropertyTypeID, SiteEnums.MultiPropertyType.VIDEO);
                //    MultiPropertyVideo.DeleteMultiPropertyVideo(mp.MultiPropertyID, vid.VideoID);
                //    mp.RemoveCache();
                //    MultiPropertyVideo.AddMultiPropertyVideo(
                //        Convert.ToInt32(ddlGuitarType.SelectedValue), vid.VideoID);
                //}

                //// Language
                //if (!string.IsNullOrWhiteSpace(this.ddlLanguage.SelectedValue)
                //    && this.ddlLanguage.SelectedValue != selectText)
                //{
                //    propTyp = new PropertyType(SiteEnums.PropertyTypeCode.LANGE);
                //    mp = new MultiProperty(vid.VideoID, propTyp.PropertyTypeID, SiteEnums.MultiPropertyType.VIDEO);
                //    MultiPropertyVideo.DeleteMultiPropertyVideo(mp.MultiPropertyID, vid.VideoID);
                //    mp.RemoveCache();
                //    MultiPropertyVideo.AddMultiPropertyVideo(
                //        Convert.ToInt32(ddlLanguage.SelectedValue), vid.VideoID);
                //}

                //// genre
                //if (!string.IsNullOrWhiteSpace(this.ddlGenre.SelectedValue)
                //    && this.ddlGenre.SelectedValue != selectText)
                //{
                //    propTyp = new PropertyType(SiteEnums.PropertyTypeCode.GENRE);
                //    mp = new MultiProperty(vid.VideoID, propTyp.PropertyTypeID, SiteEnums.MultiPropertyType.VIDEO);
                //    MultiPropertyVideo.DeleteMultiPropertyVideo(mp.MultiPropertyID, vid.VideoID);
                //    mp.RemoveCache();
                //    MultiPropertyVideo.AddMultiPropertyVideo(
                //        Convert.ToInt32(ddlGenre.SelectedValue), vid.VideoID);
                //}

                //// difficulty
                //if (!string.IsNullOrWhiteSpace(this.ddlDifficultyLevel.SelectedValue)
                //    && this.ddlDifficultyLevel.SelectedValue != selectText)
                //{
                //    propTyp = new PropertyType(SiteEnums.PropertyTypeCode.DIFFC);
                //    mp = new MultiProperty(vid.VideoID, propTyp.PropertyTypeID, SiteEnums.MultiPropertyType.VIDEO);
                //    MultiPropertyVideo.DeleteMultiPropertyVideo(mp.MultiPropertyID, vid.VideoID);
                //    mp.RemoveCache();
                //    MultiPropertyVideo.AddMultiPropertyVideo(
                //        Convert.ToInt32(this.ddlDifficultyLevel.SelectedValue), vid.VideoID);
                //}

                //VideoSong.DeleteSongsForVideo(vid.VideoID);

                // song 1

                Artist artst = new Artist(band.Trim());

                if (artst.ArtistID == 0)
                {
                    artst.GetArtistByAltname(band.Trim());
                }

                if (artst.ArtistID == 0)
                {
                    artst.Name = band.Trim();
                    artst.AltName = FromString.URLKey(artst.Name);
                    artst.Create();
                }

                Song sng = new Song(artst.ArtistID, song.Trim());

                if (sng.SongID == 0)
                {
                    sng.Name = sng.Name.Trim();
                    sng.SongKey = FromString.URLKey(sng.Name);
                    sng.Create();
                }

                VideoSong.AddVideoSong(sng.SongID, vid.VideoID, 1);

                //  RefreshLists();

                //                lblStatus.Text = "OK";

                if (vid.VideoID > 0)
                {
                    Response.Redirect(vid.VideoURL);// just send them to it
                }
            }
            catch
            {
                //              lblStatus.Text = ex.Message;

                //{
                Response.Redirect("~/videosubmission.aspx?statustype=I");
                return new EmptyResult();
                //}

            }

            //Video v1 = new Video();

            //if (!string.IsNullOrEmpty(vir.VideoKey))
            //{
            //    v1 = new Video("YT", vir.VideoKey);
            //}

            //if (v1.VideoID > 0 && v1.IsEnabled)
            //{
            //     Response.Redirect(v1.VideoURL);// just send them to it
            //     return new EmptyResult();
            //}

            //vir.GetVideoRequest();

            //if (vir.StatusType == 'W')
            //{
            //    Response.Redirect("~/videosubmission.aspx?statustype=W");
            //    return new EmptyResult();
            //}
            //else if (vir.StatusType == 'R')
            //{
            //     Response.Redirect("~/videosubmission.aspx?statustype=R");
            //     return new EmptyResult();
            //}

            //vir.StatusType = 'W';
            //vir.Create();
            // Response.Redirect("~/videosubmission.aspx?statustype=W");
            // return new EmptyResult();

            //if (vir.StatusType == 'W')
            //{
            //    Response.Redirect("~/videosubmission.aspx?statustype=W");
            //    return new EmptyResult();
            //}
            //else if (vir.StatusType == 'R')
            //{
            //    Response.Redirect("~/videosubmission.aspx?statustype=R");
            //    return new EmptyResult();
            //}
            //else
            //{
            //    v1 = new Video("YT", vir.VideoKey);

            //    if (v1.VideoID > 0 && v1.IsEnabled)
            //    {
            //        Response.Redirect(v1.VideoURL);// just send them to it
            //    }
            //    else
            //    {
            //        vir.StatusType = 'W';
            //        vir.Create();
            //        Response.Redirect("~/videosubmission.aspx?statustype=W");
            //        return new EmptyResult();
            //    }
            //}

            return new EmptyResult();
        }