Kleines ENI Update (3.4.10)

This commit is contained in:
Daniel Schick 2017-03-29 10:12:44 +00:00
parent ab2a3b7c3e
commit b59af7d809
10 changed files with 94 additions and 22 deletions

View File

@ -76,6 +76,7 @@ namespace ENI2
{
mainFrame.Children.Clear();
mainFrame.Children.Add(this.sucheControl);
this.sucheControl.buttonSuche.IsDefault = true;
}
private void logoImage_MouseUp(object sender, MouseButtonEventArgs e)

View File

@ -45,21 +45,22 @@
<ColumnDefinition Width="3*" />
</Grid.ColumnDefinitions>
<Label Grid.Column="0" Grid.Row="0" Content="Von:" HorizontalAlignment="Left" />
<xctk:DateTimePicker Grid.Column="1" Grid.Row="0" Name="dateTimePickerETAFrom" VerticalContentAlignment="Center" />
<xctk:DateTimePicker Grid.Column="1" Grid.Row="0" Name="dateTimePickerETAFrom" Format="Custom" FormatString="dd.MM.yyyy hh:mm" ShowButtonSpinner="False" VerticalContentAlignment="Center" />
<Label Grid.Column="2" Grid.Row="0" Content="Bis:" HorizontalAlignment="Left" />
<xctk:DateTimePicker Grid.Column="3" Grid.Row="0" Name="dateTimePickerETATo" VerticalContentAlignment="Center" />
<xctk:DateTimePicker Grid.Column="3" Grid.Row="0" Name="dateTimePickerETATo" Format="Custom" FormatString="dd.MM.yyyy hh:mm" ShowButtonSpinner="False" VerticalContentAlignment="Center" />
</Grid>
<TextBox Grid.Column="3" Grid.Row="2" Name="textBoxTicketNr" Margin="2"/>
<Button Grid.Column="0" Grid.Row="3" Grid.ColumnSpan="2" Content="Eingaben löschen" Name="buttonClearInput" Click="Button_Click" Margin="2"/>
<Button Grid.Column="2" Grid.Row="3" Grid.ColumnSpan="2" Content="Suche" Name="buttonSuche" Click="buttonSuche_Click" Margin="2"/>
</Grid>
<DataGrid Grid.Row="1" Margin="0,8,0,0" x:Name="dataGrid" HorizontalContentAlignment="Stretch" VerticalContentAlignment="Stretch" SelectionMode="Single" AutoGenerateColumns="False">
<DataGrid Grid.Row="1" Margin="0,8,0,0" x:Name="dataGrid" HorizontalContentAlignment="Stretch" VerticalContentAlignment="Stretch"
SelectionMode="Single" AutoGenerateColumns="False" >
<DataGrid.Columns>
<DataGridTextColumn Header="Type" Binding="{Binding HerbergReportType}" IsReadOnly="True" />
<DataGridTextColumn Header="IMO" Binding="{Binding IMO}" IsReadOnly="True" />
<DataGridTextColumn Header="Ship name" Binding="{Binding Shipname}" IsReadOnly="True" />
<DataGridTextColumn Header="ETA" Binding="{Binding ETA}" IsReadOnly="True" />
<DataGridTextColumn Header="ETA" Binding="{Binding ETA , StringFormat=\{0:dd.MM.yyyy HH:mm\}}" IsReadOnly="True" />
<DataGridTextColumn Header="Hafen" Binding="{Binding Portname}" IsReadOnly="True" />
<DataGridTextColumn Header="Id" Binding="{Binding VisitId}" IsReadOnly="True" />
<DataGridTextColumn Header="Status" Binding="{Binding BSMDStatusInternal}" IsReadOnly="True" />

View File

