Skip to content

Commit f305d1e

Browse files
committed
Updated to v1.0.2101.1.
1 parent 9b6ad51 commit f305d1e

35 files changed

+265
-236
lines changed

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,3 +14,5 @@
1414
/Geotab.DataOnlyPlan.API.Examples/obj
1515
/Geotab.DataOnlyPlan.API.Examples.FleetMonitor/bin/Debug/netcoreapp2.2
1616
/Geotab.DataOnlyPlan.API.Examples.FleetMonitor/obj
17+
/Geotab.DataOnlyPlan.API.Examples/bin/Debug/net5.0
18+
/Geotab.DataOnlyPlan.API.Examples.FleetMonitor/bin/Debug/net5.0

.vs/GitHub Copy/v16/.suo

-14.5 KB
Binary file not shown.

.vs/ProjectSettings.json

Lines changed: 0 additions & 3 deletions
This file was deleted.

.vs/VSWorkspaceState.json

Lines changed: 0 additions & 7 deletions
This file was deleted.

.vs/slnx.sqlite

-88 KB
Binary file not shown.

Geotab.DataOnlyPlan.API.Examples.FleetMonitor/DatabaseWorker.cs

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -93,26 +93,26 @@ public DatabaseWorker(string user, string password, string database, string serv
9393
{
9494
if (File.Exists(faultDataTokenFilePath))
9595
{
96-
using (StreamReader faultDataTokenFileReader = new StreamReader(faultDataTokenFilePath))
96+
using (StreamReader faultDataTokenFileReader = new(faultDataTokenFilePath))
9797
{
9898
String faultDataTokenString = faultDataTokenFileReader.ReadToEnd();
99-
long.TryParse(faultDataTokenString, out faultDataToken);
99+
_ = long.TryParse(faultDataTokenString, out faultDataToken);
100100
}
101101
}
102102
if (File.Exists(gpsTokenFilePath))
103103
{
104-
using (StreamReader gpsTokenFileReader = new StreamReader(gpsTokenFilePath))
104+
using (StreamReader gpsTokenFileReader = new(gpsTokenFilePath))
105105
{
106106
String gpsTokenString = gpsTokenFileReader.ReadToEnd();
107-
long.TryParse(gpsTokenString, out gpsToken);
107+
_ = long.TryParse(gpsTokenString, out gpsToken);
108108
}
109109
}
110110
if (File.Exists(statusDataTokenFilePath))
111111
{
112-
using (StreamReader statusDataTokenFileReader = new StreamReader(statusDataTokenFilePath))
112+
using (StreamReader statusDataTokenFileReader = new(statusDataTokenFilePath))
113113
{
114114
String statusDataTokenString = statusDataTokenFileReader.ReadToEnd();
115-
long.TryParse(statusDataTokenString, out statusDataToken);
115+
_ = long.TryParse(statusDataTokenString, out statusDataToken);
116116
}
117117
}
118118
}
@@ -131,13 +131,13 @@ public DatabaseWorker(string user, string password, string database, string serv
131131
/// <returns></returns>
132132
TrackedVehicle CreateTrackedVehicle(Device device)
133133
{
134-
TrackedVehicle trackedVehicle = new TrackedVehicle(device, OutputFolder, MaximumFileSizeInBytes);
134+
TrackedVehicle trackedVehicle = new(device, OutputFolder, MaximumFileSizeInBytes);
135135
if (DiagnosticsToTrack != null && DiagnosticsToTrack.Count > 0)
136136
{
137137
// Add TrackedDiagnostics.
138138
foreach (Diagnostic diagnosticToTrack in DiagnosticsToTrack)
139139
{
140-
TrackedDiagnostic trackedDiagnostic = new TrackedDiagnostic(trackedVehicle.Device, diagnosticToTrack, trackedVehicle.FaultDataFilePath, trackedVehicle.StatusDataFilePath, MaximumFileSizeInBytes);
140+
TrackedDiagnostic trackedDiagnostic = new(trackedVehicle.Device, diagnosticToTrack, trackedVehicle.FaultDataFilePath, trackedVehicle.StatusDataFilePath, MaximumFileSizeInBytes);
141141
trackedVehicle.TrackedDiagnostics.Add(trackedDiagnostic);
142142
}
143143
}
@@ -260,15 +260,15 @@ public async override Task WorkActionAsync()
260260
FeedResultData feedResultData = await feedProcessor.GetFeedDataAsync(feedParameters);
261261

262262
// Write the feed result token (toVersion) values to file.
263-
using (StreamWriter faultDataTokenFileWriter = new StreamWriter(faultDataTokenFilePath))
263+
using (StreamWriter faultDataTokenFileWriter = new(faultDataTokenFilePath))
264264
{
265265
faultDataTokenFileWriter.Write(feedParameters.LastFaultDataToken);
266266
}
267-
using (StreamWriter gpsTokenFileWriter = new StreamWriter(gpsTokenFilePath))
267+
using (StreamWriter gpsTokenFileWriter = new(gpsTokenFilePath))
268268
{
269269
gpsTokenFileWriter.Write(feedParameters.LastGpsDataToken);
270270
}
271-
using (StreamWriter statusDataTokenFileWriter = new StreamWriter(statusDataTokenFilePath))
271+
using (StreamWriter statusDataTokenFileWriter = new(statusDataTokenFilePath))
272272
{
273273
statusDataTokenFileWriter.Write(feedParameters.LastStatusDataToken);
274274
}
@@ -277,7 +277,7 @@ public async override Task WorkActionAsync()
277277
await ProcessFeedResultsAsync(feedResultData);
278278

279279
// Wait for the configured duration before executing the process again.
280-
ConsoleUtility.LogListItem($"Waiting for {FeedIntervalSeconds.ToString()} second(s) before starting next iteration...");
280+
ConsoleUtility.LogListItem($"Waiting for {FeedIntervalSeconds} second(s) before starting next iteration...");
281281
await Task.Delay(TimeSpan.FromSeconds(FeedIntervalSeconds));
282282
}
283283

@@ -296,7 +296,7 @@ public void WriteFeedResultStatsToConsole()
296296
vehicleListStringBuilder = new StringBuilder();
297297
foreach (TrackedVehicle trackedVehicle in trackedVehiclesWithNewData)
298298
{
299-
vehicleListStringBuilder.Append($"{trackedVehicle.DeviceId.ToString()}, ");
299+
_ = vehicleListStringBuilder.Append($"{trackedVehicle.DeviceId}, ");
300300
}
301301
vehicleList = vehicleListStringBuilder.ToString();
302302
vehicleList = vehicleList.Substring(0, vehicleList.Length - 2);
@@ -309,7 +309,7 @@ public void WriteFeedResultStatsToConsole()
309309
vehicleListStringBuilder = new StringBuilder();
310310
foreach (TrackedVehicle trackedVehicle in trackedVehiclesWithNewData)
311311
{
312-
vehicleListStringBuilder.Append($"{trackedVehicle.DeviceId.ToString()}, ");
312+
_ = vehicleListStringBuilder.Append($"{trackedVehicle.DeviceId}, ");
313313
}
314314
vehicleList = vehicleListStringBuilder.ToString();
315315
vehicleList = vehicleList.Substring(0, vehicleList.Length - 2);
@@ -322,7 +322,7 @@ public void WriteFeedResultStatsToConsole()
322322
vehicleListStringBuilder = new StringBuilder();
323323
foreach (TrackedVehicle trackedVehicle in trackedVehiclesWithNewData)
324324
{
325-
vehicleListStringBuilder.Append($"{trackedVehicle.DeviceId.ToString()}, ");
325+
_ = vehicleListStringBuilder.Append($"{trackedVehicle.DeviceId}, ");
326326
}
327327
vehicleList = vehicleListStringBuilder.ToString();
328328
vehicleList = vehicleList.Substring(0, vehicleList.Length - 2);

Geotab.DataOnlyPlan.API.Examples.FleetMonitor/FeedProcessor.cs

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ public FeedProcessor(string server, string database, string user, string passwor
5353
public FeedProcessor(GeotabDataOnlyPlanAPI api, bool useFaultDataFeed, bool useStatusDataFeed)
5454
{
5555
this.api = api;
56-
api.AuthenticateAsync();
56+
_ = api.AuthenticateAsync();
5757
controllerCache = new Dictionary<Id, Controller>();
5858
deviceCache = new Dictionary<Id, Device>();
5959
diagnosticCache = new Dictionary<Id, Diagnostic>();
@@ -166,7 +166,7 @@ async Task<FailureMode> GetFailureModeAsync(FailureMode failureMode)
166166
/// <returns><see cref="FeedResultData"/></returns>
167167
public async Task<FeedResultData> GetFeedDataAsync(FeedParameters feedParameters)
168168
{
169-
FeedResultData feedResults = new FeedResultData(new List<LogRecord>(), new List<StatusData>(), new List<FaultData>());
169+
FeedResultData feedResults = new(new List<LogRecord>(), new List<StatusData>(), new List<FaultData>());
170170
FeedResult<LogRecord> feedLogRecordData;
171171
FeedResult<StatusData> feedStatusData = null;
172172
FeedResult<FaultData> feedFaultData = null;
@@ -182,16 +182,16 @@ public async Task<FeedResultData> GetFeedDataAsync(FeedParameters feedParameters
182182
feedStartTime = feedParameters.FeedStartSpecificTimeUTC;
183183
}
184184
feedLogRecordData = await api.GetFeedLogRecordAsync(feedStartTime);
185-
ConsoleUtility.LogListItem("GPS log records received:", feedLogRecordData.Data.Count().ToString(), Common.ConsoleColorForListItems, (feedLogRecordData.Data.Count() > 0) ? Common.ConsoleColorForChangedData : Common.ConsoleColorForUnchangedData);
185+
ConsoleUtility.LogListItem("GPS log records received:", feedLogRecordData.Data.Count.ToString(), Common.ConsoleColorForListItems, (feedLogRecordData.Data.Count > 0) ? Common.ConsoleColorForChangedData : Common.ConsoleColorForUnchangedData);
186186
if (UseStatusDataFeed == true)
187187
{
188188
feedStatusData = await api.GetFeedStatusDataAsync(feedStartTime);
189-
ConsoleUtility.LogListItem("StatusData records received:", feedStatusData.Data.Count().ToString(), Common.ConsoleColorForListItems, (feedStatusData.Data.Count() > 0) ? Common.ConsoleColorForChangedData : Common.ConsoleColorForUnchangedData);
189+
ConsoleUtility.LogListItem("StatusData records received:", feedStatusData.Data.Count.ToString(), Common.ConsoleColorForListItems, (feedStatusData.Data.Count > 0) ? Common.ConsoleColorForChangedData : Common.ConsoleColorForUnchangedData);
190190
}
191191
if (UseFaultDataFeed == true)
192192
{
193193
feedFaultData = await api.GetFeedFaultDataAsync(feedStartTime);
194-
ConsoleUtility.LogListItem("FaultData records received:", feedFaultData.Data.Count().ToString(), Common.ConsoleColorForListItems, (feedFaultData.Data.Count() > 0) ? Common.ConsoleColorForChangedData : Common.ConsoleColorForUnchangedData);
194+
ConsoleUtility.LogListItem("FaultData records received:", feedFaultData.Data.Count.ToString(), Common.ConsoleColorForListItems, (feedFaultData.Data.Count > 0) ? Common.ConsoleColorForChangedData : Common.ConsoleColorForUnchangedData);
195195
}
196196
// Switch to FeedResultToken for subsequent calls.
197197
feedParameters.FeedStartOption = Common.FeedStartOption.FeedResultToken;
@@ -200,16 +200,16 @@ public async Task<FeedResultData> GetFeedDataAsync(FeedParameters feedParameters
200200
{
201201
// If the feeds are to be called based on feed result token, use the tokens returned in the toVersion of previous GetFeed() calls (or loaded from file, if continuing where processing last left-off) to populate the fromVersion parameter when making the next GetFeed() calls.
202202
feedLogRecordData = await api.GetFeedLogRecordAsync(feedParameters.LastGpsDataToken);
203-
ConsoleUtility.LogListItem("GPS log records received:", feedLogRecordData.Data.Count().ToString(), Common.ConsoleColorForListItems, (feedLogRecordData.Data.Count() > 0) ? Common.ConsoleColorForChangedData : Common.ConsoleColorForUnchangedData);
203+
ConsoleUtility.LogListItem("GPS log records received:", feedLogRecordData.Data.Count.ToString(), Common.ConsoleColorForListItems, (feedLogRecordData.Data.Count > 0) ? Common.ConsoleColorForChangedData : Common.ConsoleColorForUnchangedData);
204204
if (UseStatusDataFeed == true)
205205
{
206206
feedStatusData = await api.GetFeedStatusDataAsync(feedParameters.LastStatusDataToken);
207-
ConsoleUtility.LogListItem("StatusData records received:", feedStatusData.Data.Count().ToString(), Common.ConsoleColorForListItems, (feedStatusData.Data.Count() > 0) ? Common.ConsoleColorForChangedData : Common.ConsoleColorForUnchangedData);
207+
ConsoleUtility.LogListItem("StatusData records received:", feedStatusData.Data.Count.ToString(), Common.ConsoleColorForListItems, (feedStatusData.Data.Count > 0) ? Common.ConsoleColorForChangedData : Common.ConsoleColorForUnchangedData);
208208
}
209209
if (UseFaultDataFeed == true)
210210
{
211211
feedFaultData = await api.GetFeedFaultDataAsync(feedParameters.LastFaultDataToken);
212-
ConsoleUtility.LogListItem("FaultData records received:", feedFaultData.Data.Count().ToString(), Common.ConsoleColorForListItems, (feedFaultData.Data.Count() > 0) ? Common.ConsoleColorForChangedData : Common.ConsoleColorForUnchangedData);
212+
ConsoleUtility.LogListItem("FaultData records received:", feedFaultData.Data.Count.ToString(), Common.ConsoleColorForListItems, (feedFaultData.Data.Count > 0) ? Common.ConsoleColorForChangedData : Common.ConsoleColorForUnchangedData);
213213
}
214214
}
215215

@@ -307,7 +307,7 @@ async Task UpdateControllerCacheAsync()
307307
}
308308

309309
ConsoleUtility.LogComplete(Common.ConsoleColorForUnchangedData);
310-
ConsoleUtility.LogListItem($"Controller cache records added/updated:", returnedControllers.Count.ToString(), Common.ConsoleColorForListItems, (returnedControllers.Count() > 0) ? Common.ConsoleColorForChangedData : Common.ConsoleColorForUnchangedData);
310+
ConsoleUtility.LogListItem($"Controller cache records added/updated:", returnedControllers.Count.ToString(), Common.ConsoleColorForListItems, (returnedControllers.Count > 0) ? Common.ConsoleColorForChangedData : Common.ConsoleColorForUnchangedData);
311311
}
312312

313313
/// <summary>
@@ -343,7 +343,7 @@ async Task UpdateDeviceCacheAsync()
343343
}
344344

345345
ConsoleUtility.LogComplete(Common.ConsoleColorForUnchangedData);
346-
ConsoleUtility.LogListItem($"Device cache records added/updated:", feedResult.Data.Count().ToString(), Common.ConsoleColorForListItems, (feedResult.Data.Count() > 0) ? Common.ConsoleColorForChangedData : Common.ConsoleColorForUnchangedData);
346+
ConsoleUtility.LogListItem($"Device cache records added/updated:", feedResult.Data.Count.ToString(), Common.ConsoleColorForListItems, (feedResult.Data.Count > 0) ? Common.ConsoleColorForChangedData : Common.ConsoleColorForUnchangedData);
347347
}
348348

349349
/// <summary>
@@ -394,7 +394,7 @@ async Task UpdateDiagnosticCacheAsync()
394394
}
395395
}
396396
ConsoleUtility.LogComplete(Common.ConsoleColorForUnchangedData);
397-
ConsoleUtility.LogListItem($"Diagnostics added/updated:", feedResult.Data.Count().ToString(), Common.ConsoleColorForListItems, (feedResult.Data.Count() > 0) ? Common.ConsoleColorForChangedData : Common.ConsoleColorForUnchangedData);
397+
ConsoleUtility.LogListItem($"Diagnostics added/updated:", feedResult.Data.Count.ToString(), Common.ConsoleColorForListItems, (feedResult.Data.Count > 0) ? Common.ConsoleColorForChangedData : Common.ConsoleColorForUnchangedData);
398398
}
399399

