Excel Einlesen weitergemacht

This commit is contained in:
Daniel Schick 2016-08-17 06:36:36 +00:00
parent c9a5f7e5f0
commit 22a43dc943
5 changed files with 54 additions and 17 deletions

Binary file not shown.

View File

@ -61,6 +61,8 @@ namespace bsmd.ExcelReadService
string messageId = "";
string attachmentLocalPath = null;
string mailSender = "";
string receiptSubject = "NSW Sheet Service Status INFO";
using (BSMDPopClient bsmdPopClient = new BSMDPopClient())
{
@ -90,11 +92,14 @@ namespace bsmd.ExcelReadService
bool readResult;
string readMessage = "";
MessageCore messageCore = null;
string receiptText = "";
MessageCore messageCore = null;
if (attachmentLocalPath == null)
{
_log.WarnFormat("incoming E-Mail did not contain an Excel attachment!");
receiptText = "incoming E-Mail did not contain an Excel attachment!";
_log.WarnFormat(receiptText);
}
else
{
@ -112,7 +117,8 @@ namespace bsmd.ExcelReadService
if (!isValidSender)
{
_log.WarnFormat("ignored e-mail from illegal sender: {0}", mailSender);
receiptText = string.Format("ignored e - mail from illegal sender: { 0}", mailSender);
_log.Warn(receiptText);
}
else
{
@ -121,21 +127,29 @@ namespace bsmd.ExcelReadService
{
readResult = Util.ProcessSheet(reader, out readMessage, out messageCore);
if (!readResult)
_log.Error("Excel sheet could not be interpreted");
{
receiptText = string.Format("Incoming sheet could not be read: {0}", readMessage);
_log.Error(receiptText);
}
}
// TODO: Quittung / set messagecore to createreport and let reportGenerator create a reply?
// create a reply sheet (template + scanned highlighted content for verification
string confirmationExcelFilePath = Util.CreateConfirmationSheet(messageCore);
List<string> sendItems = new List<string>();
sendItems.Add(confirmationExcelFilePath);
// send reply sheet back to sender
BSMDMail.SendNSWReportWithAttachments(Properties.Settings.Default.SendEMailSubject, sendItems);
if (readResult)
{
string confirmationExcelFilePath = Util.CreateConfirmationSheet(messageCore);
List<string> sendItems = new List<string>();
sendItems.Add(confirmationExcelFilePath);
// send reply sheet back to sender
BSMDMail.SendNSWReportWithAttachments(Properties.Settings.Default.SendEMailSubject, sendItems);
}
}
if (receiptText.Length > 0)
BSMDMail.SendSystemInfoAsync(receiptSubject, receiptText, null);
// remove e-Mail
_log.InfoFormat("deleting mail with messageId {0}", messageId);
_log.InfoFormat("mail delete {0}", bsmdPopClient.DeleteMessageByMessageId(messageId) ? "successful" : "failed");

View File

@ -0,0 +1,16 @@
Info von Krawitowski:
Die Zugangsdaten der Postfächer:
Hallo Herr Schick,
ich habe 2 Postfächer gebaut:
Das erste nswreport@bsmd.de mit dem Kennwort avb!8pZs^V%7$$Td#CMw
Das zweite nsw-sheets@bsmd.de mit dem Kennwort WA*MpYNiM9Y5$d*6GTD3
Das erste liefert einen 5.7.1 zurück mit dem Hinweis auf NeReply Postfach..
Das zweite ist nur Pop aktiviert….
die Server IP lautet 192.168.2.101
SMTP Port ist Standard, POP3 ist 995 mit SSL

View File

@ -153,9 +153,15 @@ namespace bsmd.email
message.IsBodyHtml = false;
message.Body = body;
message.To.Add(recipient);
MailAddress adminAddress = new MailAddress(Properties.Settings.Default.AdminEmail);
message.CC.Add(adminAddress);
if (recipient != null)
{
message.To.Add(recipient);
message.CC.Add(adminAddress);
} else
{
message.To.Add(adminAddress);
}
// http://stackoverflow.com/questions/7276375/what-are-best-practices-for-using-smtpclient-sendasync-and-dispose-under-net-4
// asynchron schicken und wenn's erledigt ist gleich disposen (wichtig!)

View File

@ -68,13 +68,14 @@ namespace bsmd.email
part.Save(new FileInfo(attachmentLocalFile));
}
}
return true;
}
else
{
_log.Info("no new mail on server");
}
return true;
_log.Debug("no new mail on server");
return false;
}
}
/// <summary>