From 130d8c608e839e138fd803eb8a4d741a15e0f812 Mon Sep 17 00:00:00 2001 From: Daniel Schick Date: Sat, 10 Jun 2017 07:19:05 +0000 Subject: [PATCH] Sicherung Zwischenstand --- ENI-2/ENI2/ENI2/App.config | 5 +- ENI-2/ENI2/ENI2/App.xaml | 10 +++ ENI-2/ENI2/ENI2/Controls/ClosableTabItem.cs | 3 +- ENI-2/ENI2/ENI2/Controls/EditWindowBase.cs | 11 +++ ENI-2/ENI2/ENI2/Controls/LocodeControl.xaml | 10 ++- .../ENI2/ENI2/Controls/LocodeControl.xaml.cs | 24 ++++-- ENI-2/ENI2/ENI2/DetailBaseControl.cs | 34 +-------- ENI-2/ENI2/ENI2/DetailRootControl.xaml.cs | 22 ++++-- .../OverViewDetailControl.xaml | 13 ++-- .../OverViewDetailControl.xaml.cs | 31 ++++---- .../PortCallDetailControl.xaml.cs | 28 +++++-- .../PortNotificationDetailControl.xaml.cs | 11 --- ENI-2/ENI2/ENI2/ENI2.csproj | 1 + .../EditCallPurposeDialog.xaml.cs | 32 ++++---- .../ENI2/ENI2/EditControls/VisitIdDialog.xaml | 8 +- ENI-2/ENI2/ENI2/MainWindow.xaml.cs | 51 ++++++++++++- .../ENI2/Properties/Resources.Designer.cs | 19 +++++ ENI-2/ENI2/ENI2/Properties/Resources.resx | 6 ++ ENI-2/ENI2/ENI2/Resources/mail_forward.png | Bin 0 -> 1629 bytes .../LockingService1.xsd | 2 +- .../LockingService2.xsd | 16 ++-- .../LockingServiceReference/Reference.cs | 38 +++++----- ENI-2/ENI2/ENI2/SucheControl.xaml.cs | 14 +++- ENI-2/ENI2/ENI2/Themes/Generic.xaml | 4 +- Stundensheet.xlsx | Bin 30737 -> 30919 bytes nsw/Source/CoreDeleteTool/App.config | 2 +- .../CoreDeleteTool/CoreDeleteTool.csproj | 6 ++ .../Properties/Settings.Designer.cs | 5 +- .../Properties/Settings.settings | 2 +- .../bsmd.ExcelReadService/ExcelReader.cs | 8 +- nsw/Source/bsmd.ExcelReadService/LocodeDB.cs | 10 ++- nsw/Source/bsmd.LockingService/log4net.config | 22 ++++++ nsw/Source/bsmd.database/DBManager.cs | 52 ++++++++++++- nsw/Source/bsmd.database/DatabaseEntity.cs | 16 +++- nsw/Source/bsmd.database/HAZ.cs | 4 +- nsw/Source/bsmd.database/MessageCore.cs | 70 ++++++++++++------ .../bsmd.dbh.ResponseService/packages.config | 4 + 37 files changed, 409 insertions(+), 185 deletions(-) create mode 100644 ENI-2/ENI2/ENI2/Resources/mail_forward.png create mode 100644 nsw/Source/bsmd.LockingService/log4net.config create mode 100644 nsw/Source/bsmd.dbh.ResponseService/packages.config 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"> + @@ -13,5 +14,14 @@ + + + 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 @@