internal BroadcastMessageFactory() { this.loMessage = new LOMessage(); this.pdMessage = new PDMessage(); this.scMessage = new SCMessage(); this.aaMessage = new AAMessage(); this.nhMessage = new NHMessage(); this.broadcastMessageClient = new BroadCastOrderMessageClient(); this.dgwOrderReply = new DGWOrderReplyMessage(); }
private void timerGetOrderInfo_Tick(object sender, EventArgs e) { try { if (ApplicationInfo.AutoGetOrderNoList.Count > 0) { this.timerGetOrderInfo.Enabled = false; string text = string.Empty; List<string> list = new List<string>(); foreach (KeyValuePair<string, DateTime> current in ApplicationInfo.AutoGetOrderNoList) { if (current.Value.AddSeconds((double)ApplicationInfo.AutoGetOrderInfoInterval) < DateTime.Now) { text = text + "," + current.Key; list.Add(current.Key); } } foreach (string current2 in list) { ApplicationInfo.RemoveOrderNoFromAutoRefreshList(current2, ""); } list.Clear(); list = null; if (text.Length > 0) { text = text.Substring(1); } if (!string.IsNullOrEmpty(text)) { string text2 = ApplicationInfo.WebOrderService.ViewOrderByOrderNo(ApplicationInfo.AccInfo.CurrentAccount, text); if (!string.IsNullOrEmpty(text2)) { using (DataSet dataSet = new DataSet()) { MyDataHelper.StringToDataSet(text2, dataSet); if (dataSet.Tables.Contains("ORDERS")) { long volume = 0L; long matchedVolume = 0L; long num = 0L; long orderNumber = 0L; string text3 = string.Empty; decimal priceForCal = 0m; decimal matcedValue = 0m; string approverId = string.Empty; string sendDate = string.Empty; string orderTime = string.Empty; foreach (DataRow dataRow in dataSet.Tables["ORDERS"].Rows) { long.TryParse(dataRow["order_number"].ToString(), out orderNumber); long.TryParse(dataRow["volume"].ToString(), out volume); long.TryParse(dataRow["matched_volume"].ToString(), out matchedVolume); long.TryParse(dataRow["pub_vol"].ToString(), out num); text3 = Utilities.PriceFormat(dataRow["price_to_set"].ToString()); decimal.TryParse(dataRow["price"].ToString(), out priceForCal); decimal.TryParse(dataRow["matched_value"].ToString(), out matcedValue); orderTime = Utilities.GetTime(dataRow["order_time"].ToString()); if (dataRow.Table.Columns.Contains("bitApproval")) { if (dataRow["bitApproval"].ToString().Trim() == "1" || dataRow["bitApproval"].ToString().Trim().ToUpper() == "TRUE") { approverId = "APP"; } else { approverId = string.Empty; } } if (dataRow.Table.Columns.Contains("sSendDate")) { sendDate = dataRow["sSendDate"].ToString(); } string str = string.Empty; if (ApplicationInfo.SupportFreewill && dataSet.Tables.Contains("TABREF")) { DataRow[] array = dataSet.Tables["TABREF"].Select("iFisOrdNo=" + dataRow["order_number"].ToString()); if (array.Length > 0) { str = array[0]["iRefOrdNo"].ToString(); } } string message = new OrderInfoClient().Pack("", "", "R" + str, orderNumber, dataRow["side"].ToString(), dataRow["stock"].ToString(), volume, text3, priceForCal, matchedVolume, matcedValue, num, ApplicationInfo.AccInfo.CurrentAccount, dataRow["trustee_id"].ToString(), "", dataRow["status"].ToString(), dataRow["quote"].ToString(), orderTime, "", 0m, "1I", 0L, "", approverId, sendDate); IBroadcastMessage message2 = this._bcMessageFactory.CreateSETMessage(message); if (frmMain._OnMessageReceived != null) { frmMain._OnMessageReceived(message2, null); } } } if (ApplicationInfo.SupportFreewill) { if (dataSet.Tables.Contains("FAIL_ORD") && dataSet.Tables["FAIL_ORD"].Rows.Count > 0) { foreach (DataRow dataRow in dataSet.Tables["FAIL_ORD"].Rows) { string[] array2 = dataRow["item"].ToString().Split(new char[] { '#' }); string message = new BroadCastOrderMessageClient().Pack(array2[5], "", "", "RF", "", string.Concat(new string[] { "Sending command fails, ", Utilities.GetOrderSideName(array2[1]), " ", array2[2], " at ", array2[4], "@ vol ", array2[3], ", Account ", array2[5] })); IBroadcastMessage message2 = this._bcMessageFactory.CreateSETMessage(message); if (frmMain._OnMessageReceived != null) { frmMain._OnMessageReceived(message2, null); } } } if (dataSet.Tables.Contains("OFFLINE") && dataSet.Tables["OFFLINE"].Rows.Count > 0) { string text3 = string.Empty; string orderTime = string.Empty; string sendDate = string.Empty; decimal priceForCal = 0m; foreach (DataRow dataRow in dataSet.Tables["OFFLINE"].Rows) { long orderNumber; long.TryParse(dataRow["orderno"].ToString(), out orderNumber); long volume; long.TryParse(dataRow["volume"].ToString(), out volume); long num; long.TryParse(dataRow["pubvolume"].ToString(), out num); string text4 = dataRow["conditionprice"].ToString().Trim(); if (text4 == null) { goto IL_888; } if (!(text4 == "A")) { if (!(text4 == "C")) { if (!(text4 == "M")) { if (!(text4 == "K")) { if (!(text4 == "L")) { goto IL_888; } text3 = "ML"; } else { text3 = "MO"; } } else { text3 = "MP"; } } else { text3 = "ATC"; } } else { text3 = "ATO"; } IL_8C3: orderTime = Utilities.GetTime(dataRow["ordertime"].ToString()); sendDate = dataRow["orderdate"].ToString(); string message = new OrderInfoClient().Pack("", "", "OFFLINE", orderNumber, dataRow["side"].ToString(), dataRow["secsymbol"].ToString(), volume, text3, priceForCal, 0L, 0m, num, ApplicationInfo.AccInfo.CurrentAccount, dataRow["trusteeid"].ToString(), "", dataRow["orderstatus"].ToString(), "", orderTime, "", 0m, "1I", 0L, "", "", sendDate); IBroadcastMessage message2 = this._bcMessageFactory.CreateSETMessage(message); if (frmMain._OnMessageReceived != null) { frmMain._OnMessageReceived(message2, null); } continue; IL_888: text3 = Utilities.PriceFormat(dataRow["price"].ToString().Trim()); decimal.TryParse(dataRow["price"].ToString(), out priceForCal); goto IL_8C3; } } } dataSet.Clear(); } } } text = null; } if (ApplicationInfo.AutoGetOrderNoList_TFEX.Count > 0) { string text = string.Empty; foreach (KeyValuePair<string, DateTime> current in ApplicationInfo.AutoGetOrderNoList_TFEX) { if (current.Value.AddSeconds((double)ApplicationInfo.AutoGetOrderInfoInterval) < DateTime.Now) { text = text + "," + current.Key; } } if (text.Length > 0) { text = text.Substring(1); } if (!string.IsNullOrEmpty(text)) { string text2 = ApplicationInfo.WebServiceTFEX.ViewOrderByOrderNo(ApplicationInfo.AccInfo.CurrentAccount, text); if (!string.IsNullOrEmpty(text2)) { using (DataSet dataSet = new DataSet()) { MyDataHelper.StringToDataSet(text2, dataSet); if (dataSet.Tables.Contains("ORDERS")) { long volume = 0L; long matchedVolume = 0L; long num = 0L; long orderNumber = 0L; string text3 = string.Empty; decimal priceForCal = 0m; string orderTime = string.Empty; string sendDate2 = string.Empty; for (int i = 0; i < dataSet.Tables["ORDERS"].Rows.Count; i++) { DataRow dataRow = dataSet.Tables["ORDERS"].Rows[i]; long.TryParse(dataRow["order_number"].ToString(), out orderNumber); long.TryParse(dataRow["volume"].ToString(), out volume); long.TryParse(dataRow["matched_volume"].ToString(), out matchedVolume); long.TryParse(dataRow["pub_vol"].ToString(), out num); text3 = Utilities.PriceFormat(dataRow["price_to_set"].ToString()); decimal.TryParse(dataRow["price"].ToString(), out priceForCal); orderTime = Utilities.GetTime(dataRow["order_time"].ToString()); sendDate2 = dataRow["sSendDate"].ToString(); string message = new OrderTFEXInfoClient().Pack("", ApplicationInfo.AccInfo.CurrentAccount, orderNumber.ToString(), dataRow["position"].ToString(), dataRow["side"].ToString(), dataRow["series"].ToString().Trim(), volume, text3, matchedVolume, num, dataRow["status"].ToString().Trim(), orderTime, dataRow["quote"].ToString().Trim(), sendDate2, dataRow["sOrdType"].ToString(), 0L, "", ""); IBroadcastMessage message2 = this._bcMessageFactory.CreateTfexMessage(message); if (frmMain._OnMessageTfexReceived != null) { frmMain._OnMessageTfexReceived(message2, null); } ApplicationInfo.RemoveOrderNoFromAutoRefreshList_TFEX(orderNumber.ToString()); } } dataSet.Clear(); } } } text = null; } } catch (Exception ex) { this.ShowError("timerGetOrderInfo_Tick", ex); } this.timerGetOrderInfo.Enabled = true; }