Skip to content

Commit 1168158

Browse files
committed
Updated to version 3.2.0.
1 parent 391dc2f commit 1168158

File tree

54 files changed

+3713
-188
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

54 files changed

+3713
-188
lines changed

MyGeotabAPIAdapter.DataOptimizer/MyGeotabAPIAdapter.DataOptimizer.csproj

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,8 @@
66
<Authors>Geotab Inc.</Authors>
77
<Company>Geotab Inc.</Company>
88
<Product>MyGeotab API Adapter - DataOptimizer</Product>
9-
<AssemblyVersion>3.1.0.0</AssemblyVersion>
10-
<FileVersion>3.1.0.0</FileVersion>
9+
<AssemblyVersion>3.2.0.0</AssemblyVersion>
10+
<FileVersion>3.2.0.0</FileVersion>
1111
<RuntimeIdentifiers>win-x64;linux-x64</RuntimeIdentifiers>
1212
<Description>A worker service designed to migrate data from the MyGeotab API Adapter database into another set of tables that are optimized for use by applications and data analysis tools. Additional columns are added to some of the tables and these are populated via interpolation or other query-based procedues.</Description>
1313
</PropertyGroup>

MyGeotabAPIAdapter.Database/AdapterDatabaseObjectNames.cs

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -103,6 +103,9 @@ public class AdapterDatabaseObjectNames : IAdapterDatabaseObjectNames
103103
/// <inheritdoc/>
104104
public string DbRuleTableName => "Rules";
105105

106+
/// <inheritdoc/>
107+
public string DbRule2TableName => "Rules2";
108+
106109
/// <inheritdoc/>
107110
public string DbStatusDataTableName => "StatusData";
108111

@@ -127,6 +130,12 @@ public class AdapterDatabaseObjectNames : IAdapterDatabaseObjectNames
127130
/// <inheritdoc/>
128131
public string DbStgGroup2TableName => "stg_Groups2";
129132

133+
/// <inheritdoc/>
134+
public string DbStgRule2TableName => "stg_Rules2";
135+
136+
/// <inheritdoc/>
137+
public string DbStgTrip2TableName => "stg_Trips2";
138+
130139
/// <inheritdoc/>
131140
public string DbStgUser2TableName => "stg_Users2";
132141

@@ -139,6 +148,9 @@ public class AdapterDatabaseObjectNames : IAdapterDatabaseObjectNames
139148
/// <inheritdoc/>
140149
public string DbTripTableName => "Trips";
141150

151+
/// <inheritdoc/>
152+
public string DbTrip2TableName => "Trips2";
153+
142154
/// <inheritdoc/>
143155
public string DbUserTableName => "Users";
144156

@@ -169,6 +181,12 @@ public class AdapterDatabaseObjectNames : IAdapterDatabaseObjectNames
169181
/// <inheritdoc/>
170182
public string MergeStagingGroupsProcedureName => "spMerge_stg_Groups2";
171183

184+
/// <inheritdoc/>
185+
public string MergeStagingRulesProcedureName => "spMerge_stg_Rules2";
186+
187+
/// <inheritdoc/>
188+
public string MergeStagingTripsProcedureName => "spMerge_stg_Trips2";
189+
172190
/// <inheritdoc/>
173191
public string MergeStagingUsersProcedureName => "spMerge_stg_Users2";
174192

MyGeotabAPIAdapter.Database/DatabaseValidator.cs

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,11 @@
1-
using MyGeotabAPIAdapter.Configuration;
2-
using MyGeotabAPIAdapter.Database;
3-
using MyGeotabAPIAdapter.Database.DataAccess;
1+
using MyGeotabAPIAdapter.Database.DataAccess;
42
using MyGeotabAPIAdapter.Database.Models;
53
using MyGeotabAPIAdapter.Logging;
64
using NLog;
75
using System;
8-
using System.Collections.Generic;
96
using System.Linq;
107
using System.Reflection;
118
using System.Threading;
12-
using System.Threading.Tasks;
139

