Excel Einlesen weitergemacht
This commit is contained in:
parent
c9a5f7e5f0
commit
22a43dc943
Binary file not shown.
@ -61,6 +61,8 @@ namespace bsmd.ExcelReadService
|
|||||||
string messageId = "";
|
string messageId = "";
|
||||||
string attachmentLocalPath = null;
|
string attachmentLocalPath = null;
|
||||||
string mailSender = "";
|
string mailSender = "";
|
||||||
|
string receiptSubject = "NSW Sheet Service Status INFO";
|
||||||
|
|
||||||
|
|
||||||
using (BSMDPopClient bsmdPopClient = new BSMDPopClient())
|
using (BSMDPopClient bsmdPopClient = new BSMDPopClient())
|
||||||
{
|
{
|
||||||
@ -90,11 +92,14 @@ namespace bsmd.ExcelReadService
|
|||||||
|
|
||||||
bool readResult;
|
bool readResult;
|
||||||
string readMessage = "";
|
string readMessage = "";
|
||||||
MessageCore messageCore = null;
|
string receiptText = "";
|
||||||
|
MessageCore messageCore = null;
|
||||||
|
|
||||||
|
|
||||||
if (attachmentLocalPath == 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
|
else
|
||||||
{
|
{
|
||||||
@ -112,7 +117,8 @@ namespace bsmd.ExcelReadService
|
|||||||
|
|
||||||
if (!isValidSender)
|
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
|
else
|
||||||
{
|
{
|
||||||
@ -121,21 +127,29 @@ namespace bsmd.ExcelReadService
|
|||||||
{
|
{
|
||||||
readResult = Util.ProcessSheet(reader, out readMessage, out messageCore);
|
readResult = Util.ProcessSheet(reader, out readMessage, out messageCore);
|
||||||
if (!readResult)
|
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?
|
// TODO: Quittung / set messagecore to createreport and let reportGenerator create a reply?
|
||||||
|
|
||||||
// create a reply sheet (template + scanned highlighted content for verification
|
// create a reply sheet (template + scanned highlighted content for verification
|
||||||
|
if (readResult)
|
||||||
string confirmationExcelFilePath = Util.CreateConfirmationSheet(messageCore);
|
{
|
||||||
List<string> sendItems = new List<string>();
|
string confirmationExcelFilePath = Util.CreateConfirmationSheet(messageCore);
|
||||||
sendItems.Add(confirmationExcelFilePath);
|
List<string> sendItems = new List<string>();
|
||||||
// send reply sheet back to sender
|
sendItems.Add(confirmationExcelFilePath);
|
||||||
BSMDMail.SendNSWReportWithAttachments(Properties.Settings.Default.SendEMailSubject, sendItems);
|
// 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
|
// remove e-Mail
|
||||||
_log.InfoFormat("deleting mail with messageId {0}", messageId);
|
_log.InfoFormat("deleting mail with messageId {0}", messageId);
|
||||||
_log.InfoFormat("mail delete {0}", bsmdPopClient.DeleteMessageByMessageId(messageId) ? "successful" : "failed");
|
_log.InfoFormat("mail delete {0}", bsmdPopClient.DeleteMessageByMessageId(messageId) ? "successful" : "failed");
|
||||||
|
|||||||
16
nsw/Source/bsmd.ExcelReadService/readme.txt
Normal file
16
nsw/Source/bsmd.ExcelReadService/readme.txt
Normal 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
|
||||||
@ -153,9 +153,15 @@ namespace bsmd.email
|
|||||||
message.IsBodyHtml = false;
|
message.IsBodyHtml = false;
|
||||||
message.Body = body;
|
message.Body = body;
|
||||||
|
|
||||||
message.To.Add(recipient);
|
|
||||||
MailAddress adminAddress = new MailAddress(Properties.Settings.Default.AdminEmail);
|
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
|
// 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!)
|
// asynchron schicken und wenn's erledigt ist gleich disposen (wichtig!)
|
||||||
|
|||||||
@ -68,13 +68,14 @@ namespace bsmd.email
|
|||||||
part.Save(new FileInfo(attachmentLocalFile));
|
part.Save(new FileInfo(attachmentLocalFile));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
_log.Info("no new mail on server");
|
_log.Debug("no new mail on server");
|
||||||
}
|
return false;
|
||||||
|
}
|
||||||
return true;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user