public List <DateTime> GetCustomerIndicatorDateTime(int customerIndicatorId, List <String> blockCodeList) { List <DateTime> list = new List <DateTime>(); IndicatorEntity indicatorEntityByCustomerId = DataCore.CreateInstance().GetIndicatorEntityByCustomerId(customerIndicatorId); DataTable calculateTable = this.GetCalculateTable(indicatorEntityByCustomerId, blockCodeList); int num = calculateTable.Columns.Count - 1; if (indicatorEntityByCustomerId.IndDataType == DataType.DateTime) { foreach (DataRow row in calculateTable.Rows) { if (row[num] != DBNull.Value) { try { String str = row[num].ToString(); if (!String.IsNullOrEmpty(str) && (str != "0001-01-01")) { list.Add(Convert.ToDateTime(str)); } continue; } catch { continue; } } } } return(list); }
private void AssignIndiatorParameterToSubIndicator(IndicatorEntity indicator, IndicatorEntity subIndicator) { List <ParamterObject> list = JSONHelper.DeserializeObject <List <ParamterObject> >(indicator.Parameters); List <ParamterObject> list2 = JSONHelper.DeserializeObject <List <ParamterObject> >(subIndicator.Parameters); if ((list != null) && (list2 != null)) { Dictionary <String, IndicatorEntity> dictionary = new Dictionary <String, IndicatorEntity>(); foreach (ParamterObject obj2 in list2) { foreach (ParamterObject obj3 in list) { if (!dictionary.ContainsKey(subIndicator.NO)) { dictionary.Add(subIndicator.NO, subIndicator); } if (((!(obj3.Type == "419") && !(obj3.Type == "461")) && (obj3.IndicatorNo.Contains(subIndicator.NO) && !(obj2.Type != obj3.Type))) && !(obj2.DefaultValue.ToString() == obj3.DefaultValue.ToString())) { obj2.DefaultValue = obj3.DefaultValue; subIndicator.Parameters = JSONHelper.SerializeObject(list2); } } } foreach (IndicatorEntity entity in dictionary.Values) { entity.CustomerId = DataCore.CreateInstance().GetIndicatorCusotmerId(entity); } } }
public QuoteSeriesDataPacket(CommonEnumerators.IndicatorRequestType requestDatType, List <StockEntity> stockList, List <int> customerIndicatorIdList) { base.RequestId = RequestType.QuoteSeriesData; base._requestDataType = requestDatType; base._stockList = stockList; base._customerIndicatorIdList = customerIndicatorIdList; if ((base._stockList.Count > 1) && (base._customerIndicatorIdList.Count > 1)) { throw new Exception("行情序列不支持多个股票多个指标"); } base._indicatorList = new List <IndicatorEntity>(); foreach (int num in base._customerIndicatorIdList) { base._indicatorList.Add(IndicatorDataCore.GetIndicatorEntityByCustomerId(num, false)); base._indicatorUnitDict[num] = DataCore.CreateInstance().GetIndicatorUnit(num); } }
/// <summary> /// 加载指标 /// </summary> /// <param name="type">类型</param> private void LoadType(BrowserType type) { m_tvIndicatorBrowser.ClearNodes(); m_tvIndicatorBrowser.Update(); //请求所有指标 List <String> list = new List <String>(); IndicatorCategoryDataPacket packet = new IndicatorCategoryDataPacket(type); ConnectManager.CreateInstance().Request(packet); while (packet.ReserveFlag == 0) { Thread.Sleep(100); } List <NodeData> nodes = DataCore.CreateInstance().GetCategoryList(type); Dictionary <String, TreeNodeA> nodesMap = new Dictionary <String, TreeNodeA>(); if (nodes != null) { int nodesSzie = nodes.Count; for (int i = 0; i < nodesSzie; i++) { NodeData node = nodes[i]; TreeNodeA tn = new TreeNodeA(); tn.Text = node.Name; tn.Style = new GridCellStyle(); tn.Style.ForeColor = COLOR.ARGB(255, 255, 255); tn.Style.Font = new FONT("微软雅黑", 14, true, false, false); tn.Name = node.Id; tn.Tag = node; if (nodesMap.ContainsKey(node.ParentId)) { nodesMap[node.ParentId].AppendNode(tn); nodesMap[node.Id] = tn; } else { m_tvIndicatorBrowser.AppendNode(tn); nodesMap[node.Id] = tn; } } } }
private DataTable GetCalculateTable(IndicatorEntity indicator, List <String> blockCodeList) { DataTable accept = new DataTable(); accept.Columns.Add(); Dictionary <String, IndicatorEntity> dictionary = new Dictionary <String, IndicatorEntity>(); int num = 0; foreach (IndicatorEntity entity in indicator.CustomIndicator.IndicatorList) { num++; String columnName = accept.Columns.Contains(entity.NO) ? (entity.NO + "_" + num) : entity.NO; accept.Columns.Add(columnName).DataType = this.IsDouble(entity.IndDataType) ? typeof(double) : typeof(String); if (!dictionary.ContainsKey(columnName)) { dictionary.Add(columnName, entity); } } Dictionary <int, double> dictionary2 = new Dictionary <int, double>(); foreach (String str2 in blockCodeList) { DataRow row = accept.NewRow(); row[0] = str2; for (int i = 1; i < accept.Columns.Count; i++) { String str3 = accept.Columns[i].ColumnName; if (dictionary[str3].CustomIndicator != null) { Dictionary <String, double> customerIndicatorData = this.GetCustomerIndicatorData(dictionary[str3], blockCodeList); double num3 = customerIndicatorData.ContainsKey(str2) ? customerIndicatorData[str2] : 0.0; if (num3 == double.MinValue) { row[i] = DBNull.Value; } else { row[i] = num3; } } else { try { double num5; double num6; double num7; if (!dictionary2.ContainsKey(dictionary[str3].CustomerId)) { dictionary2.Add(dictionary[str3].CustomerId, DataCore.CreateInstance().GetIndicatorUnit(dictionary[str3].CustomerId)); } double unitValue = dictionary2[dictionary[str3].CustomerId]; switch (dictionary[str3].IndDataType) { case DataType.Bool: case DataType.Byte: case DataType.Short: case DataType.UShort: num5 = DataCore.CreateInstance().GetIndicatorInt32Value(str2, dictionary[str3].CustomerId.ToString(), unitValue); if (num5 != double.MinValue) { break; } row[i] = DBNull.Value; goto Label_03AA; case DataType.Decimal: case DataType.Double: case DataType.Float: num7 = DataCore.CreateInstance().GetIndicatorDoubleValue(str2, dictionary[str3].CustomerId.ToString(), unitValue); if (num7 != double.MinValue) { goto Label_0345; } row[i] = DBNull.Value; goto Label_03AA; case DataType.Int: case DataType.Long: case DataType.UInt: case DataType.ULong: num6 = DataCore.CreateInstance().GetIndicatorInt64Value(str2, dictionary[str3].CustomerId.ToString(), unitValue); if (num6 != double.MinValue) { goto Label_02ED; } row[i] = DBNull.Value; goto Label_03AA; default: goto Label_0357; } row[i] = num5; goto Label_03AA; Label_02ED: row[i] = num6; goto Label_03AA; Label_0345: row[i] = num7; goto Label_03AA; Label_0357: row[i] = DataCore.CreateInstance().GetIndicatorStringValue(str2, dictionary[str3].CustomerId.ToString()); } catch (Exception exception) { //LogUtility.LogTableMessage("获取自定义指标值:" + exception.Message + Environment.NewLine + exception.StackTrace); } Label_03AA :; } } accept.Rows.Add(row); } this.Calculate(indicator, accept); return(accept); }
public Dictionary <String, String> GetCustomerIndicatorDataString(int customerIndicatorId, List <String> blockCodeList) { IndicatorEntity indicatorEntityByCustomerId = DataCore.CreateInstance().GetIndicatorEntityByCustomerId(customerIndicatorId); return(this.GetCustomerIndicatorDataString(indicatorEntityByCustomerId, blockCodeList)); }