You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
714 lines
21 KiB
714 lines
21 KiB
2 weeks ago
|
using System;
|
||
|
using System.Collections.Generic;
|
||
|
using System.ComponentModel;
|
||
|
using System.Diagnostics;
|
||
|
using System.Linq;
|
||
|
using System.Net;
|
||
|
using System.Net.Mail;
|
||
|
using System.Net.Mime;
|
||
|
using System.Net.Security;
|
||
|
using System.Security.Cryptography.X509Certificates;
|
||
|
using System.Threading;
|
||
|
using iMonitorApp.Properties;
|
||
|
using _4ELogger;
|
||
|
|
||
|
namespace iMonitorApp
|
||
|
{
|
||
|
// Token: 0x02000020 RID: 32
|
||
|
public class ParseStackAlarms : INotifyPropertyChanged
|
||
|
{
|
||
|
// Token: 0x17000021 RID: 33
|
||
|
// (get) Token: 0x060000F3 RID: 243 RVA: 0x0000A5F1 File Offset: 0x000087F1
|
||
|
// (set) Token: 0x060000F4 RID: 244 RVA: 0x0000A5F9 File Offset: 0x000087F9
|
||
|
private string EncodedText { get; set; }
|
||
|
|
||
|
// Token: 0x17000022 RID: 34
|
||
|
// (get) Token: 0x060000F5 RID: 245 RVA: 0x0000A602 File Offset: 0x00008802
|
||
|
// (set) Token: 0x060000F6 RID: 246 RVA: 0x0000A60A File Offset: 0x0000880A
|
||
|
public string Theme { get; set; }
|
||
|
|
||
|
// Token: 0x17000023 RID: 35
|
||
|
// (get) Token: 0x060000F7 RID: 247 RVA: 0x0000A613 File Offset: 0x00008813
|
||
|
// (set) Token: 0x060000F8 RID: 248 RVA: 0x0000A61B File Offset: 0x0000881B
|
||
|
public string SendingEmailStatus { get; set; }
|
||
|
|
||
|
// Token: 0x14000004 RID: 4
|
||
|
// (add) Token: 0x060000F9 RID: 249 RVA: 0x0000A624 File Offset: 0x00008824
|
||
|
// (remove) Token: 0x060000FA RID: 250 RVA: 0x0000A65C File Offset: 0x0000885C
|
||
|
// [DebuggerBrowsable(DebuggerBrowsableState.Never)]
|
||
|
public event PropertyChangedEventHandler PropertyChanged;
|
||
|
|
||
|
// Token: 0x17000024 RID: 36
|
||
|
// (get) Token: 0x060000FB RID: 251 RVA: 0x0000A691 File Offset: 0x00008891
|
||
|
// (set) Token: 0x060000FC RID: 252 RVA: 0x0000A699 File Offset: 0x00008899
|
||
|
public string Subject { get; set; }
|
||
|
|
||
|
// Token: 0x17000025 RID: 37
|
||
|
// (get) Token: 0x060000FD RID: 253 RVA: 0x0000A6A2 File Offset: 0x000088A2
|
||
|
// (set) Token: 0x060000FE RID: 254 RVA: 0x0000A6AA File Offset: 0x000088AA
|
||
|
public string EmailReplyTo { get; set; }
|
||
|
|
||
|
// Token: 0x17000026 RID: 38
|
||
|
// (get) Token: 0x060000FF RID: 255 RVA: 0x0000A6B3 File Offset: 0x000088B3
|
||
|
// (set) Token: 0x06000100 RID: 256 RVA: 0x0000A6BB File Offset: 0x000088BB
|
||
|
public string EmailBCC { get; set; }
|
||
|
|
||
|
// Token: 0x17000027 RID: 39
|
||
|
// (get) Token: 0x06000101 RID: 257 RVA: 0x0000A6C4 File Offset: 0x000088C4
|
||
|
// (set) Token: 0x06000102 RID: 258 RVA: 0x0000A6CC File Offset: 0x000088CC
|
||
|
public string EmailCC { get; set; }
|
||
|
|
||
|
// Token: 0x17000028 RID: 40
|
||
|
// (get) Token: 0x06000103 RID: 259 RVA: 0x0000A6D5 File Offset: 0x000088D5
|
||
|
// (set) Token: 0x06000104 RID: 260 RVA: 0x0000A6DD File Offset: 0x000088DD
|
||
|
public string Images { get; set; }
|
||
|
|
||
|
// Token: 0x17000029 RID: 41
|
||
|
// (get) Token: 0x06000105 RID: 261 RVA: 0x0000A6E6 File Offset: 0x000088E6
|
||
|
// (set) Token: 0x06000106 RID: 262 RVA: 0x0000A6EE File Offset: 0x000088EE
|
||
|
public string Attachments { get; set; }
|
||
|
|
||
|
// Token: 0x1700002A RID: 42
|
||
|
// (get) Token: 0x06000107 RID: 263 RVA: 0x0000A6F7 File Offset: 0x000088F7
|
||
|
// (set) Token: 0x06000108 RID: 264 RVA: 0x0000A6FF File Offset: 0x000088FF
|
||
|
public bool SayIt { get; set; }
|
||
|
|
||
|
// Token: 0x1700002B RID: 43
|
||
|
// (get) Token: 0x06000109 RID: 265 RVA: 0x0000A708 File Offset: 0x00008908
|
||
|
// (set) Token: 0x0600010A RID: 266 RVA: 0x0000A710 File Offset: 0x00008910
|
||
|
public bool EmailIt { get; set; }
|
||
|
|
||
|
// Token: 0x1700002C RID: 44
|
||
|
// (get) Token: 0x0600010B RID: 267 RVA: 0x0000A719 File Offset: 0x00008919
|
||
|
// (set) Token: 0x0600010C RID: 268 RVA: 0x0000A721 File Offset: 0x00008921
|
||
|
public bool Phoneit { get; set; }
|
||
|
|
||
|
// Token: 0x1700002D RID: 45
|
||
|
// (get) Token: 0x0600010D RID: 269 RVA: 0x0000A72A File Offset: 0x0000892A
|
||
|
// (set) Token: 0x0600010E RID: 270 RVA: 0x0000A732 File Offset: 0x00008932
|
||
|
public bool SmsIt { get; set; }
|
||
|
|
||
|
// Token: 0x1700002E RID: 46
|
||
|
// (get) Token: 0x0600010F RID: 271 RVA: 0x0000A73B File Offset: 0x0000893B
|
||
|
// (set) Token: 0x06000110 RID: 272 RVA: 0x0000A743 File Offset: 0x00008943
|
||
|
public string AlertLevel { get; set; }
|
||
|
|
||
|
// Token: 0x1700002F RID: 47
|
||
|
// (get) Token: 0x06000111 RID: 273 RVA: 0x0000A74C File Offset: 0x0000894C
|
||
|
// (set) Token: 0x06000112 RID: 274 RVA: 0x0000A754 File Offset: 0x00008954
|
||
|
public string PhoneNumbers { get; set; }
|
||
|
|
||
|
// Token: 0x17000030 RID: 48
|
||
|
// (get) Token: 0x06000113 RID: 275 RVA: 0x0000A75D File Offset: 0x0000895D
|
||
|
// (set) Token: 0x06000114 RID: 276 RVA: 0x0000A765 File Offset: 0x00008965
|
||
|
public string Recipients { get; set; }
|
||
|
|
||
|
// Token: 0x17000031 RID: 49
|
||
|
// (get) Token: 0x06000115 RID: 277 RVA: 0x0000A76E File Offset: 0x0000896E
|
||
|
// (set) Token: 0x06000116 RID: 278 RVA: 0x0000A776 File Offset: 0x00008976
|
||
|
public bool YahooMessenger { get; set; }
|
||
|
|
||
|
// Token: 0x17000032 RID: 50
|
||
|
// (get) Token: 0x06000117 RID: 279 RVA: 0x0000A77F File Offset: 0x0000897F
|
||
|
// (set) Token: 0x06000118 RID: 280 RVA: 0x0000A787 File Offset: 0x00008987
|
||
|
public string Escalation { get; set; }
|
||
|
|
||
|
// Token: 0x17000033 RID: 51
|
||
|
// (get) Token: 0x06000119 RID: 281 RVA: 0x0000A790 File Offset: 0x00008990
|
||
|
// (set) Token: 0x0600011A RID: 282 RVA: 0x0000A798 File Offset: 0x00008998
|
||
|
public DateTime ReceivingTime { get; set; }
|
||
|
|
||
|
// Token: 0x17000034 RID: 52
|
||
|
// (get) Token: 0x0600011B RID: 283 RVA: 0x0000A7A1 File Offset: 0x000089A1
|
||
|
// (set) Token: 0x0600011C RID: 284 RVA: 0x0000A7A9 File Offset: 0x000089A9
|
||
|
public string Body { get; set; }
|
||
|
|
||
|
// Token: 0x0600011D RID: 285 RVA: 0x00002AAD File Offset: 0x00000CAD
|
||
|
public ParseStackAlarms()
|
||
|
{
|
||
|
}
|
||
|
|
||
|
// Token: 0x0600011E RID: 286 RVA: 0x0000A7B2 File Offset: 0x000089B2
|
||
|
public ParseStackAlarms(string text) : this(text, new ThemeEmails())
|
||
|
{
|
||
|
}
|
||
|
|
||
|
// Token: 0x0600011F RID: 287 RVA: 0x0000A7C4 File Offset: 0x000089C4
|
||
|
public ParseStackAlarms(string text, ThemeEmails te)
|
||
|
{
|
||
|
try
|
||
|
{
|
||
|
this.ReceivingTime = DateTime.Now;
|
||
|
this.EncodedText = text;
|
||
|
this.EncodedText = this.EncodedText.Replace("<EOF>", "");
|
||
|
this.themeEmails = te;
|
||
|
string[] array = this.EncodedText.Split(new char[]
|
||
|
{
|
||
|
'~'
|
||
|
});
|
||
|
this.dick = new Dictionary<string, string>();
|
||
|
foreach (string text2 in array)
|
||
|
{
|
||
|
string[] array3 = text2.Split(new string[]
|
||
|
{
|
||
|
"$#="
|
||
|
}, StringSplitOptions.RemoveEmptyEntries);
|
||
|
bool flag = this.dick.ContainsKey(array3[0]);
|
||
|
if (!flag)
|
||
|
{
|
||
|
bool flag2 = array3.Count<string>() == 1;
|
||
|
if (flag2)
|
||
|
{
|
||
|
this.dick.Add(array3[0], null);
|
||
|
}
|
||
|
else
|
||
|
{
|
||
|
this.dick.Add(array3[0], array3[1]);
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
this.Theme = this.GetVal("theme");
|
||
|
this.AlertLevel = this.GetVal("alertlevel");
|
||
|
this.Subject = this.GetVal("subject");
|
||
|
this.Body = this.GetVal("body");
|
||
|
this.Recipients = this.GetVal("recipients");
|
||
|
this.EmailBCC = this.GetVal("emailBCC");
|
||
|
this.EmailCC = this.GetVal("emailCC");
|
||
|
this.Attachments = this.GetVal("emailAttachments");
|
||
|
this.Images = this.GetVal("emailImages");
|
||
|
this.EmailReplyTo = this.GetVal("emailReplyTo");
|
||
|
this.SayIt = Convert.ToBoolean(this.GetVal("sayIt"));
|
||
|
this.EmailIt = Convert.ToBoolean(this.GetVal("emailIt"));
|
||
|
try
|
||
|
{
|
||
|
this.Phoneit = Convert.ToBoolean(this.GetVal("phoneCall"));
|
||
|
}
|
||
|
catch
|
||
|
{
|
||
|
string text3 = this.GetVal("phoneCall");
|
||
|
bool flag3 = text3.StartsWith("AUTO");
|
||
|
if (flag3)
|
||
|
{
|
||
|
text3 = text3.Replace("AUTO-", "");
|
||
|
bool flag4 = this.AlertLevel == text3;
|
||
|
if (flag4)
|
||
|
{
|
||
|
this.Phoneit = true;
|
||
|
}
|
||
|
else
|
||
|
{
|
||
|
this.Phoneit = false;
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
this.YahooMessenger = Convert.ToBoolean(this.GetVal("ym"));
|
||
|
this.SmsIt = Convert.ToBoolean(this.GetVal("sms"));
|
||
|
this.Escalation = this.GetVal("escalation");
|
||
|
bool flag5 = this.Phoneit || this.SmsIt;
|
||
|
if (flag5)
|
||
|
{
|
||
|
this.PhoneNumbers = this.GetVal("numbers");
|
||
|
}
|
||
|
this.SendingEmailStatus = "";
|
||
|
this.NotifyPropertyChanged("ym");
|
||
|
}
|
||
|
catch (Exception ex)
|
||
|
{
|
||
|
SocketClient.Send(Settings.Default.PhoneIP, Settings.Default.SpeechPort, "Error Parsing Alarm");
|
||
|
Logger.Log(string.Concat(new string[]
|
||
|
{
|
||
|
"Error parsing alarm ",
|
||
|
this.EncodedText,
|
||
|
"Exception:",
|
||
|
ex.Message,
|
||
|
ex.StackTrace
|
||
|
}), "iMonitorApp", "iMonitor");
|
||
|
}
|
||
|
}
|
||
|
|
||
|
// Token: 0x06000120 RID: 288 RVA: 0x0000AB2C File Offset: 0x00008D2C
|
||
|
private void NotifyPropertyChanged(string propertyName = "")
|
||
|
{
|
||
|
bool flag = this.PropertyChanged != null;
|
||
|
if (flag)
|
||
|
{
|
||
|
this.PropertyChanged(this, new PropertyChangedEventArgs(propertyName));
|
||
|
}
|
||
|
}
|
||
|
|
||
|
// Token: 0x06000121 RID: 289 RVA: 0x0000AB5C File Offset: 0x00008D5C
|
||
|
public void Process()
|
||
|
{
|
||
|
try
|
||
|
{
|
||
|
bool sayIt = this.SayIt;
|
||
|
if (sayIt)
|
||
|
{
|
||
|
this.Say();
|
||
|
}
|
||
|
}
|
||
|
catch (Exception ex)
|
||
|
{
|
||
|
this.SendingEmailStatus = "Error Saying - " + ex.Message;
|
||
|
}
|
||
|
try
|
||
|
{
|
||
|
bool emailIt = this.EmailIt;
|
||
|
if (emailIt)
|
||
|
{
|
||
|
this.Email(false);
|
||
|
}
|
||
|
}
|
||
|
catch (Exception ex2)
|
||
|
{
|
||
|
bool flag = ex2.Message.Contains("The specified path");
|
||
|
if (flag)
|
||
|
{
|
||
|
this.message.Subject = "Attachment Ignored - " + this.message.Subject;
|
||
|
MailMessage mailMessage = this.message;
|
||
|
mailMessage.Body = mailMessage.Body + "Attachment Ignored because: " + ex2.Message;
|
||
|
try
|
||
|
{
|
||
|
this.Email(true);
|
||
|
}
|
||
|
catch (Exception ex3)
|
||
|
{
|
||
|
this.SendingEmailStatus = "Error sending Email - " + ex3.Message;
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
try
|
||
|
{
|
||
|
bool phoneit = this.Phoneit;
|
||
|
if (phoneit)
|
||
|
{
|
||
|
this.PhoneCall();
|
||
|
}
|
||
|
}
|
||
|
catch (Exception ex4)
|
||
|
{
|
||
|
this.SendingEmailStatus = "Error sending Phonecall- " + ex4.Message;
|
||
|
}
|
||
|
try
|
||
|
{
|
||
|
bool smsIt = this.SmsIt;
|
||
|
if (smsIt)
|
||
|
{
|
||
|
this.SMS();
|
||
|
}
|
||
|
}
|
||
|
catch (Exception ex5)
|
||
|
{
|
||
|
this.SendingEmailStatus = "Error sending SMS- " + ex5.Message;
|
||
|
}
|
||
|
}
|
||
|
|
||
|
// Token: 0x06000122 RID: 290 RVA: 0x0000ACEC File Offset: 0x00008EEC
|
||
|
private void PhoneCall()
|
||
|
{
|
||
|
SocketClient.Send(Settings.Default.PhoneIP, Settings.Default.PhonePort, this.PhoneNumbers + "<EOF>");
|
||
|
Logger.Log("Phone Call Sent: " + this.PhoneNumbers, "PhoneLogs", "iMonitor");
|
||
|
}
|
||
|
|
||
|
// Token: 0x06000123 RID: 291 RVA: 0x000038AE File Offset: 0x00001AAE
|
||
|
private void SMS()
|
||
|
{
|
||
|
}
|
||
|
|
||
|
// Token: 0x06000124 RID: 292 RVA: 0x0000AD44 File Offset: 0x00008F44
|
||
|
private string GetVal(string key)
|
||
|
{
|
||
|
bool flag = this.dick.ContainsKey(key);
|
||
|
string result;
|
||
|
if (flag)
|
||
|
{
|
||
|
result = this.dick[key];
|
||
|
}
|
||
|
else
|
||
|
{
|
||
|
result = null;
|
||
|
}
|
||
|
return result;
|
||
|
}
|
||
|
|
||
|
// Token: 0x06000125 RID: 293 RVA: 0x0000AD78 File Offset: 0x00008F78
|
||
|
private void Say()
|
||
|
{
|
||
|
SocketClient.Send(Settings.Default.PhoneIP, Settings.Default.SpeechPort, this.Subject.Replace("<EOF>", ""));
|
||
|
Logger.Log("Speech Sent: " + this.Subject.Replace("<EOF>", ""), "SpeechLogs", "iMonitor");
|
||
|
}
|
||
|
|
||
|
// Token: 0x06000126 RID: 294 RVA: 0x0000ADDF File Offset: 0x00008FDF
|
||
|
private void Say(string text)
|
||
|
{
|
||
|
SocketClient.Send(Settings.Default.PhoneIP, Settings.Default.SpeechPort, text);
|
||
|
Logger.Log("Speech Sent: " + text, "SpeechLogs", "iMonitor");
|
||
|
}
|
||
|
|
||
|
// Token: 0x06000127 RID: 295 RVA: 0x0000AE14 File Offset: 0x00009014
|
||
|
private void Email(bool ignoreAttach = false)
|
||
|
{
|
||
|
string firstTheme = this.Theme.Split(new char[]
|
||
|
{
|
||
|
','
|
||
|
})[0];
|
||
|
ThemeEmail themeEmail = (from p in this.themeEmails.EmailList
|
||
|
where p.ThemeName.ToLower() == firstTheme.ToLower()
|
||
|
select p).FirstOrDefault<ThemeEmail>();
|
||
|
bool flag = themeEmail == null;
|
||
|
string text;
|
||
|
string password;
|
||
|
string displayName;
|
||
|
if (flag)
|
||
|
{
|
||
|
text = "iAlarm@4ecap.com";
|
||
|
password = "iAlarm";
|
||
|
displayName = "Theme NA";
|
||
|
}
|
||
|
else
|
||
|
{
|
||
|
text = themeEmail.EmailAddress;
|
||
|
displayName = themeEmail.DisplayName;
|
||
|
password = themeEmail.Password;
|
||
|
}
|
||
|
bool flag2 = firstTheme.ToLower() == "etrading";
|
||
|
if (flag2)
|
||
|
{
|
||
|
text = "etrading@fourelements.sg";
|
||
|
password = "etr4ec2014";
|
||
|
displayName = "E-Trading";
|
||
|
}
|
||
|
bool flag3 = firstTheme.ToLower() == "idstrategy";
|
||
|
if (flag3)
|
||
|
{
|
||
|
text = "idstrategy@fourelements.sg";
|
||
|
password = "idstra4ec2014";
|
||
|
displayName = "ID Strategy";
|
||
|
}
|
||
|
bool flag4 = firstTheme.ToLower() == "port";
|
||
|
if (flag4)
|
||
|
{
|
||
|
text = "portfolio@fourelements.sg";
|
||
|
password = "JaeVKpPF0j8F";
|
||
|
displayName = "Portfolio";
|
||
|
}
|
||
|
bool flag5 = firstTheme.ToLower() == "execution";
|
||
|
if (flag5)
|
||
|
{
|
||
|
text = "execution@fourelements.sg";
|
||
|
password = "n1ngm1KObdbx";
|
||
|
displayName = "Execution";
|
||
|
}
|
||
|
bool flag6 = firstTheme.ToLower() == "bb";
|
||
|
if (flag6)
|
||
|
{
|
||
|
text = "bb@fourelements.sg";
|
||
|
password = "jpUb3Eurer0u";
|
||
|
displayName = themeEmail.DisplayName;
|
||
|
}
|
||
|
bool flag7 = firstTheme.ToLower() == "reporting.external";
|
||
|
if (flag7)
|
||
|
{
|
||
|
text = "info@fourelements.sg";
|
||
|
password = "infoEC2014";
|
||
|
displayName = "Four Elements Capital";
|
||
|
}
|
||
|
bool flag8 = firstTheme.ToLower() == "quantopen";
|
||
|
if (flag8)
|
||
|
{
|
||
|
text = "quantopen@fourelements.sg";
|
||
|
password = "quant2017";
|
||
|
displayName = "QuantOpen";
|
||
|
}
|
||
|
bool flag9 = firstTheme.ToLower() == "alphien";
|
||
|
if (flag9)
|
||
|
{
|
||
|
text = "alphien@fourelements.sg";
|
||
|
password = "alph2017";
|
||
|
displayName = "Alphien";
|
||
|
}
|
||
|
MailAddress from = new MailAddress(text, displayName);
|
||
|
this.message = new MailMessage();
|
||
|
this.message.From = from;
|
||
|
foreach (string text2 in this.Recipients.Split(new char[]
|
||
|
{
|
||
|
','
|
||
|
}))
|
||
|
{
|
||
|
string address = text2.ToLower().Replace("ls@4ecap.com", "lionel@4ecap.com");
|
||
|
this.message.To.Add(new MailAddress(address));
|
||
|
}
|
||
|
bool flag10 = this.EmailCC != null;
|
||
|
if (flag10)
|
||
|
{
|
||
|
foreach (string text3 in this.EmailCC.Split(new char[]
|
||
|
{
|
||
|
','
|
||
|
}))
|
||
|
{
|
||
|
string address2 = text3.ToLower().Replace("ls@4ecap.com", "lionel@4ecap.com");
|
||
|
this.message.CC.Add(new MailAddress(address2));
|
||
|
}
|
||
|
}
|
||
|
bool flag11 = this.EmailBCC != null;
|
||
|
if (flag11)
|
||
|
{
|
||
|
foreach (string address3 in this.EmailBCC.Split(new char[]
|
||
|
{
|
||
|
','
|
||
|
}))
|
||
|
{
|
||
|
this.message.Bcc.Add(new MailAddress(address3));
|
||
|
}
|
||
|
}
|
||
|
bool flag12 = this.EmailReplyTo != null;
|
||
|
if (flag12)
|
||
|
{
|
||
|
foreach (string address4 in this.EmailReplyTo.Split(new char[]
|
||
|
{
|
||
|
','
|
||
|
}))
|
||
|
{
|
||
|
this.message.ReplyToList.Add(new MailAddress(address4));
|
||
|
}
|
||
|
}
|
||
|
this.message.Subject = this.Subject;
|
||
|
bool phoneit = this.Phoneit;
|
||
|
if (phoneit)
|
||
|
{
|
||
|
this.message.Subject = "☎Phone: " + this.Subject;
|
||
|
}
|
||
|
bool flag13 = this.Escalation != null;
|
||
|
if (flag13)
|
||
|
{
|
||
|
bool flag14 = this.Escalation.StartsWith("Override");
|
||
|
if (flag14)
|
||
|
{
|
||
|
}
|
||
|
}
|
||
|
this.message.Body = this.Body;
|
||
|
this.message.IsBodyHtml = true;
|
||
|
bool flag15 = !ignoreAttach;
|
||
|
if (flag15)
|
||
|
{
|
||
|
bool flag16 = this.Attachments != null;
|
||
|
if (flag16)
|
||
|
{
|
||
|
foreach (string text4 in this.Attachments.Split(new char[]
|
||
|
{
|
||
|
','
|
||
|
}))
|
||
|
{
|
||
|
bool flag17 = text4.Trim() != "";
|
||
|
if (flag17)
|
||
|
{
|
||
|
Attachment item = new Attachment(text4);
|
||
|
this.message.Attachments.Add(item);
|
||
|
this.message.Priority = MailPriority.High;
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
bool flag18 = this.Images != null;
|
||
|
if (flag18)
|
||
|
{
|
||
|
string text5 = "";
|
||
|
int num = 0;
|
||
|
List<string> list = new List<string>();
|
||
|
foreach (string text6 in this.Images.Split(new char[]
|
||
|
{
|
||
|
','
|
||
|
}))
|
||
|
{
|
||
|
bool flag19 = text6.Trim() != "";
|
||
|
if (flag19)
|
||
|
{
|
||
|
Guid guid = Guid.NewGuid();
|
||
|
text5 = text5 + "<img alt='embeddedimage' src=cid:embeddedImage_" + guid.ToString() + ">";
|
||
|
list.Add(guid.ToString());
|
||
|
num++;
|
||
|
}
|
||
|
}
|
||
|
bool flag20 = this.Body.Contains("{{{IMG}}}");
|
||
|
AlternateView alternateView;
|
||
|
if (flag20)
|
||
|
{
|
||
|
alternateView = AlternateView.CreateAlternateViewFromString(this.Body.Replace("{{{IMG}}}", text5), null, "text/html");
|
||
|
}
|
||
|
else
|
||
|
{
|
||
|
alternateView = AlternateView.CreateAlternateViewFromString(this.Body + "<br/>" + text5, null, "text/html");
|
||
|
}
|
||
|
num = 0;
|
||
|
foreach (string text7 in this.Images.Split(new char[]
|
||
|
{
|
||
|
','
|
||
|
}))
|
||
|
{
|
||
|
bool flag21 = text7.Trim() != "";
|
||
|
if (flag21)
|
||
|
{
|
||
|
LinkedResource linkedResource = new LinkedResource(text7);
|
||
|
linkedResource.ContentId = "embeddedImage_" + list[num];
|
||
|
linkedResource.TransferEncoding = TransferEncoding.Base64;
|
||
|
alternateView.LinkedResources.Add(linkedResource);
|
||
|
num++;
|
||
|
}
|
||
|
}
|
||
|
this.message.AlternateViews.Add(alternateView);
|
||
|
}
|
||
|
}
|
||
|
this.sc = new SmtpClient();
|
||
|
this.sc.Host = "smtp.gmail.com";
|
||
|
this.sc.Port = 587;
|
||
|
this.sc.EnableSsl = true;
|
||
|
ServicePointManager.ServerCertificateValidationCallback += (p0, p1, p2, p3) => true;
|
||
|
bool flag22 = firstTheme.ToLower() == "etrading" || firstTheme.ToLower() == "idstrategy" || firstTheme.ToLower() == "port" || firstTheme.ToLower() == "execution" || firstTheme.ToLower() == "bb" || firstTheme.ToLower() == "quantopen" || firstTheme.ToLower() == "alphien";
|
||
|
if (flag22)
|
||
|
{
|
||
|
this.sc.Host = Settings.Default.FourElementsMailServer;
|
||
|
this.sc.Port = Settings.Default.FourElementsMailServerPort;
|
||
|
}
|
||
|
this.sc.Credentials = new NetworkCredential(text, password);
|
||
|
this.sc.SendCompleted += this.sc_SendCompleted;
|
||
|
try
|
||
|
{
|
||
|
this.SendingEmailStatus = "Processing...";
|
||
|
this.sc.Send(this.message);
|
||
|
this.SendingEmailStatus = "Sent - " + this.sc.Host + DateTime.Now.ToShortTimeString();
|
||
|
}
|
||
|
catch (Exception ex)
|
||
|
{
|
||
|
this.SendingEmailStatus = "Error - " + ex.Message;
|
||
|
bool flag23 = themeEmail.BackupEmail != "";
|
||
|
if (flag23)
|
||
|
{
|
||
|
try
|
||
|
{
|
||
|
this.sc.Credentials = new NetworkCredential(themeEmail.BackupEmail, themeEmail.BackupPassword);
|
||
|
this.SendingEmailStatus = "Backup Processing...";
|
||
|
this.sc.Send(this.message);
|
||
|
this.SendingEmailStatus = "Sent Backup- " + DateTime.Now.ToShortTimeString();
|
||
|
}
|
||
|
catch (Exception ex2)
|
||
|
{
|
||
|
this.SendingEmailStatus = "Error Backup - " + ex2.Message;
|
||
|
this.Say("Error sending email: " + this.Subject);
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
foreach (Attachment attachment in this.message.Attachments)
|
||
|
{
|
||
|
attachment.Dispose();
|
||
|
}
|
||
|
foreach (AlternateView alternateView2 in this.message.AlternateViews)
|
||
|
{
|
||
|
alternateView2.Dispose();
|
||
|
}
|
||
|
this.message.AlternateViews.Dispose();
|
||
|
this.message.Attachments.Dispose();
|
||
|
}
|
||
|
|
||
|
// Token: 0x06000128 RID: 296 RVA: 0x0000B808 File Offset: 0x00009A08
|
||
|
private void CheckSent(object state)
|
||
|
{
|
||
|
bool flag = this.SendingEmailStatus.StartsWith("Sent");
|
||
|
if (flag)
|
||
|
{
|
||
|
this.timer.Dispose();
|
||
|
}
|
||
|
else
|
||
|
{
|
||
|
try
|
||
|
{
|
||
|
this.sc.SendAsyncCancel();
|
||
|
this.SendingEmailStatus = "Retrying - " + DateTime.Now.ToShortTimeString();
|
||
|
this.sc.Send(this.message);
|
||
|
this.SendingEmailStatus = "Sent - " + this.sc.Host + DateTime.Now.ToShortTimeString();
|
||
|
Logger.Log("Sync SendCompleted: " + this.Subject + " Status: Sent", "EmailLogs", "iMonitor");
|
||
|
this.timer.Dispose();
|
||
|
}
|
||
|
catch (Exception ex)
|
||
|
{
|
||
|
this.timer.Dispose();
|
||
|
SocketClient.Send(Settings.Default.PhoneIP, Settings.Default.SpeechPort, "Unable to send emails");
|
||
|
Logger.Log("Error Speech Sent: Unable to send emails", "SpeechLogs", "iMonitor");
|
||
|
this.SendingEmailStatus = "Error - " + ex.Message;
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
|
||
|
// Token: 0x06000129 RID: 297 RVA: 0x0000B940 File Offset: 0x00009B40
|
||
|
private void sc_SendCompleted(object sender, AsyncCompletedEventArgs e)
|
||
|
{
|
||
|
string text = (string)e.UserState;
|
||
|
Logger.Log("SendCompleted: " + this.Subject + " Status:" + text, "EmailLogs", "iMonitor");
|
||
|
bool cancelled = e.Cancelled;
|
||
|
if (cancelled)
|
||
|
{
|
||
|
this.SendingEmailStatus = "Cancelled - " + text;
|
||
|
}
|
||
|
bool flag = e.Error != null;
|
||
|
if (flag)
|
||
|
{
|
||
|
this.SendingEmailStatus = "Error - " + text;
|
||
|
}
|
||
|
else
|
||
|
{
|
||
|
this.SendingEmailStatus = "Sent - " + DateTime.Now.ToShortTimeString();
|
||
|
}
|
||
|
foreach (Attachment attachment in this.message.Attachments)
|
||
|
{
|
||
|
attachment.Dispose();
|
||
|
}
|
||
|
foreach (AlternateView alternateView in this.message.AlternateViews)
|
||
|
{
|
||
|
alternateView.Dispose();
|
||
|
}
|
||
|
this.message.AlternateViews.Dispose();
|
||
|
this.message.Attachments.Dispose();
|
||
|
}
|
||
|
|
||
|
// Token: 0x0600012A RID: 298 RVA: 0x0000BAA0 File Offset: 0x00009CA0
|
||
|
public static string GetAlarmXML(string subject, List<string> themes, string body, string overridealarmlevel = "NULL", bool say = true, bool email = true, string phone = "AUTO-m", int escalateTicks = 5, int escalateInterval = 15, string uri = "http://4ecappcsg11:5001/Convertor.aspx")
|
||
|
{
|
||
|
string text = "<IMONITOR>";
|
||
|
text = text + "<SUBJECT>" + subject + "</SUBJECT>";
|
||
|
foreach (string str in themes)
|
||
|
{
|
||
|
text = text + "<THEME>" + str + "</THEME>";
|
||
|
}
|
||
|
text = text + "<BODY>" + body + "</BODY>";
|
||
|
text = text + "<OVERRIDEALARMLEVEL>" + overridealarmlevel + "</OVERRIDEALARMLEVEL>";
|
||
|
text = text + "<SAY>" + say.ToString().ToUpper() + "</SAY>";
|
||
|
text = text + "<EMAIL>" + email.ToString().ToUpper() + "</EMAIL>";
|
||
|
text = text + "<PHONE>" + phone + "</PHONE>";
|
||
|
text = text + "<ESCALATETICKS>" + escalateTicks.ToString() + "</ESCALATETICKS>";
|
||
|
text = text + "<ESCALATEINTERVAL>" + escalateInterval.ToString() + "</ESCALATEINTERVAL>";
|
||
|
text += "</IMONITOR>";
|
||
|
Uri address = new Uri(uri);
|
||
|
string result;
|
||
|
using (WebClient webClient = new WebClient())
|
||
|
{
|
||
|
string text2 = webClient.UploadString(address, "POST", text);
|
||
|
result = text2;
|
||
|
}
|
||
|
return result;
|
||
|
}
|
||
|
|
||
|
// Token: 0x040000C9 RID: 201
|
||
|
private ThemeEmails themeEmails;
|
||
|
|
||
|
// Token: 0x040000CA RID: 202
|
||
|
private MailMessage message;
|
||
|
|
||
|
// Token: 0x040000CB RID: 203
|
||
|
private SmtpClient sc;
|
||
|
|
||
|
// Token: 0x040000CC RID: 204
|
||
|
private Dictionary<string, string> dick;
|
||
|
|
||
|
// Token: 0x040000CD RID: 205
|
||
|
private Timer timer;
|
||
|
}
|
||
|
}
|