Exemplo n.º 1
0
 private void AssessDamageAndPriority(Entities.Video video)
 {
     // AI logic goes here...
     video.Priority            = Entities.PriorityEnum.Medium;
     video.AnalyserDescription = "Description";
     System.Threading.Thread.Sleep(_random.Next(800, 1200));
 }
Exemplo n.º 2
0
        public async void StoreVideo(Entities.Video video)
        {
            var storageUrl = System.IO.Path.Combine("https://psmadd4asimagestorage.blob.core.windows.net/videos/", $"{video.Id.ToString()}-{video.Name}");

            var credentials = new StorageCredentials(storageAccount, storageKey);
            var blob        = new Microsoft.WindowsAzure.Storage.Blob.CloudBlockBlob(new Uri(storageUrl), credentials);
            await blob.UploadFromByteArrayAsync(video.Body, 0, video.Body.Length);
        }
Exemplo n.º 3
0
        private void UpdateTicketWithImageAndPriority(Entities.Ticket ticket, Entities.Video video)
        {
            var existingTicket = _repository.GetBy(ticket.Id);

            existingTicket.AddVideo(video);
            _repository.UpdatePriority(existingTicket);
            _repository.AttachVideo(ticket, video);
        }
Exemplo n.º 4
0
        private void Validate(Entities.Video video)
        {
            // validation logic goes here...
            System.Threading.Thread.Sleep(_random.Next(800, 1200));
            var isValid = true;

            if (!isValid)
            {
                throw new VideoNotValidException();
            }
        }
Exemplo n.º 5
0
        public void ForTicket(Entities.Ticket ticket, Entities.Video video)
        {
            // 1. validate image - it pictures a damaged vehicle
            Validate(video);

            // 2. analyse the image - use AI tool to estimate damage and set priority
            AssessDamageAndPriority(video);

            // 3. crop and compress the image
            CropAndCompress(video);

            // 4. update ticket
            UpdateTicketWithImageAndPriority(ticket, video);
        }
Exemplo n.º 6
0
        public static Entities.Video ToCore(this Model.Video video)
        {
            Entities.Video result = null;

            if (video != null)
            {
                result = new Entities.Video()
                {
                    Id                  = video.Id,
                    Name                = video.Name,
                    UserDescription     = video.UserDescription,
                    AnalyserDescription = video.AnalyserDescription,
                    Priority            = (Entities.PriorityEnum)video.Priority
                };
            }

            return(result);
        }
Exemplo n.º 7
0
        public static Model.Video FromCore(this Entities.Video video)
        {
            Model.Video result = null;

            if (video != null)
            {
                result = new Model.Video()
                {
                    Id                  = video.Id,
                    Name                = video.Name,
                    UserDescription     = video.UserDescription,
                    AnalyserDescription = video.AnalyserDescription,
                    Priority            = (int)video.Priority
                };
            }

            return(result);
        }
Exemplo n.º 8
0
        public Guid AttachVideo(Entities.Ticket ticket, Entities.Video video)
        {
            var result = Guid.Empty;

            using (var context = new TicketingContext())
            {
                var dbEntity = video.FromCore();
                dbEntity.TicketId = ticket.Id;
                context.Videos.Add(dbEntity);
                context.SaveChanges();

                result   = dbEntity.Id;
                video.Id = dbEntity.Id;
            }

            _storage.StoreVideo(video);

            return(result);
        }
Exemplo n.º 9
0
        public ActionResult UploadVideo([FromForm] Model.UploadFileRequest request)
        {
            var video = new Entities.Video()
            {
                UserDescription = request.Description,
                Body            = new byte[request.File.Length],
                Name            = request.File.FileName
            };

            request.File.OpenReadStream().Read(video.Body, 0, video.Body.Length);

            _videoProcessor.ForTicket(
                new Entities.Ticket()
            {
                Id = request.TicketId
            },
                video);

            return(Ok());
        }
Exemplo n.º 10
0
 private void CropAndCompress(Entities.Video video)
 {
     // crop and compress algorithm goes here...
     System.Threading.Thread.Sleep(_random.Next(400, 600));
 }