Throw sensible error if user without port assignment logs on
This commit is contained in:
parent
2df14d957b
commit
e28a5c1560
@ -168,15 +168,25 @@ namespace BreCalClient
|
|||||||
{
|
{
|
||||||
if (_loginResult.Id > 0)
|
if (_loginResult.Id > 0)
|
||||||
{
|
{
|
||||||
Mouse.OverrideCursor = Cursors.Wait;
|
Mouse.OverrideCursor = Cursors.Wait;
|
||||||
this.busyIndicator.IsBusy = false;
|
|
||||||
this._userApi.Configuration.ApiKey["Authorization"] = _loginResult.Token;
|
this._userApi.Configuration.ApiKey["Authorization"] = _loginResult.Token;
|
||||||
this._shipcallApi.Configuration.ApiKey["Authorization"] = _loginResult.Token;
|
this._shipcallApi.Configuration.ApiKey["Authorization"] = _loginResult.Token;
|
||||||
this._timesApi.Configuration.ApiKey["Authorization"] = _loginResult.Token;
|
this._timesApi.Configuration.ApiKey["Authorization"] = _loginResult.Token;
|
||||||
this._staticApi.Configuration.ApiKey["Authorization"] = _loginResult.Token;
|
this._staticApi.Configuration.ApiKey["Authorization"] = _loginResult.Token;
|
||||||
this._shipApi.Configuration.ApiKey["Authorization"] = _loginResult.Token;
|
this._shipApi.Configuration.ApiKey["Authorization"] = _loginResult.Token;
|
||||||
this.LoadStaticLists();
|
bool loadingSuccessful = await this.LoadStaticLists();
|
||||||
this.labelUsername.Text = $"{_loginResult.FirstName} {_loginResult.LastName}";
|
if (loadingSuccessful)
|
||||||
|
{
|
||||||
|
this.labelUsername.Text = $"{_loginResult.FirstName} {_loginResult.LastName}";
|
||||||
|
this.busyIndicator.IsBusy = false;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
Mouse.OverrideCursor = null;
|
||||||
|
textUsername.Text = "";
|
||||||
|
textPassword.Password = "";
|
||||||
|
textUsername.Focus();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
labelGeneralStatus.Text = $"Connection {ConnectionStatus.SUCCESSFUL}";
|
labelGeneralStatus.Text = $"Connection {ConnectionStatus.SUCCESSFUL}";
|
||||||
@ -341,7 +351,7 @@ namespace BreCalClient
|
|||||||
{
|
{
|
||||||
this.Dispatcher.Invoke(new Action(() =>
|
this.Dispatcher.Invoke(new Action(() =>
|
||||||
{
|
{
|
||||||
ShowErrorDialog(ex.Message, "Error saving user information");
|
ShowErrorDialog(ex.Message, "Error saving user information");
|
||||||
}));
|
}));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -387,7 +397,7 @@ namespace BreCalClient
|
|||||||
this.searchFilterControl.SetBerths(berths);
|
this.searchFilterControl.SetBerths(berths);
|
||||||
|
|
||||||
this.SearchFilterControl_SearchFilterChanged();
|
this.SearchFilterControl_SearchFilterChanged();
|
||||||
}
|
}
|
||||||
|
|
||||||
private async void comboBoxSortOrder_SelectionChanged(object sender, System.Windows.Controls.SelectionChangedEventArgs e)
|
private async void comboBoxSortOrder_SelectionChanged(object sender, System.Windows.Controls.SelectionChangedEventArgs e)
|
||||||
{
|
{
|
||||||
@ -428,16 +438,23 @@ namespace BreCalClient
|
|||||||
|
|
||||||
#region network operations
|
#region network operations
|
||||||
|
|
||||||
private async void LoadStaticLists()
|
private async Task<bool> LoadStaticLists()
|
||||||
{
|
{
|
||||||
if (_loginResult == null) return;
|
if (_loginResult == null) return false;
|
||||||
|
|
||||||
BreCalLists.InitializePorts(await _staticApi.GetPortsAsync());
|
BreCalLists.InitializePorts(await _staticApi.GetPortsAsync());
|
||||||
BreCalLists.InitializeBerths(await _staticApi.BerthsGetAsync());
|
BreCalLists.InitializeBerths(await _staticApi.BerthsGetAsync());
|
||||||
BreCalLists.InitializeShips(await _shipApi.ShipsGetAsync());
|
BreCalLists.InitializeShips(await _shipApi.ShipsGetAsync());
|
||||||
BreCalLists.InitializeParticipants(await _staticApi.ParticipantsGetAsync());
|
BreCalLists.InitializeParticipants(await _staticApi.ParticipantsGetAsync());
|
||||||
|
|
||||||
this.searchFilterControl.SetBerths(BreCalLists.Berths);
|
if(BreCalLists.Participants.Count == 0)
|
||||||
|
{
|
||||||
|
MessageBox.Show(BreCalClient.Resources.Resources.textNoPortAssigned, BreCalClient.Resources.Resources.textError, MessageBoxButton.OK, MessageBoxImage.Error);
|
||||||
|
Mouse.OverrideCursor = Cursors.Wait;
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
this.searchFilterControl.SetBerths(BreCalLists.Berths);
|
||||||
|
|
||||||
foreach (Participant participant in BreCalLists.Participants)
|
foreach (Participant participant in BreCalLists.Participants)
|
||||||
{
|
{
|
||||||
@ -472,8 +489,8 @@ namespace BreCalClient
|
|||||||
SearchFilterModel.filterMap[_loginResult.Id] = currentFilter;
|
SearchFilterModel.filterMap[_loginResult.Id] = currentFilter;
|
||||||
}
|
}
|
||||||
this.searchFilterControl.SetFilterFromModel(currentFilter);
|
this.searchFilterControl.SetFilterFromModel(currentFilter);
|
||||||
|
|
||||||
if (currentFilter.Ports != null)
|
if ((currentFilter.Ports != null) && (this.comboBoxPorts.ItemsSource != null))
|
||||||
{
|
{
|
||||||
foreach (Port p in this.comboBoxPorts.ItemsSource)
|
foreach (Port p in this.comboBoxPorts.ItemsSource)
|
||||||
{
|
{
|
||||||
@ -485,13 +502,14 @@ namespace BreCalClient
|
|||||||
_ = Task.Run(() => RefreshShipcalls());
|
_ = Task.Run(() => RefreshShipcalls());
|
||||||
_ = Task.Run(() => RefreshShips());
|
_ = Task.Run(() => RefreshShips());
|
||||||
|
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public async Task RefreshShips()
|
public async Task RefreshShips()
|
||||||
{
|
{
|
||||||
while (true)
|
while (true)
|
||||||
{
|
{
|
||||||
Thread.Sleep(SHIPS_UPDATE_INTERVAL_SECONDS * 1000);
|
Thread.Sleep(SHIPS_UPDATE_INTERVAL_SECONDS * 1000);
|
||||||
BreCalLists.InitializeShips(await _shipApi.ShipsGetAsync());
|
BreCalLists.InitializeShips(await _shipApi.ShipsGetAsync());
|
||||||
}
|
}
|
||||||
@ -706,7 +724,7 @@ namespace BreCalClient
|
|||||||
// first add everything
|
// first add everything
|
||||||
this._visibleControlModels.AddRange(_allShipcallsDict.Values);
|
this._visibleControlModels.AddRange(_allShipcallsDict.Values);
|
||||||
|
|
||||||
// now remove elements whose filter criteria are met
|
// now remove elements whose filter criteria are met
|
||||||
|
|
||||||
if(sfm.Berths.Count > 0 )
|
if(sfm.Berths.Count > 0 )
|
||||||
{
|
{
|
||||||
@ -1122,24 +1140,24 @@ namespace BreCalClient
|
|||||||
if (msg.error_field != null)
|
if (msg.error_field != null)
|
||||||
{
|
{
|
||||||
caption = $"{caption}: {msg.error_field}";
|
caption = $"{caption}: {msg.error_field}";
|
||||||
}
|
}
|
||||||
|
|
||||||
if(msg.error_description != null)
|
if(msg.error_description != null)
|
||||||
{
|
{
|
||||||
message = msg.error_description;
|
message = msg.error_description;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
catch (Exception) { }
|
catch (Exception) { }
|
||||||
}
|
}
|
||||||
|
|
||||||
_log.ErrorFormat("{0} - {1}", caption, message);
|
_log.ErrorFormat("{0} - {1}", caption, message);
|
||||||
|
|
||||||
Dispatcher.Invoke(new Action(() =>
|
Dispatcher.Invoke(new Action(() =>
|
||||||
{
|
{
|
||||||
MessageBox.Show(message, caption, MessageBoxButton.OK, MessageBoxImage.Error);
|
MessageBox.Show(message, caption, MessageBoxButton.OK, MessageBoxImage.Error);
|
||||||
}));
|
}));
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void EnableControlsForParticipant()
|
private void EnableControlsForParticipant()
|
||||||
@ -1157,6 +1175,6 @@ namespace BreCalClient
|
|||||||
}
|
}
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
9
src/BreCalClient/Resources/Resources.Designer.cs
generated
9
src/BreCalClient/Resources/Resources.Designer.cs
generated
@ -875,6 +875,15 @@ namespace BreCalClient.Resources {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Looks up a localized string similar to No port assigned to this participant.
|
||||||
|
/// </summary>
|
||||||
|
public static string textNoPortAssigned {
|
||||||
|
get {
|
||||||
|
return ResourceManager.GetString("textNoPortAssigned", resourceCulture);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Looks up a localized string similar to Not rotated.
|
/// Looks up a localized string similar to Not rotated.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
|||||||
@ -553,4 +553,7 @@
|
|||||||
<data name="textStartTimeMissing" xml:space="preserve">
|
<data name="textStartTimeMissing" xml:space="preserve">
|
||||||
<value>Wenn eine Ende-Zeit angegeben wird, muss auch eine Start-Zeit angegeben werden</value>
|
<value>Wenn eine Ende-Zeit angegeben wird, muss auch eine Start-Zeit angegeben werden</value>
|
||||||
</data>
|
</data>
|
||||||
|
<data name="textNoPortAssigned" xml:space="preserve">
|
||||||
|
<value>Es ist keine Hafenzuordnung vorhanden</value>
|
||||||
|
</data>
|
||||||
</root>
|
</root>
|
||||||
@ -601,4 +601,7 @@
|
|||||||
<data name="textStartTimeMissing" xml:space="preserve">
|
<data name="textStartTimeMissing" xml:space="preserve">
|
||||||
<value>If an end time is set, a start time is also required</value>
|
<value>If an end time is set, a start time is also required</value>
|
||||||
</data>
|
</data>
|
||||||
|
<data name="textNoPortAssigned" xml:space="preserve">
|
||||||
|
<value>No port assigned to this participant</value>
|
||||||
|
</data>
|
||||||
</root>
|
</root>
|
||||||
Reference in New Issue
Block a user