Example #1
0
        private tbVideo CastVideoEntity(VideoEntity objVideo)
        {
            tbVideo video = new tbVideo();

            video.ativo = objVideo.ativo;
            video.dataUltimaAlteracao = objVideo.dataUltimaAlteracao;
            video.descricao           = objVideo.descricao;
            video.estado                     = objVideo.estado;
            video.id                         = objVideo.id;
            video.imagemHomeFilePath         = objVideo.imagemHomeFilePath;
            video.responsavelUltimaAlteracao = objVideo.responsavelUltimaAlteracao;
            video.titulo                     = objVideo.titulo;
            video.videoFilePath              = objVideo.videoFilePath;

            return(video);
        }
        public void RetornaVideoVimeoThumbPorstringUrlInvalida()
        {
            VideoEntity   entity        = new VideoEntity();
            VideoBusiness videoBusiness = new VideoBusiness(entity);

            if (videoBusiness.ChaveamentoVimeo())
            {
                var  idVideoValido = RetornaIntVideoIdComVimeoIdValido();
                var  result        = videoBusiness.ObterURLThumbVimeo(idVideoValido);
                bool videoVimeo    = false;
                if (result.IndexOf("https://i.vimeocdn.com") >= 0)
                {
                    videoVimeo = true;
                }
                Assert.AreEqual(videoVimeo, true);
            }
        }
Example #3
0
        public void TestTransformToExceptionModel()
        {
            WasteManagementEventEntity wasteManagementEventEntity = _testData.CreateWasteManagementEvent();

            WasteManagementEvent result = _transformer.TransformToExceptionModel(wasteManagementEventEntity);

            Assert.AreEqual(wasteManagementEventEntity.Vin, result.Vin);
            Assert.AreEqual(wasteManagementEventEntity.AccountId, result.AccountId);
            Assert.AreEqual(wasteManagementEventEntity.EventId, result.EventId);
            Assert.AreEqual(wasteManagementEventEntity.EventType, result.EventType);
            Assert.AreEqual(wasteManagementEventEntity.TransactionId, result.TransactionId);
            Assert.AreEqual(wasteManagementEventEntity.DateTime, result.DateTime);
            Assert.AreEqual(wasteManagementEventEntity.Longitude, result.Longitude);
            Assert.AreEqual(wasteManagementEventEntity.Latitude, result.Latitude);

            Assert.AreEqual(wasteManagementEventEntity.Street1, result.Address.Street1);
            Assert.AreEqual(wasteManagementEventEntity.Street2, result.Address.Street2);
            Assert.AreEqual(wasteManagementEventEntity.City, result.Address.City);
            Assert.AreEqual(wasteManagementEventEntity.State, result.Address.State);
            Assert.AreEqual(wasteManagementEventEntity.ZipCode, result.Address.ZipCode);
            Assert.AreEqual(wasteManagementEventEntity.Country, result.Address.Country);

            Assert.AreEqual(wasteManagementEventEntity.ExceptionDetails.Type, result.ExceptionDetails.Type);
            Assert.AreEqual(wasteManagementEventEntity.ContainerColor, result.ContainerColor);
            Assert.AreEqual(wasteManagementEventEntity.ContainerSize, result.ContainerSize);
            Assert.AreEqual(wasteManagementEventEntity.ExceptionDetails.Description, result.ExceptionDetails.Description);
            Assert.AreEqual(wasteManagementEventEntity.ExceptionDetails.Notes, result.ExceptionDetails.Notes);

            List <string> urls = new List <string>(result.ExceptionDetails.PictureUrls);

            Assert.IsTrue(urls.Any(item => item == TestDataCreator.Url1));
            Assert.IsTrue(urls.Any(item => item == TestDataCreator.Url2));

            VideoUrl    videoUrl       = result.VideoUrls.First();
            VideoEntity videoUrlEntity = wasteManagementEventEntity.Videos.First();

            Assert.AreEqual(videoUrl.Heading, videoUrlEntity.Heading);
            Assert.AreEqual(videoUrl.Latitude, videoUrlEntity.Latitude);
            Assert.AreEqual(videoUrl.Longitude, videoUrlEntity.Longitude);
            Assert.AreEqual(videoUrl.MDTUrl, videoUrlEntity.MDTUrl);
            Assert.AreEqual(videoUrl.Url, videoUrlEntity.VideoURL);
            Assert.AreEqual(videoUrl.Speed, videoUrlEntity.Speed);
            Assert.AreEqual(videoUrl.EndDateTime, videoUrlEntity.EndDateTime);
            Assert.AreEqual(videoUrl.StartDateTime, videoUrlEntity.StartDateTime);
            Assert.AreEqual(videoUrl.Camera, videoUrlEntity.CameraChannel);
        }
