Skip to content

Commit

Permalink
Updated to v1.0.2101.1.
Browse files Browse the repository at this point in the history
  • Loading branch information
sdietz888 committed May 20, 2021
1 parent 9b6ad51 commit f305d1e
Show file tree
Hide file tree
Showing 35 changed files with 265 additions and 236 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -14,3 +14,5 @@
/Geotab.DataOnlyPlan.API.Examples/obj
/Geotab.DataOnlyPlan.API.Examples.FleetMonitor/bin/Debug/netcoreapp2.2
/Geotab.DataOnlyPlan.API.Examples.FleetMonitor/obj
/Geotab.DataOnlyPlan.API.Examples/bin/Debug/net5.0
/Geotab.DataOnlyPlan.API.Examples.FleetMonitor/bin/Debug/net5.0
Binary file removed .vs/GitHub Copy/v16/.suo
Binary file not shown.
3 changes: 0 additions & 3 deletions .vs/ProjectSettings.json

This file was deleted.

7 changes: 0 additions & 7 deletions .vs/VSWorkspaceState.json

This file was deleted.

Binary file removed .vs/slnx.sqlite
Binary file not shown.
30 changes: 15 additions & 15 deletions Geotab.DataOnlyPlan.API.Examples.FleetMonitor/DatabaseWorker.cs
Original file line number Diff line number Diff line change
Expand Up @@ -93,26 +93,26 @@ public DatabaseWorker(string user, string password, string database, string serv
{
if (File.Exists(faultDataTokenFilePath))
{
using (StreamReader faultDataTokenFileReader = new StreamReader(faultDataTokenFilePath))
using (StreamReader faultDataTokenFileReader = new(faultDataTokenFilePath))
{
String faultDataTokenString = faultDataTokenFileReader.ReadToEnd();
long.TryParse(faultDataTokenString, out faultDataToken);
_ = long.TryParse(faultDataTokenString, out faultDataToken);
}
}
if (File.Exists(gpsTokenFilePath))
{
using (StreamReader gpsTokenFileReader = new StreamReader(gpsTokenFilePath))
using (StreamReader gpsTokenFileReader = new(gpsTokenFilePath))
{
String gpsTokenString = gpsTokenFileReader.ReadToEnd();
long.TryParse(gpsTokenString, out gpsToken);
_ = long.TryParse(gpsTokenString, out gpsToken);
}
}
if (File.Exists(statusDataTokenFilePath))
{
using (StreamReader statusDataTokenFileReader = new StreamReader(statusDataTokenFilePath))
using (StreamReader statusDataTokenFileReader = new(statusDataTokenFilePath))
{
String statusDataTokenString = statusDataTokenFileReader.ReadToEnd();
long.TryParse(statusDataTokenString, out statusDataToken);
_ = long.TryParse(statusDataTokenString, out statusDataToken);
}
}
}
Expand All @@ -131,13 +131,13 @@ public DatabaseWorker(string user, string password, string database, string serv
/// <returns></returns>
TrackedVehicle CreateTrackedVehicle(Device device)
{
TrackedVehicle trackedVehicle = new TrackedVehicle(device, OutputFolder, MaximumFileSizeInBytes);
TrackedVehicle trackedVehicle = new(device, OutputFolder, MaximumFileSizeInBytes);
if (DiagnosticsToTrack != null && DiagnosticsToTrack.Count > 0)
{
// Add TrackedDiagnostics.
foreach (Diagnostic diagnosticToTrack in DiagnosticsToTrack)
{
TrackedDiagnostic trackedDiagnostic = new TrackedDiagnostic(trackedVehicle.Device, diagnosticToTrack, trackedVehicle.FaultDataFilePath, trackedVehicle.StatusDataFilePath, MaximumFileSizeInBytes);
TrackedDiagnostic trackedDiagnostic = new(trackedVehicle.Device, diagnosticToTrack, trackedVehicle.FaultDataFilePath, trackedVehicle.StatusDataFilePath, MaximumFileSizeInBytes);
trackedVehicle.TrackedDiagnostics.Add(trackedDiagnostic);
}
}
Expand Down Expand Up @@ -260,15 +260,15 @@ public async override Task WorkActionAsync()
FeedResultData feedResultData = await feedProcessor.GetFeedDataAsync(feedParameters);

// Write the feed result token (toVersion) values to file.
using (StreamWriter faultDataTokenFileWriter = new StreamWriter(faultDataTokenFilePath))
using (StreamWriter faultDataTokenFileWriter = new(faultDataTokenFilePath))
{
faultDataTokenFileWriter.Write(feedParameters.LastFaultDataToken);
}
using (StreamWriter gpsTokenFileWriter = new StreamWriter(gpsTokenFilePath))
using (StreamWriter gpsTokenFileWriter = new(gpsTokenFilePath))
{
gpsTokenFileWriter.Write(feedParameters.LastGpsDataToken);
}
using (StreamWriter statusDataTokenFileWriter = new StreamWriter(statusDataTokenFilePath))
using (StreamWriter statusDataTokenFileWriter = new(statusDataTokenFilePath))
{
statusDataTokenFileWriter.Write(feedParameters.LastStatusDataToken);
}
Expand All @@ -277,7 +277,7 @@ public async override Task WorkActionAsync()
await ProcessFeedResultsAsync(feedResultData);

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

Expand All @@ -296,7 +296,7 @@ public void WriteFeedResultStatsToConsole()
vehicleListStringBuilder = new StringBuilder();
foreach (TrackedVehicle trackedVehicle in trackedVehiclesWithNewData)
{
vehicleListStringBuilder.Append($"{trackedVehicle.DeviceId.ToString()}, ");
_ = vehicleListStringBuilder.Append($"{trackedVehicle.DeviceId}, ");
}
vehicleList = vehicleListStringBuilder.ToString();
vehicleList = vehicleList.Substring(0, vehicleList.Length - 2);
Expand All @@ -309,7 +309,7 @@ public void WriteFeedResultStatsToConsole()
vehicleListStringBuilder = new StringBuilder();
foreach (TrackedVehicle trackedVehicle in trackedVehiclesWithNewData)
{
vehicleListStringBuilder.Append($"{trackedVehicle.DeviceId.ToString()}, ");
_ = vehicleListStringBuilder.Append($"{trackedVehicle.DeviceId}, ");
}
vehicleList = vehicleListStringBuilder.ToString();
vehicleList = vehicleList.Substring(0, vehicleList.Length - 2);
Expand All @@ -322,7 +322,7 @@ public void WriteFeedResultStatsToConsole()
vehicleListStringBuilder = new StringBuilder();
foreach (TrackedVehicle trackedVehicle in trackedVehiclesWithNewData)
{
vehicleListStringBuilder.Append($"{trackedVehicle.DeviceId.ToString()}, ");
_ = vehicleListStringBuilder.Append($"{trackedVehicle.DeviceId}, ");
}
vehicleList = vehicleListStringBuilder.ToString();
vehicleList = vehicleList.Substring(0, vehicleList.Length - 2);
Expand Down
26 changes: 13 additions & 13 deletions Geotab.DataOnlyPlan.API.Examples.FleetMonitor/FeedProcessor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ public FeedProcessor(string server, string database, string user, string passwor
public FeedProcessor(GeotabDataOnlyPlanAPI api, bool useFaultDataFeed, bool useStatusDataFeed)
{
this.api = api;
api.AuthenticateAsync();
_ = api.AuthenticateAsync();
controllerCache = new Dictionary<Id, Controller>();
deviceCache = new Dictionary<Id, Device>();
diagnosticCache = new Dictionary<Id, Diagnostic>();
Expand Down Expand Up @@ -166,7 +166,7 @@ async Task<FailureMode> GetFailureModeAsync(FailureMode failureMode)
/// <returns><see cref="FeedResultData"/></returns>
public async Task<FeedResultData> GetFeedDataAsync(FeedParameters feedParameters)
{
FeedResultData feedResults = new FeedResultData(new List<LogRecord>(), new List<StatusData>(), new List<FaultData>());
FeedResultData feedResults = new(new List<LogRecord>(), new List<StatusData>(), new List<FaultData>());
FeedResult<LogRecord> feedLogRecordData;
FeedResult<StatusData> feedStatusData = null;
FeedResult<FaultData> feedFaultData = null;
Expand All @@ -182,16 +182,16 @@ public async Task<FeedResultData> GetFeedDataAsync(FeedParameters feedParameters
feedStartTime = feedParameters.FeedStartSpecificTimeUTC;
}
feedLogRecordData = await api.GetFeedLogRecordAsync(feedStartTime);
ConsoleUtility.LogListItem("GPS log records received:", feedLogRecordData.Data.Count().ToString(), Common.ConsoleColorForListItems, (feedLogRecordData.Data.Count() > 0) ? Common.ConsoleColorForChangedData : Common.ConsoleColorForUnchangedData);
ConsoleUtility.LogListItem("GPS log records received:", feedLogRecordData.Data.Count.ToString(), Common.ConsoleColorForListItems, (feedLogRecordData.Data.Count > 0) ? Common.ConsoleColorForChangedData : Common.ConsoleColorForUnchangedData);
if (UseStatusDataFeed == true)
{
feedStatusData = await api.GetFeedStatusDataAsync(feedStartTime);
ConsoleUtility.LogListItem("StatusData records received:", feedStatusData.Data.Count().ToString(), Common.ConsoleColorForListItems, (feedStatusData.Data.Count() > 0) ? Common.ConsoleColorForChangedData : Common.ConsoleColorForUnchangedData);
ConsoleUtility.LogListItem("StatusData records received:", feedStatusData.Data.Count.ToString(), Common.ConsoleColorForListItems, (feedStatusData.Data.Count > 0) ? Common.ConsoleColorForChangedData : Common.ConsoleColorForUnchangedData);
}
if (UseFaultDataFeed == true)
{
feedFaultData = await api.GetFeedFaultDataAsync(feedStartTime);
ConsoleUtility.LogListItem("FaultData records received:", feedFaultData.Data.Count().ToString(), Common.ConsoleColorForListItems, (feedFaultData.Data.Count() > 0) ? Common.ConsoleColorForChangedData : Common.ConsoleColorForUnchangedData);
ConsoleUtility.LogListItem("FaultData records received:", feedFaultData.Data.Count.ToString(), Common.ConsoleColorForListItems, (feedFaultData.Data.Count > 0) ? Common.ConsoleColorForChangedData : Common.ConsoleColorForUnchangedData);
}
// Switch to FeedResultToken for subsequent calls.
feedParameters.FeedStartOption = Common.FeedStartOption.FeedResultToken;
Expand All @@ -200,16 +200,16 @@ public async Task<FeedResultData> GetFeedDataAsync(FeedParameters feedParameters
{
// 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.
feedLogRecordData = await api.GetFeedLogRecordAsync(feedParameters.LastGpsDataToken);
ConsoleUtility.LogListItem("GPS log records received:", feedLogRecordData.Data.Count().ToString(), Common.ConsoleColorForListItems, (feedLogRecordData.Data.Count() > 0) ? Common.ConsoleColorForChangedData : Common.ConsoleColorForUnchangedData);
ConsoleUtility.LogListItem("GPS log records received:", feedLogRecordData.Data.Count.ToString(), Common.ConsoleColorForListItems, (feedLogRecordData.Data.Count > 0) ? Common.ConsoleColorForChangedData : Common.ConsoleColorForUnchangedData);
if (UseStatusDataFeed == true)
{
feedStatusData = await api.GetFeedStatusDataAsync(feedParameters.LastStatusDataToken);
ConsoleUtility.LogListItem("StatusData records received:", feedStatusData.Data.Count().ToString(), Common.ConsoleColorForListItems, (feedStatusData.Data.Count() > 0) ? Common.ConsoleColorForChangedData : Common.ConsoleColorForUnchangedData);
ConsoleUtility.LogListItem("StatusData records received:", feedStatusData.Data.Count.ToString(), Common.ConsoleColorForListItems, (feedStatusData.Data.Count > 0) ? Common.ConsoleColorForChangedData : Common.ConsoleColorForUnchangedData);
}
if (UseFaultDataFeed == true)
{
feedFaultData = await api.GetFeedFaultDataAsync(feedParameters.LastFaultDataToken);
ConsoleUtility.LogListItem("FaultData records received:", feedFaultData.Data.Count().ToString(), Common.ConsoleColorForListItems, (feedFaultData.Data.Count() > 0) ? Common.ConsoleColorForChangedData : Common.ConsoleColorForUnchangedData);
ConsoleUtility.LogListItem("FaultData records received:", feedFaultData.Data.Count.ToString(), Common.ConsoleColorForListItems, (feedFaultData.Data.Count > 0) ? Common.ConsoleColorForChangedData : Common.ConsoleColorForUnchangedData);
}
}

Expand Down Expand Up @@ -307,7 +307,7 @@ async Task UpdateControllerCacheAsync()
}

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

/// <summary>
Expand Down Expand Up @@ -343,7 +343,7 @@ async Task UpdateDeviceCacheAsync()
}

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

/// <summary>
Expand Down Expand Up @@ -394,7 +394,7 @@ async Task UpdateDiagnosticCacheAsync()
}
}
ConsoleUtility.LogComplete(Common.ConsoleColorForUnchangedData);
ConsoleUtility.LogListItem($"Diagnostics added/updated:", feedResult.Data.Count().ToString(), Common.ConsoleColorForListItems, (feedResult.Data.Count() > 0) ? Common.ConsoleColorForChangedData : Common.ConsoleColorForUnchangedData);
ConsoleUtility.LogListItem($"Diagnostics added/updated:", feedResult.Data.Count.ToString(), Common.ConsoleColorForListItems, (feedResult.Data.Count > 0) ? Common.ConsoleColorForChangedData : Common.ConsoleColorForUnchangedData);
}

/// <summary>
Expand All @@ -419,7 +419,7 @@ async Task UpdateFailureModeCacheAsync()
}

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

/// <summary>
Expand All @@ -444,7 +444,7 @@ async Task UpdateUnitOfMeasureCacheAsync()
}

