This commit is contained in:
2020-10-19 22:06:11 +00:00
parent 8ec761d436
commit 8c2e45175d
6 changed files with 92 additions and 89 deletions

View File

@@ -64,4 +64,4 @@ using System.Security.Permissions;
// Configure log4net using the .config file
//[assembly: log4net.Config.XmlConfigurator(ConfigFile="Log4Net.config",Watch=true)]
//[assembly: log4net.Config.XmlConfigurator( ConfigFile="Log4Net.config",Watch=true )]
[assembly: AssemblyFileVersionAttribute("7.6.8.0")]
[assembly: AssemblyFileVersionAttribute("7.6.10.0")]

View File

@@ -116,6 +116,7 @@
</Reference>
<Reference Include="ChilkatDotNet4">
<HintPath>..\..\..\3rdprtylibs\chilkat\ChilkatDotNet4.dll</HintPath>
<Private>False</Private>
</Reference>
<Reference Include="DevExpress.Charts.v10.2.Core, Version=10.2.4.0, Culture=neutral, PublicKeyToken=b88d1754d700e49a, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>

View File

@@ -5,24 +5,24 @@ using Chilkat;
namespace GZTW.AyaNova.BLL
{
/// <summary>
/// Process client notification list and
/// deliver appropriately
/// </summary>
public class GenProcessClientNotifications
{
private GenProcessClientNotifications()
{
//
// TODO: Add constructor logic here
//
}
/// <summary>
/// Process client notification list and
/// deliver appropriately
/// </summary>
public class GenProcessClientNotifications
{
private GenProcessClientNotifications()
{
//
// TODO: Add constructor logic here
//
}
/// <summary>
/// Compile a list of all pending Client notifications and deliver them
/// </summary>
public static void DeliverNotifications()
{
public static void DeliverNotifications()
{
//case 1904
if (!AyaBizUtils.GlobalSettings.UseNotification) return;
@@ -37,7 +37,7 @@ namespace GZTW.AyaNova.BLL
MailMan mailman = new MailMan();
mailman.UnlockComponent("SAyanovaMAILQ_46WCmUg3lQ1i");
// Set the SMTP variables
mailman.SmtpHost = GZTW.AyaNova.BLL.AyaBizUtils.GlobalSettings.NotifySMTPHostPortionOnly;
mailman.SmtpHost = GZTW.AyaNova.BLL.AyaBizUtils.GlobalSettings.NotifySMTPHostPortionOnly;
mailman.SmtpPort = GZTW.AyaNova.BLL.AyaBizUtils.GlobalSettings.NotifySMTPPort;
//case 1136
if (GZTW.AyaNova.BLL.AyaBizUtils.GlobalSettings.NotifySMTPUseSSL)
@@ -47,7 +47,7 @@ namespace GZTW.AyaNova.BLL
mailman.SmtpUsername = GZTW.AyaNova.BLL.AyaBizUtils.GlobalSettings.NotifySMTPAccount;
mailman.SmtpPassword = GZTW.AyaNova.BLL.AyaBizUtils.GlobalSettings.NotifySMTPPassword;
//case 1382
//if can't use smtp server then log and conditionally abort
if (!mailman.SmtpNoop())
@@ -56,7 +56,7 @@ namespace GZTW.AyaNova.BLL
NotifyDeliveryLog.LogSMTPConnectFailure("Code:" + mailman.LastSmtpStatus.ToString() + "\r\n" + mailman.LastErrorText);
//If retry then don't proceed or notifications will be deleted
if(AyaBizUtils.GlobalSettings.SMTPRetry)
if (AyaBizUtils.GlobalSettings.SMTPRetry)
return;
}
@@ -65,9 +65,10 @@ namespace GZTW.AyaNova.BLL
// so would need an external static location to store a limited number of dupes in some kind of
//queue, probably in ayabizutils with everything else
System.Collections.Generic.List<string> Hashes = new System.Collections.Generic.List<string>();
foreach (ClientNotificationList.ClientNotificationListInfo info in nl)
{
string NotifySummary = string.Empty;
try
{
//reload email from stored mime
@@ -80,24 +81,24 @@ namespace GZTW.AyaNova.BLL
ClientNotifyEvent.DeleteItem(n.ID);
continue;
}
Chilkat.Email email = new Chilkat.Email();
//email.SetFromMimeText(n.GetContentAsString);
email.Mailer = "AyaNova service management software licensed to " + AyaBizUtils.REGTO;
email.Body = sMessageFields[1];
email.Subject = sMessageFields[2];
email.Subject = sMessageFields[2];
//case 1601
string ToAddress = sMessageFields[3];
//case 3808
string NotifySummary =string.Empty;
NotifySummary = ToAddress + "|" + email.Subject;
if (nFieldCount > 4)
{
NotifySummary += "|woid:" + sMessageFields[5];
NotifySummary += "|woid:" + sMessageFields[4];//case 3829
}
if (nFieldCount > 5)
{
@@ -136,10 +137,10 @@ namespace GZTW.AyaNova.BLL
else if (r.ReportKey == "WorkorderQuoteDetailed")
o = WorkorderQuoteDetailedReportData.GetItem(woid);
NotifySummary += "|reportkey:" + r.ReportKey + "|reportid:"+sMessageFields[6];//case 3808
NotifySummary += "|reportkey:" + r.ReportKey + "|reportid:" + sMessageFields[6];//case 3808
//ms.toarray = byte array from memory stream
email.AddDataAttachment(DateTime.Now.ToString("yyyy_MM_dd_HH_mm") + ".pdf", ReportGenerator.GetReportAsPDF(r, o).ToArray());
}
@@ -147,12 +148,12 @@ namespace GZTW.AyaNova.BLL
//case 3808
var hash = CheckSum(email.Body + NotifySummary);
NotifySummary += "|hash:" + hash;
if (!Hashes.Contains(hash))
{
Hashes.Add(hash);
Hashes.Add(hash);
}
else
{
@@ -167,12 +168,12 @@ namespace GZTW.AyaNova.BLL
success = mailman.SendEmail(email);
if (success)
{
NotifyDeliveryLog.LogClientDelivery(n.ClientID,true,"");
NotifyDeliveryLog.LogClientDelivery(n.ClientID, true, "");
ClientNotifyEvent.DeleteItem(n.ID);
}
else
{
NotifyDeliveryLog.LogClientDelivery(n.ClientID,false, mailman.LastErrorText);
NotifyDeliveryLog.LogClientDelivery(n.ClientID, false, mailman.LastErrorText);
//Added this late, I'm thinking if it fails they will get the log and
//be able to fix the problem easily but if it stays in the queue there will be no way
//for them to delete it
@@ -181,25 +182,26 @@ namespace GZTW.AyaNova.BLL
ClientNotifyEvent.DeleteItem(n.ID);
}
}
catch(Exception ex)
{
//case 3829
catch (Exception ex)
{
//case 3829
//crack exception if necessary
while (ex.InnerException != null) ex = ex.InnerException;
//log and then continue
if (string.IsNullOrEmpty(NotifySummary))
{
NotifySummary = "UNKNOWN MESSAGE";
}
NotifyDeliveryLog.LogSMTPDeliveryMessage("ClientNotify Exception during delivery: Full error is:\r\n" + ex.Message + "\r\nMessage: " + NotifySummary);
continue;
}
//crack exception if necessary
while (ex.InnerException != null) ex = ex.InnerException;
//log and then continue
if(string.IsNullOrEmpty(NotifySummary)){
NotifySummary="UNKNOWN MESSAGE";
}
NotifyDeliveryLog.LogSMTPDeliveryMessage("ClientNotify Exception during delivery: Full error is:\r\n" + ex.Message + "\r\nMessage: "+ NotifySummary);
continue;
}
}
}
}
public static string CheckSum(string input)
{
@@ -213,9 +215,9 @@ namespace GZTW.AyaNova.BLL
return hash;
}
//=================================
}
//=================================
}
}