Example #4
0
        public IHttpActionResult Put(string id)
        {
            // Create a retrieve operation that takes a music entity.
            TableOperation retrieveOperation = TableOperation.Retrieve <VideoEntity>(partitionName, id);

            // Execute the retrieve operation.
            tableClient = storageAccount.CreateCloudTableClient();
            table       = tableClient.GetTableReference("Videos");
            TableResult retrievedResult = table.Execute(retrieveOperation);

            // Construct response including a new DTO as apprporiatte
            if (retrievedResult.Result == null)
            {
                return(NotFound());
            }
            else
            {
                VideoEntity sampleEntity = (VideoEntity)retrievedResult.Result;
                deleteOldBlob(sampleEntity);

                String mp4BlobName = string.Format("{0}{1}", Guid.NewGuid(), ".mp4");

                var mp4Blob = BlobStorageService.getCloudBlobContainer().GetBlockBlobReference("origin/" + mp4BlobName);
                var request = HttpContext.Current.Request;
                mp4Blob.Properties.ContentType = "video/mp4";

                mp4Blob.UploadFromStream(request.InputStream);
                mp4Blob.SetMetadata();

                var    baseUrl   = Request.RequestUri.GetLeftPart(UriPartial.Authority);
                String sampleURL = baseUrl.ToString() + "/api/data/" + id;
                sampleEntity.Mp4Blob       = mp4BlobName;
                sampleEntity.SampleMp4URL  = sampleURL;
                sampleEntity.SampleMp4Blob = null;

                TableOperation updateOperation = TableOperation.InsertOrReplace(sampleEntity);
                // Execute the insert operation.
                table.Execute(updateOperation);

                var queueMessageSample = new VideoEntity(partitionName, id);
                _queueStorageService.getCloudQueue().AddMessage(new CloudQueueMessage(JsonConvert.SerializeObject(queueMessageSample)));

                return(StatusCode(HttpStatusCode.NoContent));
            }
        }
Example #5
0
        //Function to delete a blob used for update and delete requests
        private void deleteOldBlob(VideoEntity sampleEntity)
        {
            var updateOperation = TableOperation.InsertOrReplace(sampleEntity);

            if (sampleEntity.Mp4Blob != null || sampleEntity.SampleMp4Blob != null || sampleEntity.SampleMp4URL != null || sampleEntity.SampleDate != null)
            {   //Setting the value null before setting new values
                sampleEntity.Mp4Blob       = null;
                sampleEntity.SampleMp4Blob = null;
                sampleEntity.SampleMp4URL  = null;
                // Execute the insert operation.
                table.Execute(updateOperation);

                var mp4Blob   = BlobStorageService.getCloudBlobContainer().GetBlockBlobReference("origin/" + sampleEntity.Mp4Blob);
                var videoBlob = BlobStorageService.getCloudBlobContainer().GetBlockBlobReference("updated/" + sampleEntity.Mp4Blob);
                mp4Blob.DeleteIfExists();
                videoBlob.DeleteIfExists();
            }
        }
