Dakosy Import Rahmenhandlung festgelegt, kann losgehen
This commit is contained in:
parent
aaa88db061
commit
3f6bdc7421
26
ENI2/Excel/DakosyExcelReader.cs
Normal file
26
ENI2/Excel/DakosyExcelReader.cs
Normal file
@ -0,0 +1,26 @@
|
|||||||
|
// Copyright (c) 2017- schick Informatik
|
||||||
|
// Description: Helper class to read data from "Dakosy"-Style Excel Sheets
|
||||||
|
//
|
||||||
|
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
using bsmd.database;
|
||||||
|
|
||||||
|
namespace ENI2.Excel
|
||||||
|
{
|
||||||
|
internal static class DakosyExcelReader
|
||||||
|
{
|
||||||
|
|
||||||
|
internal static bool ProcessSheet(ExcelReader reader, out string readMessage, MessageCore messageCore, List<Message.NotificationClass> notificationClasses)
|
||||||
|
{
|
||||||
|
bool result = true;
|
||||||
|
readMessage = "";
|
||||||
|
|
||||||
|
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -10,7 +10,7 @@ using System.IO;
|
|||||||
namespace ENI2.Excel
|
namespace ENI2.Excel
|
||||||
{
|
{
|
||||||
public class ExcelManager
|
public class ExcelManager
|
||||||
{
|
{
|
||||||
private readonly ILog _log = LogManager.GetLogger(typeof(ExcelManager));
|
private readonly ILog _log = LogManager.GetLogger(typeof(ExcelManager));
|
||||||
|
|
||||||
public ExcelManager()
|
public ExcelManager()
|
||||||
@ -21,29 +21,50 @@ namespace ENI2.Excel
|
|||||||
public bool Import(string filePath, MessageCore core, List<Message.NotificationClass> classes, out string readMessage)
|
public bool Import(string filePath, MessageCore core, List<Message.NotificationClass> classes, out string readMessage)
|
||||||
{
|
{
|
||||||
bool result = false;
|
bool result = false;
|
||||||
|
readMessage = "";
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
using (ExcelReader reader = new ExcelReader(filePath))
|
using (ExcelReader reader = new ExcelReader(filePath))
|
||||||
{
|
{
|
||||||
ImportHeader importHeader = new ImportHeader
|
switch (reader.SheetType)
|
||||||
{
|
{
|
||||||
ImportDate = DateTime.Now
|
case ExcelReader.SheetTypeEnum.BSMD:
|
||||||
};
|
{
|
||||||
result = ExcelUtil.ProcessSheet(reader, out readMessage, core, classes); // actual import
|
|
||||||
if (result)
|
|
||||||
{
|
|
||||||
importHeader.MessageCoreId = core.Id.Value;
|
|
||||||
importHeader.Filename = Path.GetFileName(filePath);
|
|
||||||
ReportingParty thisUser = ReportingParty.CurrentReportingParty;
|
|
||||||
importHeader.SenderEmail = thisUser.EMail;
|
|
||||||
importHeader.ReportingPartyId = thisUser.Id;
|
|
||||||
|
|
||||||
DBManager.Instance.Save(importHeader);
|
ImportHeader importHeader = new ImportHeader
|
||||||
// Saving plaintext data (ImportHeader + ImportValues) for each reading
|
{
|
||||||
List<ImportValue> valueList = importHeader.CreateUpdateList(reader.ImportValues);
|
ImportDate = DateTime.Now
|
||||||
// Bulk save recommended here..
|
};
|
||||||
ImportValue.BulkSave(valueList);
|
|
||||||
}
|
result = ExcelUtil.ProcessSheet(reader, out readMessage, core, classes); // actual import
|
||||||
|
if (result)
|
||||||
|
{
|
||||||
|
importHeader.MessageCoreId = core.Id.Value;
|
||||||
|
importHeader.Filename = Path.GetFileName(filePath);
|
||||||
|
ReportingParty thisUser = ReportingParty.CurrentReportingParty;
|
||||||
|
importHeader.SenderEmail = thisUser.EMail;
|
||||||
|
importHeader.ReportingPartyId = thisUser.Id;
|
||||||
|
|
||||||
|
DBManager.Instance.Save(importHeader);
|
||||||
|
// Saving plaintext data (ImportHeader + ImportValues) for each reading
|
||||||
|
List<ImportValue> valueList = importHeader.CreateUpdateList(reader.ImportValues);
|
||||||
|
// Bulk save recommended here..
|
||||||
|
ImportValue.BulkSave(valueList);
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case ExcelReader.SheetTypeEnum.DAKOSY:
|
||||||
|
{
|
||||||
|
result = DakosyExcelReader.ProcessSheet(reader, out readMessage, core, classes);
|
||||||
|
// at this point do not save import data values
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
default:
|
||||||
|
{
|
||||||
|
_log.WarnFormat("Unknown excel sheet type {0}", reader.SheetType);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
@ -51,8 +72,8 @@ namespace ENI2.Excel
|
|||||||
readMessage = ex.Message;
|
readMessage = ex.Message;
|
||||||
_log.Error(ex);
|
_log.Error(ex);
|
||||||
}
|
}
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
internal void Export(string fileName, MessageCore core, List<Message> messages, out string resultMessage, bool isRefSheet)
|
internal void Export(string fileName, MessageCore core, List<Message> messages, out string resultMessage, bool isRefSheet)
|
||||||
{
|
{
|
||||||
|
|||||||
@ -25,15 +25,22 @@ namespace ENI2.Excel
|
|||||||
{
|
{
|
||||||
internal enum ReadState { NONE, OK, WARN, FAIL };
|
internal enum ReadState { NONE, OK, WARN, FAIL };
|
||||||
|
|
||||||
|
internal enum SheetTypeEnum { BSMD, DAKOSY };
|
||||||
|
|
||||||
|
private SheetTypeEnum _sheetType = SheetTypeEnum.BSMD;
|
||||||
|
|
||||||
internal Dictionary<string, string> ImportValues { get; } = new Dictionary<string, string>();
|
internal Dictionary<string, string> ImportValues { get; } = new Dictionary<string, string>();
|
||||||
|
|
||||||
public ExcelReader(string filePath) : base(filePath)
|
public ExcelReader(string filePath) : base(filePath)
|
||||||
{
|
{
|
||||||
|
|
||||||
this._workBook = _excelWorkbooks.Open(filePath, 0, true, 5, "", "", false, XlPlatform.xlWindows, "", false, false, 0, false, false, false);
|
this._workBook = _excelWorkbooks.Open(filePath, 0, true, 5, "", "", false, XlPlatform.xlWindows, "", false, false, 0, false, false, false);
|
||||||
|
|
||||||
this.InitNameFields();
|
this.InitNameFields();
|
||||||
}
|
|
||||||
|
// Determine if this is a Dakosy or BSMD Sheet
|
||||||
|
_sheetType = (_nameDict.Count > 0) ? SheetTypeEnum.BSMD : SheetTypeEnum.DAKOSY;
|
||||||
|
}
|
||||||
|
|
||||||
|
public SheetTypeEnum SheetType { get { return _sheetType; } }
|
||||||
|
|
||||||
internal string ReadText(string lookup)
|
internal string ReadText(string lookup)
|
||||||
{
|
{
|
||||||
@ -71,7 +78,7 @@ namespace ENI2.Excel
|
|||||||
}
|
}
|
||||||
|
|
||||||
internal string ReadLoCode(string lookup)
|
internal string ReadLoCode(string lookup)
|
||||||
{
|
{
|
||||||
string val = this.ReadText(lookup);
|
string val = this.ReadText(lookup);
|
||||||
if (!val.IsNullOrEmpty())
|
if (!val.IsNullOrEmpty())
|
||||||
{
|
{
|
||||||
|
|||||||
@ -2,7 +2,7 @@
|
|||||||
<Project ToolsVersion="14.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
<Project ToolsVersion="14.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||||
<PropertyGroup>
|
<PropertyGroup>
|
||||||
<UseIISExpress>true</UseIISExpress>
|
<UseIISExpress>true</UseIISExpress>
|
||||||
<LastActiveSolutionConfig>Debug|Any CPU</LastActiveSolutionConfig>
|
<LastActiveSolutionConfig>Release|Any CPU</LastActiveSolutionConfig>
|
||||||
<Use64BitIISExpress />
|
<Use64BitIISExpress />
|
||||||
<IISExpressSSLPort />
|
<IISExpressSSLPort />
|
||||||
<IISExpressAnonymousAuthentication />
|
<IISExpressAnonymousAuthentication />
|
||||||
|
|||||||
@ -2,6 +2,6 @@
|
|||||||
|
|
||||||
[assembly: AssemblyCompany("schick Informatik")]
|
[assembly: AssemblyCompany("schick Informatik")]
|
||||||
[assembly: AssemblyProduct("BSMD NSW interface")]
|
[assembly: AssemblyProduct("BSMD NSW interface")]
|
||||||
[assembly: AssemblyInformationalVersion("7.0.2")]
|
[assembly: AssemblyInformationalVersion("7.1.0")]
|
||||||
[assembly: AssemblyCopyright("Copyright © 2014-2022 schick Informatik")]
|
[assembly: AssemblyCopyright("Copyright © 2014-2022 schick Informatik")]
|
||||||
[assembly: AssemblyTrademark("")]
|
[assembly: AssemblyTrademark("")]
|
||||||
@ -1,4 +1,4 @@
|
|||||||
using System.Reflection;
|
using System.Reflection;
|
||||||
|
|
||||||
[assembly: AssemblyVersion("7.0.2.*")]
|
[assembly: AssemblyVersion("7.1.0.*")]
|
||||||
|
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user