ConsoleUtility.LogComplete(Common.ConsoleColorForUnchangedData);
ConsoleUtility.LogListItem($"UnitsOfMeasure cache records added/updated:", returnedUnitsOfMeasure.Count.ToString(), Common.ConsoleColorForListItems, (returnedUnitsOfMeasure.Count() > 0) ? Common.ConsoleColorForChangedData : Common.ConsoleColorForUnchangedData);
ConsoleUtility.LogListItem($"UnitsOfMeasure cache records added/updated:", returnedUnitsOfMeasure.Count.ToString(), Common.ConsoleColorForListItems, (returnedUnitsOfMeasure.Count > 0) ? Common.ConsoleColorForChangedData : Common.ConsoleColorForUnchangedData);
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,15 @@

<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>netcoreapp2.2</TargetFramework>
<TargetFramework>net5.0</TargetFramework>
<Company>Geotab Inc.</Company>
<Product>Geotab Data-Only Plan API Examples - Fleet Monitor</Product>
<Authors>Geotab Inc.</Authors>
<Version>1.0.2101.1</Version>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Geotab.DataOnlyPlan.API" Version="1.0.1904.1" />
<PackageReference Include="Geotab.DataOnlyPlan.API" Version="1.0.2101.1" />
</ItemGroup>

</Project>
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
// This file is used by Code Analysis to maintain SuppressMessage
// attributes that are applied to this project.
// Project-level suppressions either have no target or are given
// a specific target and scoped to a namespace, type, member, etc.

using System.Diagnostics.CodeAnalysis;

[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})")]
[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")]
[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}")]
[assembly: SuppressMessage("Style", "IDE0057:Use range operator", Justification = "<Pending>", Scope = "member", Target = "~M:Geotab.DataOnlyPlan.API.Examples.FleetMonitor.DatabaseWorker.WriteFeedResultStatsToConsole")]
Loading

0 comments on commit f305d1e

Please sign in to comment.