Compare commits

..

No commits in common. "80e35223e04ee08d3b40412303c0243fee19dcba" and "fe2499707d7689149442dc89ba794f74266fcebd" have entirely different histories.

4 changed files with 43 additions and 72 deletions

View File

@ -1 +1 @@
1.2.1.2 1.2.0.0

View File

@ -8,8 +8,8 @@
<SignAssembly>True</SignAssembly> <SignAssembly>True</SignAssembly>
<StartupObject>BreCalClient.App</StartupObject> <StartupObject>BreCalClient.App</StartupObject>
<AssemblyOriginatorKeyFile>..\..\misc\brecal.snk</AssemblyOriginatorKeyFile> <AssemblyOriginatorKeyFile>..\..\misc\brecal.snk</AssemblyOriginatorKeyFile>
<AssemblyVersion>1.2.1.2</AssemblyVersion> <AssemblyVersion>1.2.0.10</AssemblyVersion>
<FileVersion>1.2.1.2</FileVersion> <FileVersion>1.2.0.0</FileVersion>
<Title>Bremen calling client</Title> <Title>Bremen calling client</Title>
<Description>A Windows WPF client for the Bremen calling API.</Description> <Description>A Windows WPF client for the Bremen calling API.</Description>
<ApplicationIcon>containership.ico</ApplicationIcon> <ApplicationIcon>containership.ico</ApplicationIcon>

View File

