From 97ef25d4a5dd93dd6e9f03c1f66415485cced4ed Mon Sep 17 00:00:00 2001 From: Daniel Schick Date: Tue, 23 May 2017 05:26:37 +0000 Subject: [PATCH] aktuellen Stand einchecken (Service Referenz muss ersetzt werden) --- ENI-2/ENI2/ENI2/App.config | 18 +- ENI-2/ENI2/ENI2/App.xaml.cs | 21 +- ENI-2/ENI2/ENI2/DetailBaseControl.cs | 11 + ENI-2/ENI2/ENI2/DetailRootControl.xaml.cs | 69 ++++++ .../OverViewDetailControl.xaml | 26 ++- .../OverViewDetailControl.xaml.cs | 64 +++--- ENI-2/ENI2/ENI2/ENI2.csproj | 30 +-- ENI-2/ENI2/ENI2/ENI2.sln | 6 + .../ENI2/Properties/Resources.Designer.cs | 58 +++++ ENI-2/ENI2/ENI2/Properties/Resources.resx | 18 ++ .../ENI2/ENI2/Properties/Settings.Designer.cs | 22 +- ENI-2/ENI2/ENI2/Properties/Settings.settings | 8 +- ENI-2/ENI2/ENI2/Resources/lock.png | Bin 0 -> 1396 bytes ENI-2/ENI2/ENI2/Resources/lock_error.png | Bin 0 -> 1548 bytes ENI-2/ENI2/ENI2/Resources/lock_ok.png | Bin 0 -> 1581 bytes ENI-2/ENI2/ENI2/Resources/lock_open.png | Bin 0 -> 1284 bytes .../LockingService.disco | 4 - .../LockingService.wsdl | 96 --------- .../LockingService.xsd | 60 ------ .../LockingService1.xsd | 10 - .../LockingService2.xsd | 42 ---- .../LockingServiceReference/Reference.cs | 102 --------- .../LockingServiceReference/Reference.svcmap | 35 --- .../configuration.svcinfo | 10 - .../configuration91.svcinfo | 201 ------------------ Stundensheet.xlsx | Bin 30484 -> 30562 bytes nsw/Source/bsmd.LockingService/CoreLock.cs | 31 +++ nsw/Source/bsmd.LockingService/IService.cs | 34 +-- .../bsmd.LockingService/LockingService.svc | 2 +- .../bsmd.LockingService/LockingService.svc.cs | 40 +++- nsw/Source/bsmd.LockingService/Web.config | 12 +- .../bsmd.LockingService.csproj | 17 +- .../bsmd.LockingService.csproj.user | 2 +- nsw/Source/bsmd.LockingService/index.htm | 16 ++ nsw/Source/bsmd.LockingService/lock.png | Bin 0 -> 37821 bytes .../logo_transparent_babyblau.png | Bin 0 -> 30443 bytes nsw/Source/bsmd.database/MessageCore.cs | 5 + 37 files changed, 385 insertions(+), 685 deletions(-) create mode 100644 ENI-2/ENI2/ENI2/Resources/lock.png create mode 100644 ENI-2/ENI2/ENI2/Resources/lock_error.png create mode 100644 ENI-2/ENI2/ENI2/Resources/lock_ok.png create mode 100644 ENI-2/ENI2/ENI2/Resources/lock_open.png delete mode 100644 ENI-2/ENI2/ENI2/Service References/LockingServiceReference/LockingService.disco delete mode 100644 ENI-2/ENI2/ENI2/Service References/LockingServiceReference/LockingService.wsdl delete mode 100644 ENI-2/ENI2/ENI2/Service References/LockingServiceReference/LockingService.xsd delete mode 100644 ENI-2/ENI2/ENI2/Service References/LockingServiceReference/LockingService1.xsd delete mode 100644 ENI-2/ENI2/ENI2/Service References/LockingServiceReference/LockingService2.xsd delete mode 100644 ENI-2/ENI2/ENI2/Service References/LockingServiceReference/Reference.cs delete mode 100644 ENI-2/ENI2/ENI2/Service References/LockingServiceReference/Reference.svcmap delete mode 100644 ENI-2/ENI2/ENI2/Service References/LockingServiceReference/configuration.svcinfo delete mode 100644 ENI-2/ENI2/ENI2/Service References/LockingServiceReference/configuration91.svcinfo create mode 100644 nsw/Source/bsmd.LockingService/CoreLock.cs create mode 100644 nsw/Source/bsmd.LockingService/index.htm create mode 100644 nsw/Source/bsmd.LockingService/lock.png create mode 100644 nsw/Source/bsmd.LockingService/logo_transparent_babyblau.png diff --git a/ENI-2/ENI2/ENI2/App.config b/ENI-2/ENI2/ENI2/App.config index 28528d5d..e175721e 100644 --- a/ENI-2/ENI2/ENI2/App.config +++ b/ENI-2/ENI2/ENI2/App.config @@ -19,6 +19,12 @@ Sample license text. Data Source=(localdb)\Projects;Initial Catalog=nsw;Integrated Security=True;Connect Timeout=30;Encrypt=False;TrustServerCertificate=False + + True + + + http://heupferd/bsmd.LockingService/LockingService.svc + @@ -29,15 +35,7 @@ Sample license text. - - - - - - - - + + \ No newline at end of file diff --git a/ENI-2/ENI2/ENI2/App.xaml.cs b/ENI-2/ENI2/ENI2/App.xaml.cs index f4960bf5..ed258f01 100644 --- a/ENI-2/ENI2/ENI2/App.xaml.cs +++ b/ENI-2/ENI2/ENI2/App.xaml.cs @@ -9,7 +9,7 @@ using bsmd.database; using System.Windows.Controls; using System.Windows.Input; using System; -using ENI2.LockingServiceReference; +using System.Net; namespace ENI2 { @@ -17,8 +17,7 @@ namespace ENI2 /// Interaction logic for App.xaml /// public partial class App : Application - { - private ServiceClient lockingServiceClient; + { public App() : base() { @@ -30,7 +29,7 @@ namespace ENI2 protected override void OnStartup(StartupEventArgs e) { - base.OnStartup(e); + base.OnStartup(e); // initialize static / localized lookups from sqlite database @@ -41,14 +40,12 @@ namespace ENI2 LADG.CargoHandlingDict.Add(key, cargoHandlingDict[key]); EventManager.RegisterClassHandler(typeof(DatePicker), DatePicker.PreviewKeyDownEvent, new KeyEventHandler(this.DatePicker_PreviewKeyDown)); - try - { - // this.lockingServiceClient = new ServiceClient(); - } - catch(Exception ex) - { - System.Diagnostics.Trace.WriteLine("Exception creating locking service client: {0}", ex.ToString()); - } + + // perform logon + // TODO: Benutzerverwaltung + + + } diff --git a/ENI-2/ENI2/ENI2/DetailBaseControl.cs b/ENI-2/ENI2/ENI2/DetailBaseControl.cs index 0ef1ba0e..a1512418 100644 --- a/ENI-2/ENI2/ENI2/DetailBaseControl.cs +++ b/ENI-2/ENI2/ENI2/DetailBaseControl.cs @@ -41,6 +41,11 @@ namespace ENI2 /// public event Action RequestReload; + /// + /// Mit diesem Event wird der Wunsch nach einem Lock zum Ausdruck gebracht ;-) + /// + public event Action RequestLock; + #endregion #region Properties @@ -49,6 +54,8 @@ namespace ENI2 public List Messages { get; set; } + public Guid UserId { get; set; } // TODO: Ersetzen mit der User-Entity + #endregion #region public methods @@ -71,6 +78,10 @@ namespace ENI2 this.RequestReload?.Invoke(); } + protected virtual void OnRequestLock(bool shouldLock) + { + this.RequestLock?.Invoke(shouldLock); + } protected void SetLocodeStateImage(Image stateImage, LocodeState state) { diff --git a/ENI-2/ENI2/ENI2/DetailRootControl.xaml.cs b/ENI-2/ENI2/ENI2/DetailRootControl.xaml.cs index bf600899..603ba5a5 100644 --- a/ENI-2/ENI2/ENI2/DetailRootControl.xaml.cs +++ b/ENI-2/ENI2/ENI2/DetailRootControl.xaml.cs @@ -4,10 +4,12 @@ using System; using System.Collections.Generic; +using System.Diagnostics; using System.Windows.Controls; using bsmd.database; using ENI2.DetailViewControls; +using ENI2.LockingServiceReference; namespace ENI2 { @@ -16,12 +18,27 @@ namespace ENI2 /// public partial class DetailRootControl : UserControl { + + #region Fields + private MessageCore _core; private List _listBoxList = new List(); private List _messages; private Dictionary controlCache = new Dictionary(); + private ServiceClient lockingServiceClient; + private Guid userId = Guid.NewGuid(); // remove THIS!! + + #endregion + + #region Properties + public MessageCore Core { get { return this._core; } } + + #endregion + + #region Construction + public DetailRootControl(MessageCore aCore) { _core = aCore; @@ -51,8 +68,23 @@ namespace ENI2 _messages = DBManager.Instance.GetMessagesForCore(_core, DBManager.MessageLoad.ALL); Dispatcher.BeginInvoke((Action)(() => this.listBoxMessages.SelectedIndex = 0)); + + // Connect to locking service (if enabled) + + try + { + if (ENI2.Properties.Settings.Default.UseLocking) + this.lockingServiceClient = new ServiceClient("BasicHttpBinding_IService", ENI2.Properties.Settings.Default.LockingServerAddress); + } + catch (Exception ex) + { + System.Diagnostics.Trace.WriteLine("Exception creating locking service client: {0}", ex.ToString()); + } + } + #endregion + #region class MessageGroup /// @@ -89,6 +121,7 @@ namespace ENI2 }; detailControl.RequestReload += DetailControl_RequestReload; + detailControl.RequestLock += DetailControl_RequestLock; detailControl.Initialize(); controlCache.Add(mg.MessageGroupControlType, detailControl); @@ -99,6 +132,42 @@ namespace ENI2 } } + private void DetailControl_RequestLock(bool shouldLock) + { + if(this.lockingServiceClient == null) + { + return; + } + if (shouldLock) + { + try + { + string lockResult = this.lockingServiceClient.Lock(this.Core.Id.Value, this.userId.ToString()); + if (lockResult == "") + { + // lock successful + this.Core.Locked = true; + + } + else + { + // locking failed: Notify User + + } + } + catch(Exception ex) + { + Trace.WriteLine(ex.ToString()); + // TODO + } + } + else + { + this.lockingServiceClient.Unlock(this.Core.Id.Value, this.userId.ToString()); + this.Core.Locked = false; + } + } + private void DetailControl_RequestReload() { /// core und messages neu laden diff --git a/ENI-2/ENI2/ENI2/DetailViewControls/OverViewDetailControl.xaml b/ENI-2/ENI2/ENI2/DetailViewControls/OverViewDetailControl.xaml index dfba5656..339f0f72 100644 --- a/ENI-2/ENI2/ENI2/DetailViewControls/OverViewDetailControl.xaml +++ b/ENI-2/ENI2/ENI2/DetailViewControls/OverViewDetailControl.xaml @@ -32,7 +32,9 @@ - + + + @@ -72,19 +74,25 @@