1410
namespace MyGeotabAPIAdapter.Database
1511
{
@@ -21,7 +17,7 @@ public class DatabaseValidator : IDatabaseValidator
2117
// The required version of the middleware database for the current version of the middleware application. Any time the middleware database is updated as part of an application update:
2218
// 1. This value should be updated to reflect the application version at the time.
2319
// 2. Database changes should be included in a single script file and the filename should be formatted as "prefix_version_suffix.sql" (e.g. "MSSQL_3.0.0.0_InitialSchemaCreation.sql") where the version portion of the filename is equal to the value of this constant.
24-
const string RequiredDatabaseVersion = "3.1.0.0";
20+
const string RequiredDatabaseVersion = "3.2.0.0";
2521

2622
readonly IExceptionHelper exceptionHelper;
2723
readonly Logger logger = LogManager.GetCurrentClassLogger();

MyGeotabAPIAdapter.Database/IAdapterDatabaseObjectNames.cs

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -173,6 +173,11 @@ public interface IAdapterDatabaseObjectNames
173173
/// </summary>
174174
string DbRuleTableName { get; }
175175

176+
/// <summary>
177+
/// The name of the database table associated with <see cref="DbRule2"/> entities.
178+
/// </summary>
179+
string DbRule2TableName { get; }
180+
176181
/// <summary>
177182
/// The name of the database table associated with <see cref="DbStatusData"/> entities.
178183
/// </summary>
@@ -213,6 +218,16 @@ public interface IAdapterDatabaseObjectNames
213218
/// </summary>
214219
string DbStgGroup2TableName { get; }
215220

221+
/// <summary>
222+
/// The name of the database table associated with <see cref="DbStgRule2"/> entities.
223+
/// </summary>
224+
string DbStgRule2TableName { get; }
225+
226+
/// <summary>
227+
/// The name of the database table associated with <see cref="DbStgTrip2"/> entities.
228+
/// </summary>
229+
string DbStgTrip2TableName { get; }
230+
216231
/// <summary>
217232
/// The name of the database table associated with <see cref="DbStgUser2"/> entities.
218233
/// </summary>
@@ -233,6 +248,11 @@ public interface IAdapterDatabaseObjectNames
233248
/// </summary>
234249
string DbTripTableName { get; }
235250

251+
/// <summary>
252+
/// The name of the database table associated with <see cref="DbTrip2"/> entities.
253+
/// </summary>
254+
string DbTrip2TableName { get; }
255+
236256
/// <summary>
237257
/// The name of the database table associated with <see cref="DbUser"/> entities.
238258
/// </summary>
@@ -283,6 +303,16 @@ public interface IAdapterDatabaseObjectNames
283303
/// </summary>
284304
string MergeStagingGroupsProcedureName { get; }
285305

306+
/// <summary>
307+
/// The name of the stored procedure or function responsible for merging staging Rules into the main Rules2 table.
308+
/// </summary>
309+
string MergeStagingRulesProcedureName { get; }
310+
311+
/// <summary>
312+
/// The name of the stored procedure or function responsible for merging staging Trips into the main Trips2 table.
313+
/// </summary>
314+
string MergeStagingTripsProcedureName { get; }
315+
286316
/// <summary>
287317
/// The name of the stored procedure or function responsible for merging staging Users into the main Users2 table.
288318
/// </summary>
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
#nullable enable
2+
using Dapper.Contrib.Extensions;
3+
using System;
4+
5+
namespace MyGeotabAPIAdapter.Database.Models
6+
{
7+
[Table("Rules2")]
8+
public class DbRule2 : IDbEntity, IIdCacheableDbEntity, IStatusableDbEntity
9+
{
10+
/// <inheritdoc/>
11+
[Write(false)]
12+
public string DatabaseTableName => "Rules2";
13+
14+
/// <inheritdoc/>
15+
[Write(false)]
16+
public Common.DatabaseWriteOperationType DatabaseWriteOperationType { get; set; }
17+
18+
/// <inheritdoc/>
19+
[Write(false)]
20+
public DateTime LastUpsertedUtc { get => RecordLastChangedUtc; }
21+
22+
[Key]
23+
public long id { get; set; }
24+
public string GeotabId { get; set; }
25+
public string Name { get; set; }
26+
public string BaseType { get; set; }
27+
public DateTime? ActiveFrom { get; set; }
28+
public DateTime? ActiveTo { get; set; }
29+
public string Comment { get; set; }
30+
public string? Groups { get; set; }
31+
public long? Version { get; set; }
32+
public int EntityStatus { get; set; }
33+
[ChangeTracker]
34+
public DateTime RecordLastChangedUtc { get; set; }
35+
}
36+
}
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
#nullable enable
2+
using Dapper.Contrib.Extensions;
3+
using System;
4+
5+
namespace MyGeotabAPIAdapter.Database.Models
6+
{
7+
[Table("stg_Rules2")]
8+
public class DbStgRule2 : IDbEntity, IIdCacheableDbEntity, IStatusableDbEntity
9+
{
10+
/// <inheritdoc/>
11+
[Write(false)]
12+
public string DatabaseTableName => "stg_Rules2";
13+
14+
/// <inheritdoc/>
15+
[Write(false)]
16+
public Common.DatabaseWriteOperationType DatabaseWriteOperationType { get; set; }
17+
18+
/// <inheritdoc/>
19+
[Write(false)]
20+
public DateTime LastUpsertedUtc { get => RecordLastChangedUtc; }
21+
22+
[Key]
23+
public long id { get; set; }
24+
public string GeotabId { get; set; }
25+
public string Name { get; set; }
26+
public string BaseType { get; set; }
27+
public DateTime? ActiveFrom { get; set; }
28+
public DateTime? ActiveTo { get; set; }
29+
public string Comment { get; set; }
30+
public string? Groups { get; set; }
31+
public long? Version { get; set; }
32+
public int EntityStatus { get; set; }
33+
[ChangeTracker]
34+
public DateTime RecordLastChangedUtc { get; set; }
35+
}
36+
}
Lines changed: 172 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,172 @@
1+
using Dapper.Contrib.Extensions;
2+
using System;
3+
4+
namespace MyGeotabAPIAdapter.Database.Models
5+
{
6+
[Table("stg_Trips2")]
7+
public class DbStgTrip2 : IDbEntity
8+
{
9+
/// <inheritdoc/>
10+
[Write(false)]
11+
public string DatabaseTableName => "stg_Trips2";
12+
13+
/// <inheritdoc/>
14+
[Write(false)]
15+
public Common.DatabaseWriteOperationType DatabaseWriteOperationType { get; set; }
16+
17+
[Key]
18+
public long id { get; set; }
19+
public string GeotabId { get; set; }
20+
public float? AfterHoursDistance { get; set; }
21+
[Write(false)]
22+
public TimeSpan? AfterHoursDrivingDuration
23+
{
24+
get { return TimeSpan.FromTicks(AfterHoursDrivingDurationTicks.GetValueOrDefault()); }
25+
set
26+
{
27+
if (value.HasValue)
28+
{
29+
AfterHoursDrivingDurationTicks = value.Value.Ticks;
30+
}
31+
}
32+
}
33+
public long? AfterHoursDrivingDurationTicks { get; set; }
34+
public bool? AfterHoursEnd { get; set; }
35+
public bool? AfterHoursStart { get; set; }
36+
[Write(false)]
37+
public TimeSpan? AfterHoursStopDuration
38+
{
39+
get { return TimeSpan.FromTicks(AfterHoursStopDurationTicks.GetValueOrDefault()); }
40+
set
41+
{
42+
if (value.HasValue)
43+
{
44+
AfterHoursStopDurationTicks = value.Value.Ticks;
45+
}
46+
}
47+
}
48+
public long? AfterHoursStopDurationTicks { get; set; }
49+
public float? AverageSpeed { get; set; }
50+
public DateTime? DeletedDateTime { get; set; }
51+
public long DeviceId { get; set; }
52+
public float? Distance { get; set; }
53+
public long? DriverId { get; set; }
54+
[Write(false)]
55+
public TimeSpan? DrivingDuration
56+
{
57+
get { return TimeSpan.FromTicks(DrivingDurationTicks.GetValueOrDefault()); }
58+
set
59+
{
60+
if (value.HasValue)
61+
{
62+
DrivingDurationTicks = value.Value.Ticks;
63+
}
64+
}
65+
}
66+
public long? DrivingDurationTicks { get; set; }
67+
[Write(false)]
68+
public TimeSpan? IdlingDuration
69+
{
70+
get { return TimeSpan.FromTicks(IdlingDurationTicks.GetValueOrDefault()); }
71+
set
72+
{
73+
if (value.HasValue)
74+
{
75+
IdlingDurationTicks = value.Value.Ticks;
76+
}
77+
}
78+
}
79+
public long? IdlingDurationTicks { get; set; }
80+
public float? MaximumSpeed { get; set; }
81+
public DateTime? NextTripStart { get; set; }
82+
public int? SpeedRange1 { get; set; }
83+
[Write(false)]
84+
public TimeSpan? SpeedRange1Duration
85+
{
86+
get { return TimeSpan.FromTicks(SpeedRange1DurationTicks.GetValueOrDefault()); }
87+
set
88+
{
89+
if (value.HasValue)
90+
{
91+
SpeedRange1DurationTicks = value.Value.Ticks;
92+
}
93+
}
94+
}
95+
public long? SpeedRange1DurationTicks { get; set; }
96+
public int? SpeedRange2 { get; set; }
97+
[Write(false)]
98+
public TimeSpan? SpeedRange2Duration
99+
{
100+
get { return TimeSpan.FromTicks(SpeedRange2DurationTicks.GetValueOrDefault()); }
101+
set
102+
{
103+
if (value.HasValue)
104+
{
105+
SpeedRange2DurationTicks = value.Value.Ticks;
106+
}
107+
}
108+
}
109+
public long? SpeedRange2DurationTicks { get; set; }
110+
public int? SpeedRange3 { get; set; }
111+
[Write(false)]
112+
public TimeSpan? SpeedRange3Duration
113+
{
114+
get { return TimeSpan.FromTicks(SpeedRange3DurationTicks.GetValueOrDefault()); }
115+
set
116+
{
117+
if (value.HasValue)
118+
{
119+
SpeedRange3DurationTicks = value.Value.Ticks;
120+
}
121+
}
122+
}
123+
public long? SpeedRange3DurationTicks { get; set; }
124+
public DateTime? Start { get; set; }
125+
public DateTime? Stop { get; set; }
126+
[Write(false)]
127+
public TimeSpan? StopDuration
128+
{
129+
get { return TimeSpan.FromTicks(StopDurationTicks.GetValueOrDefault()); }
130+
set
131+
{
132+
if (value.HasValue)
133+
{
134+
StopDurationTicks = value.Value.Ticks;
135+
}
136+
}
137+
}
138+
public long? StopDurationTicks { get; set; }
139+
public double? StopPointX { get; set; }
140+
public double? StopPointY { get; set; }
141+
public float? WorkDistance { get; set; }
142+
[Write(false)]
143+
public TimeSpan? WorkDrivingDuration
144+
{
145+
get { return TimeSpan.FromTicks(WorkDrivingDurationTicks.GetValueOrDefault()); }
146+
set
147+
{
148+
if (value.HasValue)
149+
{
150+
WorkDrivingDurationTicks = value.Value.Ticks;
151+
}
152+
}
153+
}
154+
public long? WorkDrivingDurationTicks { get; set; }
155+
[Write(false)]
156+
public TimeSpan? WorkStopDuration
157+
{
158+
get { return TimeSpan.FromTicks(WorkStopDurationTicks.GetValueOrDefault()); }
159+
set
160+
{
161+
if (value.HasValue)
162+
{
163+
WorkStopDurationTicks = value.Value.Ticks;
164+
}
165+
}
166+
}
167+
public long? WorkStopDurationTicks { get; set; }
168+
public int EntityStatus { get; set; }
169+
[ChangeTracker]
170+
public DateTime RecordLastChangedUtc { get; set; }
171+
}
172+
}

0 commit comments

Comments
 (0)