From f305d1e3759fb4239b6fab39893468da92997691 Mon Sep 17 00:00:00 2001 From: Stephen Dietz Date: Thu, 20 May 2021 15:18:36 -0400 Subject: [PATCH] Updated to v1.0.2101.1. --- .gitignore | 2 + .vs/GitHub Copy/v16/.suo | Bin 14848 -> 0 bytes .vs/ProjectSettings.json | 3 - .vs/VSWorkspaceState.json | 7 -- .vs/slnx.sqlite | Bin 90112 -> 0 bytes .../DatabaseWorker.cs | 30 ++++---- .../FeedProcessor.cs | 26 +++---- ...aOnlyPlan.API.Examples.FleetMonitor.csproj | 8 ++- .../GlobalSuppressions.cs | 11 +++ .../Program.cs | 14 ++-- .../TrackedDiagnostic.cs | 67 ++++++------------ .../TrackedGpsData.cs | 6 +- .../TrackedVehicle.cs | 12 ++-- .../Utilities/ConsoleUtility.cs | 43 +++++++++-- .../Examples/AddDriverChangeAsyncExample.cs | 2 +- .../Examples/AddTextMessageAsyncExample.cs | 26 +++---- .../Examples/AddUserAsyncExample.cs | 4 +- .../Examples/GenerateCaptchaAsyncExample.cs | 11 ++- .../Examples/GetFeedCustomDataAsyncExample.cs | 20 +++--- .../Examples/GetFeedDeviceAsyncExample.cs | 2 +- .../Examples/GetFeedDiagnosticAsyncExample.cs | 2 +- .../GetFeedDriverChangeAsyncExample.cs | 2 +- .../Examples/GetFeedFaultDataAsyncExample.cs | 20 +++--- .../Examples/GetFeedIoxAddOnAsyncExample.cs | 26 ++++--- .../Examples/GetFeedLogRecordAsyncExample.cs | 20 +++--- .../Examples/GetFeedStatusDataAsyncExample.cs | 20 +++--- .../Examples/GetFeedTripAsyncExample.cs | 20 +++--- .../Examples/GetFeedUserAsyncExample.cs | 2 +- .../Examples/SetUserAsyncExample.cs | 2 +- .../Geotab.DataOnlyPlan.API.Examples.csproj | 8 ++- Geotab.DataOnlyPlan.API.Examples/Program.cs | 8 +-- .../Utilities/ConsoleUtility.cs | 46 +++++++++--- .../Utilities/ExampleUtility.cs | 8 +-- LICENSE | 21 ------ README.md | 2 +- 35 files changed, 265 insertions(+), 236 deletions(-) delete mode 100644 .vs/GitHub Copy/v16/.suo delete mode 100644 .vs/ProjectSettings.json delete mode 100644 .vs/VSWorkspaceState.json delete mode 100644 .vs/slnx.sqlite create mode 100644 Geotab.DataOnlyPlan.API.Examples.FleetMonitor/GlobalSuppressions.cs delete mode 100644 LICENSE diff --git a/.gitignore b/.gitignore index 2f26794..53905a1 100644 --- a/.gitignore +++ b/.gitignore @@ -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 diff --git a/.vs/GitHub Copy/v16/.suo b/.vs/GitHub Copy/v16/.suo deleted file mode 100644 index 2e4f6cf6ef1e04c1da35887527a87a31be319a4c..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 14848 zcmeHO&2Jk;6dyMfX!$Iq1xld?3KZy?U9V$%3xqncomL`E)U*YJIjp^#kk*MK+bKj% zBqRhUu5jW2LISBL=mCMm5rKq+iiD6jAOU{>H-wN7l;3Z6Cth!z?bc2|LOs^(e9wFH z=FNL=-mbqtyXDspKHc$~2!tUqApSkKNnG!%k0HN7mTwp0I^Hi-UkZ zgjYw}sl(K*_fM;Iz^QSvdFVFvN$n*Sj+_qKv z`^Wb4mzM(E7k?xl_{+?bAGqJLo;<;Qm1W9!%6*o($JFoKf4T3hPolgN@jk@+5qBZR z5g$N&5b+_z-G~n(K7#ltBF8<3^l`)|yt0J(B+4qH=GE)I_B8St#H_ClQ}sg!3XF>d zSQ%B=HFHj!_E{cz)YL)4ut58R(@NVvtgmcKAoG=17>31D6DPzhtera2sCJK>YbW5x zP@oM$JY;=Xs-SU?*Wrj`?VW&yH{)1+lj0S}25Z9JBV`(46QPak=RJsaP*nJP(UKM$$=>Iu@hK0!=KbWQvXZ>TE){fCjrrN zb|C>hTmxrN1G-ow93O~@c50#phc1LN;y32FaZB7rsYL@tN}4ptUwiOsY-Y~>01uk3wP z_#8|e82a-6T9^Or_Lsbm&N-HV<=juh>=E)mr#zc37bO zLthkqP*LGi_pfIEwcsz}w3mTJH4OZU{Y9M~6~15p1mz!3{j4MV7TaV~yVPl+MEyg! zGPGJ&&r$Xr@tTA1`};5X@7maZ$t8abE#Els%b9suj+)Mzjiy~cdbr#1w1atmsgd5s zb97&6Y%!j%&z!VN2j?*LoLP-e)N9A>O0!WKwQEhY9M79gQyHJDF2*N{Bl_~v(_=G@ zN^z!YH-?rjc7m!o7tc)`EKSxH>J__`uQdthKas zN*^}Vq?Xi`Vm6miQie9D7)4c6^t4tq)U2A#=GEm5Vpy3xvQNeDl%BFPX*;Vaww*E+ zO|w+Rw3D`?s-{{o)TybdioTrxGM0C{=aR)jCRNas;Y>}X zUdWoh{olIhu0#7DUtqYphdO{K=|aJ8|F41nC&qU}eg98%{eLz2e$aWmI_99XA!S;IUySl_9^ZtO;3q5KHlD}5w1C^`ENpb@Z0*f$*YEnXd;Nbg z>i3lD1*k(+4LoGq@{+n&T`HQ@M)<|SWBgw6m*;1_rZ#q#KDeehgquebrBU3#n(#U- z;P!Lj{qJ?%S9<^H3#R=^nY?1?#l%}t*Y#O!RO|!Q#&AaBpky7?I|)jb9M6vb&2BvK zMz`V6+IDDfI<%I4PDPC44qSC+oIpx%cN}ML0&|wyZpPj3-N(8pe{=eWFaC%7pS+m! zf35Go=uv*tj~R=4SS~@owSX;s;ePabsq@cssq?WOsW1KD-Qr35^IgVzkb<4o*em}~ zcS!#QvWE~kCFA{_HE9BG)*7&>B6K&d~z8xT~-xa zPYo)mWHzf9X=_Ruw9P5qNZGcYHWI3;YpSv2@RaXyw}=I_g)CAzx-5u8^7l`>cYSB? z2dA}|QB_lATOZVwbT(rssdT2I7?x%$hFMAK6>BPOrHp0&EMJ^P*zr#LECH4-XLZFG zvSAy@yhw$YuzfbQryl}Rc f(fs~5_yu!A#PKa1HI@eL#AjHbsQCN}T2KE08dySL diff --git a/.vs/ProjectSettings.json b/.vs/ProjectSettings.json deleted file mode 100644 index f8b4888..0000000 --- a/.vs/ProjectSettings.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "CurrentProjectSetting": null -} \ No newline at end of file diff --git a/.vs/VSWorkspaceState.json b/.vs/VSWorkspaceState.json deleted file mode 100644 index d282b3b..0000000 --- a/.vs/VSWorkspaceState.json +++ /dev/null @@ -1,7 +0,0 @@ -{ - "ExpandedNodes": [ - "" - ], - "SelectedNode": "\\README.md", - "PreviewInSolutionExplorer": false -} \ No newline at end of file diff --git a/.vs/slnx.sqlite b/.vs/slnx.sqlite deleted file mode 100644 index 63885a8747b288c1043bc0d9113730d2719a856a..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 90112 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 diff --git a/Geotab.DataOnlyPlan.API.Examples.FleetMonitor/DatabaseWorker.cs b/Geotab.DataOnlyPlan.API.Examples.FleetMonitor/DatabaseWorker.cs index f907205..f047d07 100644 --- a/Geotab.DataOnlyPlan.API.Examples.FleetMonitor/DatabaseWorker.cs +++ b/Geotab.DataOnlyPlan.API.Examples.FleetMonitor/DatabaseWorker.cs @@ -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); } } } @@ -131,13 +131,13 @@ public DatabaseWorker(string user, string password, string database, string serv /// 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); } } @@ -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); } @@ -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)); } @@ -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); @@ -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); @@ -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); diff --git a/Geotab.DataOnlyPlan.API.Examples.FleetMonitor/FeedProcessor.cs b/Geotab.DataOnlyPlan.API.Examples.FleetMonitor/FeedProcessor.cs index 4b48e02..8a20f90 100644 --- a/Geotab.DataOnlyPlan.API.Examples.FleetMonitor/FeedProcessor.cs +++ b/Geotab.DataOnlyPlan.API.Examples.FleetMonitor/FeedProcessor.cs @@ -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(); deviceCache = new Dictionary(); diagnosticCache = new Dictionary(); @@ -166,7 +166,7 @@ async Task GetFailureModeAsync(FailureMode failureMode) /// public async Task GetFeedDataAsync(FeedParameters feedParameters) { - FeedResultData feedResults = new FeedResultData(new List(), new List(), new List()); + FeedResultData feedResults = new(new List(), new List(), new List()); FeedResult feedLogRecordData; FeedResult feedStatusData = null; FeedResult feedFaultData = null; @@ -182,16 +182,16 @@ public async Task 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; @@ -200,16 +200,16 @@ public async Task 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); } } @@ -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); } /// @@ -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); } /// @@ -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); } /// @@ -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); } /// @@ -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); } } } \ No newline at end of file diff --git a/Geotab.DataOnlyPlan.API.Examples.FleetMonitor/Geotab.DataOnlyPlan.API.Examples.FleetMonitor.csproj b/Geotab.DataOnlyPlan.API.Examples.FleetMonitor/Geotab.DataOnlyPlan.API.Examples.FleetMonitor.csproj index 26d6549..f674142 100644 --- a/Geotab.DataOnlyPlan.API.Examples.FleetMonitor/Geotab.DataOnlyPlan.API.Examples.FleetMonitor.csproj +++ b/Geotab.DataOnlyPlan.API.Examples.FleetMonitor/Geotab.DataOnlyPlan.API.Examples.FleetMonitor.csproj @@ -2,11 +2,15 @@ Exe - netcoreapp2.2 + net5.0 + Geotab Inc. + Geotab Data-Only Plan API Examples - Fleet Monitor + Geotab Inc. + 1.0.2101.1 - + diff --git a/Geotab.DataOnlyPlan.API.Examples.FleetMonitor/GlobalSuppressions.cs b/Geotab.DataOnlyPlan.API.Examples.FleetMonitor/GlobalSuppressions.cs new file mode 100644 index 0000000..b298a7e --- /dev/null +++ b/Geotab.DataOnlyPlan.API.Examples.FleetMonitor/GlobalSuppressions.cs @@ -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 = "", 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 = "", Scope = "member", Target = "~M:Geotab.DataOnlyPlan.API.Examples.FleetMonitor.TrackedVehicle.WriteDataToFileAsync~System.Threading.Tasks.Task")] +[assembly: SuppressMessage("Style", "IDE0063:Use simple 'using' statement", Justification = "", 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 = "", Scope = "member", Target = "~M:Geotab.DataOnlyPlan.API.Examples.FleetMonitor.DatabaseWorker.WriteFeedResultStatsToConsole")] diff --git a/Geotab.DataOnlyPlan.API.Examples.FleetMonitor/Program.cs b/Geotab.DataOnlyPlan.API.Examples.FleetMonitor/Program.cs index 22e333b..feb0e3e 100644 --- a/Geotab.DataOnlyPlan.API.Examples.FleetMonitor/Program.cs +++ b/Geotab.DataOnlyPlan.API.Examples.FleetMonitor/Program.cs @@ -73,9 +73,9 @@ static async Task Main() { throw new ArgumentException($"The specified output folder, '{parentOutputFolder}', does not exist."); } - DirectoryInfo directoryInfo = new DirectoryInfo(parentOutputFolder); - string subfolderName = $"Output_{DateTime.Now.ToString("yyyyMMdd_HHmmss")}"; - directoryInfo.CreateSubdirectory(subfolderName); + DirectoryInfo directoryInfo = new(parentOutputFolder); + string subfolderName = $"Output_{DateTime.Now:yyyyMMdd_HHmmss}"; + _ = directoryInfo.CreateSubdirectory(subfolderName); outputFolder = Path.Combine(directoryInfo.FullName, subfolderName); // Validate and set maximum file size. @@ -182,7 +182,7 @@ static async Task Main() { if (feedIntervalSecondsInt < ShortestAllowedFeedIntervalSeconds) { - ConsoleUtility.LogListItem($"Note - The specified FeedIntervalSeconds value of '{feedIntervalSecondsString}' is less then the shortest allowed value of '{ShortestAllowedFeedIntervalSeconds.ToString()}'. FeedIntervalSeconds will be set to:", ShortestAllowedFeedIntervalSeconds.ToString(), Common.ConsoleColorForUnchangedData, Common.ConsoleColorForErrors); + ConsoleUtility.LogListItem($"Note - The specified FeedIntervalSeconds value of '{feedIntervalSecondsString}' is less then the shortest allowed value of '{ShortestAllowedFeedIntervalSeconds}'. FeedIntervalSeconds will be set to:", ShortestAllowedFeedIntervalSeconds.ToString(), Common.ConsoleColorForUnchangedData, Common.ConsoleColorForErrors); feedIntervalSeconds = ShortestAllowedFeedIntervalSeconds; } else @@ -214,7 +214,7 @@ static async Task Main() finally { ConsoleUtility.LogUtilityShutdown(title); - Console.ReadKey(); + _ = Console.ReadKey(); } } @@ -251,7 +251,7 @@ static IList GetConfigItems(string configFilePathPromptMessage) static async Task> GetAllDevicesAsync(Geotab.DataOnlyPlan.API.GeotabDataOnlyPlanAPI api) { const int DefaultFeedResultsLimitDevice = 5000; - List allDevices = new List(); + List allDevices = new(); long? feedVersion = 0; FeedResult feedResult; bool keepGoing = true; @@ -277,7 +277,7 @@ static async Task> GetAllDevicesAsync(Geotab.DataOnlyPlan.API.Geota static async Task> GetAllDiagnosticsAsync(Geotab.DataOnlyPlan.API.GeotabDataOnlyPlanAPI api) { const int DefaultFeedResultsLimitDiagnostic = 50000; - List allDiagnostics = new List(); + List allDiagnostics = new(); long? feedVersion = 0; FeedResult feedResult; bool keepGoing = true; diff --git a/Geotab.DataOnlyPlan.API.Examples.FleetMonitor/TrackedDiagnostic.cs b/Geotab.DataOnlyPlan.API.Examples.FleetMonitor/TrackedDiagnostic.cs index 30e3d55..70857a8 100644 --- a/Geotab.DataOnlyPlan.API.Examples.FleetMonitor/TrackedDiagnostic.cs +++ b/Geotab.DataOnlyPlan.API.Examples.FleetMonitor/TrackedDiagnostic.cs @@ -17,8 +17,8 @@ class TrackedDiagnostic { readonly string faultDataHeader = "Device ID|Device Serial Number|Device Name|FaultData Time|Diagnostic ID|Diagnostic Name|Failure Mode Code|Failure Mode Name|Failure Mode Source|Controller Name|Fault Count|Fault State|Malfunction Lamp Lit|Red Stop Lamp Lit|Amber Warning Lamp Lit|Protect Warning Lamp Lit|DismissedDataTime|Dismissed User"; readonly string statusDataHeader = "Device ID|Device Serial Number|Device Name|StatusData Time|Diagnostic ID|Name|Source|Value|Units"; - readonly List receivedFaultData = new List(); - readonly List receivedStatusData = new List(); + readonly List receivedFaultData = new(); + readonly List receivedStatusData = new(); /// /// The broad category of diagnostic that a falls under. @@ -37,44 +37,21 @@ public TrackedDiagnostic(Device device, Diagnostic diagnostic, string outputFaul { // Determine the DiagnosticCategory based on the DiagnosticType of the suppled Diagnostic. DiagnosticType = (DiagnosticType)diagnostic.DiagnosticType; - switch (DiagnosticType) + DiagnosticCategoryType = DiagnosticType switch { - case DiagnosticType.None: - throw new NotSupportedException($"The DiagnosticType '{DiagnosticType}' is not supported."); - case DiagnosticType.Sid: - DiagnosticCategoryType = DiagnosticCategory.FaultData; - break; - case DiagnosticType.Pid: - DiagnosticCategoryType = DiagnosticCategory.FaultData; - break; - case DiagnosticType.GoDiagnostic: - DiagnosticCategoryType = DiagnosticCategory.StatusData; - break; - case DiagnosticType.DataDiagnostic: - DiagnosticCategoryType = DiagnosticCategory.StatusData; - break; - case DiagnosticType.SuspectParameter: - DiagnosticCategoryType = DiagnosticCategory.FaultData; - break; - case DiagnosticType.ObdFault: - DiagnosticCategoryType = DiagnosticCategory.FaultData; - break; - case DiagnosticType.GoFault: - DiagnosticCategoryType = DiagnosticCategory.FaultData; - break; - case DiagnosticType.ObdWwhFault: - DiagnosticCategoryType = DiagnosticCategory.FaultData; - break; - case DiagnosticType.ProprietaryFault: - DiagnosticCategoryType = DiagnosticCategory.FaultData; - break; - case DiagnosticType.LegacyFault: - DiagnosticCategoryType = DiagnosticCategory.FaultData; - break; - default: - throw new NotSupportedException($"The DiagnosticType '{DiagnosticType}' is not supported."); - } - + DiagnosticType.None => throw new NotSupportedException($"The DiagnosticType '{DiagnosticType}' is not supported."), + DiagnosticType.Sid => DiagnosticCategory.FaultData, + DiagnosticType.Pid => DiagnosticCategory.FaultData, + DiagnosticType.GoDiagnostic => DiagnosticCategory.StatusData, + DiagnosticType.DataDiagnostic => DiagnosticCategory.StatusData, + DiagnosticType.SuspectParameter => DiagnosticCategory.FaultData, + DiagnosticType.ObdFault => DiagnosticCategory.FaultData, + DiagnosticType.GoFault => DiagnosticCategory.FaultData, + DiagnosticType.ObdWwhFault => DiagnosticCategory.FaultData, + DiagnosticType.ProprietaryFault => DiagnosticCategory.FaultData, + DiagnosticType.LegacyFault => DiagnosticCategory.FaultData, + _ => throw new NotSupportedException($"The DiagnosticType '{DiagnosticType}' is not supported."), + }; DeviceId = device.Id; DeviceName = device.Name; DeviceSerialNumber = device.SerialNumber; @@ -183,11 +160,11 @@ public void AddData(FaultData faultData) // Validate to ensure FaultData is for the subject Device and Diagnostic. if (faultData.Device.Id != DeviceId) { - throw new ArgumentException($"The supplied FaultData is for a Device with Id '{faultData.Device.Id.ToString()}' and cannot be added to this TrackedDiagnostic which represents the Device with Id '{DeviceId.ToString()}'."); + throw new ArgumentException($"The supplied FaultData is for a Device with Id '{faultData.Device.Id}' and cannot be added to this TrackedDiagnostic which represents the Device with Id '{DeviceId}'."); } if (faultData.Diagnostic.Id != DiagnosticId) { - throw new ArgumentException($"The supplied FaultData is for a Diagnostic with Id '{faultData.Diagnostic.Id.ToString()}' and cannot be added to this TrackedDiagnostic which represents the Diagnostic with Id '{DiagnosticId.ToString()}'."); + throw new ArgumentException($"The supplied FaultData is for a Diagnostic with Id '{faultData.Diagnostic.Id}' and cannot be added to this TrackedDiagnostic which represents the Diagnostic with Id '{DiagnosticId}'."); } receivedFaultData.Add(faultData); @@ -213,11 +190,11 @@ public void AddData(StatusData statusData) // Validate to ensure StatusData is for the subject Device and Diagnostic. if (statusData.Device.Id != DeviceId) { - throw new ArgumentException($"The supplied StatusData is for a Device with Id '{statusData.Device.Id.ToString()}' and cannot be added to this TrackedDiagnostic which represents the Device with Id '{DeviceId.ToString()}'."); + throw new ArgumentException($"The supplied StatusData is for a Device with Id '{statusData.Device.Id}' and cannot be added to this TrackedDiagnostic which represents the Device with Id '{DeviceId}'."); } if (statusData.Diagnostic.Id != DiagnosticId) { - throw new ArgumentException($"The supplied StatusData is for a Diagnostic with Id '{statusData.Diagnostic.Id.ToString()}' and cannot be added to this TrackedDiagnostic which represents the Diagnostic with Id '{DiagnosticId.ToString()}'."); + throw new ArgumentException($"The supplied StatusData is for a Diagnostic with Id '{statusData.Diagnostic.Id}' and cannot be added to this TrackedDiagnostic which represents the Diagnostic with Id '{DiagnosticId}'."); } receivedStatusData.Add(statusData); @@ -270,7 +247,7 @@ public async Task WriteDataToFileAsync() dismissUserName = dismissUser.Name; dismissDateTime = faultData.DismissDateTime.ToString(); } - await fileWriter.WriteLineAsync($"{DeviceId.ToString()}|{DeviceSerialNumber}|{DeviceName}|{faultData.DateTime.ToString()}|{faultData.Diagnostic.Id.ToString()}|{faultData.Diagnostic.Name}|{failureModeCode}|{failureModeName}|{failureModeSourceName}|{faultData.Controller.Name}|{faultData.Count.ToString()}|{faultData.FaultState.ToString()}|{faultData.MalfunctionLamp.ToString()}|{faultData.RedStopLamp.ToString()}|{faultData.AmberWarningLamp.ToString()}|{faultData.ProtectWarningLamp.ToString()}|{dismissDateTime}|{dismissUserName}"); + await fileWriter.WriteLineAsync($"{DeviceId}|{DeviceSerialNumber}|{DeviceName}|{faultData.DateTime}|{faultData.Diagnostic.Id}|{faultData.Diagnostic.Name}|{failureModeCode}|{failureModeName}|{failureModeSourceName}|{faultData.Controller.Name}|{faultData.Count}|{faultData.FaultState}|{faultData.MalfunctionLamp}|{faultData.RedStopLamp}|{faultData.AmberWarningLamp}|{faultData.ProtectWarningLamp}|{dismissDateTime}|{dismissUserName}"); } } receivedFaultData.Clear(); @@ -286,7 +263,7 @@ public async Task WriteDataToFileAsync() { foreach (StatusData statusData in sortedStatusData) { - await fileWriter.WriteLineAsync($"{DeviceId.ToString()}|{DeviceSerialNumber}|{DeviceName}|{statusData.DateTime.ToString()}|{statusData.Diagnostic.Id.ToString()}|{statusData.Diagnostic.Name}|{statusData.Diagnostic.Source.Name}|{statusData.Data.ToString()}|{statusData.Diagnostic.UnitOfMeasure.Name}"); + await fileWriter.WriteLineAsync($"{DeviceId}|{DeviceSerialNumber}|{DeviceName}|{statusData.DateTime}|{statusData.Diagnostic.Id}|{statusData.Diagnostic.Name}|{statusData.Diagnostic.Source.Name}|{statusData.Data}|{statusData.Diagnostic.UnitOfMeasure.Name}"); } } receivedStatusData.Clear(); diff --git a/Geotab.DataOnlyPlan.API.Examples.FleetMonitor/TrackedGpsData.cs b/Geotab.DataOnlyPlan.API.Examples.FleetMonitor/TrackedGpsData.cs index b99669a..64ba081 100644 --- a/Geotab.DataOnlyPlan.API.Examples.FleetMonitor/TrackedGpsData.cs +++ b/Geotab.DataOnlyPlan.API.Examples.FleetMonitor/TrackedGpsData.cs @@ -15,7 +15,7 @@ namespace Geotab.DataOnlyPlan.API.Examples.FleetMonitor class TrackedGpsData { const string GpsDataHeader = "Device ID|Device Serial Number|Device Name|GPS Time|Latitude|Longitude|Speed"; - readonly List receivedLogRecords = new List(); + readonly List receivedLogRecords = new(); bool outputFileCreated; /// @@ -75,7 +75,7 @@ public void AddData(LogRecord logRecord) // Validate to ensure LogRecord is for the subject Device. if (logRecord.Device.Id != DeviceId) { - throw new ArgumentException($"The supplied LogRecord is for a Device with Id '{logRecord.Device.Id.ToString()}' and cannot be added to this TrackedGpsData which represents the Device with Id '{DeviceId.ToString()}'."); + throw new ArgumentException($"The supplied LogRecord is for a Device with Id '{logRecord.Device.Id}' and cannot be added to this TrackedGpsData which represents the Device with Id '{DeviceId}'."); } receivedLogRecords.Add(logRecord); @@ -108,7 +108,7 @@ public async Task WriteDataToFileAsync() } foreach (LogRecord logRecord in sortedLogRecords) { - await fileWriter.WriteLineAsync($"{DeviceId.ToString()}|{DeviceSerialNumber}|{DeviceName}|{logRecord.DateTime.ToString()}|{logRecord.Latitude.ToString()}|{logRecord.Longitude.ToString()}|{logRecord.Speed.ToString()}"); + await fileWriter.WriteLineAsync($"{DeviceId}|{DeviceSerialNumber}|{DeviceName}|{logRecord.DateTime}|{logRecord.Latitude}|{logRecord.Longitude}|{logRecord.Speed}"); } } receivedLogRecords.Clear(); diff --git a/Geotab.DataOnlyPlan.API.Examples.FleetMonitor/TrackedVehicle.cs b/Geotab.DataOnlyPlan.API.Examples.FleetMonitor/TrackedVehicle.cs index 01a7a8b..26143f6 100644 --- a/Geotab.DataOnlyPlan.API.Examples.FleetMonitor/TrackedVehicle.cs +++ b/Geotab.DataOnlyPlan.API.Examples.FleetMonitor/TrackedVehicle.cs @@ -33,11 +33,11 @@ public TrackedVehicle(Device device, string outputFolder, long maximumFileSizeIn // Generate names of files to which data associated with the TrackedVehicle will be written. DateTime startTime = DateTime.Now; - string gpsDataFilename = $"GPS Data - DeviceID {DeviceId.ToString()} FileID {startTime.ToString(DateFormatStringForOutputFilenames)}.csv"; + string gpsDataFilename = $"GPS Data - DeviceID {DeviceId} FileID {startTime.ToString(DateFormatStringForOutputFilenames)}.csv"; GpsDataFilePath = Path.Combine(outputFolder, gpsDataFilename); - string faultDataFilename = $"Fault Data - DeviceID {DeviceId.ToString()} FileID {startTime.ToString(DateFormatStringForOutputFilenames)}.csv"; + string faultDataFilename = $"Fault Data - DeviceID {DeviceId} FileID {startTime.ToString(DateFormatStringForOutputFilenames)}.csv"; FaultDataFilePath = Path.Combine(outputFolder, faultDataFilename); - string statusDataFilename = $"Status Data - DeviceID {DeviceId.ToString()} FileID {startTime.ToString(DateFormatStringForOutputFilenames)}.csv"; + string statusDataFilename = $"Status Data - DeviceID {DeviceId} FileID {startTime.ToString(DateFormatStringForOutputFilenames)}.csv"; StatusDataFilePath = Path.Combine(outputFolder, statusDataFilename); MaximumFileSizeInBytes = maximumFileSizeInBytes; @@ -132,7 +132,7 @@ public async Task WriteDataToFileAsync() // If the GPS data file for the current TrackedVehicle has reached the maximum allowed size, change the TrackedGpsData OutputFilePath so that data will be written to a new file. if (TrackedGpsData.ReceivedLogRecords.Any()) { - FileInfo gpsDataOutputFileInfo = new FileInfo(GpsDataFilePath); + FileInfo gpsDataOutputFileInfo = new(GpsDataFilePath); if (gpsDataOutputFileInfo.Exists && gpsDataOutputFileInfo.Length >= MaximumFileSizeInBytes) { filenamePrefixLength = GpsDataFilePath.Length - newFilenameSuffix.Length; @@ -149,7 +149,7 @@ public async Task WriteDataToFileAsync() if (TrackedDiagnostics.Where(trackedDiagnostic => trackedDiagnostic.DiagnosticCategoryType == TrackedDiagnostic.DiagnosticCategory.FaultData).Any()) { // If the FaultData file for the current TrackedVehicle does not yet exist, or if it exists and has reached the maximum allowed size, change the FaultDataFilePath and set the OutputFilePath of all TrackedDiagnostics that represent FaultData so that data will be written to a new file. Also, create the new file and write the header if there is any data to write. - FileInfo faultDataFileInfo = new FileInfo(FaultDataFilePath); + FileInfo faultDataFileInfo = new(FaultDataFilePath); if (faultDataFileInfo.Exists == false || faultDataFileInfo.Length >= MaximumFileSizeInBytes) { filenamePrefixLength = FaultDataFilePath.Length - newFilenameSuffix.Length; @@ -181,7 +181,7 @@ public async Task WriteDataToFileAsync() if (TrackedDiagnostics.Where(trackedDiagnostic => trackedDiagnostic.DiagnosticCategoryType == TrackedDiagnostic.DiagnosticCategory.StatusData).Any()) { // If the StatusData file for the current TrackedVehicle does not yet exist, or if it exists and has reached the maximum allowed size, change the StatusDataFilePath and set the OutputFilePath of all TrackedDiagnostics that represent StatusData so that data will be written to a new file. Also, create the new file and write the header if there is any data to write. - FileInfo statusDataFileInfo = new FileInfo(StatusDataFilePath); + FileInfo statusDataFileInfo = new(StatusDataFilePath); if (statusDataFileInfo.Exists == false || statusDataFileInfo.Length >= MaximumFileSizeInBytes) { filenamePrefixLength = StatusDataFilePath.Length - newFilenameSuffix.Length; diff --git a/Geotab.DataOnlyPlan.API.Examples.FleetMonitor/Utilities/ConsoleUtility.cs b/Geotab.DataOnlyPlan.API.Examples.FleetMonitor/Utilities/ConsoleUtility.cs index b121a35..8d69dc4 100644 --- a/Geotab.DataOnlyPlan.API.Examples.FleetMonitor/Utilities/ConsoleUtility.cs +++ b/Geotab.DataOnlyPlan.API.Examples.FleetMonitor/Utilities/ConsoleUtility.cs @@ -28,6 +28,35 @@ public static string GetUserInput(string promptMessage) return userInput; } + /// + /// Prompts the user to input a directory path until a valid entry is made. The validated directory path is returned. + /// + /// The validated directory path. + public static string GetUserInputDirectory() + { + string filePath = string.Empty; + bool filePathIsValid = false; + + // Get the user to enter a valid directory path. + while (!filePathIsValid) + { + Console.ForegroundColor = Common.ConsoleColorForUserPrompts; + Console.Write($"> Enter a folder path (e.g. 'C:\\Temp'):"); + Console.ForegroundColor = Common.ConsoleColorForUserInput; + filePath = Console.ReadLine(); + Console.ForegroundColor = Common.ConsoleColorDefault; + if (Directory.Exists(filePath)) + { + filePathIsValid = true; + } + else + { + ConsoleUtility.LogError($"The folder entered does not exist."); + } + } + return filePath; + } + /// /// Prompts the user to input a file path followed by a file name until valid entries are made. The validated full path is returned. /// @@ -319,7 +348,7 @@ public static void LogListItems(IList> listItems, Cons { Console.Write($"- "); Console.ForegroundColor = listItemIdColor; - Console.Write($"{listItem.Key.ToString()} "); + Console.Write($"{listItem.Key} "); Console.ForegroundColor = listItemColor; Console.WriteLine($"{listItem.Value}"); } @@ -336,7 +365,7 @@ public static void LogListItems(IList> listItems, Cons Console.Write($"- "); Console.ForegroundColor = listItemIdColor; - Console.Write($"{listItem.Key.ToString().PadRight(2)} "); + Console.Write($"{listItem.Key,-2} "); Console.ForegroundColor = listItemColor; Console.Write($"{listItem.Value.PadRight(maxItemLength)} "); listItemNumber++; @@ -350,7 +379,7 @@ public static void LogListItems(IList> listItems, Cons listItem = listItems[listItemNumber]; Console.Write($"- "); Console.ForegroundColor = listItemIdColor; - Console.Write($"{listItem.Key.ToString().PadRight(2)} "); + Console.Write($"{listItem.Key,-2} "); Console.ForegroundColor = listItemColor; Console.WriteLine($"{listItem.Value.PadRight(maxItemLength)}"); } @@ -392,7 +421,7 @@ public static void LogObjectProperties(object obj) Type type = obj.GetType(); Console.WriteLine($"Type: {type.Name}"); PropertyInfo[] properties = type.GetProperties(); - Console.WriteLine($"Value: {obj.ToString()}"); + Console.WriteLine($"Value: {obj}"); Console.WriteLine($"Properties (N = {properties.Length}):"); foreach (var property in properties) { @@ -458,7 +487,7 @@ public static void LogTestStart(int testNumber, string methodName, Dictionary parameter in parameters) { - Console.WriteLine($" {parameter.Key}: {parameter.Value.ToString()}"); + Console.WriteLine($" {parameter.Key}: {parameter.Value}"); } } diff --git a/Geotab.DataOnlyPlan.API.Examples/Examples/AddDriverChangeAsyncExample.cs b/Geotab.DataOnlyPlan.API.Examples/Examples/AddDriverChangeAsyncExample.cs index 919f078..d12c799 100644 --- a/Geotab.DataOnlyPlan.API.Examples/Examples/AddDriverChangeAsyncExample.cs +++ b/Geotab.DataOnlyPlan.API.Examples/Examples/AddDriverChangeAsyncExample.cs @@ -26,7 +26,7 @@ public static async Task Run(GeotabDataOnlyPlanAPI api, string deviceId, DriverChangeType driverChangeType = DriverChangeType.Driver; - ConsoleUtility.LogInfoStart($"Adding driverChange of type '{driverChangeType.ToString()}' for driver '{driver.Id.ToString()}' and device '{device.Id.ToString()}' to database '{api.Credentials.Database}'..."); + ConsoleUtility.LogInfoStart($"Adding driverChange of type '{driverChangeType}' for driver '{driver.Id}' and device '{device.Id}' to database '{api.Credentials.Database}'..."); addedDriverChangeId = await api.AddDriverChangeAsync(dateTime, device, driver, driverChangeType); diff --git a/Geotab.DataOnlyPlan.API.Examples/Examples/AddTextMessageAsyncExample.cs b/Geotab.DataOnlyPlan.API.Examples/Examples/AddTextMessageAsyncExample.cs index ae909da..61a95a4 100644 --- a/Geotab.DataOnlyPlan.API.Examples/Examples/AddTextMessageAsyncExample.cs +++ b/Geotab.DataOnlyPlan.API.Examples/Examples/AddTextMessageAsyncExample.cs @@ -26,11 +26,11 @@ public static async Task Run(GeotabDataOnlyPlanAPI api, string deviceId, string */ // Set-up the message content. - TextContent messageContent = new TextContent("Testing: Geotab API example text message", false); + TextContent messageContent = new("Testing: Geotab API example text message", false); // Construct the text message. DateTime utcNow = DateTime.UtcNow; - TextMessage basicTextMessage = new TextMessage(null, null, utcNow, utcNow, deviceForTextMessages, userForTextMessages, messageContent, true, true, null, null, null); + TextMessage basicTextMessage = new(null, null, utcNow, utcNow, deviceForTextMessages, userForTextMessages, messageContent, true, null, null, null, null, null); // Add the text message. MyGeotab will take care of the actual sending. string addedTextMessageId = await api.AddTextMessageAsync(basicTextMessage); @@ -42,15 +42,15 @@ public static async Task Run(GeotabDataOnlyPlanAPI api, string deviceId, string */ // Set up message and GPS location - LocationContent clearStopsContent = new LocationContent("Testing: Geotab API example clear all stops message", "Reset Stops", 0, 0); + LocationContent clearStopsContent = new("Testing: Geotab API example clear all stops message", "Reset Stops", 0, 0); // Construct a "Clear Previous Stops" message - TextMessage clearMessage = new TextMessage(deviceForTextMessages, userForTextMessages, clearStopsContent, true); + TextMessage clearMessage = new(deviceForTextMessages, userForTextMessages, clearStopsContent, true); // Add the clear stops text message, Geotab will take care of the sending process. string addedClearMessageId = await api.AddTextMessageAsync(clearMessage); // Set up message and GPS location - LocationContent withGPSLocation = new LocationContent("Testing: Geotab API example location message", "Geotab", 43.452879, -79.701648); + LocationContent withGPSLocation = new("Testing: Geotab API example location message", "Geotab", 43.452879, -79.701648); // Construct the location text message. - TextMessage locationMessage = new TextMessage(deviceForTextMessages, userForTextMessages, withGPSLocation, true); + TextMessage locationMessage = new(deviceForTextMessages, userForTextMessages, withGPSLocation, true); // Add the text message, Geotab will take care of the sending process. string addedLocationMessageId = await api.AddTextMessageAsync(locationMessage); @@ -58,8 +58,8 @@ public static async Task Run(GeotabDataOnlyPlanAPI api, string deviceId, string /** * Example: IoXOutput Message */ - IoxOutputContent ioxOutputContent = new IoxOutputContent(true); - TextMessage ioxOutputMessage = new TextMessage(deviceForTextMessages, userForTextMessages, ioxOutputContent, true); + IoxOutputContent ioxOutputContent = new(true); + TextMessage ioxOutputMessage = new(deviceForTextMessages, userForTextMessages, ioxOutputContent, true); string addedIoxOutputMessageId = await api.AddTextMessageAsync(ioxOutputMessage); @@ -68,17 +68,17 @@ public static async Task Run(GeotabDataOnlyPlanAPI api, string deviceId, string */ string messageString = "Secret Message!"; byte[] bytes = Encoding.ASCII.GetBytes(messageString); - TimeSpan binaryDataPacketDelay = new TimeSpan(0, 0, 0); - MimeContent mimeContent = new MimeContent("multipart/byteranges", bytes, binaryDataPacketDelay, null); - TextMessage mimeContentTextMessage = new TextMessage(deviceForTextMessages, userForTextMessages, mimeContent, true); + TimeSpan binaryDataPacketDelay = new(0, 0, 0); + MimeContent mimeContent = new("multipart/byteranges", bytes, binaryDataPacketDelay, null); + TextMessage mimeContentTextMessage = new(deviceForTextMessages, userForTextMessages, mimeContent, true); string addedMimeContentTextMessageId = await api.AddTextMessageAsync(mimeContentTextMessage); /** * Example: GoTalk Message */ - GoTalkContent goTalkContent = new GoTalkContent("You're following too closely!"); - TextMessage goTalkMessage = new TextMessage(deviceForTextMessages, userForTextMessages, goTalkContent, true); + GoTalkContent goTalkContent = new("You're following too closely!"); + TextMessage goTalkMessage = new(deviceForTextMessages, userForTextMessages, goTalkContent, true); string addedGoTalkMessageId = await api.AddTextMessageAsync(goTalkMessage); } catch (Exception ex) diff --git a/Geotab.DataOnlyPlan.API.Examples/Examples/AddUserAsyncExample.cs b/Geotab.DataOnlyPlan.API.Examples/Examples/AddUserAsyncExample.cs index cded74a..b2c33c4 100644 --- a/Geotab.DataOnlyPlan.API.Examples/Examples/AddUserAsyncExample.cs +++ b/Geotab.DataOnlyPlan.API.Examples/Examples/AddUserAsyncExample.cs @@ -18,8 +18,8 @@ public static async Task Run(GeotabDataOnlyPlanAPI api) { // Add a user that is a driver with a key. // Set parameter values to apply when adding user. - List keys = new List(); - Key key = new Key(DriverKeyType.CustomNfc, null, "1234567890"); + List keys = new(); + Key key = new(DriverKeyType.CustomNfc, null, "1234567890"); keys.Add(key); string comment = "User added as driver with key."; diff --git a/Geotab.DataOnlyPlan.API.Examples/Examples/GenerateCaptchaAsyncExample.cs b/Geotab.DataOnlyPlan.API.Examples/Examples/GenerateCaptchaAsyncExample.cs index 112257e..00809a9 100644 --- a/Geotab.DataOnlyPlan.API.Examples/Examples/GenerateCaptchaAsyncExample.cs +++ b/Geotab.DataOnlyPlan.API.Examples/Examples/GenerateCaptchaAsyncExample.cs @@ -1,4 +1,5 @@ using System; +using System.IO; using System.Threading.Tasks; using Geotab.DataOnlyPlan.API.Examples.Utilities; @@ -13,7 +14,15 @@ public static async Task Run(GeotabDataOnlyPlanAPI api) try { string id = Guid.NewGuid().ToString(); - string captchaImage = await api.GenerateCaptchaAsync(id); + + string filePath = "C:\\TEMP"; + if (!Directory.Exists(filePath)) + { + filePath = ConsoleUtility.GetUserInputDirectory(); + } + string outputFilePath = $"{filePath}\\GeotabDataOnlyPlanAPI_CAPTCHA_{id}.jpg"; + + var result = await api.GenerateCaptchaAsync(id, outputFilePath); } catch (Exception ex) { diff --git a/Geotab.DataOnlyPlan.API.Examples/Examples/GetFeedCustomDataAsyncExample.cs b/Geotab.DataOnlyPlan.API.Examples/Examples/GetFeedCustomDataAsyncExample.cs index ea91df0..a78c2f7 100644 --- a/Geotab.DataOnlyPlan.API.Examples/Examples/GetFeedCustomDataAsyncExample.cs +++ b/Geotab.DataOnlyPlan.API.Examples/Examples/GetFeedCustomDataAsyncExample.cs @@ -29,13 +29,13 @@ public static async Task Run(GeotabDataOnlyPlanAPI api) feedVersion = feedResult.ToVersion; // Log results to console. - Console.WriteLine($"Initial feed start time: {getFeedStartTime.ToString()}"); - Console.WriteLine($"Initial FeedResult ToVersion: {feedVersion.ToString()}"); - Console.WriteLine($"Initial FeedResult Records: {feedResult.Data.Count.ToString()}"); + Console.WriteLine($"Initial feed start time: {getFeedStartTime}"); + Console.WriteLine($"Initial FeedResult ToVersion: {feedVersion}"); + Console.WriteLine($"Initial FeedResult Records: {feedResult.Data.Count}"); if (feedResult.Data.Count > 0) { - Console.WriteLine($"Initial FeedResult first record DateTime: {feedResult.Data[0].DateTime.ToString()}"); - Console.WriteLine($"Initial FeedResult last record DateTime: {feedResult.Data[feedResult.Data.Count - 1].DateTime.ToString()}"); + Console.WriteLine($"Initial FeedResult first record DateTime: {feedResult.Data[0].DateTime}"); + Console.WriteLine($"Initial FeedResult last record DateTime: {feedResult.Data[feedResult.Data.Count - 1].DateTime}"); } // Execute a GetFeed loop for the prescribed number of iterations, setting the fromVersion on the first iteration to the toVersion that was returned by the initial GetFeed call. @@ -46,13 +46,13 @@ public static async Task Run(GeotabDataOnlyPlanAPI api) feedVersion = feedResult.ToVersion; // Log results to console. - Console.WriteLine($"Feed iteration: {getFeedCallNumber.ToString()}"); - Console.WriteLine($"Feed iteration: {getFeedCallNumber.ToString()} FeedResult ToVersion: {feedVersion.ToString()}"); - Console.WriteLine($"Feed iteration: {getFeedCallNumber.ToString()} FeedResult Records: {feedResult.Data.Count.ToString()}"); + Console.WriteLine($"Feed iteration: {getFeedCallNumber}"); + Console.WriteLine($"Feed iteration: {getFeedCallNumber} FeedResult ToVersion: {feedVersion}"); + Console.WriteLine($"Feed iteration: {getFeedCallNumber} FeedResult Records: {feedResult.Data.Count}"); if (feedResult.Data.Count > 0) { - Console.WriteLine($"Feed iteration: {getFeedCallNumber.ToString()} FeedResult first record DateTime: {feedResult.Data[0].DateTime.ToString()}"); - Console.WriteLine($"Feed iteration: {getFeedCallNumber.ToString()} FeedResult last record DateTime: {feedResult.Data[feedResult.Data.Count - 1].DateTime.ToString()}"); + Console.WriteLine($"Feed iteration: {getFeedCallNumber} FeedResult first record DateTime: {feedResult.Data[0].DateTime}"); + Console.WriteLine($"Feed iteration: {getFeedCallNumber} FeedResult last record DateTime: {feedResult.Data[feedResult.Data.Count - 1].DateTime}"); } // Wait for the prescribed amount of time before making the next GetFeed call. Thread.Sleep(getFeedSecondsToWaitBetweenCalls * 1000); diff --git a/Geotab.DataOnlyPlan.API.Examples/Examples/GetFeedDeviceAsyncExample.cs b/Geotab.DataOnlyPlan.API.Examples/Examples/GetFeedDeviceAsyncExample.cs index d08484b..3e03e38 100644 --- a/Geotab.DataOnlyPlan.API.Examples/Examples/GetFeedDeviceAsyncExample.cs +++ b/Geotab.DataOnlyPlan.API.Examples/Examples/GetFeedDeviceAsyncExample.cs @@ -23,7 +23,7 @@ public static async Task Run(GeotabDataOnlyPlanAPI api) int getFeedSecondsToWaitBetweenCalls = 5; long? feedVersion = 0; - List deviceCache = new List(); + List deviceCache = new(); FeedResult feedResult; // Start by populating the deviceCache with a list of all devices. diff --git a/Geotab.DataOnlyPlan.API.Examples/Examples/GetFeedDiagnosticAsyncExample.cs b/Geotab.DataOnlyPlan.API.Examples/Examples/GetFeedDiagnosticAsyncExample.cs index 98b8449..2b851be 100644 --- a/Geotab.DataOnlyPlan.API.Examples/Examples/GetFeedDiagnosticAsyncExample.cs +++ b/Geotab.DataOnlyPlan.API.Examples/Examples/GetFeedDiagnosticAsyncExample.cs @@ -24,7 +24,7 @@ public static async Task Run(GeotabDataOnlyPlanAPI api) int getFeedSecondsToWaitBetweenCalls = 5; long? feedVersion = 0; - List diagnosticCache = new List(); + List diagnosticCache = new(); FeedResult feedResult; // Start by populating the diagnosticCache with a list of all diagnostics. diff --git a/Geotab.DataOnlyPlan.API.Examples/Examples/GetFeedDriverChangeAsyncExample.cs b/Geotab.DataOnlyPlan.API.Examples/Examples/GetFeedDriverChangeAsyncExample.cs index 1320bfd..f9a29ae 100644 --- a/Geotab.DataOnlyPlan.API.Examples/Examples/GetFeedDriverChangeAsyncExample.cs +++ b/Geotab.DataOnlyPlan.API.Examples/Examples/GetFeedDriverChangeAsyncExample.cs @@ -23,7 +23,7 @@ public static async Task Run(GeotabDataOnlyPlanAPI api) int getFeedSecondsToWaitBetweenCalls = 5; long? feedVersion = 0; - List driverChangeCache = new List(); + List driverChangeCache = new(); FeedResult feedResult; // Start by populating the driverChangeCache with a list of all driverChanges. diff --git a/Geotab.DataOnlyPlan.API.Examples/Examples/GetFeedFaultDataAsyncExample.cs b/Geotab.DataOnlyPlan.API.Examples/Examples/GetFeedFaultDataAsyncExample.cs index 4cfdba4..c6da2d2 100644 --- a/Geotab.DataOnlyPlan.API.Examples/Examples/GetFeedFaultDataAsyncExample.cs +++ b/Geotab.DataOnlyPlan.API.Examples/Examples/GetFeedFaultDataAsyncExample.cs @@ -30,13 +30,13 @@ public static async Task Run(GeotabDataOnlyPlanAPI api) feedVersion = feedResult.ToVersion; // Log results to console. - Console.WriteLine($"Initial feed start time: {getFeedStartTime.ToString()}"); - Console.WriteLine($"Initial FeedResult ToVersion: {feedVersion.ToString()}"); - Console.WriteLine($"Initial FeedResult Records: {feedResult.Data.Count.ToString()}"); + Console.WriteLine($"Initial feed start time: {getFeedStartTime}"); + Console.WriteLine($"Initial FeedResult ToVersion: {feedVersion}"); + Console.WriteLine($"Initial FeedResult Records: {feedResult.Data.Count}"); if (feedResult.Data.Count > 0) { - Console.WriteLine($"Initial FeedResult first record DateTime: {feedResult.Data[0].DateTime.ToString()}"); - Console.WriteLine($"Initial FeedResult last record DateTime: {feedResult.Data[feedResult.Data.Count - 1].DateTime.ToString()}"); + Console.WriteLine($"Initial FeedResult first record DateTime: {feedResult.Data[0].DateTime}"); + Console.WriteLine($"Initial FeedResult last record DateTime: {feedResult.Data[feedResult.Data.Count - 1].DateTime}"); } // Execute a GetFeed loop for the prescribed number of iterations, setting the fromVersion on the first iteration to the toVersion that was returned by the initial GetFeed call. @@ -47,13 +47,13 @@ public static async Task Run(GeotabDataOnlyPlanAPI api) feedVersion = feedResult.ToVersion; // Log results to console. - Console.WriteLine($"Feed iteration: {getFeedCallNumber.ToString()}"); - Console.WriteLine($"Feed iteration: {getFeedCallNumber.ToString()} FeedResult ToVersion: {feedVersion.ToString()}"); - Console.WriteLine($"Feed iteration: {getFeedCallNumber.ToString()} FeedResult Records: {feedResult.Data.Count.ToString()}"); + Console.WriteLine($"Feed iteration: {getFeedCallNumber}"); + Console.WriteLine($"Feed iteration: {getFeedCallNumber} FeedResult ToVersion: {feedVersion}"); + Console.WriteLine($"Feed iteration: {getFeedCallNumber} FeedResult Records: {feedResult.Data.Count}"); if (feedResult.Data.Count > 0) { - Console.WriteLine($"Feed iteration: {getFeedCallNumber.ToString()} FeedResult first record DateTime: {feedResult.Data[0].DateTime.ToString()}"); - Console.WriteLine($"Feed iteration: {getFeedCallNumber.ToString()} FeedResult last record DateTime: {feedResult.Data[feedResult.Data.Count - 1].DateTime.ToString()}"); + Console.WriteLine($"Feed iteration: {getFeedCallNumber} FeedResult first record DateTime: {feedResult.Data[0].DateTime}"); + Console.WriteLine($"Feed iteration: {getFeedCallNumber} FeedResult last record DateTime: {feedResult.Data[feedResult.Data.Count - 1].DateTime}"); } // Wait for the prescribed amount of time before making the next GetFeed call. Thread.Sleep(getFeedSecondsToWaitBetweenCalls * 1000); diff --git a/Geotab.DataOnlyPlan.API.Examples/Examples/GetFeedIoxAddOnAsyncExample.cs b/Geotab.DataOnlyPlan.API.Examples/Examples/GetFeedIoxAddOnAsyncExample.cs index df6b2ff..086b778 100644 --- a/Geotab.DataOnlyPlan.API.Examples/Examples/GetFeedIoxAddOnAsyncExample.cs +++ b/Geotab.DataOnlyPlan.API.Examples/Examples/GetFeedIoxAddOnAsyncExample.cs @@ -17,25 +17,23 @@ public static async Task Run(GeotabDataOnlyPlanAPI api) // Feed parameters. int getFeedNumberOfCallsToMake = 5; int getFeedSecondsToWaitBetweenCalls = 5; - DateTime getFeedStartTime = DateTime.UtcNow - TimeSpan.FromDays(1); // See MyGeotab SDK Result Limits and GetFeed() documentation for information about the feed result limit defined below. int getFeedresultsLimit = 50000; - long? feedVersion; + long? feedVersion = 0; FeedResult feedResult; - // Make initial GetFeed call using the "seed" time. The returned toVersion will be used as the fromVersion to start the subsequent GetFeed loop. - feedResult = await api.GetFeedIoxAddOnAsync(getFeedStartTime, getFeedresultsLimit); + // Make initial GetFeed call. The returned toVersion will be used as the fromVersion to start the subsequent GetFeed loop. + feedResult = await api.GetFeedIoxAddOnAsync(feedVersion, getFeedresultsLimit); feedVersion = feedResult.ToVersion; // Log results to console. - Console.WriteLine($"Initial feed start time: {getFeedStartTime.ToString()}"); - Console.WriteLine($"Initial FeedResult ToVersion: {feedVersion.ToString()}"); - Console.WriteLine($"Initial FeedResult Records: {feedResult.Data.Count.ToString()}"); + Console.WriteLine($"Initial FeedResult ToVersion: {feedVersion}"); + Console.WriteLine($"Initial FeedResult Records: {feedResult.Data.Count}"); if (feedResult.Data.Count > 0) { - Console.WriteLine($"Initial FeedResult first record DateTime: {feedResult.Data[0].DateTime.ToString()}"); - Console.WriteLine($"Initial FeedResult last record DateTime: {feedResult.Data[feedResult.Data.Count - 1].DateTime.ToString()}"); + Console.WriteLine($"Initial FeedResult first record DateTime: {feedResult.Data[0].DateTime}"); + Console.WriteLine($"Initial FeedResult last record DateTime: {feedResult.Data[feedResult.Data.Count - 1].DateTime}"); } // Execute a GetFeed loop for the prescribed number of iterations, setting the fromVersion on the first iteration to the toVersion that was returned by the initial GetFeed call. @@ -46,13 +44,13 @@ public static async Task Run(GeotabDataOnlyPlanAPI api) feedVersion = feedResult.ToVersion; // Log results to console. - Console.WriteLine($"Feed iteration: {getFeedCallNumber.ToString()}"); - Console.WriteLine($"Feed iteration: {getFeedCallNumber.ToString()} FeedResult ToVersion: {feedVersion.ToString()}"); - Console.WriteLine($"Feed iteration: {getFeedCallNumber.ToString()} FeedResult Records: {feedResult.Data.Count.ToString()}"); + Console.WriteLine($"Feed iteration: {getFeedCallNumber}"); + Console.WriteLine($"Feed iteration: {getFeedCallNumber} FeedResult ToVersion: {feedVersion}"); + Console.WriteLine($"Feed iteration: {getFeedCallNumber} FeedResult Records: {feedResult.Data.Count}"); if (feedResult.Data.Count > 0) { - Console.WriteLine($"Feed iteration: {getFeedCallNumber.ToString()} FeedResult first record DateTime: {feedResult.Data[0].DateTime.ToString()}"); - Console.WriteLine($"Feed iteration: {getFeedCallNumber.ToString()} FeedResult last record DateTime: {feedResult.Data[feedResult.Data.Count - 1].DateTime.ToString()}"); + Console.WriteLine($"Feed iteration: {getFeedCallNumber} FeedResult first record DateTime: {feedResult.Data[0].DateTime}"); + Console.WriteLine($"Feed iteration: {getFeedCallNumber} FeedResult last record DateTime: {feedResult.Data[feedResult.Data.Count - 1].DateTime}"); } // Wait for the prescribed amount of time before making the next GetFeed call. Thread.Sleep(getFeedSecondsToWaitBetweenCalls * 1000); diff --git a/Geotab.DataOnlyPlan.API.Examples/Examples/GetFeedLogRecordAsyncExample.cs b/Geotab.DataOnlyPlan.API.Examples/Examples/GetFeedLogRecordAsyncExample.cs index f57b542..c2e0d92 100644 --- a/Geotab.DataOnlyPlan.API.Examples/Examples/GetFeedLogRecordAsyncExample.cs +++ b/Geotab.DataOnlyPlan.API.Examples/Examples/GetFeedLogRecordAsyncExample.cs @@ -29,13 +29,13 @@ public static async Task Run(GeotabDataOnlyPlanAPI api) feedVersion = feedResult.ToVersion; // Log results to console. - Console.WriteLine($"Initial feed start time: {getFeedStartTime.ToString()}"); - Console.WriteLine($"Initial FeedResult ToVersion: {feedVersion.ToString()}"); - Console.WriteLine($"Initial FeedResult Records: {feedResult.Data.Count.ToString()}"); + Console.WriteLine($"Initial feed start time: {getFeedStartTime}"); + Console.WriteLine($"Initial FeedResult ToVersion: {feedVersion}"); + Console.WriteLine($"Initial FeedResult Records: {feedResult.Data.Count}"); if (feedResult.Data.Count > 0) { - Console.WriteLine($"Initial FeedResult first record DateTime: {feedResult.Data[0].DateTime.ToString()}"); - Console.WriteLine($"Initial FeedResult last record DateTime: {feedResult.Data[feedResult.Data.Count - 1].DateTime.ToString()}"); + Console.WriteLine($"Initial FeedResult first record DateTime: {feedResult.Data[0].DateTime}"); + Console.WriteLine($"Initial FeedResult last record DateTime: {feedResult.Data[feedResult.Data.Count - 1].DateTime}"); } // Execute a GetFeed loop for the prescribed number of iterations, setting the fromVersion on the first iteration to the toVersion that was returned by the initial GetFeed call. @@ -46,13 +46,13 @@ public static async Task Run(GeotabDataOnlyPlanAPI api) feedVersion = feedResult.ToVersion; // Log results to console. - Console.WriteLine($"Feed iteration: {getFeedCallNumber.ToString()}"); - Console.WriteLine($"Feed iteration: {getFeedCallNumber.ToString()} FeedResult ToVersion: {feedVersion.ToString()}"); - Console.WriteLine($"Feed iteration: {getFeedCallNumber.ToString()} FeedResult Records: {feedResult.Data.Count.ToString()}"); + Console.WriteLine($"Feed iteration: {getFeedCallNumber}"); + Console.WriteLine($"Feed iteration: {getFeedCallNumber} FeedResult ToVersion: {feedVersion}"); + Console.WriteLine($"Feed iteration: {getFeedCallNumber} FeedResult Records: {feedResult.Data.Count}"); if (feedResult.Data.Count > 0) { - Console.WriteLine($"Feed iteration: {getFeedCallNumber.ToString()} FeedResult first record DateTime: {feedResult.Data[0].DateTime.ToString()}"); - Console.WriteLine($"Feed iteration: {getFeedCallNumber.ToString()} FeedResult last record DateTime: {feedResult.Data[feedResult.Data.Count - 1].DateTime.ToString()}"); + Console.WriteLine($"Feed iteration: {getFeedCallNumber} FeedResult first record DateTime: {feedResult.Data[0].DateTime}"); + Console.WriteLine($"Feed iteration: {getFeedCallNumber} FeedResult last record DateTime: {feedResult.Data[feedResult.Data.Count - 1].DateTime}"); } // Wait for the prescribed amount of time before making the next GetFeed call. Thread.Sleep(getFeedSecondsToWaitBetweenCalls * 1000); diff --git a/Geotab.DataOnlyPlan.API.Examples/Examples/GetFeedStatusDataAsyncExample.cs b/Geotab.DataOnlyPlan.API.Examples/Examples/GetFeedStatusDataAsyncExample.cs index 90c9ebf..c46cbaa 100644 --- a/Geotab.DataOnlyPlan.API.Examples/Examples/GetFeedStatusDataAsyncExample.cs +++ b/Geotab.DataOnlyPlan.API.Examples/Examples/GetFeedStatusDataAsyncExample.cs @@ -30,13 +30,13 @@ public static async Task Run(GeotabDataOnlyPlanAPI api) feedVersion = feedResult.ToVersion; // Log results to console. - Console.WriteLine($"Initial feed start time: {getFeedStartTime.ToString()}"); - Console.WriteLine($"Initial FeedResult ToVersion: {feedVersion.ToString()}"); - Console.WriteLine($"Initial FeedResult Records: {feedResult.Data.Count.ToString()}"); + Console.WriteLine($"Initial feed start time: {getFeedStartTime}"); + Console.WriteLine($"Initial FeedResult ToVersion: {feedVersion}"); + Console.WriteLine($"Initial FeedResult Records: {feedResult.Data.Count}"); if (feedResult.Data.Count > 0) { - Console.WriteLine($"Initial FeedResult first record DateTime: {feedResult.Data[0].DateTime.ToString()}"); - Console.WriteLine($"Initial FeedResult last record DateTime: {feedResult.Data[feedResult.Data.Count - 1].DateTime.ToString()}"); + Console.WriteLine($"Initial FeedResult first record DateTime: {feedResult.Data[0].DateTime}"); + Console.WriteLine($"Initial FeedResult last record DateTime: {feedResult.Data[feedResult.Data.Count - 1].DateTime}"); } // Execute a GetFeed loop for the prescribed number of iterations, setting the fromVersion on the first iteration to the toVersion that was returned by the initial GetFeed call. @@ -47,13 +47,13 @@ public static async Task Run(GeotabDataOnlyPlanAPI api) feedVersion = feedResult.ToVersion; // Log results to console. - Console.WriteLine($"Feed iteration: {getFeedCallNumber.ToString()}"); - Console.WriteLine($"Feed iteration: {getFeedCallNumber.ToString()} FeedResult ToVersion: {feedVersion.ToString()}"); - Console.WriteLine($"Feed iteration: {getFeedCallNumber.ToString()} FeedResult Records: {feedResult.Data.Count.ToString()}"); + Console.WriteLine($"Feed iteration: {getFeedCallNumber}"); + Console.WriteLine($"Feed iteration: {getFeedCallNumber} FeedResult ToVersion: {feedVersion}"); + Console.WriteLine($"Feed iteration: {getFeedCallNumber} FeedResult Records: {feedResult.Data.Count}"); if (feedResult.Data.Count > 0) { - Console.WriteLine($"Feed iteration: {getFeedCallNumber.ToString()} FeedResult first record DateTime: {feedResult.Data[0].DateTime.ToString()}"); - Console.WriteLine($"Feed iteration: {getFeedCallNumber.ToString()} FeedResult last record DateTime: {feedResult.Data[feedResult.Data.Count - 1].DateTime.ToString()}"); + Console.WriteLine($"Feed iteration: {getFeedCallNumber} FeedResult first record DateTime: {feedResult.Data[0].DateTime}"); + Console.WriteLine($"Feed iteration: {getFeedCallNumber} FeedResult last record DateTime: {feedResult.Data[feedResult.Data.Count - 1].DateTime}"); } // Wait for the prescribed amount of time before making the next GetFeed call. Thread.Sleep(getFeedSecondsToWaitBetweenCalls * 1000); diff --git a/Geotab.DataOnlyPlan.API.Examples/Examples/GetFeedTripAsyncExample.cs b/Geotab.DataOnlyPlan.API.Examples/Examples/GetFeedTripAsyncExample.cs index c276443..950c40b 100644 --- a/Geotab.DataOnlyPlan.API.Examples/Examples/GetFeedTripAsyncExample.cs +++ b/Geotab.DataOnlyPlan.API.Examples/Examples/GetFeedTripAsyncExample.cs @@ -29,13 +29,13 @@ public static async Task Run(GeotabDataOnlyPlanAPI api) feedVersion = feedResult.ToVersion; // Log results to console. - Console.WriteLine($"Initial feed start time: {getFeedStartTime.ToString()}"); - Console.WriteLine($"Initial FeedResult ToVersion: {feedVersion.ToString()}"); - Console.WriteLine($"Initial FeedResult Records: {feedResult.Data.Count.ToString()}"); + Console.WriteLine($"Initial feed start time: {getFeedStartTime}"); + Console.WriteLine($"Initial FeedResult ToVersion: {feedVersion}"); + Console.WriteLine($"Initial FeedResult Records: {feedResult.Data.Count}"); if (feedResult.Data.Count > 0) { - Console.WriteLine($"Initial FeedResult first record DateTime: {feedResult.Data[0].DateTime.ToString()}"); - Console.WriteLine($"Initial FeedResult last record DateTime: {feedResult.Data[feedResult.Data.Count - 1].DateTime.ToString()}"); + Console.WriteLine($"Initial FeedResult first record DateTime: {feedResult.Data[0].DateTime}"); + Console.WriteLine($"Initial FeedResult last record DateTime: {feedResult.Data[feedResult.Data.Count - 1].DateTime}"); } // Execute a GetFeed loop for the prescribed number of iterations, setting the fromVersion on the first iteration to the toVersion that was returned by the initial GetFeed call. @@ -46,13 +46,13 @@ public static async Task Run(GeotabDataOnlyPlanAPI api) feedVersion = feedResult.ToVersion; // Log results to console. - Console.WriteLine($"Feed iteration: {getFeedCallNumber.ToString()}"); - Console.WriteLine($"Feed iteration: {getFeedCallNumber.ToString()} FeedResult ToVersion: {feedVersion.ToString()}"); - Console.WriteLine($"Feed iteration: {getFeedCallNumber.ToString()} FeedResult Records: {feedResult.Data.Count.ToString()}"); + Console.WriteLine($"Feed iteration: {getFeedCallNumber}"); + Console.WriteLine($"Feed iteration: {getFeedCallNumber} FeedResult ToVersion: {feedVersion}"); + Console.WriteLine($"Feed iteration: {getFeedCallNumber} FeedResult Records: {feedResult.Data.Count}"); if (feedResult.Data.Count > 0) { - Console.WriteLine($"Feed iteration: {getFeedCallNumber.ToString()} FeedResult first record DateTime: {feedResult.Data[0].DateTime.ToString()}"); - Console.WriteLine($"Feed iteration: {getFeedCallNumber.ToString()} FeedResult last record DateTime: {feedResult.Data[feedResult.Data.Count - 1].DateTime.ToString()}"); + Console.WriteLine($"Feed iteration: {getFeedCallNumber} FeedResult first record DateTime: {feedResult.Data[0].DateTime}"); + Console.WriteLine($"Feed iteration: {getFeedCallNumber} FeedResult last record DateTime: {feedResult.Data[feedResult.Data.Count - 1].DateTime}"); } // Wait for the prescribed amount of time before making the next GetFeed call. Thread.Sleep(getFeedSecondsToWaitBetweenCalls * 1000); diff --git a/Geotab.DataOnlyPlan.API.Examples/Examples/GetFeedUserAsyncExample.cs b/Geotab.DataOnlyPlan.API.Examples/Examples/GetFeedUserAsyncExample.cs index 5bb3600..5d4af0d 100644 --- a/Geotab.DataOnlyPlan.API.Examples/Examples/GetFeedUserAsyncExample.cs +++ b/Geotab.DataOnlyPlan.API.Examples/Examples/GetFeedUserAsyncExample.cs @@ -23,7 +23,7 @@ public static async Task Run(GeotabDataOnlyPlanAPI api) int getFeedSecondsToWaitBetweenCalls = 5; long? feedVersion = 0; - List userCache = new List(); + List userCache = new(); FeedResult feedResult; // Start by populating the userCache with a list of all users. diff --git a/Geotab.DataOnlyPlan.API.Examples/Examples/SetUserAsyncExample.cs b/Geotab.DataOnlyPlan.API.Examples/Examples/SetUserAsyncExample.cs index 8d24bf9..b79f1ed 100644 --- a/Geotab.DataOnlyPlan.API.Examples/Examples/SetUserAsyncExample.cs +++ b/Geotab.DataOnlyPlan.API.Examples/Examples/SetUserAsyncExample.cs @@ -15,7 +15,7 @@ public static async Task Run(GeotabDataOnlyPlanAPI api, string userId) // Update a driver with keys to a NON-driver. // Set parameter values to apply when adding device. string id = userId; - DateTime activeTo = new DateTime(2037, 1, 31); + DateTime activeTo = new(2037, 1, 31); string comment = "Driver with keys updated to NON-driver"; string designation = "Driver 2 Upd"; string employeeNo = "Employee 2 Upd"; diff --git a/Geotab.DataOnlyPlan.API.Examples/Geotab.DataOnlyPlan.API.Examples.csproj b/Geotab.DataOnlyPlan.API.Examples/Geotab.DataOnlyPlan.API.Examples.csproj index 26d6549..5e847b6 100644 --- a/Geotab.DataOnlyPlan.API.Examples/Geotab.DataOnlyPlan.API.Examples.csproj +++ b/Geotab.DataOnlyPlan.API.Examples/Geotab.DataOnlyPlan.API.Examples.csproj @@ -2,11 +2,15 @@ Exe - netcoreapp2.2 + net5.0 + Geotab Inc. + Geotab Data-Only Plan API Examples + Geotab Inc. + 1.0.2101.1 - + diff --git a/Geotab.DataOnlyPlan.API.Examples/Program.cs b/Geotab.DataOnlyPlan.API.Examples/Program.cs index 780cdda..459f3a6 100644 --- a/Geotab.DataOnlyPlan.API.Examples/Program.cs +++ b/Geotab.DataOnlyPlan.API.Examples/Program.cs @@ -18,8 +18,6 @@ static async Task Main() GeotabDataOnlyPlanAPI api; string username; string password; - string server = "my.geotab.com"; - string database = ""; string title = ""; string lastCreateDatabaseResult; @@ -41,8 +39,8 @@ static async Task Main() ConsoleUtility.LogUtilityStartup(title); // Request MyGeotab credentials and database name. - server = ConsoleUtility.GetUserInput($"MyGeotab server"); - database = ConsoleUtility.GetUserInput($"Database to run examples against.").ToLower(); + string server = ConsoleUtility.GetUserInput($"MyGeotab server"); + string database = ConsoleUtility.GetUserInput($"Database to run examples against.").ToLower(); username = ConsoleUtility.GetUserInput($"MyGeotab username"); password = ConsoleUtility.GetUserInputMasked($"MyGeotab password"); @@ -329,7 +327,7 @@ static async Task Main() finally { ConsoleUtility.LogUtilityShutdown(title); - Console.ReadKey(); + _ = Console.ReadKey(); } } } diff --git a/Geotab.DataOnlyPlan.API.Examples/Utilities/ConsoleUtility.cs b/Geotab.DataOnlyPlan.API.Examples/Utilities/ConsoleUtility.cs index 18496bc..71afbdf 100644 --- a/Geotab.DataOnlyPlan.API.Examples/Utilities/ConsoleUtility.cs +++ b/Geotab.DataOnlyPlan.API.Examples/Utilities/ConsoleUtility.cs @@ -28,6 +28,35 @@ public static string GetUserInput(string promptMessage) return userInput; } + /// + /// Prompts the user to input a directory path until a valid entry is made. The validated directory path is returned. + /// + /// The validated directory path. + public static string GetUserInputDirectory() + { + string filePath = string.Empty; + bool filePathIsValid = false; + + // Get the user to enter a valid directory path. + while (!filePathIsValid) + { + Console.ForegroundColor = Common.ConsoleColorForUserPrompts; + Console.Write($"> Enter a folder path (e.g. 'C:\\Temp'):"); + Console.ForegroundColor = Common.ConsoleColorForUserInput; + filePath = Console.ReadLine(); + Console.ForegroundColor = Common.ConsoleColorDefault; + if (Directory.Exists(filePath)) + { + filePathIsValid = true; + } + else + { + ConsoleUtility.LogError($"The folder entered does not exist."); + } + } + return filePath; + } + /// /// Prompts the user to input a file path followed by a file name until valid entries are made. The validated full path is returned. /// @@ -36,7 +65,6 @@ public static string GetUserInput(string promptMessage) public static string GetUserInputFilePath(string fileTypeDescription) { string filePath = string.Empty; - string fileName = string.Empty; string fileFullPath = string.Empty; bool filePathIsValid = false; bool fileNameIsValid = false; @@ -65,7 +93,7 @@ public static string GetUserInputFilePath(string fileTypeDescription) Console.ForegroundColor = Common.ConsoleColorForUserPrompts; Console.Write($"> Enter {fileTypeDescription} file name (e.g. 'FileName.csv'):"); Console.ForegroundColor = Common.ConsoleColorForUserInput; - fileName = Console.ReadLine(); + string fileName = Console.ReadLine(); Console.ForegroundColor = Common.ConsoleColorDefault; fileFullPath = Path.Combine(filePath, fileName); if (File.Exists(fileFullPath)) @@ -320,7 +348,7 @@ public static void LogListItems(IList> listItems, Cons { Console.Write($"- "); Console.ForegroundColor = listItemIdColor; - Console.Write($"{listItem.Key.ToString()} "); + Console.Write($"{listItem.Key} "); Console.ForegroundColor = listItemColor; Console.WriteLine($"{listItem.Value}"); } @@ -337,7 +365,7 @@ public static void LogListItems(IList> listItems, Cons Console.Write($"- "); Console.ForegroundColor = listItemIdColor; - Console.Write($"{listItem.Key.ToString().PadRight(2)} "); + Console.Write($"{listItem.Key,-2} "); Console.ForegroundColor = listItemColor; Console.Write($"{listItem.Value.PadRight(maxItemLength)} "); listItemNumber++; @@ -351,7 +379,7 @@ public static void LogListItems(IList> listItems, Cons listItem = listItems[listItemNumber]; Console.Write($"- "); Console.ForegroundColor = listItemIdColor; - Console.Write($"{listItem.Key.ToString().PadRight(2)} "); + Console.Write($"{listItem.Key,-2} "); Console.ForegroundColor = listItemColor; Console.WriteLine($"{listItem.Value.PadRight(maxItemLength)}"); } @@ -393,7 +421,7 @@ public static void LogObjectProperties(object obj) Type type = obj.GetType(); Console.WriteLine($"Type: {type.Name}"); PropertyInfo[] properties = type.GetProperties(); - Console.WriteLine($"Value: {obj.ToString()}"); + Console.WriteLine($"Value: {obj}"); Console.WriteLine($"Properties (N = {properties.Length}):"); foreach (var property in properties) { @@ -459,7 +487,7 @@ public static void LogTestStart(int testNumber, string methodName, Dictionary parameter in parameters) { - Console.WriteLine($" {parameter.Key}: {parameter.Value.ToString()}"); + Console.WriteLine($" {parameter.Key}: {parameter.Value}"); } } diff --git a/Geotab.DataOnlyPlan.API.Examples/Utilities/ExampleUtility.cs b/Geotab.DataOnlyPlan.API.Examples/Utilities/ExampleUtility.cs index c50ccc8..0238b3c 100644 --- a/Geotab.DataOnlyPlan.API.Examples/Utilities/ExampleUtility.cs +++ b/Geotab.DataOnlyPlan.API.Examples/Utilities/ExampleUtility.cs @@ -20,7 +20,7 @@ public class ExampleUtility public static async Task> GetAllDevicesAsync(Geotab.DataOnlyPlan.API.GeotabDataOnlyPlanAPI api) { const int DefaultFeedResultsLimitDevice = 5000; - List allDevices = new List(); + List allDevices = new(); long? feedVersion = 0; FeedResult feedResult; bool keepGoing = true; @@ -46,7 +46,7 @@ public static async Task> GetAllDevicesAsync(Geotab.DataOnlyPlan.AP public static async Task> GetAllDiagnosticsAsync(Geotab.DataOnlyPlan.API.GeotabDataOnlyPlanAPI api) { const int DefaultFeedResultsLimitDiagnostic = 50000; - List allDiagnostics = new List(); + List allDiagnostics = new(); long? feedVersion = 0; FeedResult feedResult; bool keepGoing = true; @@ -72,7 +72,7 @@ public static async Task> GetAllDiagnosticsAsync(Geotab.DataOnl public static async Task> GetAllDriverChangesAsync(Geotab.DataOnlyPlan.API.GeotabDataOnlyPlanAPI api) { const int DefaultFeedResultsLimitDriverChange = 50000; - List allDriverChanges = new List(); + List allDriverChanges = new(); long? feedVersion = 0; FeedResult feedResult; bool keepGoing = true; @@ -98,7 +98,7 @@ public static async Task> GetAllDriverChangesAsync(Geotab.Dat public static async Task> GetAllUsersAsync(Geotab.DataOnlyPlan.API.GeotabDataOnlyPlanAPI api) { const int DefaultFeedResultsLimitUser = 5000; - List allUsers = new List(); + List allUsers = new(); long? feedVersion = 0; FeedResult feedResult; bool keepGoing = true; diff --git a/LICENSE b/LICENSE deleted file mode 100644 index fae2424..0000000 --- a/LICENSE +++ /dev/null @@ -1,21 +0,0 @@ -MIT License - -Copyright (c) 2020 Geotab Inc. - -Permission is hereby granted, free of charge, to any person obtaining a copy -of this software and associated documentation files (the "Software"), to deal -in the Software without restriction, including without limitation the rights -to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -copies of the Software, and to permit persons to whom the Software is -furnished to do so, subject to the following conditions: - -The above copyright notice and this permission notice shall be included in all -copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE -SOFTWARE. diff --git a/README.md b/README.md index 4470c26..433c689 100644 --- a/README.md +++ b/README.md @@ -6,7 +6,7 @@ The *Geotab Data-Only Plan API Examples* solution is a Visual Studio solution th The solution requires: -- [.Net core 2.0 SDK](https://dot.net/core) or higher +- [.NET 5.0 SDK](https://dotnet.microsoft.com/download) or higher - Geotab.Checkmate.ObjectModel (included with the NuGet package) - Ideally, MyAdmin credentials with the *MyAdminApiUser* and *Device_Admin* roles should be used when authenticating in order to be able to take advantage of all available methods; MyGeotab credentials may be used, but then the *CreateDatabaseAsync()* method cannot be used.