400400
/// <summary>
@@ -419,7 +419,7 @@ async Task UpdateFailureModeCacheAsync()
419419
}
420420

421421
ConsoleUtility.LogComplete(Common.ConsoleColorForUnchangedData);
422-
ConsoleUtility.LogListItem($"FailureMode cache records added/updated:", returnedFailureModes.Count.ToString(), Common.ConsoleColorForListItems, (returnedFailureModes.Count() > 0) ? Common.ConsoleColorForChangedData : Common.ConsoleColorForUnchangedData);
422+
ConsoleUtility.LogListItem($"FailureMode cache records added/updated:", returnedFailureModes.Count.ToString(), Common.ConsoleColorForListItems, (returnedFailureModes.Count > 0) ? Common.ConsoleColorForChangedData : Common.ConsoleColorForUnchangedData);
423423
}
424424

425425
/// <summary>
@@ -444,7 +444,7 @@ async Task UpdateUnitOfMeasureCacheAsync()
444444
}
445445

446446
ConsoleUtility.LogComplete(Common.ConsoleColorForUnchangedData);
447-
ConsoleUtility.LogListItem($"UnitsOfMeasure cache records added/updated:", returnedUnitsOfMeasure.Count.ToString(), Common.ConsoleColorForListItems, (returnedUnitsOfMeasure.Count() > 0) ? Common.ConsoleColorForChangedData : Common.ConsoleColorForUnchangedData);
447+
ConsoleUtility.LogListItem($"UnitsOfMeasure cache records added/updated:", returnedUnitsOfMeasure.Count.ToString(), Common.ConsoleColorForListItems, (returnedUnitsOfMeasure.Count > 0) ? Common.ConsoleColorForChangedData : Common.ConsoleColorForUnchangedData);
448448
}
449449
}
450450
}

