You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: DayFile.cs
+14-3Lines changed: 14 additions & 3 deletions
Original file line number
Diff line number
Diff line change
@@ -63,12 +63,14 @@ public void LoadDayFile()
63
63
using(varsr=newStreamReader(dayFileName))
64
64
{
65
65
varlastDate=DateTime.MinValue;
66
+
66
67
do
67
68
{
68
69
try
69
70
{
70
71
// process each record in the file
71
72
73
+
72
74
linenum++;
73
75
stringLine=sr.ReadLine();
74
76
varnewRec=ParseDayFileRec(Line);
@@ -79,7 +81,7 @@ public void LoadDayFile()
79
81
Program.LogMessage($"LoadDayFile: Error - Date is out of order at line {linenum} of {dayFileName}, '{newRec.Date.ToString("dd"+DateSep+"MM"+DateSep+"yy")}'");
80
82
Console.WriteLine();
81
83
Program.LogConsole($"Error, date is out of order at line {linenum} of {dayFileName}, '{newRec.Date.ToString("dd"+DateSep+"MM"+DateSep+"yy")}'",ConsoleColor.Red);
82
-
Environment.Exit(3);
84
+
errorCount++;
83
85
}
84
86
85
87
// sanity check if this date has already been added
@@ -94,7 +96,10 @@ public void LoadDayFile()
94
96
Environment.Exit(4);
95
97
}
96
98
97
-
DayfileRecs.Add(newRec);
99
+
if(errorCount==0)
100
+
{
101
+
DayfileRecs.Add(newRec);
102
+
}
98
103
99
104
lastDate=newRec.Date;
100
105
@@ -114,14 +119,20 @@ public void LoadDayFile()
114
119
Environment.Exit(5);
115
120
}
116
121
}
117
-
}while(!(sr.EndOfStream||errorCount>=20));
122
+
}while(!sr.EndOfStream);
118
123
}
119
124
}
120
125
catch(Exceptione)
121
126
{
122
127
Program.LogMessage($"LoadDayFile: Error at line {linenum} of {dayFileName} : {e.Message}");
123
128
Program.LogMessage("Please edit the file to correct the error");
124
129
}
130
+
131
+
if(errorCount>0)
132
+
{
133
+
Environment.Exit(3);
134
+
}
135
+
125
136
Program.LogMessage($"LoadDayFile: Loaded {addedEntries} entries to the daily data list");
126
137
Console.WriteLine($"Loaded {addedEntries} entries to the daily data list");
0 commit comments