private static void AddPositionCountBySearch(bool isCheckPort, 券商 o, DataTable dt) { if (dt.Rows.Count == 0) { return; } string codeColumnName0 = GetCodeColumnName(dt); if (codeColumnName0 != string.Empty) { //查询当日委托,统计各股票下单情况,进行合计,并将合计信息作为仓位列信息,加入到当前 DataTable dt1 = DataAdapter.QueryTradeData(o, 2, isCheckPort); string codeColumnName1 = GetCodeColumnName(dt1); if (codeColumnName1 != string.Empty && dt1.Columns.Contains("买卖标志") && dt1.Columns.Contains("成交数量")) { Dictionary <string, decimal> dict = CalculateTotalBuyCount(dt1, codeColumnName1); dt.Columns.Add("仓位"); foreach (DataRow dr in dt.Rows) { var code = CommonUtils.GetCode(dr[codeColumnName0]); if (dict.ContainsKey(code)) { dr["仓位"] = dict[code]; } } } } }
private void Button_Search_Click(object sender, RoutedEventArgs e) { this.NotUseCount = 0; int tradeDataType = int.Parse((cbTodayType.SelectedItem as ComboBoxItem).DataContext.ToString()); bool isCheckPort = this.ckbIsCheckPort.IsChecked == true; var group = cmbGroup.SelectedItem as string; if (!string.IsNullOrEmpty(group) && GroupDict.ContainsKey(group)) { this.loading.Visibility = Visibility.Visible; var action = new Action(() => { try { var o = Cryptor.MD5Decrypt(GroupDict[group]).FromJson <券商>(); if (o != null) { DateTime dt1 = DateTime.Now; DataTable dt = DataAdapter.QueryTradeData(o, tradeDataType, isCheckPort); var span = DateTime.Now - dt1; var s = span.TotalSeconds; if (dt != null && dictDataColumn != null && dictDataColumn.ContainsKey(tradeDataType.ToString())) { CommonUtils.Log(string.Format("交易接口查询耗时记录, 交易类型 {0}, 耗时 {1}", tradeDataType, s)); var list = dictDataColumn[tradeDataType.ToString()]; //if ("FCAA14B3008F 005056C00001 005056C00008".IndexOf(CommonUtils.GetMac()) > -1 && CommonUtils.GetCpuID() == "BFEBFBFF000306C3") if (tradeDataType != 0 && tradeDataType != 6) { for (int i = dt.Columns.Count - 1; i > -1; i--) { if (!list.Contains(dt.Columns[i].ColumnName)) { dt.Columns.RemoveAt(i); } } } if (tradeDataType == 2 && dt.Columns.Contains("买卖标志") && dt.Rows.Count > 0 && Regex.IsMatch(dt.Rows[0]["买卖标志"] + "", "^[01]+$")) { foreach (DataRow row in dt.Rows) { row["买卖标志"] = GetBuySaleInfo(row["买卖标志"] + ""); } } if (tradeDataType == 1) { AddPosition(isCheckPort, o, dt); } } this.QueryData = dt; } } catch (Exception ex) { this.Dispatcher.ShowMsg(ex.Message); } }); var completeAction = new Action(() => { if (QueryData == null) { dgMain.ItemsSource = null; } else { //dgMain.AutoGenerateColumns = false; dgMain.ItemsSource = QueryData.DefaultView; } this.loading.Visibility = Visibility.Collapsed; }); this.Dispatcher.RunAsync(action, null, null, completeAction); } }