コード例 #1
0
ファイル: QueueProcessor.cs プロジェクト: y1024/HandBrake
        /// <summary>
        /// Run through all the jobs on the queue.
        /// </summary>
        private void ProcessNextJob()
        {
            QueueTask job = this.GetNextJobForProcessing();

            if (job != null)
            {
                if (this.userSettingService.GetUserSetting <bool>(UserSettingConstants.PauseOnLowDiskspace) && !DriveUtilities.HasMinimumDiskSpace(job.Task.Destination, this.userSettingService.GetUserSetting <long>(UserSettingConstants.PauseOnLowDiskspaceLevel)))
                {
                    LogService.GetLogger().LogMessage(Resources.PauseOnLowDiskspace, LogMessageType.ScanOrEncode, LogLevel.Info);
                    job.Status = QueueItemStatus.Waiting;
                    this.Pause();
                    this.BackupQueue(string.Empty);
                    return; // Don't start the next job.
                }

                job.Status = QueueItemStatus.InProgress;
                job.Statistics.StartTime = DateTime.Now;
                this.LastProcessedJob    = job;
                this.IsProcessing        = true;
                this.InvokeQueueChanged(EventArgs.Empty);
                this.InvokeJobProcessingStarted(new QueueProgressEventArgs(job));
                this.EncodeService.Start(job.Task, job.Configuration);
                this.BackupQueue(string.Empty);
            }
            else
            {
                // No more jobs to process, so unsubscribe the event
                this.EncodeService.EncodeCompleted -= this.EncodeServiceEncodeCompleted;

                this.BackupQueue(string.Empty);

                // Fire the event to tell connected services.
                this.OnQueueCompleted(new QueueCompletedEventArgs(false));
            }
        }
コード例 #2
0
ファイル: LogManager.cs プロジェクト: zoyag/HandBrake
        /// <summary>
        /// The init.
        /// </summary>
        public static void Init()
        {
            ILog   log     = LogService.GetLogger();
            string logDir  = DirectoryUtilities.GetLogDirectory();
            string logFile = Path.Combine(logDir, string.Format("activity_log{0}.txt", GeneralUtilities.ProcessId));

            if (!Directory.Exists(Path.GetDirectoryName(logFile)))
            {
                Directory.CreateDirectory(Path.GetDirectoryName(logFile));
            }

            log.Enable();
            log.SetupLogHeader(GeneralUtilities.CreateLogHeader().ToString());
            log.EnableLoggingToDisk(logFile, true);
            HandBrakeUtils.MessageLogged += HandBrakeUtils_MessageLogged;
            HandBrakeUtils.ErrorLogged   += HandBrakeUtils_ErrorLogged;
        }
コード例 #3
0
ファイル: EncodeBase.cs プロジェクト: zoyag/HandBrake
        /// <summary>
        /// Save a copy of the log to the users desired location or a default location
        /// if this feature is enabled in options.
        /// </summary>
        /// <param name="destination">
        /// The Destination File Path
        /// </param>
        /// <param name="isPreview">
        /// The is Preview.
        /// </param>
        /// <param name="configuration">
        /// The configuration.
        /// </param>
        public string ProcessLogs(string destination, bool isPreview, HBConfiguration configuration)
        {
            try
            {
                string logDir = DirectoryUtilities.GetLogDirectory();
                string encodeDestinationPath = Path.GetDirectoryName(destination);
                string destinationFile       = Path.GetFileName(destination);
                string encodeLogFile         = destinationFile + " " + DateTime.Now.ToString(CultureInfo.InvariantCulture).Replace("/", "-").Replace(":", "-") + ".txt";
                ILog   log        = LogService.GetLogger();
                string logContent = log.ActivityLog;

                // Make sure the log directory exists.
                if (!Directory.Exists(logDir))
                {
                    Directory.CreateDirectory(logDir);
                }

                // Copy the Log to HandBrakes log folder in the users applciation data folder.
                this.WriteFile(logContent, Path.Combine(logDir, encodeLogFile));

                // Save a copy of the log file in the same location as the enocde.
                if (configuration.SaveLogWithVideo)
                {
                    this.WriteFile(logContent, Path.Combine(encodeDestinationPath, encodeLogFile));
                }

                // Save a copy of the log file to a user specified location
                if (Directory.Exists(configuration.SaveLogCopyDirectory) && configuration.SaveLogToCopyDirectory)
                {
                    this.WriteFile(logContent, Path.Combine(configuration.SaveLogCopyDirectory, encodeLogFile));
                }

                return(Path.Combine(logDir, encodeLogFile));
            }
            catch (Exception exc)
            {
                Debug.WriteLine(exc); // This exception doesn't warrant user interaction, but it should be logged
            }

            return(null);
        }
コード例 #4
0
 /// <summary>
 /// Initializes a new instance of the <see cref="LogViewModel"/> class.
 /// </summary>
 public LogViewModel(IErrorService errorService)
 {
     this.errorService = errorService;
     this.logService   = LogService.GetLogger();
     this.Title        = Resources.LogViewModel_Title;
 }
コード例 #5
0
ファイル: LogViewModel.cs プロジェクト: ystallonne/HandBrake
 /// <summary>
 /// Initializes a new instance of the <see cref="LogViewModel"/> class.
 /// </summary>
 public LogViewModel(IErrorService errorService)
 {
     this.errorService = errorService;
     this.logService   = LogService.GetLogger();
     this.Title        = "Log Viewer";
 }
コード例 #6
0
ファイル: LogViewModel.cs プロジェクト: wwwutz/HandBrake
 /// <summary>
 /// Initializes a new instance of the <see cref="LogViewModel"/> class.
 /// </summary>
 public LogViewModel()
 {
     this.logService = LogService.GetLogger();
     this.Title      = "Log Viewer";
 }