Excel Vergleich jetzt mit Speicherdialog
This commit is contained in:
parent
eb001c78bc
commit
6ca0a5dda9
@ -72,7 +72,7 @@ namespace ENI2.DetailViewControls
|
||||
this.textBoxENI.IsReadOnly = !iAmAdmin;
|
||||
this.textBoxIMO.IsReadOnly = !iAmAdmin;
|
||||
this.locodePoC.IsEnabled = iAmAdmin;
|
||||
this.textBoxDisplayId.IsReadOnly = !iAmAdmin;
|
||||
this.textBoxDisplayId.IsReadOnly = !iAmAdmin;
|
||||
|
||||
this.textBoxENI.DataContext = this.Core;
|
||||
this.textBoxIMO.DataContext = this.Core;
|
||||
|
||||
@ -3,6 +3,7 @@
|
||||
//
|
||||
|
||||
using bsmd.database;
|
||||
using Microsoft.Win32;
|
||||
using System;
|
||||
using System.Diagnostics;
|
||||
using System.IO;
|
||||
@ -174,15 +175,26 @@ namespace ENI2.EditControls
|
||||
private void buttonCompare_Click(object sender, RoutedEventArgs e)
|
||||
{
|
||||
Util.UIHelper.SetBusyState();
|
||||
string resultPath = Excel.ExcelComparer.Compare(_sourcePath, _targetPath, out string errorMessage);
|
||||
if(!errorMessage.IsNullOrEmpty()) {
|
||||
MessageBox.Show(errorMessage, "Comparison error", MessageBoxButton.OK, MessageBoxImage.Warning);
|
||||
}
|
||||
if(File.Exists(resultPath))
|
||||
|
||||
string defaultName = string.Format("{0}.xlsx", Guid.NewGuid().ToString());
|
||||
SaveFileDialog sfd = new SaveFileDialog
|
||||
{
|
||||
if(new FileInfo(resultPath).Length > 0)
|
||||
Filter = "Excel Files|*.xls;*.xlsx",
|
||||
FileName = defaultName
|
||||
};
|
||||
|
||||
if (sfd.ShowDialog() ?? false)
|
||||
{
|
||||
string resultPath = Excel.ExcelComparer.Compare(_sourcePath, _targetPath, sfd.FileName, out string errorMessage);
|
||||
if (!errorMessage.IsNullOrEmpty()) {
|
||||
MessageBox.Show(errorMessage, "Comparison error", MessageBoxButton.OK, MessageBoxImage.Warning);
|
||||
}
|
||||
if (File.Exists(resultPath))
|
||||
{
|
||||
Process.Start(resultPath);
|
||||
if (new FileInfo(resultPath).Length > 0)
|
||||
{
|
||||
Process.Start(resultPath);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -23,7 +23,7 @@ namespace ENI2.EditControls
|
||||
{
|
||||
InitializeComponent();
|
||||
Loaded += CopyDeclarationDialog_Loaded;
|
||||
}
|
||||
}
|
||||
|
||||
#region Properties
|
||||
|
||||
|
||||
@ -38,7 +38,7 @@ namespace ENI2.EditControls
|
||||
|
||||
this.EnableOK(false);
|
||||
this.locodePoC.PropertyChanged += LocodePoC_PropertyChanged;
|
||||
}
|
||||
}
|
||||
|
||||
private void VisitIdDialog_OKClicked()
|
||||
{
|
||||
|
||||
@ -61,17 +61,16 @@ namespace ENI2.Excel
|
||||
return columnName;
|
||||
}
|
||||
|
||||
public static string Compare(string sourcePath, string targetPath, out string errorMessage)
|
||||
{
|
||||
string fileName = Path.GetTempPath() + Guid.NewGuid().ToString() + ".xlsx";
|
||||
public static string Compare(string sourcePath, string targetPath, string comparisonFileName, out string errorMessage)
|
||||
{
|
||||
errorMessage = "";
|
||||
int counter = 0;
|
||||
|
||||
try
|
||||
{
|
||||
File.Copy(targetPath, fileName);
|
||||
File.Copy(targetPath, comparisonFileName);
|
||||
ExcelReader source = new ExcelReader(sourcePath, true, false);
|
||||
ExcelReader comparison = new ExcelReader(fileName, false, false);
|
||||
ExcelReader comparison = new ExcelReader(comparisonFileName, false, false);
|
||||
|
||||
/* erste Variante Vergleich über Namen der Zellen
|
||||
|
||||
@ -182,7 +181,9 @@ namespace ENI2.Excel
|
||||
}
|
||||
}
|
||||
|
||||
comparison.Save(fileName);
|
||||
comparison.Save(comparisonFileName);
|
||||
source.Dispose();
|
||||
comparison.Dispose();
|
||||
errorMessage = string.Format("{0} differences found", counter);
|
||||
}
|
||||
catch (Exception ex)
|
||||
@ -190,7 +191,7 @@ namespace ENI2.Excel
|
||||
errorMessage = ex.Message;
|
||||
}
|
||||
|
||||
return fileName;
|
||||
return comparisonFileName;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Loading…
Reference in New Issue
Block a user