diff --git a/AutoTx/AutoTx.cs b/AutoTx/AutoTx.cs index f4dfd510f78aafde5a07c8af2e5b0b7e9f11dc51..eacf7e09ba89e8d585fabe8dccee57859833b5b4 100644 --- a/AutoTx/AutoTx.cs +++ b/AutoTx/AutoTx.cs @@ -601,6 +601,7 @@ namespace AutoTx try { _status.CurrentTransferSrc = queued[0].GetDirectories()[0].FullName; + _status.CurrentTransferSize = GetDirectorySize(_status.CurrentTransferSrc); } catch (Exception ex) { writeLog("Error checking for data to be transferred: " + ex.Message); @@ -651,6 +652,7 @@ namespace AutoTx MoveToGraceLocation(); SendTransferCompletedMail(); _status.CurrentTransferSrc = ""; // cleanup completed, so reset CurrentTransferSrc + _status.CurrentTransferSize = 0; _transferredFiles.Clear(); // empty the list of transferred files } } @@ -928,6 +930,17 @@ namespace AutoTx _lastUserDirCheck = DateTime.Now; } + /// <summary> + /// Recursively sum up size of all files under a given path. + /// </summary> + /// <param name="path"></param> + /// <returns>The total size in bytes.</returns> + public static long GetDirectorySize(string path) { + return new DirectoryInfo(path) + .GetFiles("*", SearchOption.AllDirectories) + .Sum(file => file.Length); + } + #endregion } diff --git a/AutoTx/RoboCommand.cs b/AutoTx/RoboCommand.cs index 4129b3ba3b31c6b345b9265b2ae4ed40bdffee10..4cfa85bd609c35984a4d08861081518800ae514b 100644 --- a/AutoTx/RoboCommand.cs +++ b/AutoTx/RoboCommand.cs @@ -69,7 +69,8 @@ namespace AutoTx _roboCommand.RetryOptions.RetryCount = 0; _roboCommand.RetryOptions.RetryWaitTime = 2; _roboCommand.Start(); - writeLogDebug("Transfer started"); + writeLogDebug("Transfer started, total size: " + + _status.CurrentTransferSize / MegaBytes + " MB"); } catch (ManagementException ex) { writeLog("Error in StartTransfer(): " + ex.Message); diff --git a/AutoTx/XmlConfiguration.cs b/AutoTx/XmlConfiguration.cs index 3b9c74cee1448aa93daac1de7d2289c2acfdad6d..90d0de47c3ca953dbd4b005cdb7c612faed08f18 100644 --- a/AutoTx/XmlConfiguration.cs +++ b/AutoTx/XmlConfiguration.cs @@ -128,6 +128,8 @@ namespace AutoTx bool _filecopyFinished; private bool _cleanShutdown; + private long _currentTransferSize; + [XmlElement("LastStatusUpdate", DataType = "dateTime")] public DateTime LastStatusUpdate { get { return _lastStatusUpdate; } @@ -190,6 +192,16 @@ namespace AutoTx } } + public long CurrentTransferSize { + get { return _currentTransferSize; } + set + { + _currentTransferSize = value; + log("CurrentTransferSize was updated (" + value + "), calling Serialize()..."); + Serialize(); + } + } + public XmlStatus() { _currentTransferSrc = ""; _currentTargetTmp = "";