-
Notifications
You must be signed in to change notification settings - Fork 34
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #86 from cyberman1/patch-1
Update BatchCsvOut.cs
- Loading branch information
Showing
1 changed file
with
41 additions
and
20 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,27 +1,48 @@ | ||
using System; | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Globalization; | ||
using System.IO; | ||
|
||
namespace RECmd; | ||
|
||
public class BatchCsvOut | ||
namespace RECmd | ||
{ | ||
public string HivePath { get; set; } | ||
public string HiveType { get; set; } | ||
public string Description { get; set; } | ||
public string Category { get; set; } | ||
public string KeyPath { get; set; } | ||
public string ValueName { get; set; } | ||
public class BatchCsvOut | ||
{ | ||
public string HivePath { get; set; } | ||
public string HiveType { get; set; } | ||
public string Description { get; set; } | ||
public string Category { get; set; } | ||
public string KeyPath { get; set; } | ||
public string ValueName { get; set; } | ||
|
||
public string ValueType { get; set; } | ||
public string ValueData { get; set; } | ||
public string ValueData2 { get; set; } | ||
public string ValueData3 { get; set; } | ||
|
||
public string ValueType { get; set; } | ||
public string ValueData { get; set; } | ||
public string ValueData2 { get; set; } | ||
public string ValueData3 { get; set; } | ||
public string Comment { get; set; } | ||
public bool Recursive { get; set; } | ||
public bool Deleted { get; set; } | ||
|
||
public string Comment { get; set; } | ||
public bool Recursive { get; set; } | ||
public bool Deleted { get; set; } | ||
public DateTimeOffset? LastWriteTimestamp { get; set; } | ||
|
||
public string PluginDetailFile { get; set; } | ||
|
||
public DateTimeOffset? LastWriteTimestamp { get; set; } | ||
// Method to write the CSV | ||
public static void WriteCsv(string filePath, List<BatchCsvOut> data) | ||
{ | ||
string dateTimeFormat = "yyyy-MM-dd HH:mm:ss.fffffff"; | ||
using (StreamWriter writer = new StreamWriter(filePath)) | ||
{ | ||
// Write CSV header | ||
writer.WriteLine("HivePath,HiveType,Description,Category,KeyPath,ValueName,ValueType,ValueData,ValueData2,ValueData3,Comment,Recursive,Deleted,LastWriteTimestamp,PluginDetailFile"); | ||
|
||
public string PluginDetailFile { get; set; } | ||
} | ||
// Write CSV rows | ||
foreach (var item in data) | ||
{ | ||
string formattedTimestamp = item.LastWriteTimestamp?.ToString(dateTimeFormat, CultureInfo.InvariantCulture) ?? string.Empty; | ||
writer.WriteLine($"{item.HivePath},{item.HiveType},{item.Description},{item.Category},{item.KeyPath},{item.ValueName},{item.ValueType},{item.ValueData},{item.ValueData2},{item.ValueData3},{item.Comment},{item.Recursive},{item.Deleted},{formattedTimestamp},{item.PluginDetailFile}"); | ||
} | ||
} | ||
} | ||
} | ||
} |