iMonitor desktop application using dotnet 4.8
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.

351 lines
11 KiB

2 weeks ago
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Diagnostics;
using System.Drawing;
using System.Media;
using System.Net;
using System.Text;
using System.Threading;
using System.Timers;
using System.Windows.Forms;
using iMonitorAPI;
using iMonitorApp.Classes;
using iMonitorApp.Properties;
namespace iMonitorApp
{
// Token: 0x0200001C RID: 28
public partial class ParentForm : Form
{
// Token: 0x060000C9 RID: 201 RVA: 0x00008E3C File Offset: 0x0000703C
public ParentForm()
{
this.InitializeComponent();
Settings.Default.CurrentIP = Config.GetIP4Address();
this.pdForm = new PhoneDialer(this);
this.pdForm.MdiParent = this;
this.pdForm.Show();
new StackAlarm
{
MdiParent = this
}.Show();
this.backgroundWorker1.WorkerReportsProgress = true;
this.backgroundWorker1.DoWork += this.backgroundWorker1_DoWork;
this.backgroundWorker1.RunWorkerCompleted += this.backgroundWorker1_RunWorkerCompleted;
this.marketAlertTimer = new System.Threading.Timer(new TimerCallback(this.MarketAlertProc), null, 100, Settings.Default.TimerMarketDataChecks * 1000);
this.tradeAlertTimer = new System.Threading.Timer(new TimerCallback(this.TradeAlertProc), null, 100, Settings.Default.TimerTradeChecks * 1000);
this.heartBeatTimer = new System.Threading.Timer(new TimerCallback(this.SendAMHeartBeat), null, 100, Settings.Default.ExternalHeartbeatTimer * 1000);
}
// Token: 0x060000CA RID: 202 RVA: 0x00008F88 File Offset: 0x00007188
private void iTradeTimer_Elapsed(object sender, ElapsedEventArgs e)
{
throw new NotImplementedException();
}
// Token: 0x060000CB RID: 203 RVA: 0x00008F90 File Offset: 0x00007190
private void backgroundWorker1_RunWorkerCompleted(object sender, RunWorkerCompletedEventArgs e)
{
this.tss_working.Text = "market data check complete";
}
// Token: 0x060000CC RID: 204 RVA: 0x00008FA4 File Offset: 0x000071A4
private void ExitToolsStripMenuItem_Click(object sender, EventArgs e)
{
this.isClosing = true;
Application.Exit();
Environment.Exit(0);
}
// Token: 0x060000CD RID: 205 RVA: 0x00008FBC File Offset: 0x000071BC
private void optionsToolStripMenuItem_Click(object sender, EventArgs e)
{
SettingsForm settingsForm = new SettingsForm();
settingsForm.ShowDialog();
}
// Token: 0x060000CE RID: 206 RVA: 0x00008FD8 File Offset: 0x000071D8
public void SendAMHeartBeat(object state)
{
bool primary = Settings.Default.Primary;
if (primary)
{
try
{
Stopwatch stopwatch = new Stopwatch();
stopwatch.Start();
this.Status("Sending Heartbeat...", "tss_heartbeat", Color.Yellow);
HttpWebRequest httpWebRequest = (HttpWebRequest)WebRequest.Create(Settings.Default.ExternalHeartbeatURL);
string str = Convert.ToBase64String(Encoding.ASCII.GetBytes(Settings.Default.ExternalHeartbeatUsername + ":" + Settings.Default.ExternalHeartbeatPassword));
httpWebRequest.Headers.Add("Authorization", "Basic " + str);
httpWebRequest.ReadWriteTimeout = 20000;
httpWebRequest.Timeout = 20000;
httpWebRequest.Method = "GET";
this.Status("Waiting For Response..", "tss_heartbeat", Color.Orange);
HttpWebResponse httpWebResponse = (HttpWebResponse)httpWebRequest.GetResponse();
stopwatch.Stop();
this.Status(httpWebResponse.StatusDescription + stopwatch.Elapsed.TotalSeconds.ToString() + " secs", "tss_heartbeat", Color.Green);
httpWebResponse.Close();
httpWebRequest.Abort();
}
catch (Exception ex)
{
this.Status("Unable to send heartbeat at " + DateTime.Now.ToString() + " Error:" + ex.Message, "tss_heartbeat", Color.Red);
}
}
}
// Token: 0x060000CF RID: 207 RVA: 0x00009170 File Offset: 0x00007370
private void notifyIcon1_MouseDoubleClick(object sender, MouseEventArgs e)
{
bool flag = e.Button == MouseButtons.Left;
if (flag)
{
base.Show();
base.WindowState = this.lastWindowState;
}
}
// Token: 0x060000D0 RID: 208 RVA: 0x000091A8 File Offset: 0x000073A8
private void ParentForm_FormClosing(object sender, FormClosingEventArgs e)
{
bool flag = this.isClosing;
if (!flag)
{
e.Cancel = true;
base.Hide();
this.notifyIcon1.ShowBalloonTip(3000, "iMonitor!!", "iMonitor is still running. \r\nDoubleClick to access.", ToolTipIcon.Info);
}
}
// Token: 0x060000D1 RID: 209 RVA: 0x000091F0 File Offset: 0x000073F0
private void ParentForm_Resize(object sender, EventArgs e)
{
bool flag = base.WindowState == FormWindowState.Minimized;
if (flag)
{
base.ShowInTaskbar = false;
}
else
{
base.ShowInTaskbar = true;
}
}
// Token: 0x060000D2 RID: 210 RVA: 0x0000921D File Offset: 0x0000741D
private void backgroundWorker1_DoWork(object sender, DoWorkEventArgs e)
{
new MarketData().CheckAlarms();
}
// Token: 0x060000D3 RID: 211 RVA: 0x0000922B File Offset: 0x0000742B
private void testToolStripMenuItem_Click(object sender, EventArgs e)
{
this.backgroundWorker1.RunWorkerAsync();
}
// Token: 0x060000D4 RID: 212 RVA: 0x0000923C File Offset: 0x0000743C
private void TradeAlertProc(object state)
{
bool flag = !Settings.Default.Primary;
if (!flag)
{
CountdownEvent countdownEvent = new CountdownEvent(6);
new Thread(delegate()
{
this.Status(TradeAlerts.CheckWorkingOrders(), "tss_working", Color.Transparent);
countdownEvent.Signal();
}).Start();
new Thread(delegate()
{
this.Status(TradeAlerts.CheckNewOrders(), "tss_new", Color.Transparent);
countdownEvent.Signal();
}).Start();
new Thread(delegate()
{
this.Status(TradeAlerts.CheckBaskets(), "tss_basket", Color.Transparent);
countdownEvent.Signal();
}).Start();
new Thread(delegate()
{
this.Status(TradeAlerts.CheckOutbox(), "tss_outbox", Color.Transparent);
countdownEvent.Signal();
}).Start();
new Thread(delegate()
{
this.Status(TradeAlerts.CheckGun(), "tss_gun", Color.Transparent);
countdownEvent.Signal();
}).Start();
countdownEvent.Wait();
}
}
// Token: 0x060000D5 RID: 213 RVA: 0x000092F8 File Offset: 0x000074F8
private void MarketAlertProc(object state)
{
bool flag = !Settings.Default.Primary;
if (!flag)
{
CountdownEvent countdownEvent = new CountdownEvent(1);
new Thread(delegate()
{
MarketData marketData = new MarketData();
this.Status(marketData.CheckAlarms(), "tss_market", Color.Transparent);
countdownEvent.Signal();
}).Start();
countdownEvent.Wait();
}
}
// Token: 0x060000D6 RID: 214 RVA: 0x00009355 File Offset: 0x00007555
private void tileToolStripMenuItem_Click(object sender, EventArgs e)
{
base.LayoutMdi(MdiLayout.TileVertical);
}
// Token: 0x060000D7 RID: 215 RVA: 0x00009360 File Offset: 0x00007560
public void Status(string msg, string labelname, Color c)
{
StatusStrip statusStrip = (StatusStrip)base.Controls["statusStrip"];
ToolStripStatusLabel toolStripStatusLabel = (ToolStripStatusLabel)statusStrip.Items[labelname];
bool flag = !statusStrip.IsHandleCreated;
if (flag)
{
IntPtr handle = statusStrip.Handle;
}
bool invokeRequired = statusStrip.InvokeRequired;
if (invokeRequired)
{
statusStrip.Invoke(new ParentForm.updateTextCallback(this.updateText), new object[]
{
msg,
labelname,
c
});
}
else
{
toolStripStatusLabel.Text = msg;
statusStrip.Refresh();
}
}
// Token: 0x060000D8 RID: 216 RVA: 0x000093F8 File Offset: 0x000075F8
private void updateText(string text, string labelname, Color c)
{
StatusStrip statusStrip = (StatusStrip)base.Controls["statusStrip"];
ToolStripStatusLabel toolStripStatusLabel = (ToolStripStatusLabel)statusStrip.Items[labelname];
toolStripStatusLabel.Text = text;
toolStripStatusLabel.BackColor = c;
}
// Token: 0x060000D9 RID: 217 RVA: 0x00009440 File Offset: 0x00007640
private void aboutToolStripMenuItem_Click(object sender, EventArgs e)
{
AboutBox1 aboutBox = new AboutBox1();
aboutBox.ShowDialog();
}
// Token: 0x060000DA RID: 218 RVA: 0x0000945B File Offset: 0x0000765B
private void phoneDialerToolStripMenuItem_Click(object sender, EventArgs e)
{
this.pdForm.Show();
}
// Token: 0x060000DB RID: 219 RVA: 0x0000946C File Offset: 0x0000766C
private void FixingAlertProc(object state)
{
try
{
bool flag = (DateTime.Now - new DateTime(DateTime.Now.Year, DateTime.Now.Month, DateTime.Now.Day, 7, 25, 0)).TotalSeconds <= 11.0 && (DateTime.Now - new DateTime(DateTime.Now.Year, DateTime.Now.Month, DateTime.Now.Day, 7, 25, 0)).TotalSeconds > 0.0;
if (flag)
{
this._fixings = new Fixings();
this._fixings.GetFixings("EE02");
this._fixings.GetFixings("RIN02");
this._doneAlready.Clear();
}
foreach (KeyValuePair<DateTime, List<string>> keyValuePair in this._fixings.fixings)
{
bool flag2 = (keyValuePair.Key - DateTime.Now).TotalSeconds < 11.0 && (keyValuePair.Key - DateTime.Now).TotalSeconds > 0.0;
if (flag2)
{
new SoundPlayer(Resources.OpeningBellRingTone).Play();
bool flag3 = this._doneAlready.Count >= this._fixings.fixings.Count || (DateTime.Now.TimeOfDay < new TimeSpan(7, 0, 0) && DateTime.Now.TimeOfDay >= new TimeSpan(6, 59, 50));
if (flag3)
{
}
}
bool flag4 = (keyValuePair.Key - DateTime.Now).TotalMinutes < 11.0 && (keyValuePair.Key - DateTime.Now).TotalMinutes > 1.0 && !this._doneAlready.ContainsKey(keyValuePair.Key);
if (flag4)
{
iMonitor.SendAlarm(string.Join(",", keyValuePair.Value) + " Fixing in 10 minutes", new List<string>
{
"etrading"
}, "l", "NULL", true, false, "FALSE", 5, 15, "http://10.153.64.31:5001/iMonitor/Responder.aspx");
this._doneAlready.Add(keyValuePair.Key, keyValuePair.Value);
}
bool flag5 = (keyValuePair.Key - DateTime.Now).TotalMinutes < 0.0;
if (flag5)
{
bool flag6 = !this._doneAlready.ContainsKey(keyValuePair.Key);
if (flag6)
{
this._doneAlready.Add(keyValuePair.Key, keyValuePair.Value);
}
}
}
}
catch
{
}
}
// Token: 0x060000DC RID: 220 RVA: 0x000038AE File Offset: 0x00001AAE
private void FixingRefillAlertProc(object state)
{
}
// Token: 0x0400008A RID: 138
private int childFormNumber = 0;
// Token: 0x0400008B RID: 139
private FormWindowState lastWindowState;
// Token: 0x0400008C RID: 140
private TradeAlerts ta = new TradeAlerts();
// Token: 0x0400008D RID: 141
private System.Threading.Timer tradeAlertTimer;
// Token: 0x0400008E RID: 142
private System.Threading.Timer marketAlertTimer;
// Token: 0x0400008F RID: 143
private System.Threading.Timer fixingsTimer;
// Token: 0x04000090 RID: 144
private System.Threading.Timer fixingsReFillTimer;
// Token: 0x04000091 RID: 145
private System.Threading.Timer heartBeatTimer;
// Token: 0x04000092 RID: 146
private PhoneDialer pdForm;
// Token: 0x04000093 RID: 147
private Fixings _fixings;
// Token: 0x04000094 RID: 148
private bool isClosing = false;
// Token: 0x04000095 RID: 149
private Dictionary<DateTime, List<string>> _doneAlready = new Dictionary<DateTime, List<string>>();
// Token: 0x02000040 RID: 64
// (Invoke) Token: 0x0600021B RID: 539
public delegate void updateTextCallback(string text, string labelname, Color c);
}
}