diff --git a/ENI-2/ENI2/ENI2/App.config b/ENI-2/ENI2/ENI2/App.config
index 8c9908cc..6243d275 100644
--- a/ENI-2/ENI2/ENI2/App.config
+++ b/ENI-2/ENI2/ENI2/App.config
@@ -20,13 +20,14 @@
True
- http://heupferd/bsmd.LockingService/LockingService.svc
+
+ http://192.168.2.4/LockingService/LockingService.svc
60
- Data Source=192.168.2.12;Initial Catalog=nsw;Uid=dfuser;Pwd=dfpasswd;Connect Timeout=30;Encrypt=False;TrustServerCertificate=False
+ Data Source=(localdb)\Projects;Initial Catalog=nsw;Integrated Security=True;Connect Timeout=30;Encrypt=False;TrustServerCertificate=False
diff --git a/ENI-2/ENI2/ENI2/App.xaml b/ENI-2/ENI2/ENI2/App.xaml
index e792b792..f9bc5948 100644
--- a/ENI-2/ENI2/ENI2/App.xaml
+++ b/ENI-2/ENI2/ENI2/App.xaml
@@ -6,6 +6,7 @@
xmlns:p="clr-namespace:ENI2.Properties"
StartupUri="MainWindow.xaml">
+
+
+
+
diff --git a/ENI-2/ENI2/ENI2/Controls/ClosableTabItem.cs b/ENI-2/ENI2/ENI2/Controls/ClosableTabItem.cs
index cc47d729..5dc4a556 100644
--- a/ENI-2/ENI2/ENI2/Controls/ClosableTabItem.cs
+++ b/ENI-2/ENI2/ENI2/Controls/ClosableTabItem.cs
@@ -51,11 +51,12 @@ namespace ENI2.Controls
public event EventHandler TabClosing;
- public void SetHeaderText(string headerText)
+ public void SetHeaderText(string headerText, bool lockedTab)
{
// Container for header controls
var dockPanel = new DockPanel();
var header = new TextBlock { Text = headerText };
+ header.Background = lockedTab ? Brushes.LightGreen : Brushes.Orange;
dockPanel.Children.Add(header);
// Close button to remove the tab
diff --git a/ENI-2/ENI2/ENI2/Controls/EditWindowBase.cs b/ENI-2/ENI2/ENI2/Controls/EditWindowBase.cs
index b0a62657..c575c90e 100644
--- a/ENI-2/ENI2/ENI2/Controls/EditWindowBase.cs
+++ b/ENI-2/ENI2/ENI2/Controls/EditWindowBase.cs
@@ -14,11 +14,14 @@ namespace ENI2.Controls
///
[TemplatePart(Name = "buttonOK", Type = typeof(Button))]
[TemplatePart(Name = "buttonCancel", Type = typeof(Button))]
+ [TemplatePart(Name = "buttonAdd", Type = typeof(Button))]
public class EditWindowBase : Window
{
public event Action OKClicked;
public event Action CancelClicked;
+ public event Action AddClicked;
+
protected bool shouldCancel;
static EditWindowBase()
@@ -32,14 +35,22 @@ namespace ENI2.Controls
{
var okButton = (Button)Template.FindName("buttonOK", this);
var cancelButton = (Button)Template.FindName("buttonCancel", this);
+ var addButton = (Button)Template.FindName("buttonAdd", this);
okButton.Click += (s, e) => { if (IsModal) DialogResult = true; else this.Close(); OKClicked?.Invoke(); };
cancelButton.Click += (s, e) => { if (IsModal) DialogResult = false; else this.Close(); CancelClicked?.Invoke(); };
+ addButton.Click += (s, e) => { AddClicked?.Invoke(); };
};
this.IsModal = true; // default
}
public bool IsModal { get; set; }
+ public bool AddVisible
+ {
+ get { var addButton = (Button)Template.FindName("buttonAdd", this); return addButton.Visibility == Visibility.Visible; }
+ set { var addButton = (Button)Template.FindName("buttonAdd", this); addButton.Visibility = value ? Visibility.Visible : Visibility.Hidden; }
+ }
+
private void Window_Closing(object sender, CancelEventArgs e)
{
if (this.shouldCancel) e.Cancel = true;
diff --git a/ENI-2/ENI2/ENI2/Controls/LocodeControl.xaml b/ENI-2/ENI2/ENI2/Controls/LocodeControl.xaml
index 7ffaa378..e3619884 100644
--- a/ENI-2/ENI2/ENI2/Controls/LocodeControl.xaml
+++ b/ENI-2/ENI2/ENI2/Controls/LocodeControl.xaml
@@ -14,10 +14,12 @@
-
-
+
+
+
diff --git a/ENI-2/ENI2/ENI2/Controls/LocodeControl.xaml.cs b/ENI-2/ENI2/ENI2/Controls/LocodeControl.xaml.cs
index f420030a..3d713761 100644
--- a/ENI-2/ENI2/ENI2/Controls/LocodeControl.xaml.cs
+++ b/ENI-2/ENI2/ENI2/Controls/LocodeControl.xaml.cs
@@ -95,7 +95,7 @@ namespace ENI2.Controls
private void ComboBox_TextChanged(object sender, RoutedEventArgs e)
{
bool locodeFound = false;
- this.comboBoxLocode.ItemsSource = null;
+
if (this._comboSelect)
{
@@ -105,6 +105,7 @@ namespace ENI2.Controls
else
{
+ this.comboBoxLocode.ItemsSource = null;
if (this.comboBoxLocode.Text.Length > 4)
{
@@ -131,14 +132,18 @@ namespace ENI2.Controls
{
// assume this is a harbour name typed out..
List locodeEntries = LocodeDB.AllLocodesForCityNameAsEntries("%" + this.comboBoxLocode.Text + "%");
+ locodeEntries.Sort();
+
foreach (LocodeDB.LocodeEntry entry in locodeEntries)
this.LocodeList.Add(string.Format("{0} - {1}", entry.Locode, entry.Name));
+ this.comboBoxLocode.ItemsSource = this.LocodeList;
+
if (this.LocodeList.Count == 1)
{
this.comboBoxLocode.SelectedItem = this.LocodeList[0];
this.SetLocodeStateImage(this.imageLocodeState, LocodeState.OK);
- this.LocodeValue = this.LocodeList[0];
+ this.LocodeValue = this.LocodeList[0].Substring(0,5);
}
else if (this.LocodeList.Count == 0)
{
@@ -147,14 +152,13 @@ namespace ENI2.Controls
else
{
this.SetLocodeStateImage(this.imageLocodeState, LocodeState.AMBIGUOUS);
- }
-
- this.comboBoxLocode.ItemsSource = this.LocodeList;
+ }
}
}
}
this.PropertyChanged?.Invoke(this, new PropertyChangedEventArgs("LocodeList"));
+
}
private void comboBoxLocode_SelectionChanged(object sender, SelectionChangedEventArgs e)
@@ -200,6 +204,14 @@ namespace ENI2.Controls
}
#endregion
-
+
+ private void comboBoxLocode_PreviewKeyDown(object sender, System.Windows.Input.KeyEventArgs e)
+ {
+ if((e.Key == System.Windows.Input.Key.Down) && !this.comboBoxLocode.IsDropDownOpen)
+ {
+ this.comboBoxLocode.IsDropDownOpen = true;
+ e.Handled = true;
+ }
+ }
}
}
diff --git a/ENI-2/ENI2/ENI2/DetailBaseControl.cs b/ENI-2/ENI2/ENI2/DetailBaseControl.cs
index 4426c79e..f5ce8e7f 100644
--- a/ENI-2/ENI2/ENI2/DetailBaseControl.cs
+++ b/ENI-2/ENI2/ENI2/DetailBaseControl.cs
@@ -57,11 +57,6 @@ namespace ENI2
///
public event Action RequestReload;
- ///
- /// Mit diesem Event wird der Wunsch nach einem Lock zum Ausdruck gebracht ;-)
- ///
- public event Action RequestLock;
-
///
/// Eine in der Detailansicht enthaltene Meldeklasse hat sich geändert
///
@@ -88,6 +83,8 @@ namespace ENI2
public Guid UserId { get; set; } // TODO: Ersetzen mit der User-Entity
+ public bool LockedByOtherUser { get; set; }
+
#endregion
#region public methods
@@ -121,32 +118,7 @@ namespace ENI2
protected virtual void OnRequestReload()
{
this.RequestReload?.Invoke();
- }
-
- protected virtual void OnRequestLock(bool shouldLock)
- {
- this.RequestLock?.Invoke(shouldLock);
- }
-
- protected void SetLocodeStateImage(Image stateImage, LocodeState state)
- {
- switch(state)
- {
- case LocodeState.AMBIGUOUS:
- stateImage.Source = new BitmapImage(new Uri("pack://application:,,,/Resources/bullet_ball_yellow.png"));
- break;
- case LocodeState.INVALID:
- stateImage.Source = new BitmapImage(new Uri("pack://application:,,,/Resources/bullet_ball_red.png"));
- break;
- case LocodeState.OK:
- stateImage.Source = new BitmapImage(new Uri("pack://application:,,,/Resources/bullet_ball_green.png"));
- break;
- case LocodeState.UNKNOWN:
- default:
- stateImage.Source = new BitmapImage(new Uri("pack://application:,,,/Resources/bullet_ball_grey.png"));
- break;
- }
- }
+ }
#region event handling for control content changes (signal dirty etc)
diff --git a/ENI-2/ENI2/ENI2/DetailRootControl.xaml.cs b/ENI-2/ENI2/ENI2/DetailRootControl.xaml.cs
index 52cf9408..2a24188f 100644
--- a/ENI-2/ENI2/ENI2/DetailRootControl.xaml.cs
+++ b/ENI-2/ENI2/ENI2/DetailRootControl.xaml.cs
@@ -11,6 +11,7 @@ using bsmd.database;
using ENI2.DetailViewControls;
using ENI2.LockingServiceReference;
using System.Windows;
+using System.Windows.Data;
namespace ENI2
{
@@ -27,6 +28,7 @@ namespace ENI2
private List _messages;
private Dictionary controlCache = new Dictionary();
private Guid userId = Guid.NewGuid(); // remove THIS!!
+ private object messageListLock = new object();
#endregion
@@ -34,6 +36,7 @@ namespace ENI2
public MessageCore Core { get { return this._core; } }
+ public bool LockedByOtherUser { get; set; }
#endregion
@@ -67,6 +70,7 @@ namespace ENI2
this.listBoxMessages.ItemsSource = this._listBoxList;
_messages = DBManager.Instance.GetMessagesForCore(_core, DBManager.MessageLoad.ALL);
+ BindingOperations.EnableCollectionSynchronization(_messages, this.messageListLock);
Dispatcher.BeginInvoke((Action)(() => this.listBoxMessages.SelectedIndex = 0));
}
@@ -85,7 +89,8 @@ namespace ENI2
}
#endregion
-
+
+ #region event handler
private void listBoxMessages_SelectionChanged(object sender, SelectionChangedEventArgs e)
{
@@ -98,6 +103,7 @@ namespace ENI2
DetailBaseControl detailControl = (DetailBaseControl)Activator.CreateInstance(mg.MessageGroupControlType);
detailControl.Core = _core;
detailControl.Messages = _messages;
+ detailControl.LockedByOtherUser = this.LockedByOtherUser;
detailControl.JumpToListElementRequest += (index) =>
{
@@ -107,11 +113,12 @@ namespace ENI2
}
};
- detailControl.RequestReload += DetailControl_RequestReload;
- detailControl.RequestLock += DetailControl_RequestLock;
+ detailControl.RequestReload += DetailControl_RequestReload;
detailControl.NotificationClassChanged += DetailControl_NotificationClassChanged;
detailControl.Initialize();
+ detailControl.IsEnabled = !this.LockedByOtherUser;
+
controlCache.Add(mg.MessageGroupControlType, detailControl);
this.buttonSave.Visibility = Visibility.Hidden;
}
@@ -193,8 +200,8 @@ namespace ENI2
{
try
{
- string lockResult = App.LockingServiceClient.Lock(this.Core.Id.Value, this.userId.ToString());
- if (lockResult == "")
+ Guid lockedUserId = App.LockingServiceClient.Lock(this.Core.Id.Value, this.userId);
+ if (lockedUserId == Guid.Empty)
{
// lock successful
this.Core.Locked = true;
@@ -214,7 +221,7 @@ namespace ENI2
}
else
{
- App.LockingServiceClient.Unlock(this.Core.Id.Value, this.userId.ToString());
+ App.LockingServiceClient.Unlock(this.Core.Id.Value, this.userId);
this.Core.Locked = false;
}
}
@@ -233,5 +240,8 @@ namespace ENI2
// return to "new" overview
Dispatcher.BeginInvoke((Action)(() => this.listBoxMessages_SelectionChanged(this, null)));
}
+
+ #endregion
+
}
}
diff --git a/ENI-2/ENI2/ENI2/DetailViewControls/OverViewDetailControl.xaml b/ENI-2/ENI2/ENI2/DetailViewControls/OverViewDetailControl.xaml
index 1bbc949d..3ed13ccc 100644
--- a/ENI-2/ENI2/ENI2/DetailViewControls/OverViewDetailControl.xaml
+++ b/ENI-2/ENI2/ENI2/DetailViewControls/OverViewDetailControl.xaml
@@ -73,13 +73,12 @@
-
-
+
+
+
+
+
+
diff --git a/ENI-2/ENI2/ENI2/DetailViewControls/OverViewDetailControl.xaml.cs b/ENI-2/ENI2/ENI2/DetailViewControls/OverViewDetailControl.xaml.cs
index 3ca6e0e2..93cbeba3 100644
--- a/ENI-2/ENI2/ENI2/DetailViewControls/OverViewDetailControl.xaml.cs
+++ b/ENI-2/ENI2/ENI2/DetailViewControls/OverViewDetailControl.xaml.cs
@@ -11,6 +11,7 @@ using System.Timers;
using bsmd.database;
using ENI2.EditControls;
+using System.Windows.Media.Imaging;
namespace ENI2.DetailViewControls
{
@@ -188,6 +189,17 @@ namespace ENI2.DetailViewControls
// kann das eigentlich passieren??!
}
+ #region Context-Menu Meldeklassen
+
+ this.dataGridMessages.ContextMenu = new ContextMenu();
+ MenuItem sendItem = new MenuItem();
+ sendItem.Header = Properties.Resources.textSendToNSW;
+ sendItem.Icon = new Image { Source = new BitmapImage(new Uri("pack://application:,,,/Resources/mail_forward.png")) };
+ sendItem.Click += new RoutedEventHandler(this.contextSendMessage);
+ this.dataGridMessages.ContextMenu.Items.Add(sendItem);
+
+ #endregion
+
#region init ATA
// ganz hakelig ich weiß dafür kapiert das gleich jeder
@@ -322,6 +334,11 @@ namespace ENI2.DetailViewControls
#region Command button event handler
+ private void contextSendMessage(object sender, RoutedEventArgs e)
+ {
+ MessageBox.Show("not yet..");
+ }
+
private void buttonStorno_Click(object sender, RoutedEventArgs e)
{
@@ -412,19 +429,7 @@ namespace ENI2.DetailViewControls
{
this.OnRequestReload();
}));
- }
-
- private void buttonLock_Click(object sender, RoutedEventArgs e)
- {
- this.Dispatcher.BeginInvoke(new Action(() =>
- {
- bool reqValue = true;
- if (this.Core.Locked ?? false) // I locked it already, means unlock now
- reqValue = false;
- this.OnRequestLock(reqValue);
- }));
-
- }
+ }
private void buttonInfoCore_Click(object sender, RoutedEventArgs e)
{
diff --git a/ENI-2/ENI2/ENI2/DetailViewControls/PortCallDetailControl.xaml.cs b/ENI-2/ENI2/ENI2/DetailViewControls/PortCallDetailControl.xaml.cs
index ce0d8d5d..9795f5e4 100644
--- a/ENI-2/ENI2/ENI2/DetailViewControls/PortCallDetailControl.xaml.cs
+++ b/ENI-2/ENI2/ENI2/DetailViewControls/PortCallDetailControl.xaml.cs
@@ -115,13 +115,21 @@ namespace ENI2.DetailViewControls
}
private void DataGridCallPurposes_CreateRequested()
- {
- CallPurpose cp = new CallPurpose();
+ {
EditCallPurposeDialog ecpd = new EditCallPurposeDialog();
- ecpd.CallPurpose = cp;
+ ecpd.AddClicked += () =>
+ {
+ ecpd.CopyValuesToEntity();
+ if (!_noa_nod.CallPurposes.Contains(ecpd.CallPurpose))
+ _noa_nod.CallPurposes.Add(ecpd.CallPurpose);
+ this.dataGridCallPurposes.Items.Refresh();
+ ecpd.CallPurpose = new CallPurpose();
+ };
+ ecpd.CallPurpose = new CallPurpose();
if(ecpd.ShowDialog() ?? false)
{
- _noa_nod.CallPurposes.Add(cp);
+ if(!_noa_nod.CallPurposes.Contains(ecpd.CallPurpose))
+ _noa_nod.CallPurposes.Add(ecpd.CallPurpose);
this.dataGridCallPurposes.Items.Refresh();
}
}
@@ -135,8 +143,18 @@ namespace ENI2.DetailViewControls
{
EditCallPurposeDialog ecpd = new EditCallPurposeDialog();
ecpd.CallPurpose = obj as CallPurpose;
- if(ecpd.ShowDialog() ?? false)
+ ecpd.AddClicked += () =>
{
+ ecpd.CopyValuesToEntity();
+ if (!_noa_nod.CallPurposes.Contains(ecpd.CallPurpose))
+ _noa_nod.CallPurposes.Add(ecpd.CallPurpose);
+ this.dataGridCallPurposes.Items.Refresh();
+ ecpd.CallPurpose = new CallPurpose();
+ };
+ if (ecpd.ShowDialog() ?? false)
+ {
+ if (!_noa_nod.CallPurposes.Contains(ecpd.CallPurpose))
+ _noa_nod.CallPurposes.Add(ecpd.CallPurpose);
this.dataGridCallPurposes.Items.Refresh();
// signal up
this.SublistElementChanged(Message.NotificationClass.NOA_NOD);
diff --git a/ENI-2/ENI2/ENI2/DetailViewControls/PortNotificationDetailControl.xaml.cs b/ENI-2/ENI2/ENI2/DetailViewControls/PortNotificationDetailControl.xaml.cs
index 44ed1004..02d0ac4e 100644
--- a/ENI-2/ENI2/ENI2/DetailViewControls/PortNotificationDetailControl.xaml.cs
+++ b/ENI-2/ENI2/ENI2/DetailViewControls/PortNotificationDetailControl.xaml.cs
@@ -2,20 +2,9 @@
// Description: Detailansicht Gruppe Port Notification
//
-using System;
using System.Collections.Generic;
-using System.Linq;
-using System.Text;
-using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;
-using System.Windows.Data;
-using System.Windows.Documents;
-using System.Windows.Input;
-using System.Windows.Media;
-using System.Windows.Media.Imaging;
-using System.Windows.Navigation;
-using System.Windows.Shapes;
using ENI2.EditControls;
diff --git a/ENI-2/ENI2/ENI2/ENI2.csproj b/ENI-2/ENI2/ENI2/ENI2.csproj
index 479b6e41..f444e9d0 100644
--- a/ENI-2/ENI2/ENI2/ENI2.csproj
+++ b/ENI-2/ENI2/ENI2/ENI2.csproj
@@ -418,6 +418,7 @@
+
Always
diff --git a/ENI-2/ENI2/ENI2/EditControls/EditCallPurposeDialog.xaml.cs b/ENI-2/ENI2/ENI2/EditControls/EditCallPurposeDialog.xaml.cs
index c15876d1..aba18f5a 100644
--- a/ENI-2/ENI2/ENI2/EditControls/EditCallPurposeDialog.xaml.cs
+++ b/ENI-2/ENI2/ENI2/EditControls/EditCallPurposeDialog.xaml.cs
@@ -1,20 +1,9 @@
// Copyright (c) 2017 schick Informatik
-// Description:
+// Description: Bearbeitung von Call Purposes
//
-using System;
using System.Collections.Generic;
-using System.Linq;
-using System.Text;
-using System.Threading.Tasks;
using System.Windows;
-using System.Windows.Controls;
-using System.Windows.Data;
-using System.Windows.Documents;
-using System.Windows.Input;
-using System.Windows.Media;
-using System.Windows.Media.Imaging;
-using System.Windows.Shapes;
using ENI2.Controls;
using bsmd.database;
@@ -61,8 +50,7 @@ namespace ENI2.EditControls
{
InitializeComponent();
- Loaded += EditCallPurposeDialog_Loaded;
-
+ Loaded += EditCallPurposeDialog_Loaded;
}
public CallPurpose CallPurpose { get; set; }
@@ -82,9 +70,16 @@ namespace ENI2.EditControls
}
}
+ public void CopyValuesToEntity()
+ {
+ this.CallPurpose.CallPurposeCode = this.comboBoxCode.SelectedIndex;
+ this.CallPurpose.CallPurposeDescription = this.textBoxDescription.Text;
+ }
+
private void EditCallPurposeDialog_Loaded(object sender, RoutedEventArgs e)
{
this.OKClicked += EditCallPurposeDialog_OKClicked;
+ this.AddVisible = true;
this.comboBoxCode.ItemsSource = this.EdiCodes;
if((this.CallPurpose != null) && (this.CallPurpose.CallPurposeCode != 0))
@@ -95,10 +90,8 @@ namespace ENI2.EditControls
}
private void EditCallPurposeDialog_OKClicked()
- {
- // copy selected values back into entity
- this.CallPurpose.CallPurposeCode = this.comboBoxCode.SelectedIndex;
- this.CallPurpose.CallPurposeDescription = this.textBoxDescription.Text;
+ {
+ this.CopyValuesToEntity();
}
private void comboBoxCode_Selected(object sender, RoutedEventArgs e)
@@ -106,7 +99,8 @@ namespace ENI2.EditControls
if (this.comboBoxCode.SelectedIndex != this.CallPurpose.CallPurposeCode)
{
this.textBoxDescription.Text = edifact8025Codes[this.comboBoxCode.SelectedIndex];
- this.OnOkClicked();
+ this.textBoxDescription.Focus();
+ // this.OnOkClicked(); // doch nicht gleich zu
}
}
}
diff --git a/ENI-2/ENI2/ENI2/EditControls/VisitIdDialog.xaml b/ENI-2/ENI2/ENI2/EditControls/VisitIdDialog.xaml
index d675b55f..0c5f42af 100644
--- a/ENI-2/ENI2/ENI2/EditControls/VisitIdDialog.xaml
+++ b/ENI-2/ENI2/ENI2/EditControls/VisitIdDialog.xaml
@@ -32,9 +32,7 @@
IsReadOnly="False"
MouseWheelActiveOnFocus="True"
FormatString="G"
- Increment="1"
- Maximum="9999999"
- Minimum="1000000"
+ Increment="1"
DisplayDefaultValueOnEmptyText="False"
ButtonSpinnerLocation="Right"
ParsingNumberStyle="Integer"
@@ -47,9 +45,7 @@
IsReadOnly="False"
MouseWheelActiveOnFocus="True"
FormatString="00000000"
- Increment="1"
- Minimum="1000000"
- Maximum="99999999"
+ Increment="1"
DisplayDefaultValueOnEmptyText="False"
ButtonSpinnerLocation="Right"
ParsingNumberStyle="Integer"
diff --git a/ENI-2/ENI2/ENI2/MainWindow.xaml.cs b/ENI-2/ENI2/ENI2/MainWindow.xaml.cs
index 4ec53ebb..246a3b88 100644
--- a/ENI-2/ENI2/ENI2/MainWindow.xaml.cs
+++ b/ENI-2/ENI2/ENI2/MainWindow.xaml.cs
@@ -15,6 +15,7 @@ using System.Windows.Controls;
using ENI2.Controls;
using ENI2.EditControls;
using System.Threading;
+using log4net;
namespace ENI2
{
@@ -32,8 +33,10 @@ namespace ENI2
private bool efMode = false;
ScaleTransform _transform = new ScaleTransform(1.0, 1.0);
private Dictionary openTabs = new Dictionary();
+ private Dictionary lockedCores = new Dictionary();
private int failedLogonCount = 0;
private ReportingParty userEntity = null;
+ private ILog _log = LogManager.GetLogger(typeof(MainWindow));
#endregion
@@ -63,10 +66,30 @@ namespace ENI2
if (!openTabs.ContainsKey(aMessageCore.Id.Value))
{
ClosableTabItem searchResultItem = new ClosableTabItem();
+
+ // try to lock the item
+ Guid lockedUserId = Guid.Empty;
+ try
+ {
+ lockedUserId = App.LockingServiceClient.Lock(aMessageCore.Id.Value, this.userEntity.Id.Value);
+ if(lockedUserId == Guid.Empty)
+ {
+ this.lockedCores[searchResultItem] = aMessageCore.Id.Value;
+ }
+ }
+ catch(Exception ex)
+ {
+ // TODO: wenn der Locking Service nicht erreichbar ist sollte das Ganze trotzdem noch irgendwie funktionieren
+ _log.ErrorFormat("LockingService.Lock: {0}", ex.Message);
+ }
+ bool iDidLockIt = (lockedUserId == Guid.Empty);
+
searchResultItem.TabClosing += SearchResultItem_TabClosing;
DateTime? eta = aMessageCore.IsTransit ? aMessageCore.ETAKielCanal : aMessageCore.ETA;
- searchResultItem.SetHeaderText(string.Format("{0} [{1}-{2}]", aMessageCore.Shipname, aMessageCore.PoC, eta.HasValue ? eta.Value.ToShortDateString() : ""));
+ searchResultItem.SetHeaderText(string.Format("{0} [{1}-{2}]", aMessageCore.Shipname, aMessageCore.PoC, eta.HasValue ? eta.Value.ToShortDateString() : ""),
+ iDidLockIt);
DetailRootControl drc = new DetailRootControl(aMessageCore);
+ drc.LockedByOtherUser = !iDidLockIt;
searchResultItem.Content = drc;
this.mainFrame.Items.Add(searchResultItem);
Dispatcher.BeginInvoke((Action)(() => this.mainFrame.SelectedIndex = (this.mainFrame.Items.Count - 1)));
@@ -84,6 +107,19 @@ namespace ENI2
ClosableTabItem tabItem = sender as ClosableTabItem;
if(tabItem != null)
{
+ if(lockedCores.ContainsKey(tabItem))
+ {
+ try
+ {
+ App.LockingServiceClient.Unlock(lockedCores[tabItem], this.userEntity.Id.Value);
+ lockedCores.Remove(tabItem);
+ }
+ catch(Exception ex)
+ {
+ _log.ErrorFormat("LockingService.Unlock: {0}", ex.Message);
+ }
+ }
+
DetailRootControl drc = tabItem.Content as DetailRootControl;
if (openTabs.ContainsKey(drc.Core.Id.Value))
openTabs.Remove(drc.Core.Id.Value);
@@ -119,6 +155,19 @@ namespace ENI2
private void Window_Closing(object sender, System.ComponentModel.CancelEventArgs e)
{
+ try
+ {
+ // unlock all cores
+ foreach (ClosableTabItem tabItem in this.lockedCores.Keys)
+ {
+ App.LockingServiceClient.Unlock(lockedCores[tabItem], this.userEntity.Id.Value);
+ }
+ }
+ catch(Exception ex)
+ {
+ _log.ErrorFormat("LockingService.Unlock: {0}", ex.Message);
+ }
+
DBManager.Instance.Disconnect();
Properties.Settings.Default.MainWindowPlacement = this.GetPlacement();
Properties.Settings.Default.Save();
diff --git a/ENI-2/ENI2/ENI2/Properties/Resources.Designer.cs b/ENI-2/ENI2/ENI2/Properties/Resources.Designer.cs
index f5648310..2b33b778 100644
--- a/ENI-2/ENI2/ENI2/Properties/Resources.Designer.cs
+++ b/ENI-2/ENI2/ENI2/Properties/Resources.Designer.cs
@@ -390,6 +390,16 @@ namespace ENI2.Properties {
}
}
+ ///
+ /// Looks up a localized resource of type System.Drawing.Bitmap.
+ ///
+ public static System.Drawing.Bitmap mail_forward {
+ get {
+ object obj = ResourceManager.GetObject("mail_forward", resourceCulture);
+ return ((System.Drawing.Bitmap)(obj));
+ }
+ }
+
///
/// Looks up a localized resource of type System.Drawing.Bitmap.
///
@@ -1363,6 +1373,15 @@ namespace ENI2.Properties {
}
}
+ ///
+ /// Looks up a localized string similar to Send to NSW.
+ ///
+ public static string textSendToNSW {
+ get {
+ return ResourceManager.GetString("textSendToNSW", resourceCulture);
+ }
+ }
+
///
/// Looks up a localized string similar to Ship services.
///
diff --git a/ENI-2/ENI2/ENI2/Properties/Resources.resx b/ENI-2/ENI2/ENI2/Properties/Resources.resx
index dff364b8..62ddcc18 100644
--- a/ENI-2/ENI2/ENI2/Properties/Resources.resx
+++ b/ENI-2/ENI2/ENI2/Properties/Resources.resx
@@ -634,4 +634,10 @@
Request timed out
+
+ ..\Resources\mail_forward.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a
+
+
+ Send to NSW
+
\ No newline at end of file
diff --git a/ENI-2/ENI2/ENI2/Resources/mail_forward.png b/ENI-2/ENI2/ENI2/Resources/mail_forward.png
new file mode 100644
index 00000000..bf43afe7
Binary files /dev/null and b/ENI-2/ENI2/ENI2/Resources/mail_forward.png differ
diff --git a/ENI-2/ENI2/ENI2/Service References/LockingServiceReference/LockingService1.xsd b/ENI-2/ENI2/ENI2/Service References/LockingServiceReference/LockingService1.xsd
index 68693d94..7c98bdb2 100644
--- a/ENI-2/ENI2/ENI2/Service References/LockingServiceReference/LockingService1.xsd
+++ b/ENI-2/ENI2/ENI2/Service References/LockingServiceReference/LockingService1.xsd
@@ -10,7 +10,7 @@
-
+
diff --git a/ENI-2/ENI2/ENI2/Service References/LockingServiceReference/LockingService2.xsd b/ENI-2/ENI2/ENI2/Service References/LockingServiceReference/LockingService2.xsd
index 13ae77e2..0c14d7de 100644
--- a/ENI-2/ENI2/ENI2/Service References/LockingServiceReference/LockingService2.xsd
+++ b/ENI-2/ENI2/ENI2/Service References/LockingServiceReference/LockingService2.xsd
@@ -7,22 +7,22 @@
-
+
-
+
-
-
+
+
@@ -39,15 +39,15 @@
-
+
-
-
+
+
@@ -61,7 +61,7 @@
-
+
diff --git a/ENI-2/ENI2/ENI2/Service References/LockingServiceReference/Reference.cs b/ENI-2/ENI2/ENI2/Service References/LockingServiceReference/Reference.cs
index adb75cd3..fce6d6ea 100644
--- a/ENI-2/ENI2/ENI2/Service References/LockingServiceReference/Reference.cs
+++ b/ENI-2/ENI2/ENI2/Service References/LockingServiceReference/Reference.cs
@@ -26,7 +26,7 @@ namespace ENI2.LockingServiceReference {
private System.Guid CoreIdField;
[System.Runtime.Serialization.OptionalFieldAttribute()]
- private string UserIdField;
+ private System.Guid UserIdField;
[global::System.ComponentModel.BrowsableAttribute(false)]
public System.Runtime.Serialization.ExtensionDataObject ExtensionData {
@@ -52,12 +52,12 @@ namespace ENI2.LockingServiceReference {
}
[System.Runtime.Serialization.DataMemberAttribute()]
- public string UserId {
+ public System.Guid UserId {
get {
return this.UserIdField;
}
set {
- if ((object.ReferenceEquals(this.UserIdField, value) != true)) {
+ if ((this.UserIdField.Equals(value) != true)) {
this.UserIdField = value;
this.RaisePropertyChanged("UserId");
}
@@ -79,16 +79,16 @@ namespace ENI2.LockingServiceReference {
public interface IService {
[System.ServiceModel.OperationContractAttribute(Action="http://tempuri.org/IService/Lock", ReplyAction="http://tempuri.org/IService/LockResponse")]
- string Lock(System.Guid messageCoreId, string userId);
+ System.Guid Lock(System.Guid messageCoreId, System.Guid userId);
[System.ServiceModel.OperationContractAttribute(Action="http://tempuri.org/IService/Lock", ReplyAction="http://tempuri.org/IService/LockResponse")]
- System.Threading.Tasks.Task LockAsync(System.Guid messageCoreId, string userId);
+ System.Threading.Tasks.Task LockAsync(System.Guid messageCoreId, System.Guid userId);
[System.ServiceModel.OperationContractAttribute(Action="http://tempuri.org/IService/Unlock", ReplyAction="http://tempuri.org/IService/UnlockResponse")]
- void Unlock(System.Guid messageCoreId, string userId);
+ void Unlock(System.Guid messageCoreId, System.Guid userId);
[System.ServiceModel.OperationContractAttribute(Action="http://tempuri.org/IService/Unlock", ReplyAction="http://tempuri.org/IService/UnlockResponse")]
- System.Threading.Tasks.Task UnlockAsync(System.Guid messageCoreId, string userId);
+ System.Threading.Tasks.Task UnlockAsync(System.Guid messageCoreId, System.Guid userId);
[System.ServiceModel.OperationContractAttribute(Action="http://tempuri.org/IService/GetLocks", ReplyAction="http://tempuri.org/IService/GetLocksResponse")]
ENI2.LockingServiceReference.CoreLock[] GetLocks();
@@ -97,16 +97,16 @@ namespace ENI2.LockingServiceReference {
System.Threading.Tasks.Task GetLocksAsync();
[System.ServiceModel.OperationContractAttribute(Action="http://tempuri.org/IService/LockRefresh", ReplyAction="http://tempuri.org/IService/LockRefreshResponse")]
- void LockRefresh(System.Guid[] currentLocks, string userId);
+ void LockRefresh(System.Guid[] currentLocks, System.Guid userId);
[System.ServiceModel.OperationContractAttribute(Action="http://tempuri.org/IService/LockRefresh", ReplyAction="http://tempuri.org/IService/LockRefreshResponse")]
- System.Threading.Tasks.Task LockRefreshAsync(System.Guid[] currentLocks, string userId);
+ System.Threading.Tasks.Task LockRefreshAsync(System.Guid[] currentLocks, System.Guid userId);
[System.ServiceModel.OperationContractAttribute(Action="http://tempuri.org/IService/Log", ReplyAction="http://tempuri.org/IService/LogResponse")]
- void Log(string msg, string host, string userId);
+ void Log(string msg, string host, System.Guid userId);
[System.ServiceModel.OperationContractAttribute(Action="http://tempuri.org/IService/Log", ReplyAction="http://tempuri.org/IService/LogResponse")]
- System.Threading.Tasks.Task LogAsync(string msg, string host, string userId);
+ System.Threading.Tasks.Task LogAsync(string msg, string host, System.Guid userId);
}
[System.CodeDom.Compiler.GeneratedCodeAttribute("System.ServiceModel", "4.0.0.0")]
@@ -136,19 +136,19 @@ namespace ENI2.LockingServiceReference {
base(binding, remoteAddress) {
}
- public string Lock(System.Guid messageCoreId, string userId) {
+ public System.Guid Lock(System.Guid messageCoreId, System.Guid userId) {
return base.Channel.Lock(messageCoreId, userId);
}
- public System.Threading.Tasks.Task LockAsync(System.Guid messageCoreId, string userId) {
+ public System.Threading.Tasks.Task LockAsync(System.Guid messageCoreId, System.Guid userId) {
return base.Channel.LockAsync(messageCoreId, userId);
}
- public void Unlock(System.Guid messageCoreId, string userId) {
+ public void Unlock(System.Guid messageCoreId, System.Guid userId) {
base.Channel.Unlock(messageCoreId, userId);
}
- public System.Threading.Tasks.Task UnlockAsync(System.Guid messageCoreId, string userId) {
+ public System.Threading.Tasks.Task UnlockAsync(System.Guid messageCoreId, System.Guid userId) {
return base.Channel.UnlockAsync(messageCoreId, userId);
}
@@ -160,19 +160,19 @@ namespace ENI2.LockingServiceReference {
return base.Channel.GetLocksAsync();
}
- public void LockRefresh(System.Guid[] currentLocks, string userId) {
+ public void LockRefresh(System.Guid[] currentLocks, System.Guid userId) {
base.Channel.LockRefresh(currentLocks, userId);
}
- public System.Threading.Tasks.Task LockRefreshAsync(System.Guid[] currentLocks, string userId) {
+ public System.Threading.Tasks.Task LockRefreshAsync(System.Guid[] currentLocks, System.Guid userId) {
return base.Channel.LockRefreshAsync(currentLocks, userId);
}
- public void Log(string msg, string host, string userId) {
+ public void Log(string msg, string host, System.Guid userId) {
base.Channel.Log(msg, host, userId);
}
- public System.Threading.Tasks.Task LogAsync(string msg, string host, string userId) {
+ public System.Threading.Tasks.Task LogAsync(string msg, string host, System.Guid userId) {
return base.Channel.LogAsync(msg, host, userId);
}
}
diff --git a/ENI-2/ENI2/ENI2/SucheControl.xaml.cs b/ENI-2/ENI2/ENI2/SucheControl.xaml.cs
index 24b18e8e..58b41c9b 100644
--- a/ENI-2/ENI2/ENI2/SucheControl.xaml.cs
+++ b/ENI-2/ENI2/ENI2/SucheControl.xaml.cs
@@ -10,6 +10,7 @@ using System.Windows.Input;
using System.Windows.Media;
using bsmd.database;
+using System.Windows.Data;
namespace ENI2
{
@@ -20,6 +21,7 @@ namespace ENI2
{
private List anmeldungen = new List();
+ private object searchLock = new object();
#region Construction
@@ -77,8 +79,16 @@ namespace ENI2
if (from.HasValue || to.HasValue)
filterDict.Add(MessageCore.SearchFilterType.FILTER_ETA, string.Format("{0}:{1}", from?.ToString() ?? "", to?.ToString() ?? ""));
+ // menge suchen
+
+ int? resultLimit = null;
+ int? expectedResultNum = DBManager.Instance.GetNumCoresWithFilters(filterDict);
+ if ((expectedResultNum ?? 0) > 100)
+ resultLimit = 100;
+
// suche auslösen
- this.anmeldungen = DBManager.Instance.GetMessageCoresWithFilters(filterDict);
+ this.anmeldungen = DBManager.Instance.GetMessageCoresWithFilters(filterDict, resultLimit);
+ BindingOperations.EnableCollectionSynchronization(this.anmeldungen, this.searchLock); // prevent sync lock exceptions (trat bei Sandra auf)
if (App.UserId.HasValue)
{
@@ -102,7 +112,7 @@ namespace ENI2
// ergebnis anzeigen
this.dataGrid.ItemsSource = this.anmeldungen;
- this.searchResultLabel.Content = (this.anmeldungen.Count > 0) ? string.Format("{0} results found.", this.anmeldungen.Count) : "no results";
+ this.searchResultLabel.Content = ((expectedResultNum ?? 0) > 0) ? string.Format("{0} results found, {1} displayed.", (expectedResultNum ?? 0), this.anmeldungen.Count) : "no results";
}
diff --git a/ENI-2/ENI2/ENI2/Themes/Generic.xaml b/ENI-2/ENI2/ENI2/Themes/Generic.xaml
index 8d5cd4e0..b3ce3811 100644
--- a/ENI-2/ENI2/ENI2/Themes/Generic.xaml
+++ b/ENI-2/ENI2/ENI2/Themes/Generic.xaml
@@ -19,7 +19,7 @@
-
+