Example #6
0
        public async Task TrashVideoAsync(VideoEntity video)
        {
            await using var dbConnection = new SqlConnection(_connectionString);

            const string query = @"UPDATE [VideotekaDb].[dbo].[Videos]
                                   SET 
                                      TrashedDateTime = @TrashedDateTime,
                                      IsTrashed = @IsTrashed
                                   WHERE Id = @Id AND UserId = @UserId";

            var result = await dbConnection.ExecuteAsync(query, new
            {
                Id              = video.Id,
                UserId          = video.UserId,
                TrashedDateTime = video.TrashedDateTime,
                IsTrashed       = video.IsTrashed,
            });
        }
Example #7
0
        public ActionResult <DataResult> Create([Bind("remark, url")] VideoEntity videoEntity)
        {
            DataResult dataResult = new DataResult();

            try
            {
                if (string.IsNullOrWhiteSpace(videoEntity.url))
                {
                    dataResult.code = "201";
                    dataResult.msg  = "视频不能为空";
                    return(dataResult);
                }

                VideoBLL    videoBLL = new VideoBLL();
                VideoEntity video    = new VideoEntity()
                {
                    createDate = DateTime.Now,
                    modifyDate = DateTime.Now,
                    remark     = videoEntity.remark ?? "",
                    url        = videoEntity.url
                };

                int rows = videoBLL.ActionDal.ActionDBAccess.Insertable(video).ExecuteCommand();

                if (rows > 0)
                {
                    dataResult.code = "200";
                    dataResult.msg  = "成功";
                }
                else
                {
                    dataResult.code = "201";
                    dataResult.msg  = "失败";
                }
            }
            catch (Exception e)
            {
                dataResult.code = "999";
                dataResult.msg  = e.Message;
                return(dataResult);
            }

            return(dataResult);
        }
Example #8
0
        public ActionResult Remove(int videoId)
        {
            List <VideoQuestionEntity> questions = VideoQuestionRepository.Instance.GetAllByVideo(videoId, CurrentFirm.Id);

            foreach (VideoQuestionEntity item in questions)
            {
                item.Status = GenericStatus.INACTIVE;

                VideoQuestionRepository.Instance.UpdateVideoQuestion(item);
            }

            VideoEntity video = VideoRepository.Instance.GetById(videoId);

            video.Status = GenericStatus.INACTIVE;

            VideoRepository.Instance.UpdateUpdate(video);

            return(View("Index"));
        }
Example #9
0
        public IActionResult Upload(VideoEntity video, IFormFile file)
        {
            if (file == null)
            {
                ViewData["message"] = "Wybierz plik wideo.";
                return(Upload());
            }

            if (file.Length == 0 || file.Length > Config.VideoMaxBytes)
            {
                ViewData["message"] = $"Nieprawidłowy rozmiar pliku. Maksymalna wielkość to {Config.VideoMaxMb} MB.";
                return(Upload());
            }

            if (!Config.AllowedVideoMimeTypes.Contains(file.ContentType))
            {
                ViewData["message"] = $"Nieobsługiwany typ pliku ({file.ContentType}).";
                return(Upload());
            }

            var fileName = Path.GetRandomFileName();
            var filePath = Path.Combine(Config.Parsed["Videos:StoredFilesPath"], fileName);

            using (var stream = System.IO.File.Create(filePath))
            {
                file.CopyTo(stream);
            }

            ffmpegHelper.CreateThumbnailFromVideo(filePath, fileName);

            video.UserId            = LoggedUserId;
            video.UploadedAt        = DateTime.Now;
            video.FileName          = fileName;
            video.MimeType          = file.ContentType;
            video.ThumbnailFileName = ffmpegHelper.ProvideOutputFilename(fileName);
            video.ThumbnailMimeType = FFMPEGHelper.THUMB_MIME_TYPE;

            DbContext.Videos.Add(video);
            DbContext.SaveChanges();

            return(RedirectToAction("Watch", new { id = video.Id }));
        }