@ -49,17 +49,29 @@ namespace ENI2
{
// filter auswerten
Dictionary<MessageCore.SearchFilterType, string> filterDict = new Dictionary<MessageCore.SearchFilterType, string>();
if (!this.textBoxHafen.Text.IsNullOrEmpty())
filterDict.Add(MessageCore.SearchFilterType.FILTER_PORT, this.textBoxHafen.Text);
if (!this.textBoxId.Text.IsNullOrEmpty())
filterDict.Add(MessageCore.SearchFilterType.FILTER_ID, this.textBoxId.Text);
if (!this.textBoxIMO.Text.IsNullOrEmpty())
filterDict.Add(MessageCore.SearchFilterType.FILTER_IMO, this.textBoxIMO.Text);
if (!this.textBoxName.Text.IsNullOrEmpty())
filterDict.Add(MessageCore.SearchFilterType.FILTER_SHIPNAME, this.textBoxName.Text);
if (!this.textBoxTicketNr.Text.IsNullOrEmpty())
filterDict.Add(MessageCore.SearchFilterType.FILTER_TICKETNO, this.textBoxTicketNr.Text);
if (!this.textBoxHafen.Text.Trim().IsNullOrEmpty())
filterDict.Add(MessageCore.SearchFilterType.FILTER_PORT, this.textBoxHafen.Text.Trim());
if (!this.textBoxId.Text.Trim().IsNullOrEmpty())
filterDict.Add(MessageCore.SearchFilterType.FILTER_ID, this.textBoxId.Text.Trim());
if (!this.textBoxIMO.Text.Trim().IsNullOrEmpty())
filterDict.Add(MessageCore.SearchFilterType.FILTER_IMO, this.textBoxIMO.Text.Trim());
if (!this.textBoxName.Text.Trim().IsNullOrEmpty())
filterDict.Add(MessageCore.SearchFilterType.FILTER_SHIPNAME, this.textBoxName.Text.Trim());
if (!this.textBoxTicketNr.Text.Trim().IsNullOrEmpty())
filterDict.Add(MessageCore.SearchFilterType.FILTER_TICKETNO, this.textBoxTicketNr.Text.Trim());
uint? from = null, to = null;
if(!this.dateTimePickerETAFrom.Text.IsNullOrEmpty())
{
from = this.dateTimePickerETAFrom.Value.Value.ToUnixTimeStamp();
}
if(!this.dateTimePickerETATo.Text.IsNullOrEmpty())
{
to = this.dateTimePickerETATo.Value.Value.ToUnixTimeStamp();
}
if (from.HasValue || to.HasValue)
filterDict.Add(MessageCore.SearchFilterType.FILTER_ETA, string.Format("{0}:{1}", from?.ToString() ?? "", to?.ToString() ?? ""));
// suche auslösen
this.anmeldungen = DBManager.Instance.GetMessageCoresWithFilters(filterDict);

View File

@ -12,7 +12,7 @@
<DataGridTextColumn Header="Type" Binding="{Binding HerbergReportType}" IsReadOnly="True" />
<DataGridTextColumn Header="IMO" Binding="{Binding IMO}" IsReadOnly="True" />
<DataGridTextColumn Header="Ship name" Binding="{Binding Shipname}" IsReadOnly="True" />
<DataGridTextColumn Header="ETA" Binding="{Binding ETA}" IsReadOnly="True" />
<DataGridTextColumn Header="ETA" Binding="{Binding ETA , StringFormat=\{0:dd.MM.yyyy HH:mm\}}" IsReadOnly="True" />
<DataGridTextColumn Header="Hafen" Binding="{Binding Portname}" IsReadOnly="True" />
<DataGridTextColumn Header="Id" Binding="{Binding VisitId}" IsReadOnly="True" />
<DataGridTextColumn Header="Status" Binding="{Binding BSMDStatusInternal}" IsReadOnly="True" />

Binary file not shown.

View File

@ -21,6 +21,7 @@ namespace bsmd.database
public static class Extensions
{
private static ILog _log = LogManager.GetLogger(typeof(Extensions));
private static Regex splitRegex = new Regex(@"(""((\\"")|([^""]))*"")|('((\\')|([^']))*')|(\S+)");
public static bool IsNullOrEmpty(this String str)
{
@ -62,6 +63,18 @@ namespace bsmd.database
return source.IndexOf(toCheck, comp) >= 0;
}
public static uint ToUnixTimeStamp(this DateTime source)
{
System.DateTime rootDateTime = new DateTime(1970, 1, 1, 0, 0, 0, 0, System.DateTimeKind.Utc);
return (uint) (source - rootDateTime).TotalSeconds;
}
public static DateTime FromUnixTimeStamp(this UInt32 source)
{
System.DateTime rootDateTime = new DateTime(1970, 1, 1, 0, 0, 0, 0, System.DateTimeKind.Utc);
return rootDateTime.AddSeconds(source);
}
public static DateTime? TryParseDateTime(string text)
{
DateTime date;
@ -95,5 +108,17 @@ namespace bsmd.database
return source.ToString("yyyy'-'MM'-'dd'T'HH':'mm':'ss'Z'");
}
public static List<string> RegexSplit(this string source)
{
List<string> result = new List<string>();
foreach(Match match in splitRegex.Matches(source))
{
result.Add(match.Value);
}
return result;
}
}
}

