Beispiel #1
0
        public static bool VerifyTaskLengthAndSplitTask(TASK Task)
        {
            int    MaxLength;
            string MaxLengthString = new CONFIG_Service().GetConfigValueById((int)EnumManager.CONFIG.MAXLENGTHWITHOUTSPLIT);

            int.TryParse(MaxLengthString, out MaxLength);

            if (Task.LENGTH >= MaxLength)
            {
                VideoFile VideoFile = new VideoFile(Task.FILE_URL);
                VideoFile.GetVideoInfo();
                Task.STATUS = 0;
                new TASK_Service().AddOrUpdateTask(Task);
                CreateSplits(Task, VideoFile);
                return(true);
            }
            return(false);
        }
        public static bool ExtractAudioSegment(TASK Task)
        {
            try
            {
                Task.STATUS = (int)EnumManager.PARAM_TASK_STATUS.EN_COURS;
                Task.DATE_BEGIN_CONVERSION = DateTime.Now;
                string fileName = GetFileName(Task);

                CopyFileInTempFolder(fileName, Task);
                new TASK_Service().UpdateTask(Task);

                VideoFile VideoFile = new VideoFile(Task.FILE_URL_TEMP);
                VideoFile.GetVideoInfo();
                // On set le debut du premier split
                TimeSpan begin = new TimeSpan(0);
                // on récupère la durée totale de la video
                long durationTotal = VideoFile.Duration.Ticks;
                int  count         = (fileName.LastIndexOf('.') + 1);
                fileName = fileName.Substring(0, count);
                Task.FILE_URL_DESTINATION = destinationFolder + @"\" + fileName + Task.FORMAT.FORMAT_NAME;
                // A voir pour l'extraction d'un morceau de son particulier
                VideoFile.ExtractAudioSegment(begin.Ticks, durationTotal, Task.FORMAT.FORMAT_NAME, Task.FILE_URL_DESTINATION);
                Task.STATUS = (int)EnumManager.PARAM_TASK_STATUS.EFFECTUE;
                Task.DATE_END_CONVERSION = DateTime.Now;
                new TASK_Service().UpdateTask(Task);
                return(true);
            }
            catch (Exception e)
            {
                Task.STATUS = (int)EnumManager.PARAM_TASK_STATUS.ERREUR;
                Task.DATE_END_CONVERSION = DateTime.Now;
                new TASK_Service().UpdateTask(Task);
                var trace = new TRACE()
                {
                    FK_ID_TASK = Task.PK_ID_TASK, DATE_TRACE = DateTime.Now, NOM_SERVER = System.Environment.MachineName, DESCRIPTION = e.Message + " " + e.InnerException, METHOD = "Erreur lors de l'extraction audio", TYPE = "ERROR"
                };
                new TRACE_Service().AddTrace(trace);
                return(false);
            }
        }
        public static bool VerifyTaskLengthAndSplitTask(TASK Task)
        {
            // Si c'est une sous tache on ne split pas
            if (Task.FK_ID_PARENT_TASK != null)
            {
                return(false);
            }
            //On récupère la taille maximum sans split
            var listParamLength = new PARAM_LENGTH_Service().GetAll().ToList();
            //int.TryParse(MaxLengthString, out MaxLength);
            // Si la tache est trop lourde on la split
            int megabytes = (int)ConverterUtil.ConvertBytesToMegabytes((double)Task.LENGTH);

            if (listParamLength.Where(x => x.LENGTH <= megabytes).FirstOrDefault() != null)
            {
                VideoFile VideoFile = new VideoFile(Task.FILE_URL);
                VideoFile.GetVideoInfo();
                Task.STATUS = (int)EnumManager.PARAM_TASK_STATUS.SPLIT_EN_COURS;
                new TASK_Service().UpdateTask(Task);
                CreateSplits(Task, VideoFile);
                return(true);
            }
            return(false);
        }