Example #10
0
        public IHttpActionResult DeleteProduct(string id)
        {
            // Create a retrieve operation that takes a product entity.
            TableOperation retrieveOperation = TableOperation.Retrieve <VideoEntity>(partitionName, id);
            TableResult    retrievedResult   = table.Execute(retrieveOperation);


            if (retrievedResult.Result == null)
            {
                return(NotFound());
            }
            else
            {
                VideoEntity updateEntity = (VideoEntity)retrievedResult.Result;
                deleteOldBlob(updateEntity);
                TableOperation deleteOperation = TableOperation.Delete(updateEntity);
                table.Execute(deleteOperation);

                return(Ok(retrievedResult.Result));
            }
        }
Example #11
0
        public int InsereVideo(VideoEntity video)
        {
            int idVideo = 0;

            try
            {
                using (var context = new CirculoNegocioEntities())
                {
                    tbVideo tb = CastVideoEntity(video);
                    context.tbVideos.AddObject(tb);
                    context.SaveChanges();

                    idVideo = tb.id;
                }
            }
            catch (Exception)
            {
                throw;
            }

            return(idVideo);
        }
Example #12
0
        public long AddNew(VideoAddDto dto)
        {
            VideoEntity videoEntity = dto.EntityMap();

            videoEntity.CreateDateTime = DateTime.Now;
            using (YersDbContext ctx = new YersDbContext())
            {
                BaseService <VideoEntity> bs
                    = new BaseService <VideoEntity>(ctx);

                if (bs.GetAll().Any(m => m.Title == videoEntity.Title))
                {
                    throw new ArgumentException("该视频标题已存在,请检查");
                }

                ctx.Videos.Add(videoEntity);

                ctx.SaveChanges();

                return(videoEntity.Id);
            }
        }
Example #13
0
        private List <VideoEntity> CastListEntityVideo(List <tbVideo> lstEntityVideos)
        {
            List <VideoEntity> lst = new List <VideoEntity>();

            foreach (var item in lstEntityVideos)
            {
                VideoEntity obj = new VideoEntity();

                obj.ativo = item.ativo;
                obj.dataUltimaAlteracao = item.dataUltimaAlteracao;
                obj.descricao           = item.descricao;
                obj.estado                     = item.estado;
                obj.id                         = item.id;
                obj.imagemHomeFilePath         = item.imagemHomeFilePath;
                obj.responsavelUltimaAlteracao = item.responsavelUltimaAlteracao;
                obj.titulo                     = item.titulo;
                obj.videoFilePath              = item.videoFilePath;

                lst.Add(obj);
            }

            return(lst);
        }
Example #14
0
        public static void go()
        {
            const String partitionName = "Video_Partition";

            CloudStorageAccount storageAccount = CloudStorageAccount.Parse(ConfigurationManager.ConnectionStrings["AzureStorage"].ToString());
            CloudTableClient    tableClient    = storageAccount.CreateCloudTableClient();
            CloudTable          table          = tableClient.GetTableReference("Videos");

            // If table doesn't already exist in storage then create and populate it with some initial values, otherwise do nothing
            if (!table.Exists())
            {
                // Create table if it doesn't exist already
                table.CreateIfNotExists();

                // Create the batch operation.
                TableBatchOperation batchOperation = new TableBatchOperation();

                // Create a video entity and add it to the table.
                VideoEntity video1 = new VideoEntity(partitionName, "1");
                video1.Title       = "bee.mp4";
                video1.CreatedDate = DateTime.Now;

                // Create another video entity and add it to the table.
                VideoEntity video2 = new VideoEntity(partitionName, "2");
                video2.Title       = "bunny.mp4";
                video2.CreatedDate = DateTime.Now;


                // Create another video entity and add it to the table.
                VideoEntity video3 = new VideoEntity(partitionName, "3");
                video3.Title       = "giraffes.mp4";
                video3.CreatedDate = DateTime.Now;
                //video3.SampleDate = null;


                // Create another video entity and add it to the table.
                VideoEntity video4 = new VideoEntity(partitionName, "4");
                video4.Title       = "ostrich.mp4";
                video4.CreatedDate = DateTime.Now;


                // Create another video entity and add it to the table.
                VideoEntity video5 = new VideoEntity(partitionName, "5");
                video5.Title       = "sintel.mp4";
                video5.CreatedDate = DateTime.Now;


                // Create another video entity and add it to the table.
                VideoEntity video6 = new VideoEntity(partitionName, "6");
                video6.Title       = "swann.mp4";
                video6.CreatedDate = DateTime.Now;

                // Create another video entity and add it to the table.
                VideoEntity video7 = new VideoEntity(partitionName, "7");
                video7.Title       = "swann.mp4";
                video7.CreatedDate = DateTime.Now;


                // Add video entities to the batch insert operation.
                batchOperation.Insert(video1);
                batchOperation.Insert(video2);
                batchOperation.Insert(video3);
                batchOperation.Insert(video4);
                batchOperation.Insert(video5);
                batchOperation.Insert(video6);
                batchOperation.Insert(video7);

                // Execute the batch operation.
                table.ExecuteBatch(batchOperation);
            }
        }
