Merge branch 'feature/improve_error_display' into develop
This commit is contained in:
commit
1f854b6cde
@ -105,7 +105,7 @@ Usually the "Z" is missing at the end indicating local time.
|
||||
| tidal_window_from | value must be in the future |
|
||||
| tidal_window_to | value must be in the future, value must be > tidal_window_from |
|
||||
| recommended_tugs | 0 < value < 10 |
|
||||
| canceled | may not be set on POST |
|
||||
| canceled | optional on POST |
|
||||
| evaluation | may not be set |
|
||||
| evaluation_message | may not be set |
|
||||
| created / modified | may not be set |
|
||||
|
||||
@ -23,6 +23,8 @@ using Polly;
|
||||
using System.Net.Http;
|
||||
using System.Net;
|
||||
using System.Windows.Input;
|
||||
using System.Text.RegularExpressions;
|
||||
using Newtonsoft.Json.Linq;
|
||||
|
||||
|
||||
namespace BreCalClient
|
||||
@ -1058,13 +1060,27 @@ namespace BreCalClient
|
||||
|
||||
private void ShowErrorDialog(string message, string caption)
|
||||
{
|
||||
// Example:
|
||||
// Error calling ShipcallUpdate: {\"message\": \"PUT Requests for shipcalls can only be issued by an assigned AGENCY or BSMD users
|
||||
// (if the special-flag is enabled). Assigned Agency: ShipcallParticipantMap(id=628, shipcall_id=115, participant_id=10,
|
||||
// type=8, created=datetime.datetime(2024, 8, 28, 15, 13, 14), modified=None) with Flags: 42\"}
|
||||
Match m = Regex.Match(message, "\\{(.*)\\}");
|
||||
if ((m != null) && m.Success)
|
||||
{
|
||||
dynamic? msg = JsonConvert.DeserializeObject(m.Value);
|
||||
if(msg != null)
|
||||
{
|
||||
message = msg.message;
|
||||
}
|
||||
}
|
||||
|
||||
_log.ErrorFormat("{0} - {1}", caption, message);
|
||||
/*
|
||||
|
||||
Dispatcher.Invoke(new Action(() =>
|
||||
{
|
||||
MessageBox.Show(message, caption, MessageBoxButton.OK, MessageBoxImage.Error);
|
||||
}));
|
||||
*/
|
||||
|
||||
}
|
||||
|
||||
private void EnableControlsForParticipant()
|
||||
|
||||
@ -90,7 +90,9 @@ namespace BreCalClient
|
||||
|
||||
private async void DataGridShips_CreateRequested()
|
||||
{
|
||||
ShipModel shipModel = new(new Ship());
|
||||
|
||||
ShipModel shipModel = new((ShipModel.LastEditShip != null) ? ShipModel.LastEditShip : new Ship());
|
||||
|
||||
EditShipDialog esd = new()
|
||||
{
|
||||
Ship = shipModel.Ship
|
||||
@ -111,14 +113,15 @@ namespace BreCalClient
|
||||
if(!BreCalLists.ShipLookupDict.TryAdd(id.VarId, shipModel))
|
||||
BreCalLists.ShipLookupDict[id.VarId] = shipModel;
|
||||
this.dataGridShips.ItemsSource = BreCalLists.AllShips;
|
||||
ShipModel.LastEditShip = null;
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
ShipModel.LastEditShip = shipModel.Ship;
|
||||
MessageBox.Show(ex.Message);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
@ -16,6 +16,8 @@ namespace BreCalClient
|
||||
|
||||
public Ship Ship { get; private set; }
|
||||
|
||||
public static Ship? LastEditShip { get; set; }
|
||||
|
||||
public string TugCompany
|
||||
{
|
||||
get { if(this.Ship.ParticipantId.HasValue)
|
||||
|
||||
Loading…
Reference in New Issue
Block a user