public static bool MergeChunks(Job job)
        {
            if (CheckOutputs(job) == false)
            {
                job.ErrorStatus = JobErrorStatus.JES_OUTPUTFILE_COUNT_MISMATCH;
                return(false);
            }

            SavePreviewImage(job);

            if (job.Production.IsZipProduction)
            {
                return(true);
            }

            CreateChunklistFile(job);

            string cmd = "-y -loglevel panic -safe 0 -f concat -i " + JobPathHelper.GetChunkListPath(job) + " -c copy ";

            cmd += JobPathHelper.GetJobClipPath(job);

            Encode(job, cmd);

            return(true);
        }
        private void CreateCliplistFile()
        {
            //create cliplist file
            StreamWriter writer = new StreamWriter(ProductionPathHelper.GetClipListPath(production), false);

            writer.WriteLine(@"# cliplist");

            FilmOutputFormat largestOutputFormat = production.Film.LargestFilmOutputFormat;

            //clips
            for (int i = 0; i < production.JobList.Count; i++)
            {
                Job job = production.JobList[i];

                if (job.IsDicative)
                {
                    VerifyDicativeSize(job, largestOutputFormat);
                    writer.WriteLine(CreateDicativeLine(job, largestOutputFormat));
                }
                else
                {
                    writer.WriteLine("file '" + JobPathHelper.GetJobClipPath(job) + "'");
                }
            }

            writer.Close();
        }
        private void RenameToProduct()
        {
            string sourceFile = JobPathHelper.GetJobClipPath(production.JobList[0]);
            string targetFile = ProductionPathHelper.GetProductMp4Path(production.JobList[0].ProductID);

            IOHelper.CreateDirectory(Path.GetDirectoryName(targetFile));
            System.IO.File.Copy(sourceFile, targetFile, true);

            FireSuccessEvent();
        }
        //create job statistics data and send to server
        private void WriteStatistics()
        {
            if (job.FrameCount < 2)
            {
                return;
            }

            float totalSeconds         = 0;
            int   totalFrames          = 0;
            float totalProcessorFactor = 0;

            foreach (RenderChunkStatus renderChunk in job.RenderChunkStatusList)
            {
                TimeSpan renderTimeSpan = renderChunk.RenderEndDate - renderChunk.RenderStartDate;
                float    seconds        = (float)Math.Round(renderTimeSpan.TotalSeconds, 2);
                totalSeconds += seconds;
                int frames = (renderChunk.EndFrame - renderChunk.StartFrame + 1);
                totalFrames += frames;

                totalProcessorFactor += ((float)frames / (float)job.FrameCount) * renderChunk.Processors * renderChunk.ProcessorSpeed;
            }

            float totalStandardizedTime = (float)Math.Round(totalSeconds * totalProcessorFactor / (float)job.FrameCount, 2);

            string   filename = JobPathHelper.GetJobClipPath(job);
            FileInfo fileInfo = new FileInfo(filename);

            long fileSize = fileInfo.Length;

            if (job.Production.IsZipProduction)
            {
                fileSize /= job.Production.JobList.Count;
            }

            Dictionary <string, string> param = new Dictionary <string, string>
            {
                { "productID", job.ProductID.ToString() },
                { "seconds", ((decimal)totalSeconds).ToString().Replace(",", ".") },
                { "processorFactor", ((decimal)totalProcessorFactor).ToString().Replace(",", ".") },
                { "standardizedComplexity", ((decimal)totalStandardizedTime).ToString().Replace(",", ".") },
                { "filesize", fileSize.ToString() }
            };

            JobRepository.UpdateProductStatistics(param);
        }