public void AddOccurrence(SummaryDocType d) { if (ht.ContainsKey(d.FileExtension.GetHashCode())) { SummaryDocType olderSummary = ht[d.FileExtension.GetHashCode()] as SummaryDocType; if (olderSummary.MaxSizeFile < d.MaxSizeFile) { olderSummary.MaxSizeFile = d.MaxSizeFile; } if (olderSummary.RecentFile < d.RecentFile) { olderSummary.RecentFile = d.RecentFile; } if (olderSummary.OlderFile > d.OlderFile) { olderSummary.OlderFile = d.OlderFile; } olderSummary.TotalSize += d.TotalSize; olderSummary.TotalQuantity++; } else { this.ht.Add(d.FileExtension.GetHashCode(), d); } signalEvent(this.quant); }
public List<SummaryDocType> List() { List<SummaryDocType> result = new List<SummaryDocType>(); string text = System.IO.File.ReadAllText(reportFilePath); string[] logEntrysTxtLines = text.Split(Environment.NewLine.ToCharArray()); foreach (string item in logEntrysTxtLines) { if ((!string.IsNullOrEmpty(item)) & (!item.Contains(logEntrysTxtLines[0]))) { string[] properties = item.Split(separator); SummaryDocType entry = new SummaryDocType(properties[0].ToString()); entry.TotalQuantity = Convert.ToInt64(properties[1].ToString()); entry.TotalSize = Convert.ToInt64(properties[2].ToString()); entry.MaxSizeFile = Convert.ToInt64(properties[3].ToString()); entry.OlderFile = Convert.ToDateTime(properties[4].ToString()); entry.RecentFile = Convert.ToDateTime(properties[5].ToString()); result.Add(entry); } } return result; }
private void ProcessFile(string fileName) { try { SummaryDocType newDoc = new SummaryDocType(this.fileSystemHelper.GetExtension(fileName)); newDoc.MaxSizeFile = this.fileSystemHelper.GetFileSize(fileName); newDoc.OlderFile = this.fileSystemHelper.GetCreationDate(fileName); newDoc.RecentFile = this.fileSystemHelper.GetCreationDate(fileName); newDoc.TotalSize = this.fileSystemHelper.GetFileSize(fileName); newDoc.TotalQuantity = 1; this.quant += 1; this.totalSize += this.fileSystemHelper.GetFileSize(fileName); AddOccurrence(newDoc); } catch (PathTooLongException e) { //only for not supported file name mode. //redundancy Log entryLog = new Log(); entryLog.TaskDescription = "File Name is Too Long"; entryLog.ExecutionTime = timeDif; entryLog.StartDateTime = startTime; entryLog.LogParameters = new List<string>(); entryLog.LogParameters.Add("FileName: " + fileName); entryLog.LogParameters.Add("Track: " + e.Message); this.repLog.Write(entryLog); this.skippedFiles++; } }
public void Write(SummaryDocType entry) { File.AppendAllText(reportFilePath, entry.ToString()); }