private void btnSave_Click(object sender, EventArgs e) { try { bool ischek = false; foreach (DataGridViewRow row in dataGridViewData.Rows) { if (Convert.ToBoolean(row.Cells["chkCol"].Value)) { ischek = true; } } if (!ischek) { MessageBox.Show("请先选择要监听的用户"); return; } double lots; double rate; if (!double.TryParse(textBoxMonLots.Text, out lots)) { MessageBox.Show("输入Monlots有误 int!"); return; } if (!double.TryParse(textBoxMonRate.Text, out rate)) { MessageBox.Show("输入MonRate有误 double!"); return; } if (lots >= 100 || lots <= -50) { MessageBox.Show("您设置的手数过大,请重新设置"); return; } loading.ShowLoading(); MonitorSetting setting = new MonitorSetting(); setting.DateTimePriceMonStartTime = dateTimePriceMonStartTime.Value; setting.DateTimePickerMonEndTime = dateTimePickerMonEndTime.Value; setting.TextBoxMonLots = lots; setting.TextBoxMonRate = rate; foreach (DataGridViewRow row in dataGridViewData.Rows) { if (Convert.ToBoolean(row.Cells["chkCol"].Value)) { row.Cells["colMonLots"].Value = (row.Cells["colMonLots"].Value == null ? string.Empty : row.Cells["colMonLots"].Value.ToString() + ",") + lots; row.Cells["colMonRate"].Value = (row.Cells["colMonRate"].Value == null ? string.Empty : row.Cells["colMonRate"].Value.ToString() + ",") + rate; } } queueSetting.Enqueue(setting); DisplayQueue(setting); loading.HideLoading(); WriteLogs("设置成功添加到队列"); } catch (Exception ex) { loading.HideLoading(); _log.Error(ex); } }
public void SetMonitorWighttSixteenOnNine_PossitiveTest(double WightMonitor, ScreenRatio screenRatio) { var monitor = new MonitorSetting(); monitor.ScreenRatio = screenRatio; monitor.MonitorWight = WightMonitor; }
public void SetStandHeightSixteenOnNine_PossitiveTest(double HeightStand, ScreenRatio screenRatio) { var monitor = new MonitorSetting(); monitor.ScreenRatio = screenRatio; monitor.StandHeight = HeightStand; }
public void SetRadiusSixteenOnNine_PossitiveTest(double Radius, ScreenRatio screenRatio) { var monitor = new MonitorSetting(); monitor.ScreenRatio = screenRatio; monitor.Radius = Radius; }
private void DisplayQueue(MonitorSetting setting) { int index = dataGridViewQueue.Rows.Add(); dataGridViewQueue.Rows[index].Cells["colDataTimePriceMonStartTime"].Value = setting.DateTimePriceMonStartTime; dataGridViewQueue.Rows[index].Cells["colDateTimePickerMonEndTime"].Value = setting.DateTimePickerMonEndTime; dataGridViewQueue.Rows[index].Cells["colTextBoxMonLots"].Value = setting.TextBoxMonLots; dataGridViewQueue.Rows[index].Cells["colTextBoxMonRate"].Value = setting.TextBoxMonRate; }
public void SetMonitorWightSixteenOnNine_NegativTest(double WightMonitor, ScreenRatio screenRatio) { var monitor = new MonitorSetting(); monitor.ScreenRatio = screenRatio; Assert.Throws <MonitorSettings.ExceptionFolder.WightMonitorException>(() => monitor.MonitorWight = WightMonitor); }
public void SetRadiusSixteenOnNine_NegativTest(double Radius, ScreenRatio screenRatio) { var monitor = new MonitorSetting(); monitor.ScreenRatio = screenRatio; Assert.Throws <MonitorSettings.ExceptionFolder.RadiusException>(() => monitor.Radius = Radius); }
public void SetStandrWightSixteenOnNine_NegativTest(double WightStand , ScreenRatio screenRatio) { var monitor = new MonitorSetting(); monitor.ScreenRatio = ScreenRatio.SixteenOnNine; Assert.Throws <MonitorSettings.ExceptionFolder.WightStandeException>(() => monitor.StandeWight = WightStand); }
public void SetStandHeightThreeByTwo_NegativTest(double HeightStand, ScreenRatio screenRatio) { var monitor = new MonitorSetting(); monitor.ScreenRatio = screenRatio; Assert.Throws <MonitorSettings.ExceptionFolder.HeightStandeException>(() => monitor.StandHeight = HeightStand); }
private void RemoveQueue(MonitorSetting setting) { this.BeginInvoke((MethodInvoker)(() => { foreach (DataGridViewRow row in dataGridViewQueue.Rows) { if (Convert.ToDateTime(row.Cells["colDataTimePriceMonStartTime"].Value) == setting.DateTimePriceMonStartTime && Convert.ToDateTime(row.Cells["colDateTimePickerMonEndTime"].Value) == setting.DateTimePickerMonEndTime && Convert.ToInt32(row.Cells["colTextBoxMonLots"].Value) == setting.TextBoxMonLots && Convert.ToDouble(row.Cells["colTextBoxMonRate"].Value) == setting.TextBoxMonRate) { dataGridViewQueue.Rows.Remove(row); break; } } })); }
/// <summary> /// /// </summary> /// <param name="settings">Параметры монитора</param> public void SetParametr(MonitorSetting settings) { _monitorSetting = settings; }
private void ShowSettingDialog() { var dialog = new MonitorSetting(); dialog.ShowDialog(); }
private void MonPrice(List <TxtParamClass> listMonitors) { WriteLogs("开启价格处理线程"); isMon = true; ThreadPool.QueueUserWorkItem(p => { MonitorSetting setting = null; while (isMon && queueSetting.TryDequeue(out setting)) { RemoveQueue(setting); TradingHelper.heightprice.Price = 0; TradingHelper.lowprice.Price = 0; bool flg = true; while (DateTime.Now < setting.DateTimePriceMonStartTime) { if (flg) { WriteLogs("等待时间...." + DateTime.Now.ToString() + "->" + setting.DateTimePriceMonStartTime.ToString()); flg = false; } Thread.Sleep(1000); } for (int i = 0; i < listMonitors.Count; i++) { foreach (DataGridViewRow row in dataGridViewData.Rows) { if (row.Tag != null && row.Tag.ToString() == listMonitors[i].MemberId.ToString()) { if (row.Cells["colMonLots"].Value == null || row.Cells["colMonRate"].Value == null) { MessageBox.Show("请认真检查Monlots 和 MonRate是否设置值!"); } else { string monlots = row.Cells["colMonLots"].Value.ToString(); string monrates = row.Cells["colMonRate"].Value.ToString(); if (monlots.IndexOf(",") >= 0 && monrates.IndexOf(",") >= 0) { int lotsindex = monlots.IndexOf(","), rateindex = monrates.IndexOf(","); string lots = monlots.Substring(0, lotsindex); string rate = monrates.Substring(0, rateindex); row.Cells["colMonLots"].Value = monlots.Remove(0, lotsindex + 1); row.Cells["colMonRate"].Value = monrates.Remove(0, rateindex + 1); listMonitors[i].MonLots = double.Parse(lots); listMonitors[i].MonRate = double.Parse(rate); } else { listMonitors[i].MonLots = double.Parse(monlots); listMonitors[i].MonRate = double.Parse(monrates); row.Cells["colMonLots"].Value = string.Empty; row.Cells["colMonRate"].Value = string.Empty; } } } } listMonitors[i].Action = TxtParamActionEnum.Monitor;//重置当前已经交易的用户 } while (DateTime.Now > setting.DateTimePriceMonStartTime && DateTime.Now < setting.DateTimePickerMonEndTime) { try { double price = 0; bool isopen = false; while (priceList.TryDequeue(out price)) { for (int i = 0; i < listMonitors.Count; i++) { listMonitors[i].MonEnd = setting.DateTimePickerMonEndTime; listMonitors[i].MonStart = setting.DateTimePriceMonStartTime; } isopen = TradingHelper.StartPriceProcess(listMonitors, price, chkShowLog.Checked); if (isopen) { break; } Thread.Sleep(5); } if (isopen) { //queueSetting.Enqueue(setting); break; } } catch (Exception ex) { _log.Error(ex); WriteLogs("处理报价出错:" + ex.ToString()); } Thread.Sleep(50); } } this.BeginInvoke((MethodInvoker)(() => { toolStartMonitor.Text = "开启监听"; priceList = new ConcurrentQueue <double>(); isMon = false; File.AppendAllText(Path.Combine("log", DateTime.Now.ToString("yyyyMMdd") + ".log"), txtLogs.Text); txtLogs.Clear(); txtLogs.ClearUndo(); })); WriteLogs("所有参数设置已经完成处理"); }); }