V. 3.2.20, TOWA Korrektur, Kill EXCEL

This commit is contained in:
Daniel Schick 2016-11-01 13:20:53 +00:00
parent ae98ea27fb
commit 7fe80e4e80
9 changed files with 63 additions and 8 deletions

Binary file not shown.

View File

@ -140,8 +140,15 @@ namespace bsmd.ExcelReadService
{
List<string> sendItems = new List<string>();
sendItems.Add(confirmationFileName);
// get the ship's name
string shipname = DBManager.Instance.GetShipNameFromCore(messageCore);
if (shipname.IsNullOrEmpty()) shipname = messageCore.IMO;
string subject = string.Format("{0}: {1}", Properties.Settings.Default.SendEMailSubject, shipname);
// send reply sheet back to sender
BSMDMail.SendNSWReportWithAttachments(Properties.Settings.Default.SendEMailSubject, sendItems);
BSMDMail.SendNSWReportWithAttachments(subject, sendItems, mailSender);
}
}
}
@ -183,6 +190,24 @@ namespace bsmd.ExcelReadService
_log.Error("DB Connection failure");
}
// close any excel processes still running
Process[] process = Process.GetProcessesByName("Excel");
foreach (Process p in process)
{
if (!string.IsNullOrEmpty(p.ProcessName))
{
try
{
_log.DebugFormat("Killing process {0} {1}", p.ProcessName, p.Id);
p.Kill();
}
catch (Exception ex)
{
_log.WarnFormat("Error killing process {0} {1}: {2}", p.ProcessName, p.Id, ex.Message);
}
}
}
lock (this._timerlock)
{
this.processRunning = false;

View File

@ -829,7 +829,7 @@ namespace bsmd.ExcelReadService
// TOWA ist eigentlich 1:n, es ist aber keine Liste im Sheet!
Message towaMessage = Util.GetMessageWithType(messages, messageCore, Message.NotificationClass.TOWA);
string towageName = reader.ReadText("TOWA.TowageOnArrivalName");
string towageName = reader.ReadText("TOWA.TowageOnArrivalName_1");
if (!towageName.IsNullOrEmpty())
{
if (towaMessage.Elements.Count == 0)
@ -852,7 +852,7 @@ namespace bsmd.ExcelReadService
{
// TOWD ist 1:n, es ist aber keine Liste im Sheet!
Message towdMessage = Util.GetMessageWithType(messages, messageCore, Message.NotificationClass.TOWD);
string towageName = reader.ReadText("TOWD.TowageOnDepartureName");
string towageName = reader.ReadText("TOWD.TowageOnDepartureName_1");
if(!towageName.IsNullOrEmpty())
{
if(towdMessage.Elements.Count == 0)

View File

@ -188,7 +188,7 @@ namespace bsmd.ReportGenerator
attachments.Add(crewCSV);
}
BSMDMail.SendNSWReportWithAttachments(subject, attachments);
BSMDMail.SendNSWReportWithAttachments(subject, attachments, null);
// reset report status
reportCore.ReportStatus = MessageCore.ReportStatusEnum.NONE;
DBManager.Instance.Save(reportCore);

View File

@ -182,6 +182,24 @@ namespace bsmd.database
return messageList;
}
public string GetShipNameFromCore(MessageCore core)
{
foreach(Message message in this.GetMessagesForCore(core, MessageLoad.ALL))
{
if (message.MessageNotificationClass == Message.NotificationClass.STAT)
{
if (message.Elements.Count > 0)
{
STAT stat = message.Elements[0] as STAT;
if (stat != null)
return stat.ShipName;
}
break;
}
}
return null;
}
public Dictionary<Guid, ReportingParty> GetReportingPartyDict()
{
if (DBManager.allReportingParties == null)

View File

@ -2,6 +2,6 @@
[assembly: AssemblyCompany("Informatikbüro Daniel Schick")]
[assembly: AssemblyProduct("BSMD NSW interface")]
[assembly: AssemblyInformationalVersion("3.2.18")]
[assembly: AssemblyInformationalVersion("3.2.20")]
[assembly: AssemblyCopyright("Copyright © 2014-2016 Informatikbüro Daniel Schick. All rights reserved.")]
[assembly: AssemblyTrademark("")]

View File

@ -1,4 +1,4 @@
using System.Reflection;
[assembly: AssemblyVersion("3.2.18.*")]
[assembly: AssemblyVersion("3.2.20.*")]

View File

@ -69,7 +69,7 @@ namespace bsmd.email
/// </summary>
/// <param name="subject">Betreffzeile</param>
/// <param name="filenameList">Liste von Dateien die angehängt werden sollen</param>
public static void SendNSWReportWithAttachments(string subject, List<string> filenameList)
public static void SendNSWReportWithAttachments(string subject, List<string> filenameList, string recipient)
{
BSMDMail mailer = new BSMDMail();
@ -81,11 +81,23 @@ namespace bsmd.email
message.IsBodyHtml = false;
message.Body = "see attachment";
foreach (string recipient in Properties.Settings.Default.Recipient)
// wenn recipient leer ist, geht es an die Recipientliste
// wenn nicht, an den Recipient + die Admin-Email
if ((recipient == null) || (recipient.Length == 0))
{
foreach (string defaultRecipient in Properties.Settings.Default.Recipient)
{
message.To.Add(defaultRecipient);
}
}
else
{
message.To.Add(recipient);
message.CC.Add(Properties.Settings.Default.AdminEmail);
}
foreach (string filename in filenameList)
{
Attachment attachment = new Attachment(filename, MediaTypeNames.Application.Octet);

Binary file not shown.