WIP
This commit is contained in:
parent
a596e197e1
commit
6031b5df94
@ -31,6 +31,8 @@
|
||||
<ColumnDefinition Width="40" />
|
||||
<ColumnDefinition Width="120" />
|
||||
<ColumnDefinition Width="80" />
|
||||
<ColumnDefinition Width="80" />
|
||||
<ColumnDefinition Width="80" />
|
||||
<ColumnDefinition Width="*" />
|
||||
<ColumnDefinition Width="80" />
|
||||
<ColumnDefinition Width="80" />
|
||||
@ -41,9 +43,11 @@
|
||||
<Label Content="To" Grid.Column="2" />
|
||||
<xctk:DateTimePicker x:Name="dateTimePickerTo" Margin="2" Grid.Column="3" Format="ShortDate" />
|
||||
<Button x:Name="buttonLoad" Grid.Column="4" Content="Load" Margin="2" Click="buttonLoad_Click" />
|
||||
<Button x:Name="buttonImport" Grid.Column="6" Margin="2" Content="Import" Click="buttonImport_Click" />
|
||||
<Button x:Name="buttonExport" Grid.Column="7" Margin="2" Content="Export" Click="buttonExport_Click" />
|
||||
<local:BusyControl x:Name="busyControl" Grid.Column="8" />
|
||||
<Button x:Name="buttonSave" Grid.Column="5" Content="Save" Margin="2" Click="buttonSave_Click" />
|
||||
<Button x:Name="buttonRequestIds" Grid.Column="6" Content="Request Ids" Margin="2" Click="buttonRequestIds_Click" />
|
||||
<Button x:Name="buttonImport" Grid.Column="8" Margin="2" Content="Import" Click="buttonImport_Click" />
|
||||
<Button x:Name="buttonExport" Grid.Column="9" Margin="2" Content="Export" Click="buttonExport_Click" />
|
||||
<local:BusyControl x:Name="busyControl" Grid.Column="10" />
|
||||
</Grid>
|
||||
<local:ENIDataGrid Grid.Row="1" Margin="2,8,2,2" x:Name="dataGridPOCores" HorizontalContentAlignment="Stretch" VerticalContentAlignment="Stretch"
|
||||
SelectionMode="Extended" AutoGenerateColumns="False" CellEditEnding="dataGridPOCores_CellEditEnding" CanUserAddRows="False">
|
||||
|
||||
@ -169,7 +169,7 @@ namespace ENI2.Controls
|
||||
this.PerformSearch();
|
||||
}
|
||||
|
||||
private void buttonImport_Click(object sender, RoutedEventArgs e)
|
||||
private async void buttonImport_Click(object sender, RoutedEventArgs e)
|
||||
{
|
||||
OpenFileDialog ofd = new OpenFileDialog
|
||||
{
|
||||
@ -233,8 +233,16 @@ namespace ENI2.Controls
|
||||
// we only want cores for the next 3 days
|
||||
if (importData.Count > 0)
|
||||
{
|
||||
busyControl.BusyState = Util.UIHelper.BusyStateEnum.BUSY;
|
||||
// TODO: find matching message cores..
|
||||
|
||||
foreach(MaerskData md in importData)
|
||||
{
|
||||
if(!md.ColM.IsNullOrEmpty())
|
||||
{
|
||||
md.MessageCore = await DBManagerAsync.LoadCoreByVisitIdAsync(md.ColM);
|
||||
}
|
||||
}
|
||||
busyControl.BusyState = Util.UIHelper.BusyStateEnum.NEUTRAL;
|
||||
}
|
||||
|
||||
// sort
|
||||
@ -257,6 +265,24 @@ namespace ENI2.Controls
|
||||
|
||||
}
|
||||
|
||||
private async void buttonSave_Click(object sender, RoutedEventArgs e)
|
||||
{
|
||||
// save the current list to DB (only if the entries have matching cores!)
|
||||
foreach(MaerskData md in this.maerskDataList)
|
||||
{
|
||||
if(md.MessageCore != null)
|
||||
{
|
||||
await DBManagerAsync.Save(md.MessageCore);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private void buttonRequestIds_Click(object sender, RoutedEventArgs e)
|
||||
{
|
||||
// find all entries from now until 3 days into the future and track parallel requests
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
}
|
||||
|
||||
@ -7,8 +7,6 @@ using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Data.SqlClient;
|
||||
using System.Diagnostics;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
@ -33,6 +31,13 @@ namespace bsmd.database
|
||||
|
||||
#region public methods
|
||||
|
||||
public static async Task<int> Save(DatabaseEntity entity)
|
||||
{
|
||||
SqlCommand cmd = new SqlCommand();
|
||||
entity.PrepareSave(cmd);
|
||||
return await PerformNonQueryAsync(cmd);
|
||||
}
|
||||
|
||||
#region convenience loading functions
|
||||
|
||||
public static async Task<List<MessageCore>> LoadMaerskCoresByIntervalAsync(Dictionary<MessageCore.SearchFilterType, string> filterDict, bool loadXtraData = false)
|
||||
@ -41,20 +46,32 @@ namespace bsmd.database
|
||||
MessageCore aMessageCore = new MessageCore();
|
||||
aMessageCore.PrepareLoadCommand(cmd, Message.LoadFilter.SEARCH_CORE_FILTERS, filterDict);
|
||||
SqlDataReader reader = await PerformCommandAsync(cmd);
|
||||
List<MessageCore> result = await aMessageCore.LoadListAsync(reader);
|
||||
return await aMessageCore.LoadListAsync(reader);
|
||||
}
|
||||
|
||||
public static async Task<MessageCore> LoadCoreByVisitIdAsync(string visitId)
|
||||
{
|
||||
SqlCommand cmd = new SqlCommand();
|
||||
MessageCore aMessageCore = new MessageCore();
|
||||
aMessageCore.PrepareLoadCommand(cmd, Message.LoadFilter.BY_VISITID, visitId);
|
||||
SqlDataReader reader = await PerformCommandAsync(cmd);
|
||||
List<MessageCore> resultList = await aMessageCore.LoadListAsync(reader);
|
||||
MessageCore result = null;
|
||||
if(resultList.Count > 0)
|
||||
{
|
||||
if(resultList.Count > 1)
|
||||
_log.WarnFormat("more than one core found for VISIT-ID {0}", visitId);
|
||||
result = resultList[0];
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
|
||||
|
||||
#endregion
|
||||
|
||||
#region async DB access methods
|
||||
|
||||
|
||||
|
||||
internal static async Task<SqlDataReader> PerformCommandAsync(SqlCommand cmd)
|
||||
{
|
||||
SqlDataReader reader = null;
|
||||
@ -87,7 +104,7 @@ namespace bsmd.database
|
||||
return reader;
|
||||
}
|
||||
|
||||
internal static async Task<int> PerformNonQuery(SqlCommand cmd)
|
||||
internal static async Task<int> PerformNonQueryAsync(SqlCommand cmd)
|
||||
{
|
||||
int result = -1;
|
||||
// await _asyncSemaphore.WaitAsync();
|
||||
@ -114,7 +131,7 @@ namespace bsmd.database
|
||||
return result;
|
||||
}
|
||||
|
||||
internal static async Task<int?> PerformReadIntQuery(SqlCommand cmd)
|
||||
internal static async Task<int?> PerformReadIntQueryAsync(SqlCommand cmd)
|
||||
{
|
||||
int? result = null;
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user