Example #15
0
        public ActionResult Create()
        {
            VideoEntity video = new VideoEntity();

            return(PartialView("_Edit", video));
        }
Example #16
0
        public ActionResult Edit(int videoId)
        {
            VideoEntity video = VideoRepository.Instance.GetById(videoId);

            return(PartialView("_Edit", video));
        }
Example #17
0
 public int InsereVideo(VideoEntity video)
 {
     return(lObjVideoDAL.InsereVideo(video));
 }
Example #18
0
 /// <summary>
 /// Updates individual properties of an existing video resource.
 /// </summary>
 /// <remarks>
 /// Updates individual properties of an existing video resource with the given
 /// name.
 /// </remarks>
 /// <param name='operations'>
 /// The operations group for this extension method.
 /// </param>
 /// <param name='resourceGroupName'>
 /// The name of the resource group. The name is case insensitive.
 /// </param>
 /// <param name='accountName'>
 /// The Azure Video Analyzer account name.
 /// </param>
 /// <param name='videoName'>
 /// The Video name.
 /// </param>
 /// <param name='parameters'>
 /// The request parameters
 /// </param>
 /// <param name='cancellationToken'>
 /// The cancellation token.
 /// </param>
 public static async Task <VideoEntity> UpdateAsync(this IVideosOperations operations, string resourceGroupName, string accountName, string videoName, VideoEntity parameters, CancellationToken cancellationToken = default(CancellationToken))
 {
     using (var _result = await operations.UpdateWithHttpMessagesAsync(resourceGroupName, accountName, videoName, parameters, null, cancellationToken).ConfigureAwait(false))
     {
         return(_result.Body);
     }
 }
Example #19
0
 /// <summary>
 /// Updates individual properties of an existing video resource.
 /// </summary>
 /// <remarks>
 /// Updates individual properties of an existing video resource with the given
 /// name.
 /// </remarks>
 /// <param name='operations'>
 /// The operations group for this extension method.
 /// </param>
 /// <param name='resourceGroupName'>
 /// The name of the resource group. The name is case insensitive.
 /// </param>
 /// <param name='accountName'>
 /// The Azure Video Analyzer account name.
 /// </param>
 /// <param name='videoName'>
 /// The Video name.
 /// </param>
 /// <param name='parameters'>
 /// The request parameters
 /// </param>
 public static VideoEntity Update(this IVideosOperations operations, string resourceGroupName, string accountName, string videoName, VideoEntity parameters)
 {
     return(operations.UpdateAsync(resourceGroupName, accountName, videoName, parameters).GetAwaiter().GetResult());
 }
Example #20
0
        public void DeleteBy(int id)
        {
            VideoEntity entity = _video.Find(id);

            entity.IsDel = true;
        }
Example #21
0
 public static VideoAddDto EntityMap(this VideoEntity model)
 {
     return(Mapper.Map <VideoAddDto>(model));
 }
Example #22
0
 public static VideoListDto EntityMapToList(this VideoEntity model)
 {
     return(Mapper.Map <VideoListDto>(model));
 }