summaryrefslogtreecommitdiffstats
path: root/win/CS/HandBrakeWPF/Services/Encode
diff options
context:
space:
mode:
authorsr55 <[email protected]>2017-08-28 15:16:40 +0100
committersr55 <[email protected]>2017-08-28 15:16:40 +0100
commitec19d8520ea39761053cccb2744931f0195b7bba (patch)
treec141be678fb13ee103cc2831737eaad40734b0c9 /win/CS/HandBrakeWPF/Services/Encode
parent871ffc2ed52c5480b4765a21d12e18173c1c0eac (diff)
WinGui: Putting in some back-end infrastructure into the queue screen to support future features + some misc tidy up.
Diffstat (limited to 'win/CS/HandBrakeWPF/Services/Encode')
-rw-r--r--win/CS/HandBrakeWPF/Services/Encode/EncodeBase.cs6
-rw-r--r--win/CS/HandBrakeWPF/Services/Encode/EventArgs/EncodeCompletedEventArgs.cs34
-rw-r--r--win/CS/HandBrakeWPF/Services/Encode/LibEncode.cs40
3 files changed, 60 insertions, 20 deletions
diff --git a/win/CS/HandBrakeWPF/Services/Encode/EncodeBase.cs b/win/CS/HandBrakeWPF/Services/Encode/EncodeBase.cs
index 8f7dee945..b822b976d 100644
--- a/win/CS/HandBrakeWPF/Services/Encode/EncodeBase.cs
+++ b/win/CS/HandBrakeWPF/Services/Encode/EncodeBase.cs
@@ -131,7 +131,7 @@ namespace HandBrakeWPF.Services.Encode
/// <param name="configuration">
/// The configuration.
/// </param>
- public void ProcessLogs(string destination, bool isPreview, HBConfiguration configuration)
+ public string ProcessLogs(string destination, bool isPreview, HBConfiguration configuration)
{
try
{
@@ -162,11 +162,15 @@ namespace HandBrakeWPF.Services.Encode
{
this.WriteFile(logContent, Path.Combine(configuration.SaveLogCopyDirectory, encodeLogFile));
}
+
+ return encodeLogFile;
}
catch (Exception exc)
{
Debug.WriteLine(exc); // This exception doesn't warrent user interaction, but it should be logged
}
+
+ return null;
}
/// <summary>
diff --git a/win/CS/HandBrakeWPF/Services/Encode/EventArgs/EncodeCompletedEventArgs.cs b/win/CS/HandBrakeWPF/Services/Encode/EventArgs/EncodeCompletedEventArgs.cs
index ea334705d..1f2fe3bb0 100644
--- a/win/CS/HandBrakeWPF/Services/Encode/EventArgs/EncodeCompletedEventArgs.cs
+++ b/win/CS/HandBrakeWPF/Services/Encode/EventArgs/EncodeCompletedEventArgs.cs
@@ -10,12 +10,10 @@
namespace HandBrakeWPF.Services.Encode.EventArgs
{
using System;
- using System.Runtime.Serialization;
/// <summary>
/// Encode Progress Event Args
/// </summary>
- [DataContract]
public class EncodeCompletedEventArgs : EventArgs
{
/// <summary>
@@ -33,36 +31,50 @@ namespace HandBrakeWPF.Services.Encode.EventArgs
/// <param name="filename">
/// The filename.
/// </param>
- public EncodeCompletedEventArgs(bool sucessful, Exception exception, string errorInformation, string filename)
+ /// <param name="logPath">
+ /// The path and filename of the log for this encode.
+ /// </param>
+ /// <param name="finalSizeInBytes">
+ /// The final size of the file in bytes.
+ /// </param>
+ public EncodeCompletedEventArgs(bool sucessful, Exception exception, string errorInformation, string filename, string logPath, long finalSizeInBytes)
{
this.Successful = sucessful;
this.Exception = exception;
this.ErrorInformation = errorInformation;
this.FileName = filename;
+ this.ActivityLogPath = logPath;
+ this.FinalFilesizeInBytes = finalSizeInBytes;
}
/// <summary>
/// Gets or sets the file name.
/// </summary>
- [DataMember]
- public string FileName { get; set; }
+ public string FileName { get; private set; }
/// <summary>
/// Gets or sets a value indicating whether Successful.
/// </summary>
- [DataMember]
- public bool Successful { get; set; }
+ public bool Successful { get; private set; }
/// <summary>
/// Gets or sets Exception.
/// </summary>
- [DataMember]
- public Exception Exception { get; set; }
+ public Exception Exception { get; private set; }
/// <summary>
/// Gets or sets ErrorInformation.
/// </summary>
- [DataMember]
- public string ErrorInformation { get; set; }
+ public string ErrorInformation { get; private set; }
+
+ /// <summary>
+ ///
+ /// </summary>
+ public string ActivityLogPath { get; private set; }
+
+ /// <summary>
+ /// Final filesize in bytes
+ /// </summary>
+ public long FinalFilesizeInBytes { get; private set; }
}
}
diff --git a/win/CS/HandBrakeWPF/Services/Encode/LibEncode.cs b/win/CS/HandBrakeWPF/Services/Encode/LibEncode.cs
index 2ad5f0688..f8bd78fb7 100644
--- a/win/CS/HandBrakeWPF/Services/Encode/LibEncode.cs
+++ b/win/CS/HandBrakeWPF/Services/Encode/LibEncode.cs
@@ -11,6 +11,7 @@ namespace HandBrakeWPF.Services.Encode
{
using System;
using System.Diagnostics;
+ using System.IO;
using HandBrake.ApplicationServices.Interop;
using HandBrake.ApplicationServices.Interop.EventArgs;
@@ -21,15 +22,16 @@ namespace HandBrakeWPF.Services.Encode
using HandBrake.ApplicationServices.Services.Logging.Model;
using HandBrakeWPF.Exceptions;
+ using HandBrakeWPF.Properties;
using HandBrakeWPF.Services.Encode.Factories;
- using EncodeTask = HandBrakeWPF.Services.Encode.Model.EncodeTask;
- using IEncode = HandBrakeWPF.Services.Encode.Interfaces.IEncode;
+ using EncodeTask = Model.EncodeTask;
+ using IEncode = Interfaces.IEncode;
/// <summary>
/// LibHB Implementation of IEncode
/// </summary>
- public class LibEncode : HandBrakeWPF.Services.Encode.EncodeBase, IEncode
+ public class LibEncode : EncodeBase, IEncode
{
#region Private Variables
@@ -63,7 +65,7 @@ namespace HandBrakeWPF.Services.Encode
// Sanity Checking and Setup
if (this.IsEncoding)
{
- throw new GeneralApplicationException("HandBrake is already encoding a file.", "Please stop the current encode. If the problem persists, please restart HandBrake.", null);
+ throw new GeneralApplicationException(Resources.Queue_AlreadyEncoding, Resources.Queue_AlreadyEncodingSolution, null);
}
// Setup
@@ -99,7 +101,7 @@ namespace HandBrakeWPF.Services.Encode
this.IsEncoding = false;
this.ServiceLogMessage("Failed to start encoding ..." + Environment.NewLine + exc);
- this.InvokeEncodeCompleted(new EventArgs.EncodeCompletedEventArgs(false, exc, "Unable to start encoding", task.Source));
+ this.InvokeEncodeCompleted(new EventArgs.EncodeCompletedEventArgs(false, exc, "Unable to start encoding", task.Source, null, 0));
}
}
@@ -203,14 +205,36 @@ namespace HandBrakeWPF.Services.Encode
this.ServiceLogMessage("Encode Completed ...");
// Handling Log Data
- this.ProcessLogs(this.currentTask.Destination, this.isPreviewInstance, this.currentConfiguration);
+ string hbLog = this.ProcessLogs(this.currentTask.Destination, this.isPreviewInstance, this.currentConfiguration);
+ long filesize = this.GetFilesize(this.currentTask.Destination);
// Raise the Encode Completed EVent.
this.InvokeEncodeCompleted(
e.Error
- ? new EventArgs.EncodeCompletedEventArgs(false, null, string.Empty, this.currentTask.Destination)
- : new EventArgs.EncodeCompletedEventArgs(true, null, string.Empty, this.currentTask.Destination));
+ ? new EventArgs.EncodeCompletedEventArgs(false, null, string.Empty, this.currentTask.Destination, hbLog, filesize)
+ : new EventArgs.EncodeCompletedEventArgs(true, null, string.Empty, this.currentTask.Destination, hbLog, filesize));
}
+
+ private long GetFilesize(string destination)
+ {
+ try
+ {
+ if (!string.IsNullOrEmpty(destination) && File.Exists(destination))
+ {
+ return new FileInfo(destination).Length;
+ }
+
+ return 0;
+ }
+ catch (Exception e)
+ {
+ this.ServiceLogMessage("Unable to get final filesize ..." + Environment.NewLine + e);
+ Debug.WriteLine(e);
+ }
+
+ return 0;
+ }
+
#endregion
}
}