From 508a86a8ac23f2ab3e861f5818c335de71ae68d3 Mon Sep 17 00:00:00 2001 From: Rich Date: Mon, 21 May 2012 13:27:44 +0000 Subject: [PATCH] Added memory usage to output Add separate counts for Errors, Warnings and Information --- PROMS/DataLoader/Documents.cs | 3 ++- PROMS/DataLoader/frmErrors.cs | 51 ++++++++++++++++++++++++++++------- 2 files changed, 43 insertions(+), 11 deletions(-) diff --git a/PROMS/DataLoader/Documents.cs b/PROMS/DataLoader/Documents.cs index 5c601f94..fa166e9e 100644 --- a/PROMS/DataLoader/Documents.cs +++ b/PROMS/DataLoader/Documents.cs @@ -52,7 +52,8 @@ namespace DataLoader if (System.IO.File.Exists(fname)) { FileInfo myFile = new FileInfo(fname); - frmMain.AddInfo("Processing {0}", fname); + GC.Collect(); + frmMain.AddInfo("Processing {0} {1}", fname, GC.GetTotalMemory(true)); //string tmpName = @"C:\Temp\DataLoader\" + myFile.Name.Replace(".", "_") + ".RTF"; string tmpName = Path.GetTempFileName(); string temppath = Path.GetTempFileName(); diff --git a/PROMS/DataLoader/frmErrors.cs b/PROMS/DataLoader/frmErrors.cs index 775348ee..d8772606 100644 --- a/PROMS/DataLoader/frmErrors.cs +++ b/PROMS/DataLoader/frmErrors.cs @@ -17,15 +17,44 @@ namespace DataLoader InitializeComponent(); _MyParent = myParent; } - private List _MyErrors = new List(); - public List MyErrors + private List _MyMessages = new List(); + private int _ErrorCount = 0; + + public int ErrorCount { - get { return _MyErrors; } + get { return _ErrorCount; } + set { _ErrorCount = value; } + } + private int _WarningCount = 0; + public int WarningCount + { + get { return _WarningCount; } + set { _WarningCount = value; } + } + private int _InfoCount = 0; + public int InfoCount + { + get { return _InfoCount; } + set { _InfoCount = value; } } string sep = ""; - public void Add(string err) + public void Add(string err, MessageType messageType) { - _MyErrors.Add(err); + switch (messageType) + { + case MessageType.Information: + _InfoCount++; + break; + case MessageType.Warning: + _WarningCount++; + break; + case MessageType.Error: + _ErrorCount++; + break; + default: + break; + } + _MyMessages.Add(err); tbErrors.SelectionStart = tbErrors.TextLength; tbErrors.SelectedText = sep + err; sep = "\r\n"; @@ -47,13 +76,15 @@ namespace DataLoader public void Save(string path) { StreamWriter fs = new StreamWriter(path,false); - foreach (string txt in MyErrors) + foreach (string txt in _MyMessages) fs.WriteLine(txt); fs.Close(); } - public int ItemCount() - { - return MyErrors.Count; - } + } + public enum MessageType + { + Information, + Warning, + Error } } \ No newline at end of file