diff --git a/ENI-2/ENI2/ENI2/App.config b/ENI-2/ENI2/ENI2/App.config index bc6cfbfc..8c9908cc 100644 --- a/ENI-2/ENI2/ENI2/App.config +++ b/ENI-2/ENI2/ENI2/App.config @@ -16,15 +16,18 @@ - - Data Source=192.168.2.12;Initial Catalog=nsw;Uid=dfuser;Pwd=dfpasswd;Connect Timeout=30;Encrypt=False;TrustServerCertificate=False - True http://heupferd/bsmd.LockingService/LockingService.svc + + 60 + + + Data Source=192.168.2.12;Initial Catalog=nsw;Uid=dfuser;Pwd=dfpasswd;Connect Timeout=30;Encrypt=False;TrustServerCertificate=False + diff --git a/ENI-2/ENI2/ENI2/Controls/EditWindowBase.cs b/ENI-2/ENI2/ENI2/Controls/EditWindowBase.cs index 6d39ef86..b0a62657 100644 --- a/ENI-2/ENI2/ENI2/Controls/EditWindowBase.cs +++ b/ENI-2/ENI2/ENI2/Controls/EditWindowBase.cs @@ -45,6 +45,12 @@ namespace ENI2.Controls if (this.shouldCancel) e.Cancel = true; } + protected void EnableOK(bool enabled) + { + var okButton = (Button)Template.FindName("buttonOK", this); + okButton.IsEnabled = enabled; + } + protected override void OnSourceInitialized(EventArgs e) { base.OnSourceInitialized(e); diff --git a/ENI-2/ENI2/ENI2/Controls/LocodeControl.xaml.cs b/ENI-2/ENI2/ENI2/Controls/LocodeControl.xaml.cs index f2fc7481..f420030a 100644 --- a/ENI-2/ENI2/ENI2/Controls/LocodeControl.xaml.cs +++ b/ENI-2/ENI2/ENI2/Controls/LocodeControl.xaml.cs @@ -21,6 +21,7 @@ namespace ENI2.Controls { private List _locodeList = new List(); public event PropertyChangedEventHandler PropertyChanged; + private bool _comboSelect; public LocodeControl() { @@ -52,9 +53,9 @@ namespace ENI2.Controls { // Get instance of current control from sender // and property value from e.NewValue - - if(e.NewValue != null) - ((LocodeControl)sender).SelectedItem = e.NewValue.ToString().Substring(0,5); + + if (e.NewValue != null) + ((LocodeControl)sender).SelectedItem = e.NewValue.ToString();//.Substring(0,5); } @@ -63,11 +64,18 @@ namespace ENI2.Controls get { return this.comboBoxLocode.SelectedItem as string; } set { this._locodeList.Clear(); - this._locodeList.Add(value); - this.comboBoxLocode.ItemsSource = this.LocodeList; - LocodeState locodeState = LocodeDB.PortNameFromLocode(value).IsNullOrEmpty() ? LocodeState.INVALID : LocodeState.OK; + + string portName = LocodeDB.PortNameFromLocode(value); + LocodeState locodeState = portName.IsNullOrEmpty() ? LocodeState.INVALID : LocodeState.OK; this.SetLocodeStateImage(this.imageLocodeState, locodeState); - this.comboBoxLocode.SelectedItem = value; + + if (locodeState == LocodeState.OK) + { + string valString = string.Format("{0} - {1}", value, portName); + this._locodeList.Add(valString); + this.comboBoxLocode.ItemsSource = this.LocodeList; + this.comboBoxLocode.SelectedItem = valString; + } } } @@ -85,46 +93,65 @@ namespace ENI2.Controls #region event handler private void ComboBox_TextChanged(object sender, RoutedEventArgs e) - { - if (this.comboBoxLocode.Text.Length > 4) - { - this.LocodeList.Clear(); + { + bool locodeFound = false; + this.comboBoxLocode.ItemsSource = null; - // check if actual locode - if (this.comboBoxLocode.Text.Length == 5) + if (this._comboSelect) + { + this._comboSelect = false; + this.SetLocodeStateImage(this.imageLocodeState, LocodeState.OK); + } + + else + { + + if (this.comboBoxLocode.Text.Length > 4) { - string directLocode = this.comboBoxLocode.Text.Trim().ToUpper(); - bool isLocode = !LocodeDB.PortNameFromLocode(directLocode).IsNullOrEmpty(); - if (isLocode) + this.LocodeList.Clear(); + this.LocodeValue = null; + + // check if actual locode + if (this.comboBoxLocode.Text.Length == 5) { - this.comboBoxLocode.Text = directLocode; - this.LocodeList.Add(directLocode); - this.SetLocodeStateImage(this.imageLocodeState, LocodeState.OK); - return; + string directLocode = this.comboBoxLocode.Text.Trim().ToUpper(); + string portname = LocodeDB.PortNameFromLocode(directLocode); + bool isLocode = !portname.IsNullOrEmpty(); + if (isLocode) + { + this.comboBoxLocode.Text = string.Format("{0} - {1}", directLocode, portname); + this.LocodeList.Add(string.Format("{0} - {1}", directLocode, portname)); + this.SetLocodeStateImage(this.imageLocodeState, LocodeState.OK); + this.LocodeValue = directLocode; + locodeFound = true; + } + } + + if (!locodeFound) + { + // assume this is a harbour name typed out.. + List locodeEntries = LocodeDB.AllLocodesForCityNameAsEntries("%" + this.comboBoxLocode.Text + "%"); + foreach (LocodeDB.LocodeEntry entry in locodeEntries) + this.LocodeList.Add(string.Format("{0} - {1}", entry.Locode, entry.Name)); + + if (this.LocodeList.Count == 1) + { + this.comboBoxLocode.SelectedItem = this.LocodeList[0]; + this.SetLocodeStateImage(this.imageLocodeState, LocodeState.OK); + this.LocodeValue = this.LocodeList[0]; + } + else if (this.LocodeList.Count == 0) + { + this.SetLocodeStateImage(this.imageLocodeState, LocodeState.INVALID); + } + else + { + this.SetLocodeStateImage(this.imageLocodeState, LocodeState.AMBIGUOUS); + } + + this.comboBoxLocode.ItemsSource = this.LocodeList; } } - - // assume this is a harbour name typed out.. - List locodeEntries = LocodeDB.AllLocodesForCityNameAsEntries(this.comboBoxLocode.Text + "%"); - foreach (LocodeDB.LocodeEntry entry in locodeEntries) - this.LocodeList.Add(string.Format("{0} - {1}", entry.Locode, entry.Name)); - - if (this.LocodeList.Count == 1) - { - this.comboBoxLocode.SelectedItem = this.LocodeList[0]; - this.SetLocodeStateImage(this.imageLocodeState, LocodeState.OK); - } - else if (this.LocodeList.Count == 0) - { - this.SetLocodeStateImage(this.imageLocodeState, LocodeState.INVALID); - } - else - { - this.SetLocodeStateImage(this.imageLocodeState, LocodeState.AMBIGUOUS); - } - - this.comboBoxLocode.ItemsSource = this.LocodeList; - } this.PropertyChanged?.Invoke(this, new PropertyChangedEventArgs("LocodeList")); @@ -132,7 +159,20 @@ namespace ENI2.Controls private void comboBoxLocode_SelectionChanged(object sender, SelectionChangedEventArgs e) { - this.LocodeValue = this.SelectedItem; + if (this.SelectedItem == null) + this.LocodeValue = null; + else + { + if (this.SelectedItem.Length > 5) + { + this.LocodeValue = this.SelectedItem.Substring(0, 5); + this._comboSelect = true; + } + else + { + this.LocodeValue = this.SelectedItem; + } + } } #endregion diff --git a/ENI-2/ENI2/ENI2/DetailViewControls/OverViewDetailControl.xaml.cs b/ENI-2/ENI2/ENI2/DetailViewControls/OverViewDetailControl.xaml.cs index c199023c..3ca6e0e2 100644 --- a/ENI-2/ENI2/ENI2/DetailViewControls/OverViewDetailControl.xaml.cs +++ b/ENI-2/ENI2/ENI2/DetailViewControls/OverViewDetailControl.xaml.cs @@ -367,18 +367,31 @@ namespace ENI2.DetailViewControls bool? statusFlag = DBManager.Instance.GetMessageCoreQueryStatusFlag(this.Core.Id.Value); if (statusFlag ?? true) { - // not yet.. (calling ui thread async) - this.Dispatcher.BeginInvoke(new Action(() => - { - this.labelBusyTimeElapsed.Content = string.Format(Properties.Resources.textSecondsElapsed, (DateTime.Now - _startStatusCheck).TotalSeconds.ToString("N0")); - })); + double elapsedSec = (DateTime.Now - _startStatusCheck).TotalSeconds; + if (elapsedSec < Properties.Settings.Default.RequestTimeout) + { + // not yet.. (calling ui thread async) + this.Dispatcher.BeginInvoke(new Action(() => + { + this.labelBusyTimeElapsed.Content = string.Format(Properties.Resources.textSecondsElapsed, elapsedSec.ToString("N0")); + })); + } + else + { + this._checkStatusTimer.Stop(); + this.Dispatcher.BeginInvoke(new Action(() => + { + MessageBox.Show(Properties.Resources.textRequestTimedOut, Properties.Resources.textCaptionInformation, MessageBoxButton.OK, MessageBoxImage.Warning); + this.busyIndicator.IsBusy = false; + })); + } } else { this._checkStatusTimer.Stop(); this.Dispatcher.BeginInvoke(new Action(() => - { + { this.busyIndicator.IsBusy = false; this.OnRequestReload(); })); diff --git a/ENI-2/ENI2/ENI2/ENI2.csproj b/ENI-2/ENI2/ENI2/ENI2.csproj index fe581afc..479b6e41 100644 --- a/ENI-2/ENI2/ENI2/ENI2.csproj +++ b/ENI-2/ENI2/ENI2/ENI2.csproj @@ -35,7 +35,7 @@ 3.5.1.0 true publish.html - 0 + 2 3.6.3.%2a false true diff --git a/ENI-2/ENI2/ENI2/EditControls/VisitIdDialog.xaml b/ENI-2/ENI2/ENI2/EditControls/VisitIdDialog.xaml index 1b8efc25..d675b55f 100644 --- a/ENI-2/ENI2/ENI2/EditControls/VisitIdDialog.xaml +++ b/ENI-2/ENI2/ENI2/EditControls/VisitIdDialog.xaml @@ -8,7 +8,7 @@ xmlns:p="clr-namespace:ENI2.Properties" xmlns:xctk="http://schemas.xceed.com/wpf/xaml/toolkit" mc:Ignorable="d" - Title="{x:Static p:Resources.textNewVisitTransitId}" Height="192" Width="300" WindowStyle="SingleBorderWindow" Background="AliceBlue" ResizeMode="NoResize"> + Title="{x:Static p:Resources.textNewVisitTransitId}" Height="192" Width="350" WindowStyle="SingleBorderWindow" Background="AliceBlue" ResizeMode="NoResize"> @@ -18,7 +18,7 @@ - + diff --git a/ENI-2/ENI2/ENI2/EditControls/VisitIdDialog.xaml.cs b/ENI-2/ENI2/ENI2/EditControls/VisitIdDialog.xaml.cs index 9e498a3a..38723e2d 100644 --- a/ENI-2/ENI2/ENI2/EditControls/VisitIdDialog.xaml.cs +++ b/ENI-2/ENI2/ENI2/EditControls/VisitIdDialog.xaml.cs @@ -23,9 +23,11 @@ namespace ENI2.EditControls } private void VisitIdDialog_Loaded(object sender, RoutedEventArgs e) - { + { this.OKClicked += VisitIdDialog_OKClicked; - } + this.EnableOK(false); + this.locodePoC.PropertyChanged += LocodePoC_PropertyChanged; + } private void VisitIdDialog_OKClicked() { @@ -56,16 +58,51 @@ namespace ENI2.EditControls private void doubleUpDownIMO_ValueChanged(object sender, RoutedPropertyChangedEventArgs e) { bool hasValue = (doubleUpDownIMO.Value.HasValue && doubleUpDownIMO.Value > 0); - doubleUpDownENI.IsReadOnly = hasValue; + doubleUpDownENI.IsReadOnly = hasValue; + this.CheckComplete(); } private void doubleUpDownENI_ValueChanged(object sender, RoutedPropertyChangedEventArgs e) { bool hasValue = (doubleUpDownENI.Value.HasValue && doubleUpDownENI.Value > 0); - doubleUpDownIMO.IsReadOnly = hasValue; + doubleUpDownIMO.IsReadOnly = hasValue; + this.CheckComplete(); + } + + private void LocodePoC_PropertyChanged(object sender, System.ComponentModel.PropertyChangedEventArgs e) + { + this.CheckComplete(); + } + + private void datePickerETA_SelectedDateChanged(object sender, System.Windows.Controls.SelectionChangedEventArgs e) + { + this.CheckComplete(); } #endregion + #region input validation + + private void CheckComplete() + { + bool isComplete = true; + + isComplete &= this.datePickerETA.SelectedDate.HasValue; // ETA + + bool imo_OR_eni = ((doubleUpDownIMO.Value.HasValue) && (doubleUpDownIMO.Value > 1000000) && (doubleUpDownIMO.Value < 9999999)) || + ((doubleUpDownENI.Value.HasValue) && (doubleUpDownENI.Value > 100000) && (doubleUpDownENI.Value < 99999999)); + + isComplete &= imo_OR_eni; + + string locode = this.locodePoC.LocodeValue; + bool validLocode = (locode != null) && (locode.Length == 5) && (locode.StartsWith("DE") || locode.StartsWith("DK") || locode.Equals("ZZNOK")); + + isComplete &= validLocode; + + this.EnableOK(isComplete); + } + + #endregion + } } diff --git a/ENI-2/ENI2/ENI2/MainWindow.xaml.cs b/ENI-2/ENI2/ENI2/MainWindow.xaml.cs index 53ec3840..4ec53ebb 100644 --- a/ENI-2/ENI2/ENI2/MainWindow.xaml.cs +++ b/ENI-2/ENI2/ENI2/MainWindow.xaml.cs @@ -40,7 +40,7 @@ namespace ENI2 #region Construction public MainWindow() - { + { Thread.Sleep(500); InitializeComponent(); App.SplashScreen.ShowMessage("loading.."); @@ -104,6 +104,8 @@ namespace ENI2 private void Window_Loaded(object sender, RoutedEventArgs e) { + if (Debugger.IsAttached) this.busyIndicator.IsBusy = false; // not for me :-P + this.dbConnected = DBManager.Instance.Connect(Properties.Settings.Default.ConnectionString); labelGeneralStatus.Text = dbConnected ? "DB Connected" : "DB Connect failed"; labelVersion.Text = "V. " + System.Reflection.Assembly.GetExecutingAssembly().GetName().Version; diff --git a/ENI-2/ENI2/ENI2/Properties/Resources.Designer.cs b/ENI-2/ENI2/ENI2/Properties/Resources.Designer.cs index b972d54a..f5648310 100644 --- a/ENI-2/ENI2/ENI2/Properties/Resources.Designer.cs +++ b/ENI-2/ENI2/ENI2/Properties/Resources.Designer.cs @@ -616,6 +616,15 @@ namespace ENI2.Properties { } } + /// + /// Looks up a localized string similar to Information. + /// + public static string textCaptionInformation { + get { + return ResourceManager.GetString("textCaptionInformation", resourceCulture); + } + } + /// /// Looks up a localized string similar to Code (NST). /// @@ -1300,6 +1309,15 @@ namespace ENI2.Properties { } } + /// + /// Looks up a localized string similar to Request timed out. + /// + public static string textRequestTimedOut { + get { + return ResourceManager.GetString("textRequestTimedOut", resourceCulture); + } + } + /// /// Looks up a localized string similar to Save. /// diff --git a/ENI-2/ENI2/ENI2/Properties/Resources.resx b/ENI-2/ENI2/ENI2/Properties/Resources.resx index 3be95025..dff364b8 100644 --- a/ENI-2/ENI2/ENI2/Properties/Resources.resx +++ b/ENI-2/ENI2/ENI2/Properties/Resources.resx @@ -628,4 +628,10 @@ Detail info for: {0} + + Information + + + Request timed out + \ No newline at end of file diff --git a/ENI-2/ENI2/ENI2/Properties/Settings.Designer.cs b/ENI-2/ENI2/ENI2/Properties/Settings.Designer.cs index 8cef7ee2..f661ccb8 100644 --- a/ENI-2/ENI2/ENI2/Properties/Settings.Designer.cs +++ b/ENI-2/ENI2/ENI2/Properties/Settings.Designer.cs @@ -23,16 +23,6 @@ namespace ENI2.Properties { } } - [global::System.Configuration.ApplicationScopedSettingAttribute()] - [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] - [global::System.Configuration.DefaultSettingValueAttribute("Data Source=(localdb)\\Projects;Initial Catalog=nsw;Integrated Security=True;Conne" + - "ct Timeout=30;Encrypt=False;TrustServerCertificate=False")] - public string ConnectionString { - get { - return ((string)(this["ConnectionString"])); - } - } - [global::System.Configuration.UserScopedSettingAttribute()] [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] [global::System.Configuration.DefaultSettingValueAttribute("")] @@ -62,5 +52,24 @@ namespace ENI2.Properties { return ((string)(this["LockingServerAddress"])); } } + + [global::System.Configuration.ApplicationScopedSettingAttribute()] + [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] + [global::System.Configuration.DefaultSettingValueAttribute("60")] + public int RequestTimeout { + get { + return ((int)(this["RequestTimeout"])); + } + } + + [global::System.Configuration.ApplicationScopedSettingAttribute()] + [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] + [global::System.Configuration.DefaultSettingValueAttribute("Data Source=(localdb)\\Projects;Initial Catalog=nsw;Integrated Security=True;Conne" + + "ct Timeout=30;Encrypt=False;TrustServerCertificate=False")] + public string ConnectionString { + get { + return ((string)(this["ConnectionString"])); + } + } } } diff --git a/ENI-2/ENI2/ENI2/Properties/Settings.settings b/ENI-2/ENI2/ENI2/Properties/Settings.settings index dc433b30..e5d7c842 100644 --- a/ENI-2/ENI2/ENI2/Properties/Settings.settings +++ b/ENI-2/ENI2/ENI2/Properties/Settings.settings @@ -2,9 +2,6 @@ - - Data Source=(localdb)\Projects;Initial Catalog=nsw;Integrated Security=True;Connect Timeout=30;Encrypt=False;TrustServerCertificate=False - @@ -14,5 +11,11 @@ http://heupferd/bsmd.LockingService/LockingService.svc + + 60 + + + Data Source=(localdb)\Projects;Initial Catalog=nsw;Integrated Security=True;Connect Timeout=30;Encrypt=False;TrustServerCertificate=False + \ No newline at end of file diff --git a/ENI-2/ENI2/ENI2/SucheControl.xaml.cs b/ENI-2/ENI2/ENI2/SucheControl.xaml.cs index f000315d..24b18e8e 100644 --- a/ENI-2/ENI2/ENI2/SucheControl.xaml.cs +++ b/ENI-2/ENI2/ENI2/SucheControl.xaml.cs @@ -97,6 +97,9 @@ namespace ENI2 } + // 31.5.17: Komische Display ETA Vorsortierung + this.anmeldungen.Sort(); + // ergebnis anzeigen this.dataGrid.ItemsSource = this.anmeldungen; this.searchResultLabel.Content = (this.anmeldungen.Count > 0) ? string.Format("{0} results found.", this.anmeldungen.Count) : "no results"; diff --git a/Stundensheet.xlsx b/Stundensheet.xlsx index 6e603dc0..9a1b5155 100644 Binary files a/Stundensheet.xlsx and b/Stundensheet.xlsx differ diff --git a/nsw/Source/bsmd.database/MessageCore.cs b/nsw/Source/bsmd.database/MessageCore.cs index 92d9554d..61886a3f 100644 --- a/nsw/Source/bsmd.database/MessageCore.cs +++ b/nsw/Source/bsmd.database/MessageCore.cs @@ -9,7 +9,7 @@ using System.Text; namespace bsmd.database { - public class MessageCore : DatabaseEntity + public class MessageCore : DatabaseEntity, IComparable { #region Fields @@ -571,5 +571,18 @@ namespace bsmd.database #endregion + #region IComparable implementation + + public int CompareTo(object obj) + { + if(obj is MessageCore) + { + return Nullable.Compare(((MessageCore)obj).ETADisplay, this.ETADisplay); + } + return 0; + } + + #endregion + } } diff --git a/nsw/Source/bsmd.database/ReportingParty.cs b/nsw/Source/bsmd.database/ReportingParty.cs index 87a42198..d64918e6 100644 --- a/nsw/Source/bsmd.database/ReportingParty.cs +++ b/nsw/Source/bsmd.database/ReportingParty.cs @@ -77,6 +77,12 @@ namespace bsmd.database /// public string Logon { get; set; } + /// + /// Personal / OTRS / User Email + /// + [MaxLength(100)] + public string UserEMail { get; set; } + /// /// SHA 512 /// @@ -124,24 +130,25 @@ namespace bsmd.database scmd.Parameters.AddWithNullableValue("@P9", this.Phone); scmd.Parameters.AddWithNullableValue("@P10", this.Fax); scmd.Parameters.AddWithNullableValue("@P11", this.EMail); - scmd.Parameters.AddWithNullableValue("@P12", this.Logon); + scmd.Parameters.AddWithNullableValue("@P12", this.Logon); scmd.Parameters.AddWithNullableValue("@P13", this.PasswordHash); scmd.Parameters.AddWithNullableValue("@P14", this.Salt); scmd.Parameters.AddWithNullableValue("@P15", this.Flags); scmd.Parameters.AddWithNullableValue("@P16", this.Deleted); + scmd.Parameters.AddWithNullableValue("@P17", this.UserEMail); if (this.IsNew) { scmd.CommandText = string.Format("INSERT INTO {0} (RPName, RPStreetAndNumber, RPPostalCode, RPCity, RPCountry " + - "RPLastName, RPFirstName, RPPhone, RPFax, RPEMail, Logon, PasswordHash, Salt, Flags) VALUES " + - "( @P2, @P3, @P4, @P5, @P6, @P7, @P8, @P9, @P10, @P11, @P12, @P13, @P14, @P15 )", this.Tablename); + "RPLastName, RPFirstName, RPPhone, RPFax, RPEMail, Logon, PasswordHash, Salt, Flags, EMail) VALUES " + + "( @P2, @P3, @P4, @P5, @P6, @P7, @P8, @P9, @P10, @P11, @P12, @P13, @P14, @P15, @P17 )", this.Tablename); } else { scmd.Parameters.AddWithValue(@"ID", this.Id); scmd.CommandText = string.Format("UPDATE {0} SET RPName = @P2, RPStreetAndNumber = @P3, RPPostalCode = @P4, " + "RPCity = @P5, RPCountry = @P6, RPLastName = @P7, RPFirstName = @P8, RPPhone = @P9, RPFax = @P10, " + - "RPEMail = @P11, Logon = @P12, PasswordHash = @P13, Salt= @P14, Flags = @P15, Deleted = @P16 WHERE Id = @ID", this.Tablename); + "RPEMail = @P11, Logon = @P12, PasswordHash = @P13, Salt= @P14, Flags = @P15, Deleted = @P16, EMail = @P17 WHERE Id = @ID", this.Tablename); } } @@ -149,7 +156,7 @@ namespace bsmd.database { string query = string.Format("SELECT Id, RPName, RPStreetAndNumber, RPPostalCode, RPCity, RPCountry, RPLastName, " + - "RPFirstName, RPPhone, RPFax, RPEMail, Logon, PasswordHash, Salt, Created, Changed, Flags, Deleted FROM {0} ", this.Tablename); + "RPFirstName, RPPhone, RPFax, RPEMail, Logon, PasswordHash, Salt, Created, Changed, Flags, Deleted, EMail FROM {0} ", this.Tablename); switch (filter) { @@ -191,6 +198,7 @@ namespace bsmd.database if (!reader.IsDBNull(15)) rp._changed = reader.GetDateTime(15); if (!reader.IsDBNull(16)) rp.Flags = reader.GetInt32(16); if (!reader.IsDBNull(17)) rp.Deleted = reader.GetInt32(17); + if (!reader.IsDBNull(18)) rp.UserEMail = reader.GetString(18); result.Add(rp); } reader.Close();