Aktueller Stand Ende Mai vor Besuch in Bremen

This commit is contained in:
Daniel Schick 2017-06-01 08:06:20 +00:00
parent 03813b1921
commit 14c5daff20
16 changed files with 241 additions and 80 deletions

View File

@ -16,15 +16,18 @@
</startup>
<applicationSettings>
<ENI2.Properties.Settings>
<setting name="ConnectionString" serializeAs="String">
<value>Data Source=192.168.2.12;Initial Catalog=nsw;Uid=dfuser;Pwd=dfpasswd;Connect Timeout=30;Encrypt=False;TrustServerCertificate=False</value>
</setting>
<setting name="UseLocking" serializeAs="String">
<value>True</value>
</setting>
<setting name="LockingServerAddress" serializeAs="String">
<value>http://heupferd/bsmd.LockingService/LockingService.svc</value>
</setting>
<setting name="RequestTimeout" serializeAs="String">
<value>60</value>
</setting>
<setting name="ConnectionString" serializeAs="String">
<value>Data Source=192.168.2.12;Initial Catalog=nsw;Uid=dfuser;Pwd=dfpasswd;Connect Timeout=30;Encrypt=False;TrustServerCertificate=False</value>
</setting>
</ENI2.Properties.Settings>
</applicationSettings>
<userSettings>

View File

@ -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);

View File

@ -21,6 +21,7 @@ namespace ENI2.Controls
{
private List<string> _locodeList = new List<string>();
public event PropertyChangedEventHandler PropertyChanged;
private bool _comboSelect;
public LocodeControl()
{
@ -53,8 +54,8 @@ 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;
}
}
}
@ -86,45 +94,64 @@ namespace ENI2.Controls
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<LocodeDB.LocodeEntry> 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<LocodeDB.LocodeEntry> 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

View File

@ -367,11 +367,24 @@ 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
{

View File

@ -35,7 +35,7 @@
<MinimumRequiredVersion>3.5.1.0</MinimumRequiredVersion>
<CreateWebPageOnPublish>true</CreateWebPageOnPublish>
<WebPage>publish.html</WebPage>
<ApplicationRevision>0</ApplicationRevision>
<ApplicationRevision>2</ApplicationRevision>
<ApplicationVersion>3.6.3.%2a</ApplicationVersion>
<UseApplicationTrust>false</UseApplicationTrust>
<CreateDesktopShortcut>true</CreateDesktopShortcut>

View File

@ -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">
<Grid Margin="4">
<Grid.RowDefinitions>
<RowDefinition Height="28" />
@ -18,7 +18,7 @@
</Grid.RowDefinitions>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="1*" />
<ColumnDefinition Width="2*" />
<ColumnDefinition Width="3*" />
</Grid.ColumnDefinitions>
<Label Name="labelIMO" Grid.Row="0" Grid.Column="0" Content="{x:Static p:Resources.textIMO}" />
<Label Name="labelENI" Grid.Row="1" Grid.Column="0" Content="{x:Static p:Resources.textENI}" />
@ -55,6 +55,6 @@
ParsingNumberStyle="Integer"
Watermark="Enter ENI" ValueChanged="doubleUpDownENI_ValueChanged"/>
<enictrl:LocodeControl Grid.Column="1" Grid.Row="2" Width="Auto" x:Name="locodePoC" LocodeValue="{Binding PoC, Mode=TwoWay}" />
<DatePicker Name="datePickerETA" Grid.Row="3" Grid.Column="1" Margin="2"/>
<DatePicker Name="datePickerETA" Grid.Row="3" Grid.Column="1" Margin="2" SelectedDateChanged="datePickerETA_SelectedDateChanged" />
</Grid>
</enictrl:EditWindowBase>

View File

@ -25,6 +25,8 @@ 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()
@ -57,12 +59,47 @@ namespace ENI2.EditControls
{
bool hasValue = (doubleUpDownIMO.Value.HasValue && doubleUpDownIMO.Value > 0);
doubleUpDownENI.IsReadOnly = hasValue;
this.CheckComplete();
}
private void doubleUpDownENI_ValueChanged(object sender, RoutedPropertyChangedEventArgs<object> e)
{
bool hasValue = (doubleUpDownENI.Value.HasValue && doubleUpDownENI.Value > 0);
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

View File

@ -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;

View File

@ -616,6 +616,15 @@ namespace ENI2.Properties {
}
}
/// <summary>
/// Looks up a localized string similar to Information.
/// </summary>
public static string textCaptionInformation {
get {
return ResourceManager.GetString("textCaptionInformation", resourceCulture);
}
}
/// <summary>
/// Looks up a localized string similar to Code (NST).
/// </summary>
@ -1300,6 +1309,15 @@ namespace ENI2.Properties {
}
}
/// <summary>
/// Looks up a localized string similar to Request timed out.
/// </summary>
public static string textRequestTimedOut {
get {
return ResourceManager.GetString("textRequestTimedOut", resourceCulture);
}
}
/// <summary>
/// Looks up a localized string similar to Save.
/// </summary>

View File

@ -628,4 +628,10 @@
<data name="textDetailInfoPropertyGridTitle" xml:space="preserve">
<value>Detail info for: {0}</value>
</data>
<data name="textCaptionInformation" xml:space="preserve">
<value>Information</value>
</data>
<data name="textRequestTimedOut" xml:space="preserve">
<value>Request timed out</value>
</data>
</root>

View File

@ -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"]));
}
}
}
}

View File

@ -2,9 +2,6 @@
<SettingsFile xmlns="http://schemas.microsoft.com/VisualStudio/2004/01/settings" CurrentProfile="(Default)" GeneratedClassNamespace="ENI2.Properties" GeneratedClassName="Settings">
<Profiles />
<Settings>
<Setting Name="ConnectionString" Type="System.String" Scope="Application">
<Value Profile="(Default)">Data Source=(localdb)\Projects;Initial Catalog=nsw;Integrated Security=True;Connect Timeout=30;Encrypt=False;TrustServerCertificate=False</Value>
</Setting>
<Setting Name="MainWindowPlacement" Type="System.String" Scope="User">
<Value Profile="(Default)" />
</Setting>
@ -14,5 +11,11 @@
<Setting Name="LockingServerAddress" Type="System.String" Scope="Application">
<Value Profile="(Default)">http://heupferd/bsmd.LockingService/LockingService.svc</Value>
</Setting>
<Setting Name="RequestTimeout" Type="System.Int32" Scope="Application">
<Value Profile="(Default)">60</Value>
</Setting>
<Setting Name="ConnectionString" Type="System.String" Scope="Application">
<Value Profile="(Default)">Data Source=(localdb)\Projects;Initial Catalog=nsw;Integrated Security=True;Connect Timeout=30;Encrypt=False;TrustServerCertificate=False</Value>
</Setting>
</Settings>
</SettingsFile>

View File

@ -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";

Binary file not shown.

View File

@ -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
}
}

View File

@ -77,6 +77,12 @@ namespace bsmd.database
/// </summary>
public string Logon { get; set; }
/// <summary>
/// Personal / OTRS / User Email
/// </summary>
[MaxLength(100)]
public string UserEMail { get; set; }
/// <summary>
/// SHA 512
/// </summary>
@ -129,19 +135,20 @@ namespace bsmd.database
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();