private void OnAlert(AlertItem e) { if (base.InvokeRequired) { base.Invoke(new frmMain.OnAlertCallback(this.OnAlert), new object[] { e }); } else { try { this.CreateAlertDetailForm(); this._alertDetailForm.AddAlertItem(e); if (ApplicationInfo.AlertAutoPopup) { this._alertDetailForm.Show(); this._alertDetailForm.BringToFront(); } else { this.MarketStateBox.IsAllowBlinkAlert = true; this.MarketStateBox.AlterMessageCount++; } if (ApplicationInfo.AlertSound) { ApplicationInfo.Beep(500, 200); } } catch (Exception ex) { this.ShowError("OnAlert", ex); } } }
public AlertItem(AlertItem item) { this.symbol = item.symbol; this.isReaded = item.IsReaded; this.fieldCondition = item.Field; this.operatorCondition = item.Operator; this.valueCondition = item.Value; this.valueMessageRealtime = item.ValueMessageRealtime; }
internal frmAlertDetail(AlertItem alertItem) { this.InitializeComponent(); }
internal void AddAlertItem(AlertItem item) { try { if (this.lvDetailAlert.InvokeRequired) { this.lvDetailAlert.Invoke(new frmAlertDetail.AddAlertItemCallback(this.AddAlertItem), new object[] { item }); } else { ListViewItem listViewItem = new ListViewItem(); listViewItem.Text = item.Symbol; if (item.Field.ToLower() == "%change") { listViewItem.SubItems.Add(string.Concat(new string[] { item.Field, " >= ", Utilities.PriceFormat(item.Value), ", Current = ", Utilities.PriceFormat(item.ValueMessageRealtime) })); } else { listViewItem.SubItems.Add(string.Concat(new string[] { item.Field, " ", item.Operator, " ", Utilities.PriceFormat(item.Value), ", Current = ", Utilities.PriceFormat(item.ValueMessageRealtime) })); } listViewItem.SubItems.Add(DateTime.Now.ToLongTimeString()); listViewItem.Tag = item; if (this.lvDetailAlert != null) { this.lvDetailAlert.Items.Insert(0, listViewItem); } this.UpdateRowCountLabel(); } } catch (Exception ex) { this.ShowError("AddAlertItem", ex); } }
private void btnPCupdate_Click(object sender, EventArgs e) { try { decimal d = 0m; if (!decimal.TryParse(this.tbValuePc.Text, out d)) { this.ShowMessage("Invalid value!"); this.tbValuePc.Focus(); } else { string text = this.tbStockPc.Text.Trim().ToUpper(); string text2 = this.cbFieldPc.Text; string text3 = this.cbOperatorPc.Text; bool flag; if (text != string.Empty) { StockList.StockInformation stockInformation = ApplicationInfo.StockInfo[text]; if (stockInformation.Number > 0) { flag = true; } else if (ApplicationInfo.IsSupportTfex) { SeriesList.SeriesInformation seriesInformation = ApplicationInfo.SeriesInfo[text.ToUpper()]; flag = !string.IsNullOrEmpty(seriesInformation.Symbol); } else { flag = false; } } else { flag = false; } if (flag) { int num = -1; RecordItem recordItem; for (int i = 0; i < this.intzaPC.Rows; i++) { recordItem = this.intzaPC.Records(i); if (recordItem.Fields("stock").Text.ToString() == text && recordItem.Fields("field").Text.ToString() == text2 && recordItem.Fields("operator").Text.ToString() == text3) { num = i; break; } } if (num > -1) { recordItem = this.intzaPC.Records(num); } else { recordItem = this.intzaPC.AddRecord(-1, false); } recordItem.Fields("stock").Text = text; recordItem.Fields("field").Text = text2; recordItem.Fields("operator").Text = text3; recordItem.Fields("value").Text = d.ToString(); recordItem.Fields("alert_time").Text = ""; recordItem.Fields("value_at_alert").Text = ""; this.intzaPC.Redraw(); AlertItem alertItem = null; if (!AlertManager.Instance.Symbols.ContainsKey(text)) { AlertManager.Instance.Symbols.Add(text, new AlertItemCollection()); } else { foreach (AlertItem current in AlertManager.Instance.Symbols[text]) { if (current.Field == text2 && current.Operator == text3) { alertItem = current; break; } } } if (alertItem == null) { alertItem = new AlertItem(); alertItem.Symbol = text; alertItem.Field = text2; if (text2 == "%Change") { if (d > 0m) { text3 = ">="; } else { text3 = "<="; } } alertItem.Operator = text3; AlertManager.Instance.Symbols[alertItem.Symbol].Add(alertItem); } alertItem.Value = d.ToString(); alertItem.IsReaded = false; alertItem.AlertTime = DateTime.MinValue; alertItem.ValueMessageRealtime = string.Empty; } else { this.ShowMessage("Invalid Stock!"); this.tbStockPc.Focus(); } } } catch (Exception ex) { this.ShowError("btnAlertAdd_Click", ex); } }
private void ImportFromXML(DataSet ds) { try { if (ds.Tables[0].Rows.Count > 0) { lock (this.symbols) { string key = string.Empty; try { bool flag = ds.Tables[0].Columns.Contains("AlertTime"); bool flag2 = ds.Tables[0].Columns.Contains("AlertValue"); for (int i = 0; i < ds.Tables[0].Rows.Count; i++) { key = ds.Tables[0].Rows[i]["Symbol"].ToString(); if (!this.symbols.ContainsKey(key)) { this.symbols.Add(key, new AlertItemCollection()); } AlertItem alertItem = new AlertItem(); alertItem.Symbol = ds.Tables[0].Rows[i]["Symbol"].ToString(); alertItem.Field = ds.Tables[0].Rows[i]["ColumnsAlert"].ToString(); alertItem.Operator = ds.Tables[0].Rows[i]["Operator"].ToString(); alertItem.Value = ds.Tables[0].Rows[i]["Values"].ToString(); alertItem.IsReaded = false; if (flag && !string.IsNullOrEmpty(ds.Tables[0].Rows[i]["AlertTime"].ToString())) { alertItem.AlertTime = Convert.ToDateTime(ds.Tables[0].Rows[i]["AlertTime"].ToString()); } else { alertItem.AlertTime = DateTime.MinValue; } if (flag2 && !string.IsNullOrEmpty(ds.Tables[0].Rows[i]["AlertValue"].ToString())) { alertItem.ValueMessageRealtime = ds.Tables[0].Rows[i]["AlertValue"].ToString(); } else { alertItem.ValueMessageRealtime = string.Empty; } this.symbols[alertItem.Symbol].Add(alertItem); } } catch (Exception ex) { throw ex; } } } } catch (Exception ex) { throw ex; } }
private bool ConditionCompare(AlertItem alertItem, long itemValue) { bool result = false; long num; long.TryParse(alertItem.Value, out num); if (alertItem.Operator == "=") { result = (itemValue == num); } else if (alertItem.Operator == ">=") { result = (itemValue >= num); } else if (alertItem.Operator == "<=") { result = (itemValue <= num); } return result; }
private bool ConditionCompare(AlertItem alertItem, decimal itemValue) { bool result = false; decimal d; decimal.TryParse(alertItem.Value, out d); if (alertItem.Operator == "=") { result = (Math.Round(itemValue, 4) == Math.Round(d, 4)); } else if (alertItem.Operator == ">=") { result = (Math.Round(itemValue, 4) >= Math.Round(d, 4)); } else if (alertItem.Operator == "<=") { result = (Math.Round(itemValue, 4) <= Math.Round(d, 4)); } return result; }
internal void MarkUnRead(string symbol, AlertItem item) { AlertItemCollection alertItemCollection = null; if (this.symbols.TryGetValue(symbol, out alertItemCollection)) { if (alertItemCollection.Contains(item)) { item.IsReaded = false; } } }