|
|
@@ -51,7 +51,7 @@ namespace qdr.app.studiou.orders2printpack
|
|
|
private void butOpenOrdersFile_Click(object sender, EventArgs e)
|
|
|
{
|
|
|
if (dlgOpenFile.ShowDialog() == DialogResult.OK)
|
|
|
- OpenOrderBarchFile(dlgOpenFile.FileName);
|
|
|
+ OpenOrderBatchFile(dlgOpenFile.FileName);
|
|
|
RefreshToolButtons();
|
|
|
}
|
|
|
|
|
|
@@ -64,9 +64,16 @@ namespace qdr.app.studiou.orders2printpack
|
|
|
dlgOpenDir.InitialDirectory = AppSettings.Default.LastSourceDir;
|
|
|
if (dlgOpenDir.ShowDialog() == DialogResult.OK)
|
|
|
{
|
|
|
- AppSettings.Default.LastSourceDir = dlgOpenDir.SelectedPath;
|
|
|
- AppSettings.Default.Save();
|
|
|
- OpenSourceDir(dlgOpenDir.SelectedPath);
|
|
|
+ BlockErrorHandled(() =>
|
|
|
+ {
|
|
|
+ if (!string.IsNullOrEmpty(_outputPath) && dlgOpenDir.SelectedPath == _outputPath)
|
|
|
+ throw new Exception($"Vstupní složka '{dlgOpenDir.SelectedPath}' je stejná jako výstupní.");
|
|
|
+
|
|
|
+ AppSettings.Default.LastSourceDir = dlgOpenDir.SelectedPath;
|
|
|
+ AppSettings.Default.Save();
|
|
|
+
|
|
|
+ OpenSourceDir(dlgOpenDir.SelectedPath);
|
|
|
+ });
|
|
|
}
|
|
|
RefreshToolButtons();
|
|
|
}
|
|
|
@@ -80,11 +87,17 @@ namespace qdr.app.studiou.orders2printpack
|
|
|
dlgOpenDir.InitialDirectory = AppSettings.Default.LastOutputDir;
|
|
|
if (dlgOpenDir.ShowDialog() == DialogResult.OK)
|
|
|
{
|
|
|
- _outputPath = dlgOpenDir.SelectedPath;
|
|
|
- Log($"Otevřena složka výstupu '{_outputPath}'");
|
|
|
- AppSettings.Default.LastOutputDir = dlgOpenDir.SelectedPath;
|
|
|
- AppSettings.Default.Save();
|
|
|
- tbOutputDir.Text = _outputPath;
|
|
|
+ BlockErrorHandled(() =>
|
|
|
+ {
|
|
|
+ if (!string.IsNullOrEmpty(AppSettings.Default.LastSourceDir) && dlgOpenDir.SelectedPath == AppSettings.Default.LastSourceDir)
|
|
|
+ throw new Exception($"Výstupní složka '{dlgOpenDir.SelectedPath}' je stejná jako vstupní.");
|
|
|
+
|
|
|
+ _outputPath = dlgOpenDir.SelectedPath;
|
|
|
+ Log($"Otevřena složka výstupu '{_outputPath}'");
|
|
|
+ AppSettings.Default.LastOutputDir = dlgOpenDir.SelectedPath;
|
|
|
+ AppSettings.Default.Save();
|
|
|
+ tbOutputDir.Text = _outputPath;
|
|
|
+ });
|
|
|
|
|
|
}
|
|
|
RefreshToolButtons();
|
|
|
@@ -223,7 +236,7 @@ namespace qdr.app.studiou.orders2printpack
|
|
|
#endregion
|
|
|
|
|
|
#region **** Bussiness ****
|
|
|
- private void OpenOrderBarchFile(string fileName)
|
|
|
+ private void OpenOrderBatchFile(string fileName)
|
|
|
{
|
|
|
BlockErrorHandled(() =>
|
|
|
{
|
|
|
@@ -234,21 +247,21 @@ namespace qdr.app.studiou.orders2printpack
|
|
|
_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();
|
|
|
for (int i = 0; i < _source.Columns.Count; i++)
|
|
|
_sourceColOrdinals.Add(_source.Columns[i].ColumnName.Replace("\"", ""), i);
|
|
|
|
|
|
- var invalidRows = new List<DataRow>();
|
|
|
+ var invalidRows = new List<DataRow>();
|
|
|
foreach (DataRow row in _source.Rows)
|
|
|
{
|
|
|
- if (string.Equals(row[_sourceColOrdinals[AppSettings.Default.MapColUri]]?.ToString(),"null", StringComparison.CurrentCultureIgnoreCase))
|
|
|
+ if (string.Equals(row[_sourceColOrdinals[AppSettings.Default.MapColUri]]?.ToString(), "null", StringComparison.CurrentCultureIgnoreCase))
|
|
|
invalidRows.Add(row);
|
|
|
}
|
|
|
|
|
|
- foreach(var row in invalidRows)
|
|
|
- _source.Rows.Remove(row);
|
|
|
+ foreach (var row in invalidRows)
|
|
|
+ _source.Rows.Remove(row);
|
|
|
|
|
|
Log($"{invalidRows.Count} položek ignorováno, nebylo vyplněno URL");
|
|
|
|
|
|
@@ -277,7 +290,7 @@ namespace qdr.app.studiou.orders2printpack
|
|
|
|
|
|
Log($"Procházím všechny soubory {AppSettings.Default.SourceSearchPattern} ve složce '{pathToSourceFolder}'...");
|
|
|
Log("Tato operace může chvíli trvat!");
|
|
|
- var files = fsrch.Search(new[] {AppSettings.Default.SourceSearchPattern, "*" });
|
|
|
+ var files = fsrch.Search(new[] { AppSettings.Default.SourceSearchPattern, "*" });
|
|
|
if (files.Length == 0)
|
|
|
throw new Exception($"Nenalezeny žádné soubory pro zpracování ve složce '{pathToSourceFolder}'.");
|
|
|
|
|
|
@@ -320,6 +333,7 @@ namespace qdr.app.studiou.orders2printpack
|
|
|
ssProgress.Value = 0;
|
|
|
BlockErrorHandled(() =>
|
|
|
{
|
|
|
+
|
|
|
var rows = _source.AsEnumerable().Where(x => string.IsNullOrEmpty(x.Field<string>(_sourceColOrdinals[CS_COL_SOURCE_PATH])));
|
|
|
|
|
|
if (rows.Any())
|
|
|
@@ -382,7 +396,7 @@ namespace qdr.app.studiou.orders2printpack
|
|
|
row.SetField(_sourceColOrdinals[CS_COL_EXTERNALORDERDATE], externalOrderDate.ToFileUtcString());
|
|
|
}
|
|
|
Log($"Generuji protokol ...");
|
|
|
- CsvUtils.DataTableToCsv(_fs, _source, protocolFile, ";", (column) => { return NormalizeColumnName(column);});
|
|
|
+ CsvUtils.DataTableToCsv(_fs, _source, protocolFile, ";", (column) => { return NormalizeColumnName(column); });
|
|
|
Log($"Protokol uložen do souboru '{protocolFile}'.");
|
|
|
});
|
|
|
}
|
|
|
@@ -428,6 +442,8 @@ namespace qdr.app.studiou.orders2printpack
|
|
|
#region **** Support opperations ****
|
|
|
public static void CleanupDirectory(string directoryPath)
|
|
|
{
|
|
|
+ return;
|
|
|
+ /*
|
|
|
if (string.IsNullOrWhiteSpace(directoryPath))
|
|
|
throw new ArgumentException("Directory path cannot be null or empty.", nameof(directoryPath));
|
|
|
|
|
|
@@ -442,24 +458,27 @@ namespace qdr.app.studiou.orders2printpack
|
|
|
|
|
|
foreach (var file in di.GetFiles())
|
|
|
{
|
|
|
- try{
|
|
|
+ try
|
|
|
+ {
|
|
|
file.Delete();
|
|
|
}
|
|
|
- catch{}
|
|
|
+ catch { }
|
|
|
}
|
|
|
|
|
|
foreach (var dir in di.GetDirectories())
|
|
|
{
|
|
|
- try{
|
|
|
+ try
|
|
|
+ {
|
|
|
dir.Delete(true);
|
|
|
}
|
|
|
- catch{}
|
|
|
+ catch { }
|
|
|
}
|
|
|
}
|
|
|
catch (Exception)
|
|
|
{
|
|
|
throw;
|
|
|
}
|
|
|
+ */
|
|
|
}
|
|
|
#endregion
|
|
|
|