Compare commits
6 Commits
fe2499707d
...
80e35223e0
| Author | SHA1 | Date | |
|---|---|---|---|
| 80e35223e0 | |||
| dd61368233 | |||
| 5bf5a2c8fa | |||
| a289b014a3 | |||
| f26465398a | |||
| cc743cd602 |
@ -1 +1 @@
|
||||
1.2.0.0
|
||||
1.2.1.2
|
||||
@ -8,8 +8,8 @@
|
||||
<SignAssembly>True</SignAssembly>
|
||||
<StartupObject>BreCalClient.App</StartupObject>
|
||||
<AssemblyOriginatorKeyFile>..\..\misc\brecal.snk</AssemblyOriginatorKeyFile>
|
||||
<AssemblyVersion>1.2.0.10</AssemblyVersion>
|
||||
<FileVersion>1.2.0.0</FileVersion>
|
||||
<AssemblyVersion>1.2.1.2</AssemblyVersion>
|
||||
<FileVersion>1.2.1.2</FileVersion>
|
||||
<Title>Bremen calling client</Title>
|
||||
<Description>A Windows WPF client for the Bremen calling API.</Description>
|
||||
<ApplicationIcon>containership.ico</ApplicationIcon>
|
||||
|
||||
@ -38,7 +38,8 @@ namespace BreCalClient
|
||||
|
||||
#region Fields
|
||||
|
||||
private static int _uiUpdateRunning = 0;
|
||||
//private static int _uiUpdateRunning = 0;
|
||||
private static SemaphoreSlim uiLock = new SemaphoreSlim(1);
|
||||
|
||||
private Credentials? _credentials;
|
||||
|
||||
@ -97,9 +98,10 @@ namespace BreCalClient
|
||||
var jitterer = new Random();
|
||||
|
||||
var retryPolicy =
|
||||
Policy.Handle<HttpRequestException>()
|
||||
.OrResult<RestSharp.RestResponse>(resp => resp.StatusCode == HttpStatusCode.Unauthorized)
|
||||
.WaitAndRetryAsync(3,
|
||||
// Policy.Handle<HttpRequestException>()
|
||||
Policy.HandleResult<RestSharp.RestResponse>(resp => resp.StatusCode == HttpStatusCode.Unauthorized)
|
||||
//.OrResult<RestSharp.RestResponse>
|
||||
.WaitAndRetryAsync(1,
|
||||
retryAttempt =>
|
||||
{
|
||||
var calculatedDelayInMilliseconds = Math.Pow(2, retryAttempt) * 1000;
|
||||
@ -114,6 +116,7 @@ namespace BreCalClient
|
||||
Trace.WriteLine("token refreshed");
|
||||
});
|
||||
RetryConfiguration.AsyncRetryPolicy = retryPolicy;
|
||||
|
||||
this.generalProgressStatus.Maximum = PROGRESS_STEPS;
|
||||
}
|
||||
|
||||
@ -235,7 +238,7 @@ namespace BreCalClient
|
||||
NewWithModel(null);
|
||||
}
|
||||
|
||||
private void NewWithModel(ShipcallControlModel? model)
|
||||
private async void NewWithModel(ShipcallControlModel? model)
|
||||
{
|
||||
EditShipcallControl esc = new()
|
||||
{
|
||||
@ -250,7 +253,9 @@ namespace BreCalClient
|
||||
// create UI & save new dialog model
|
||||
if (esc.ShipcallModel.Shipcall != null)
|
||||
{
|
||||
await uiLock.WaitAsync();
|
||||
this.UpdateUI();
|
||||
uiLock.Release();
|
||||
|
||||
esc.ShipcallModel.Shipcall?.Participants.Clear();
|
||||
foreach (ParticipantAssignment pa in esc.ShipcallModel.AssignedParticipants.Values)
|
||||
@ -344,10 +349,12 @@ namespace BreCalClient
|
||||
this.FilterShipcalls();
|
||||
}
|
||||
|
||||
private void SearchFilterControl_SearchFilterChanged()
|
||||
private async void SearchFilterControl_SearchFilterChanged()
|
||||
{
|
||||
this.FilterShipcalls();
|
||||
await uiLock.WaitAsync();
|
||||
this.UpdateUI();
|
||||
uiLock.Release();
|
||||
}
|
||||
|
||||
private void checkboxShowCancelledCalls_Checked(object sender, RoutedEventArgs e)
|
||||
@ -356,11 +363,13 @@ namespace BreCalClient
|
||||
this.SearchFilterControl_SearchFilterChanged();
|
||||
}
|
||||
|
||||
private void comboBoxSortOrder_SelectionChanged(object sender, System.Windows.Controls.SelectionChangedEventArgs e)
|
||||
private async void comboBoxSortOrder_SelectionChanged(object sender, System.Windows.Controls.SelectionChangedEventArgs e)
|
||||
{
|
||||
_sortOrder = (Extensions.SortOrder) this.comboBoxSortOrder.SelectedIndex;
|
||||
this.FilterShipcalls();
|
||||
await uiLock.WaitAsync();
|
||||
this.UpdateUI();
|
||||
uiLock.Release();
|
||||
}
|
||||
|
||||
private void buttonHistory_Click(object sender, RoutedEventArgs e)
|
||||
@ -445,6 +454,7 @@ namespace BreCalClient
|
||||
{
|
||||
labelGeneralStatus.Text = $"Connection {ConnectionStatus.SUCCESSFUL}";
|
||||
labelLatestUpdate.Text = $"Last update: {DateTime.Now.ToLongTimeString()}";
|
||||
labelStatusBar.Text = "";
|
||||
generalProgressStatus.Value = 0;
|
||||
}));
|
||||
}
|
||||
@ -462,49 +472,68 @@ namespace BreCalClient
|
||||
}
|
||||
}
|
||||
|
||||
if (shipcalls != null)
|
||||
try
|
||||
{
|
||||
foreach (Shipcall shipcall in shipcalls)
|
||||
{
|
||||
// load times for each shipcall
|
||||
List<Times> currentTimes = await _timesApi.TimesGetAsync(shipcall.Id);
|
||||
|
||||
if(!_allShipcallsDict.ContainsKey(shipcall.Id))
|
||||
if (shipcalls != null)
|
||||
{
|
||||
foreach (Shipcall shipcall in shipcalls)
|
||||
{
|
||||
// add entry
|
||||
ShipcallControlModel scm = new()
|
||||
// load times for each shipcall
|
||||
List<Times> currentTimes = await _timesApi.TimesGetAsync(shipcall.Id);
|
||||
|
||||
if (!_allShipcallsDict.ContainsKey(shipcall.Id))
|
||||
{
|
||||
Shipcall = shipcall,
|
||||
Times = currentTimes
|
||||
};
|
||||
this.AddShipcall(scm);
|
||||
// add entry
|
||||
ShipcallControlModel scm = new()
|
||||
{
|
||||
Shipcall = shipcall,
|
||||
Times = currentTimes
|
||||
};
|
||||
this.AddShipcall(scm);
|
||||
}
|
||||
else
|
||||
{
|
||||
// update entry
|
||||
_allShipcallsDict[shipcall.Id].Shipcall = shipcall;
|
||||
_allShipcallsDict[shipcall.Id].Times = currentTimes;
|
||||
UpdateShipcall(_allShipcallsDict[shipcall.Id]);
|
||||
}
|
||||
}
|
||||
else
|
||||
|
||||
List<int> existingIds = new(this._allShipcallsDict.Keys);
|
||||
|
||||
foreach (int existingId in existingIds)
|
||||
{
|
||||
// update entry
|
||||
_allShipcallsDict[shipcall.Id].Shipcall = shipcall;
|
||||
_allShipcallsDict[shipcall.Id].Times = currentTimes;
|
||||
UpdateShipcall(_allShipcallsDict[shipcall.Id]);
|
||||
if (shipcalls.Find(s => s.Id == existingId) == null) // the model is no longer in the search result
|
||||
{
|
||||
this.RemoveShipcall(existingId);
|
||||
}
|
||||
}
|
||||
|
||||
this.FilterShipcalls();
|
||||
await uiLock.WaitAsync();
|
||||
this.UpdateUI();
|
||||
}
|
||||
|
||||
List<int> existingIds = new(this._allShipcallsDict.Keys);
|
||||
|
||||
foreach (int existingId in existingIds)
|
||||
{
|
||||
if (shipcalls.Find(s => s.Id == existingId) == null) // the model is no longer in the search result
|
||||
{
|
||||
this.RemoveShipcall(existingId);
|
||||
}
|
||||
}
|
||||
|
||||
this.FilterShipcalls();
|
||||
this.UpdateUI();
|
||||
}
|
||||
catch(Exception ex)
|
||||
{
|
||||
_log.Error(ex);
|
||||
}
|
||||
finally
|
||||
{
|
||||
uiLock.Release();
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
double interval = (double) SHIPCALL_UPDATE_INTERVAL_SECONDS / PROGRESS_STEPS;
|
||||
|
||||
|
||||
//if (Interlocked.CompareExchange(ref _uiUpdateRunning, 1, 0) == 1) // do not restart progress unless UI update has completed
|
||||
// await Task.Delay(TimeSpan.FromSeconds(interval));
|
||||
|
||||
System.Diagnostics.Trace.WriteLine("restarting refresh countdown");
|
||||
for (int i = 0; i < PROGRESS_STEPS; i++)
|
||||
{
|
||||
await Task.Delay(TimeSpan.FromSeconds(interval), _tokenSource.Token);
|
||||
@ -762,7 +791,7 @@ namespace BreCalClient
|
||||
|
||||
this.Dispatcher.Invoke(new Action(() =>
|
||||
{
|
||||
if (Interlocked.CompareExchange(ref _uiUpdateRunning, 1, 0) == 1) return;
|
||||
//if (Interlocked.CompareExchange(ref _uiUpdateRunning, 1, 0) == 1) return;
|
||||
|
||||
try
|
||||
{
|
||||
@ -782,7 +811,7 @@ namespace BreCalClient
|
||||
}
|
||||
finally
|
||||
{
|
||||
_uiUpdateRunning = 0;
|
||||
// _uiUpdateRunning = 0;
|
||||
}
|
||||
|
||||
Mouse.OverrideCursor = null;
|
||||
|
||||
@ -5,7 +5,7 @@ https://go.microsoft.com/fwlink/?LinkID=208121.
|
||||
<Project>
|
||||
<PropertyGroup>
|
||||
<ApplicationRevision>10</ApplicationRevision>
|
||||
<ApplicationVersion>1.2.0.10</ApplicationVersion>
|
||||
<ApplicationVersion>1.2.1.2</ApplicationVersion>
|
||||
<BootstrapperEnabled>False</BootstrapperEnabled>
|
||||
<Configuration>Release</Configuration>
|
||||
<CreateWebPageOnPublish>True</CreateWebPageOnPublish>
|
||||
|
||||
Loading…
Reference in New Issue
Block a user