Beispiel #1
0
        public IEnumerable <ResultMedia> GetMediaforTest(string path)
        {
            if (string.IsNullOrEmpty(path))
            {
                return(null);
            }
            _logger.Info("\nMedia Path: " + path);
            var media    = new List <ResultMedia>();
            var fileName = "Echo_" + Guid.NewGuid() + "(1)";
            var counter  = Directory.GetFiles(path).Select(Path.GetExtension).Where(ext => !string.IsNullOrEmpty(ext)).LongCount(ext => ext.Contains(".jpg") || ext.Contains(".jpeg") || ext.Contains(".bmp") || ext.Contains(".png"));

            try
            {
                if (counter > 1)
                {
                    string fileNameWithoutExtension = fileName;
                    fileName = fileName + ".flv";
                    var returnResult = _movieMaker.GenerateMoviefromImageGroup(path, _mediaLocation, fileName);
                    if (string.IsNullOrEmpty(returnResult))
                    {
                        return(null);
                    }

                    var mp4File = _movieMaker.GenerateMPEG(_mediaLocation + "\\" + returnResult, _mediaLocation, fileNameWithoutExtension);

                    var file = new FileInfo(_mediaLocation + fileName);

                    var resultMedia = new ResultMedia
                    {
                        File =
                            new Core.Application.Domain.File
                        {
                            FileSize   = file.Length,
                            Path       = mp4File,                        //fileName,
                            UploadedOn = DateTime.Now,
                            Type       = FileType.Video
                        }
                    };
                    media.Add(resultMedia);
                }
                else if (counter > 0)
                {
                    var imgFilePath = "";
                    foreach (string filePath in Directory.GetFiles(path))
                    {
                        string ext = Path.GetExtension(filePath);
                        if (!string.IsNullOrEmpty(ext) && (ext.Contains(".jpg") || ext.Contains(".jpeg") || ext.Contains(".bmp") || ext.Contains(".png")))
                        {
                            imgFilePath = filePath;
                            break;
                        }
                    }

                    var imageName = fileName + Path.GetExtension(imgFilePath);
                    var file      = new FileInfo(imgFilePath);
                    file.MoveTo(_mediaLocation + imageName);

                    decimal fileSize;
                    var     thumbnailImageName = CreateThumbnailImage(_mediaLocation + imageName, out fileSize);
                    var     resultMedia        = new ResultMedia
                    {
                        File =
                            new Core.Application.Domain.File
                        {
                            FileSize   = file.Length,
                            Path       = imageName,
                            UploadedOn = DateTime.Now,
                            Type       = FileType.Image
                        },
                        Thumbnail =
                            new Core.Application.Domain.File
                        {
                            FileSize   = fileSize,
                            Path       = thumbnailImageName,
                            UploadedOn = DateTime.Now,
                            Type       = FileType.Image
                        }
                    };
                    media.Add(resultMedia);
                }
            }
            catch (Exception ex)
            {
                _errorSummary += "Media Extraction Failed. ";
                _logger.Error("\n Media Extraction Failed! Error: " + ex.Message + "\n\t\t" + ex.StackTrace);
            }

            return(media);
        }
Beispiel #2
0
        public void GenerateMoviefromImageGroupTest()
        {
            const string tempPath = @"D:\Project Docs\ResultArchives\24031\FRONT ROOM\ge\GEMS_IMG\2011_AUG\08\DiacomExtract\B88FCE02\";

            _movieMaker.GenerateMoviefromImageGroup(tempPath, tempPath);
        }