View File

@ -300,10 +300,31 @@ namespace bsmd.database
foreach (SearchFilterType key in searchDict.Keys)
{
if (moreThanOne) sb.Append(" AND ");
switch(key)
switch (key)
{
case SearchFilterType.FILTER_ETA:
// ist eine "between" Suche
uint? from = null, to = null;
string[] elems = searchDict[key].Split(':');
if (!elems[0].IsNullOrEmpty()) from = UInt32.Parse(elems[0]);
if (!elems[1].IsNullOrEmpty()) to = UInt32.Parse(elems[1]);
if (from.HasValue && !to.HasValue)
{
sb.Append(" (ETA > @SEARCHFROM) ");
((SqlCommand)cmd).Parameters.AddWithValue("@SEARCHFROM", from.Value.FromUnixTimeStamp());
}
if(to.HasValue && !from.HasValue)
{
sb.Append(" (ETA < @SEARCHTO) ");
((SqlCommand)cmd).Parameters.AddWithValue("@SEARCHTO", to.Value.FromUnixTimeStamp());
}
if(from.HasValue && to.HasValue)
{
sb.Append(" (ETA > @SEARCHFROM AND ETA < @SEARCHTO) ");
((SqlCommand)cmd).Parameters.AddWithValue("@SEARCHFROM", from.Value.FromUnixTimeStamp());
((SqlCommand)cmd).Parameters.AddWithValue("@SEARCHTO", to.Value.FromUnixTimeStamp());
}
break;
case SearchFilterType.FILTER_ID:
@ -315,8 +336,20 @@ namespace bsmd.database
((SqlCommand)cmd).Parameters.AddWithValue("@SEARCH_IMO", searchDict[key]);
break;
case SearchFilterType.FILTER_PORT:
sb.Append(" Portname LIKE @SEARCH_PORT ");
((SqlCommand)cmd).Parameters.AddWithValue("@SEARCH_PORT", string.Format("%{0}%", searchDict[key]));
{
sb.Append("( ");
int paramCnt = 0;
foreach (string param in searchDict[key].RegexSplit())
{
string paramName = string.Format("@SEARCH_PORT{0}", paramCnt);
if (paramCnt > 0) sb.Append(" OR ");
sb.AppendFormat(" Portname LIKE {0} OR PoC LIKE {0} ", paramName);
((SqlCommand)cmd).Parameters.AddWithValue(paramName, string.Format("%{0}%", param));
paramCnt++;
}
sb.Append(") ");
}
break;
case SearchFilterType.FILTER_SHIPNAME:

View File

@ -2,6 +2,6 @@
[assembly: AssemblyCompany("Informatikbüro Daniel Schick")]
[assembly: AssemblyProduct("BSMD NSW interface")]
[assembly: AssemblyInformationalVersion("3.4.9")]
[assembly: AssemblyInformationalVersion("3.4.10")]
[assembly: AssemblyCopyright("Copyright © 2014-2017 Informatikbüro Daniel Schick. All rights reserved.")]
[assembly: AssemblyTrademark("")]

View File

@ -1,4 +1,4 @@
using System.Reflection;
[assembly: AssemblyVersion("3.4.9.*")]
[assembly: AssemblyVersion("3.4.10.*")]

View File

@ -114,7 +114,7 @@ namespace bsmd.database
{
if (val.IsNullOrEmpty()) return false;
return regexTransit.IsMatch(val);
}
}
}
}