|
@@ -2,6 +2,7 @@
|
|
|
using Quadarax.Foundation.Core.Data;
|
|
using Quadarax.Foundation.Core.Data;
|
|
|
using Quadarax.Foundation.Core.IO;
|
|
using Quadarax.Foundation.Core.IO;
|
|
|
using Quadarax.Foundation.Core.Value;
|
|
using Quadarax.Foundation.Core.Value;
|
|
|
|
|
+using Quadarax.Foundation.Core.Value.Extensions;
|
|
|
using System.Data;
|
|
using System.Data;
|
|
|
using System.IO.Abstractions;
|
|
using System.IO.Abstractions;
|
|
|
|
|
|
|
@@ -12,6 +13,9 @@ namespace qdr.app.studiou.orders2printpack
|
|
|
#region *** Constants ***
|
|
#region *** Constants ***
|
|
|
private const string CS_COL_SOURCE_PATH = "LocalPath";
|
|
private const string CS_COL_SOURCE_PATH = "LocalPath";
|
|
|
private const string CS_COL_ID = "LocalID";
|
|
private const string CS_COL_ID = "LocalID";
|
|
|
|
|
+ private const string CS_COL_OUTPUT = "OutputFileName";
|
|
|
|
|
+ private const string CS_COL_EXTERNALORDER = "ExternalOrder";
|
|
|
|
|
+ private const string CS_COL_EXTERNALORDERDATE = "ExternalOrderDate";
|
|
|
private const string CS_TAG_LB = "{";
|
|
private const string CS_TAG_LB = "{";
|
|
|
private const string CS_TAG_RB = "}";
|
|
private const string CS_TAG_RB = "}";
|
|
|
private const string CS_TAG_EXT = "ext";
|
|
private const string CS_TAG_EXT = "ext";
|
|
@@ -89,12 +93,14 @@ namespace qdr.app.studiou.orders2printpack
|
|
|
private void tsbCheck_Click(object sender, EventArgs e)
|
|
private void tsbCheck_Click(object sender, EventArgs e)
|
|
|
{
|
|
{
|
|
|
CheckSourceOrderFile();
|
|
CheckSourceOrderFile();
|
|
|
|
|
+ RefreshToolButtons();
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
[System.Diagnostics.CodeAnalysis.SuppressMessage("Style", "IDE1006:Naming Styles", Justification = "<Pending>")]
|
|
[System.Diagnostics.CodeAnalysis.SuppressMessage("Style", "IDE1006:Naming Styles", Justification = "<Pending>")]
|
|
|
private void tsbDo_Click(object sender, EventArgs e)
|
|
private void tsbDo_Click(object sender, EventArgs e)
|
|
|
{
|
|
{
|
|
|
ProcessSourceFile();
|
|
ProcessSourceFile();
|
|
|
|
|
+ RefreshToolButtons();
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
[System.Diagnostics.CodeAnalysis.SuppressMessage("Style", "IDE1006:Naming Styles", Justification = "<Pending>")]
|
|
[System.Diagnostics.CodeAnalysis.SuppressMessage("Style", "IDE1006:Naming Styles", Justification = "<Pending>")]
|
|
@@ -112,6 +118,14 @@ namespace qdr.app.studiou.orders2printpack
|
|
|
RefreshToolButtons();
|
|
RefreshToolButtons();
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+ [System.Diagnostics.CodeAnalysis.SuppressMessage("Style", "IDE1006:Naming Styles", Justification = "<Pending>")]
|
|
|
|
|
+ private void tsbProtocol_Click(object sender, EventArgs e)
|
|
|
|
|
+ {
|
|
|
|
|
+ var dlg = new dlgProtocol();
|
|
|
|
|
+ if (dlg.ShowDialog(this) == DialogResult.OK)
|
|
|
|
|
+ GenerateProtocol(dlg.ExternalOrder, dlg.ExternalOrderDate, dlg.ProtocolFile);
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
[System.Diagnostics.CodeAnalysis.SuppressMessage("Style", "IDE1006:Naming Styles", Justification = "<Pending>")]
|
|
[System.Diagnostics.CodeAnalysis.SuppressMessage("Style", "IDE1006:Naming Styles", Justification = "<Pending>")]
|
|
|
private void lbNotMapped_MouseDoubleClick(object sender, MouseEventArgs e)
|
|
private void lbNotMapped_MouseDoubleClick(object sender, MouseEventArgs e)
|
|
|
{
|
|
{
|
|
@@ -216,6 +230,9 @@ namespace qdr.app.studiou.orders2printpack
|
|
|
_source = CsvHelper.CsvToDataTable(_fs, fileName, AppSettings.Default.CSVDelimiter);
|
|
_source = CsvHelper.CsvToDataTable(_fs, fileName, AppSettings.Default.CSVDelimiter);
|
|
|
_source.Columns.Add(new DataColumn(CS_COL_SOURCE_PATH, typeof(string)));
|
|
_source.Columns.Add(new DataColumn(CS_COL_SOURCE_PATH, typeof(string)));
|
|
|
_source.Columns.Add(new DataColumn(CS_COL_ID, typeof(int)));
|
|
_source.Columns.Add(new DataColumn(CS_COL_ID, typeof(int)));
|
|
|
|
|
+ _source.Columns.Add(new DataColumn(CS_COL_OUTPUT, typeof(string)));
|
|
|
|
|
+ _source.Columns.Add(new DataColumn(CS_COL_EXTERNALORDER, typeof(string)));
|
|
|
|
|
+ _source.Columns.Add(new DataColumn(CS_COL_EXTERNALORDERDATE, typeof(string)));
|
|
|
_sourceColOrdinals.Clear();
|
|
_sourceColOrdinals.Clear();
|
|
|
for (int i = 0; i < _source.Columns.Count; i++)
|
|
for (int i = 0; i < _source.Columns.Count; i++)
|
|
|
_sourceColOrdinals.Add(_source.Columns[i].ColumnName.Replace("\"", ""), i);
|
|
_sourceColOrdinals.Add(_source.Columns[i].ColumnName.Replace("\"", ""), i);
|
|
@@ -318,6 +335,7 @@ namespace qdr.app.studiou.orders2printpack
|
|
|
var outputPath = _fs.Path.Combine(_outputPath, outputFileName);
|
|
var outputPath = _fs.Path.Combine(_outputPath, outputFileName);
|
|
|
_fs.File.Copy(sourcePath!, outputPath, true);
|
|
_fs.File.Copy(sourcePath!, outputPath, true);
|
|
|
Log($"Soubor '{outputPath}' vytvořen.");
|
|
Log($"Soubor '{outputPath}' vytvořen.");
|
|
|
|
|
+ row.SetField(_sourceColOrdinals[CS_COL_OUTPUT], outputPath);
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
ssProgress.Increment(1);
|
|
ssProgress.Increment(1);
|
|
@@ -326,6 +344,23 @@ namespace qdr.app.studiou.orders2printpack
|
|
|
ssProgress.Value = 0;
|
|
ssProgress.Value = 0;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+
|
|
|
|
|
+ private void GenerateProtocol(string externalOrder, DateTime externalOrderDate, string protocolFile)
|
|
|
|
|
+ {
|
|
|
|
|
+ BlockErrorHandled(() =>
|
|
|
|
|
+ {
|
|
|
|
|
+ Log($"Nastavuji číslo externí objednávky: {externalOrder} a datum: {externalOrderDate.ToShortDateString()} ...");
|
|
|
|
|
+ foreach(var row in _source.AsEnumerable())
|
|
|
|
|
+ {
|
|
|
|
|
+ row.SetField(_sourceColOrdinals[CS_COL_EXTERNALORDER], externalOrder);
|
|
|
|
|
+ row.SetField(_sourceColOrdinals[CS_COL_EXTERNALORDERDATE], externalOrderDate.ToFileUtcString());
|
|
|
|
|
+ }
|
|
|
|
|
+ Log($"Generuji protokol ...");
|
|
|
|
|
+ CsvHelper.DataTableToCsv(_fs, _source, protocolFile, AppSettings.Default.CSVDelimiter);
|
|
|
|
|
+ Log($"Protokol uložen do souboru '{protocolFile}'.");
|
|
|
|
|
+ });
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
#endregion
|
|
#endregion
|
|
|
|
|
|
|
|
|
|
|
|
@@ -334,9 +369,11 @@ namespace qdr.app.studiou.orders2printpack
|
|
|
{
|
|
{
|
|
|
var canBeChecked = GetOrderCount() > 0 && _sourcePathCache.Count > 0;
|
|
var canBeChecked = GetOrderCount() > 0 && _sourcePathCache.Count > 0;
|
|
|
var canBeProcess = canBeChecked && !_source.AsEnumerable().Any(x => string.IsNullOrEmpty(x.Field<string>(_sourceColOrdinals[CS_COL_SOURCE_PATH]))) && !string.IsNullOrEmpty(_outputPath);
|
|
var canBeProcess = canBeChecked && !_source.AsEnumerable().Any(x => string.IsNullOrEmpty(x.Field<string>(_sourceColOrdinals[CS_COL_SOURCE_PATH]))) && !string.IsNullOrEmpty(_outputPath);
|
|
|
|
|
+ var canBeCreateProtocol = canBeProcess && _source.AsEnumerable().All(x => !string.IsNullOrEmpty(x.Field<string>(_sourceColOrdinals[CS_COL_OUTPUT])));
|
|
|
|
|
|
|
|
tsbCheck.Enabled = canBeChecked;
|
|
tsbCheck.Enabled = canBeChecked;
|
|
|
tsbDo.Enabled = canBeProcess;
|
|
tsbDo.Enabled = canBeProcess;
|
|
|
|
|
+ tsbProtocol.Enabled = canBeCreateProtocol;
|
|
|
|
|
|
|
|
RefreshNotMappedList();
|
|
RefreshNotMappedList();
|
|
|
}
|
|
}
|
|
@@ -365,5 +402,7 @@ namespace qdr.app.studiou.orders2printpack
|
|
|
|
|
|
|
|
|
|
|
|
|
#endregion
|
|
#endregion
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|