Include getlatest endpoint in yaml and call before shipcall sync in reg update
This commit is contained in:
parent
50e9261267
commit
129b8c8d49
1711
misc/BreCalApi.cs
1711
misc/BreCalApi.cs
File diff suppressed because it is too large
Load Diff
@ -457,8 +457,43 @@ paths:
|
||||
$ref: '#/components/responses/500'
|
||||
'503':
|
||||
$ref: '#/components/responses/503'
|
||||
/getlatest:
|
||||
get:
|
||||
description: 'Returns timestamps for latest data changes'
|
||||
summary: Get latest timestamps of changes
|
||||
tags:
|
||||
- shipcall
|
||||
operationId: getLatest
|
||||
responses:
|
||||
'200':
|
||||
description: ship call list
|
||||
content:
|
||||
application/json:
|
||||
schema:
|
||||
$ref: '#/components/schemas/latest'
|
||||
'401':
|
||||
$ref: '#/components/responses/401'
|
||||
'500':
|
||||
$ref: '#/components/responses/500'
|
||||
'503':
|
||||
$ref: '#/components/responses/503'
|
||||
components:
|
||||
schemas:
|
||||
latest:
|
||||
type: object
|
||||
properties:
|
||||
shipcalls:
|
||||
type: string
|
||||
format: date-time
|
||||
nullable: true
|
||||
times:
|
||||
type: string
|
||||
format: date-time
|
||||
nullable: true
|
||||
ship:
|
||||
type: string
|
||||
format: date-time
|
||||
nullable: true
|
||||
credentials:
|
||||
type: object
|
||||
properties:
|
||||
|
||||
@ -39,7 +39,7 @@ namespace BreCalClient
|
||||
#region Fields
|
||||
|
||||
//private static int _uiUpdateRunning = 0;
|
||||
private static SemaphoreSlim uiLock = new SemaphoreSlim(1);
|
||||
private static readonly SemaphoreSlim uiLock = new SemaphoreSlim(1);
|
||||
|
||||
private Credentials? _credentials;
|
||||
|
||||
@ -65,6 +65,10 @@ namespace BreCalClient
|
||||
// private bool _sequenceChanged = false;
|
||||
private HistoryDialog? _historyDialog;
|
||||
|
||||
// Fields to store the latest check flags
|
||||
private DateTime? _latestShipcall;
|
||||
private DateTime? _latestShip;
|
||||
|
||||
#endregion
|
||||
|
||||
#region Enums
|
||||
@ -443,7 +447,47 @@ namespace BreCalClient
|
||||
}
|
||||
|
||||
List<Shipcall>? shipcalls = null;
|
||||
bool skipShipLoad, skipShipcallLoad;
|
||||
skipShipLoad = false;
|
||||
skipShipcallLoad = false;
|
||||
|
||||
try
|
||||
{
|
||||
// this only works with API v1.3 onwards
|
||||
Latest latest = await _shipcallApi.GetLatestAsync();
|
||||
|
||||
if (latest != null)
|
||||
{
|
||||
// compare timestamps to decide whether an update is required
|
||||
if ((_latestShip != null) && ((latest.Ship.HasValue &&
|
||||
(latest.Ship.Value <= _latestShip.Value)) ||
|
||||
!_latestShip.HasValue)
|
||||
)
|
||||
{
|
||||
skipShipLoad = true;
|
||||
}
|
||||
|
||||
if(!skipShipLoad)
|
||||
{
|
||||
_latestShip = latest.Ship ?? DateTime.Now;
|
||||
}
|
||||
|
||||
|
||||
if ((_latestShipcall != null) && ((latest.Shipcalls.HasValue &&
|
||||
(latest.Shipcalls.Value <= _latestShipcall.Value)) ||
|
||||
!_latestShipcall.HasValue)
|
||||
)
|
||||
{
|
||||
skipShipcallLoad = true;
|
||||
}
|
||||
|
||||
if(!skipShipcallLoad)
|
||||
{
|
||||
_latestShipcall = latest.Shipcalls ?? DateTime.Now;
|
||||
}
|
||||
}
|
||||
|
||||
if (!skipShipcallLoad)
|
||||
{
|
||||
if (this.searchPastDays != 0)
|
||||
shipcalls = await _shipcallApi.ShipcallsGetAsync(this.searchPastDays);
|
||||
@ -458,6 +502,7 @@ namespace BreCalClient
|
||||
generalProgressStatus.Value = 0;
|
||||
}));
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
this.Dispatcher.Invoke(new Action(() =>
|
||||
|
||||
Reference in New Issue
Block a user