Geotab.DataOnlyPlan.API.Examples.FleetMonitor/Geotab.DataOnlyPlan.API.Examples.FleetMonitor.csproj

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,15 @@
22

33
<PropertyGroup>
44
<OutputType>Exe</OutputType>
5-
<TargetFramework>netcoreapp2.2</TargetFramework>
5+
<TargetFramework>net5.0</TargetFramework>
6+
<Company>Geotab Inc.</Company>
7+
<Product>Geotab Data-Only Plan API Examples - Fleet Monitor</Product>
8+
<Authors>Geotab Inc.</Authors>
9+
<Version>1.0.2101.1</Version>
610
</PropertyGroup>
711

812
<ItemGroup>
9-
<PackageReference Include="Geotab.DataOnlyPlan.API" Version="1.0.1904.1" />
13+
<PackageReference Include="Geotab.DataOnlyPlan.API" Version="1.0.2101.1" />
1014
</ItemGroup>
1115

1216
</Project>
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
// This file is used by Code Analysis to maintain SuppressMessage
2+
// attributes that are applied to this project.
3+
// Project-level suppressions either have no target or are given
4+
// a specific target and scoped to a namespace, type, member, etc.
5+
6+
using System.Diagnostics.CodeAnalysis;
7+
8+
[assembly: SuppressMessage("Style", "IDE0063:Use simple 'using' statement", Justification = "<Pending>", Scope = "member", Target = "~M:Geotab.DataOnlyPlan.API.Examples.FleetMonitor.DatabaseWorker.#ctor(System.String,System.String,System.String,System.String,System.String,System.String,System.Int64,System.Int32,Geotab.DataOnlyPlan.API.Examples.FleetMonitor.Utilities.Common.FeedStartOption,System.Nullable{System.DateTime},System.Boolean,System.Collections.Generic.IList{Geotab.Checkmate.ObjectModel.Device},System.Collections.Generic.IList{Geotab.Checkmate.ObjectModel.Engine.Diagnostic})")]
9+
[assembly: SuppressMessage("Style", "IDE0063:Use simple 'using' statement", Justification = "<Pending>", Scope = "member", Target = "~M:Geotab.DataOnlyPlan.API.Examples.FleetMonitor.TrackedVehicle.WriteDataToFileAsync~System.Threading.Tasks.Task")]
10+
[assembly: SuppressMessage("Style", "IDE0063:Use simple 'using' statement", Justification = "<Pending>", Scope = "member", Target = "~M:Geotab.DataOnlyPlan.API.Examples.FleetMonitor.Utilities.CsvUtility.CsvToList``1(System.IO.Stream,System.Collections.Generic.Dictionary{System.String,System.String},System.Int32,System.Int32,System.Char,System.Char)~System.Collections.Generic.List{``0}")]
11+
[assembly: SuppressMessage("Style", "IDE0057:Use range operator", Justification = "<Pending>", Scope = "member", Target = "~M:Geotab.DataOnlyPlan.API.Examples.FleetMonitor.DatabaseWorker.WriteFeedResultStatsToConsole")]

0 commit comments

Comments
 (0)