@ -38,8 +38,7 @@ namespace BreCalClient
#region Fields #region Fields
//private static int _uiUpdateRunning = 0; private static int _uiUpdateRunning = 0;
private static SemaphoreSlim uiLock = new SemaphoreSlim(1);
private Credentials? _credentials; private Credentials? _credentials;
@ -98,10 +97,9 @@ namespace BreCalClient
var jitterer = new Random(); var jitterer = new Random();
var retryPolicy = var retryPolicy =
// Policy.Handle<HttpRequestException>() Policy.Handle<HttpRequestException>()
Policy.HandleResult<RestSharp.RestResponse>(resp => resp.StatusCode == HttpStatusCode.Unauthorized) .OrResult<RestSharp.RestResponse>(resp => resp.StatusCode == HttpStatusCode.Unauthorized)
//.OrResult<RestSharp.RestResponse> .WaitAndRetryAsync(3,
.WaitAndRetryAsync(1,
retryAttempt => retryAttempt =>
{ {
var calculatedDelayInMilliseconds = Math.Pow(2, retryAttempt) * 1000; var calculatedDelayInMilliseconds = Math.Pow(2, retryAttempt) * 1000;
@ -116,7 +114,6 @@ namespace BreCalClient
Trace.WriteLine("token refreshed"); Trace.WriteLine("token refreshed");
}); });
RetryConfiguration.AsyncRetryPolicy = retryPolicy; RetryConfiguration.AsyncRetryPolicy = retryPolicy;
this.generalProgressStatus.Maximum = PROGRESS_STEPS; this.generalProgressStatus.Maximum = PROGRESS_STEPS;
} }
@ -238,7 +235,7 @@ namespace BreCalClient
NewWithModel(null); NewWithModel(null);
} }
private async void NewWithModel(ShipcallControlModel? model) private void NewWithModel(ShipcallControlModel? model)
{ {
EditShipcallControl esc = new() EditShipcallControl esc = new()
{ {
@ -253,9 +250,7 @@ namespace BreCalClient
// create UI & save new dialog model // create UI & save new dialog model
if (esc.ShipcallModel.Shipcall != null) if (esc.ShipcallModel.Shipcall != null)
{ {
await uiLock.WaitAsync();
this.UpdateUI(); this.UpdateUI();
uiLock.Release();
esc.ShipcallModel.Shipcall?.Participants.Clear(); esc.ShipcallModel.Shipcall?.Participants.Clear();
foreach (ParticipantAssignment pa in esc.ShipcallModel.AssignedParticipants.Values) foreach (ParticipantAssignment pa in esc.ShipcallModel.AssignedParticipants.Values)
@ -349,12 +344,10 @@ namespace BreCalClient
this.FilterShipcalls(); this.FilterShipcalls();
} }
private async void SearchFilterControl_SearchFilterChanged() private void SearchFilterControl_SearchFilterChanged()
{ {
this.FilterShipcalls(); this.FilterShipcalls();
await uiLock.WaitAsync();
this.UpdateUI(); this.UpdateUI();
uiLock.Release();
} }
private void checkboxShowCancelledCalls_Checked(object sender, RoutedEventArgs e) private void checkboxShowCancelledCalls_Checked(object sender, RoutedEventArgs e)
@ -363,13 +356,11 @@ namespace BreCalClient
this.SearchFilterControl_SearchFilterChanged(); this.SearchFilterControl_SearchFilterChanged();
} }
private async void comboBoxSortOrder_SelectionChanged(object sender, System.Windows.Controls.SelectionChangedEventArgs e) private void comboBoxSortOrder_SelectionChanged(object sender, System.Windows.Controls.SelectionChangedEventArgs e)
{ {
_sortOrder = (Extensions.SortOrder) this.comboBoxSortOrder.SelectedIndex; _sortOrder = (Extensions.SortOrder) this.comboBoxSortOrder.SelectedIndex;
this.FilterShipcalls(); this.FilterShipcalls();
await uiLock.WaitAsync();
this.UpdateUI(); this.UpdateUI();
uiLock.Release();
} }
private void buttonHistory_Click(object sender, RoutedEventArgs e) private void buttonHistory_Click(object sender, RoutedEventArgs e)
@ -454,7 +445,6 @@ namespace BreCalClient
{ {
labelGeneralStatus.Text = $"Connection {ConnectionStatus.SUCCESSFUL}"; labelGeneralStatus.Text = $"Connection {ConnectionStatus.SUCCESSFUL}";
labelLatestUpdate.Text = $"Last update: {DateTime.Now.ToLongTimeString()}"; labelLatestUpdate.Text = $"Last update: {DateTime.Now.ToLongTimeString()}";
labelStatusBar.Text = "";
generalProgressStatus.Value = 0; generalProgressStatus.Value = 0;
})); }));
} }
@ -472,9 +462,6 @@ namespace BreCalClient
} }
} }
try
{
if (shipcalls != null) if (shipcalls != null)
{ {
foreach (Shipcall shipcall in shipcalls) foreach (Shipcall shipcall in shipcalls)
@ -482,7 +469,7 @@ namespace BreCalClient
// load times for each shipcall // load times for each shipcall
List<Times> currentTimes = await _timesApi.TimesGetAsync(shipcall.Id); List<Times> currentTimes = await _timesApi.TimesGetAsync(shipcall.Id);
if (!_allShipcallsDict.ContainsKey(shipcall.Id)) if(!_allShipcallsDict.ContainsKey(shipcall.Id))
{ {
// add entry // add entry
ShipcallControlModel scm = new() ShipcallControlModel scm = new()
@ -512,28 +499,12 @@ namespace BreCalClient
} }
this.FilterShipcalls(); this.FilterShipcalls();
await uiLock.WaitAsync();
this.UpdateUI(); this.UpdateUI();
} }
}
catch(Exception ex)
{
_log.Error(ex);
}
finally
{
uiLock.Release();
}
try try
{ {
double interval = (double) SHIPCALL_UPDATE_INTERVAL_SECONDS / PROGRESS_STEPS; 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++) for (int i = 0; i < PROGRESS_STEPS; i++)
{ {
await Task.Delay(TimeSpan.FromSeconds(interval), _tokenSource.Token); await Task.Delay(TimeSpan.FromSeconds(interval), _tokenSource.Token);
@ -791,7 +762,7 @@ namespace BreCalClient
this.Dispatcher.Invoke(new Action(() => this.Dispatcher.Invoke(new Action(() =>
{ {
//if (Interlocked.CompareExchange(ref _uiUpdateRunning, 1, 0) == 1) return; if (Interlocked.CompareExchange(ref _uiUpdateRunning, 1, 0) == 1) return;
try try
{ {
@ -811,7 +782,7 @@ namespace BreCalClient
} }
finally finally
{ {
// _uiUpdateRunning = 0; _uiUpdateRunning = 0;
} }
Mouse.OverrideCursor = null; Mouse.OverrideCursor = null;

View File

@ -5,7 +5,7 @@ https://go.microsoft.com/fwlink/?LinkID=208121.
<Project> <Project>
<PropertyGroup> <PropertyGroup>
<ApplicationRevision>10</ApplicationRevision> <ApplicationRevision>10</ApplicationRevision>
<ApplicationVersion>1.2.1.2</ApplicationVersion> <ApplicationVersion>1.2.0.10</ApplicationVersion>
<BootstrapperEnabled>False</BootstrapperEnabled> <BootstrapperEnabled>False</BootstrapperEnabled>
<Configuration>Release</Configuration> <Configuration>Release</Configuration>
<CreateWebPageOnPublish>True</CreateWebPageOnPublish> <CreateWebPageOnPublish>True</CreateWebPageOnPublish>