-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathOpenStudioDataDataSet.cs
73 lines (71 loc) · 2.38 KB
/
OpenStudioDataDataSet.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
using CsvHelper;
using CsvHelper.Configuration;
using System.Collections.Generic;
using System;
using System.Globalization;
using System.IO;
using System.Threading.Tasks;
namespace OpenStudioIDE
{
partial class OpenStudioDataDataSet
{
partial class ideDataTable
{
public void AddRow(string filename, string path, string location, DateTime lastmodified, string extention, bool? latest)
{
ideRow row = (ideRow)NewRow();
row.BeginEdit();
row["filename"] = filename;
row["location"] = path;
row["lastmodified"] = lastmodified;
row["extention"] = extention;
row["latest?"] = latest;
row.EndEdit();
}
public void RemoveRow(string filename)
{
foreach (ideRow row in this.Rows)
{
if (row["filename"].ToString() == filename)
{
row.Delete();
break;
}
}
}
public void UpdateRow(string filename, string path, string location, DateTime lastmodified, string extention, bool? latest)
{
foreach (ideRow row in this.Rows)
{
if (row["filename"].ToString() == filename)
{
row.BeginEdit();
row["filename"] = filename;
row["location"] = path;
row["lastmodified"] = lastmodified;
row["extention"] = extention;
row["latest?"] = latest;
row.EndEdit();
break;
}
}
}
public void DumpDBToxml(string filename)
{
this.WriteXml(filename);
}
public void LoadDBFromxml(string filename)
{
this.ReadXml(filename);
}
public void ExportDBToCSV(string filename)
{
using (var writer = new StreamWriter(filename))
using (var csv = new CsvWriter(writer, CultureInfo.InvariantCulture))
{
csv.WriteRecords(this);
}
}
}
}
}