public Dictionary <String, String> GetCustomerIndicatorDataString(IndicatorEntity indicator, List <String> blockCodeList)
        {
            Dictionary <String, String> dictionary = new Dictionary <String, String>();
            DataTable calculateTable = this.GetCalculateTable(indicator, blockCodeList);
            int       num            = calculateTable.Columns.Count - 1;
            bool      flag           = indicator.IndDataType == DataType.DateTime;

            foreach (DataRow row in calculateTable.Rows)
            {
                String str  = (row[num] == DBNull.Value) ? String.Empty : row[num].ToString();
                String str2 = str;
                if (!String.IsNullOrEmpty(str) && flag)
                {
                    DateTime result = new DateTime();
                    DateTime.TryParse(str, out result);
                    str2 = result.ToString("yyyy-MM-dd");
                    if (str2 == "0001-01-01")
                    {
                        str2 = "--";
                    }
                }
                dictionary[row[0].ToString()] = str2;
            }
            return(dictionary);
        }
Esempio n. 2
0
 public static void SetIndicatorEntity(String categoryCode, IndicatorEntity entity)
 {
     lock (_IndicatorEntityDict)
     {
         _IndicatorEntityDict[categoryCode] = entity;
     }
 }
        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);
        }
        public Dictionary <String, double> GetCustomerIndicatorData(IndicatorEntity indicator, List <String> blockCodeList)
        {
            DataTable calculateTable = this.GetCalculateTable(indicator, blockCodeList);
            Dictionary <String, double> dictionary = new Dictionary <String, double>();
            int num = calculateTable.Columns.Count - 1;

            foreach (DataRow row in calculateTable.Rows)
            {
                double result = 0.0;
                String str    = (row[num] == DBNull.Value) ? String.Empty : row[num].ToString();
                if (!String.IsNullOrEmpty(str))
                {
                    if (indicator.IndDataType == DataType.Bool)
                    {
                        result = (str.ToLower() == "true") ? ((double)1) : ((double)0);
                    }
                    else
                    {
                        double.TryParse(str, out result);
                    }
                }
                else
                {
                    result = double.MinValue;
                }
                dictionary[row[0].ToString()] = result;
            }
            return(dictionary);
        }
        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);
                }
            }
        }
Esempio n. 6
0
 public static void SetCustomerIndicatorEntity(int customerIndicatorId, IndicatorEntity entity)
 {
     lock (_CustomerIndicatorDict)
     {
         _CustomerIndicatorDict[customerIndicatorId] = entity;
     }
 }
 public void SetIndicatorParam(IndicatorEntity indicator)
 {
     if (!String.IsNullOrEmpty(indicator.Parameters))
     {
         foreach (IndicatorEntity entity in indicator.CustomIndicator.IndicatorList)
         {
             this.AssignIndiatorParameterToSubIndicator(indicator, entity);
         }
     }
 }
 public CustomIndicatorDataPacket(CommonEnumerators.IndicatorRequestType requestDatType, List <StockEntity> stockList, List <int> customerIndicatorIdList)
 {
     this._categoryStockCodeDict = new Dictionary <int, List <String> >();
     base.RequestId        = RequestType.IndicatorData;
     this._requestDataType = requestDatType;
     this._stockList       = stockList;
     this._indicatorList   = new List <IndicatorEntity>();
     foreach (int num in customerIndicatorIdList)
     {
         IndicatorEntity indicatorEntityByCustomerId = IndicatorDataCore.GetIndicatorEntityByCustomerId(num);
         indicatorEntityByCustomerId.CustomerId = num;
         this._indicatorList.Add(indicatorEntityByCustomerId);
     }
 }
Esempio n. 9
0
 public IndicatorDataPacket2(CommonEnumerators.IndicatorRequestType requestDatType, List <StockEntity> stockList, List <int> customerIndicatorIdList)
 {
     base.RequestId                = RequestType.IndicatorData;
     this._requestDataType         = requestDatType;
     this._stockList               = stockList;
     this._customerIndicatorIdList = new List <int>();
     this._indicatorList           = new List <IndicatorEntity>();
     foreach (int num in customerIndicatorIdList)
     {
         IndicatorEntity indicatorEntityByCustomerId = IndicatorDataCore.GetIndicatorEntityByCustomerId(num);
         indicatorEntityByCustomerId.CustomerId = num;
         this._indicatorList.Add(indicatorEntityByCustomerId);
         this._customerIndicatorIdList.Add(num);
     }
 }
Esempio n. 10
0
 public BlockIndicatorDataPacket(CommonEnumerators.IndicatorRequestType requestDataType, List <String> blockCodeList, List <int> customerIndicatorIdList, BlockIndicatorParams blockParam)
 {
     base.RequestId  = RequestType.BlockQuoteSeriesData;
     this._blockList = blockCodeList;
     this._customerIndicatorIdList = new List <int>();
     this._blockParam      = blockParam;
     this._requestDataType = requestDataType;
     this._indicatorList   = new List <IndicatorEntity>();
     foreach (int num in customerIndicatorIdList)
     {
         IndicatorEntity indicatorEntityByCustomerId = IndicatorDataCore.GetIndicatorEntityByCustomerId(num);
         indicatorEntityByCustomerId.CustomerId = num;
         this._indicatorList.Add(indicatorEntityByCustomerId);
         this._customerIndicatorIdList.Add(num);
     }
 }
 public FinanceSeriesDataPacket(CommonEnumerators.IndicatorRequestType requestDatType, List <StockEntity> stockList, List <int> customerIndicatorIdList)
 {
     base.RequestId                = RequestType.FinanceSeriesData;
     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)
     {
         IndicatorEntity indicatorEntityByCustomerId = IndicatorDataCore.GetIndicatorEntityByCustomerId(num, false);
         base._indicatorList.Add(indicatorEntityByCustomerId);
         base._indicatorUnitDict[num] = DataCore.CreateInstance().GetIndicatorUnit(indicatorEntityByCustomerId);
     }
 }
Esempio n. 12
0
 public IndicatorEntityListDataPacket(List <String> categoryCodeList)
 {
     base.RequestId                = RequestType.IndicatorEntityList;
     this.CategoryCodeList         = categoryCodeList;
     this.IndicatorEntityDict      = new Dictionary <String, IndicatorEntity>();
     this._requestCategoryCodeList = new List <String>();
     foreach (String str in categoryCodeList)
     {
         IndicatorEntity indicatorEntityByCategoryCode = IndicatorDataCore.GetIndicatorEntityByCategoryCode(str);
         if (indicatorEntityByCategoryCode != null)
         {
             this.IndicatorEntityDict[str] = indicatorEntityByCategoryCode;
         }
         else
         {
             this._requestCategoryCodeList.Add(str);
         }
     }
 }
Esempio n. 13
0
        public override bool Decoding(byte[] bytes)
        {
            if (((bytes != null) && (bytes.Length > 0)) && bytes[0].ToString().Equals("48"))
            {
                return(false);
            }
            bool            flag   = true;
            IndicatorEntity entity = null;

            try
            {
                entity = JSONHelper.DeserializeObject <IndicatorEntity>(Encoding.UTF8.GetString(bytes));
                IndicatorDataCore.SetIndicatorEntity(this._categoryCode, entity);
            }
            catch (Exception exception)
            {
                //LogUtility.LogMessage("获取指标实体解包失败," + exception.ToString());
                flag = false;
            }
            return(flag);
        }
Esempio n. 14
0
 public override bool Decoding(byte[] bytes)
 {
     if (((bytes != null) && (bytes.Length > 0)) && bytes[0].ToString().Equals("48"))
     {
         return(false);
     }
     try
     {
         String   str        = Encoding.UTF8.GetString(bytes);
         int      index      = str.IndexOf('|');
         String   str2       = str.Substring(0, index);
         String   str3       = str.Substring(index + 1);
         String[] strArray   = str2.Split(new String[] { "," }, StringSplitOptions.RemoveEmptyEntries);
         int      startIndex = 0;
         if ((strArray != null) && (strArray.Length > 0))
         {
             for (int i = 0; i < strArray.Length; i++)
             {
                 if ((i % 2) == 0)
                 {
                     int    length       = Convert.ToInt32(strArray[i]);
                     String categoryCode = str3.Substring(startIndex, length);
                     startIndex += length;
                     int    num5 = Convert.ToInt32(strArray[i + 1]);
                     String str5 = str3.Substring(startIndex, num5);
                     startIndex += num5;
                     IndicatorEntity entity = JSONHelper.DeserializeObject <IndicatorEntity>(str5);
                     this.IndicatorEntityDict[categoryCode] = entity;
                     IndicatorDataCore.SetIndicatorEntity(categoryCode, entity);
                 }
             }
         }
         return(true);
     }
     catch (Exception exception)
     {
         //LogUtility.LogMessage("获取指标实体List解包失败," + exception.Message + exception.StackTrace);
         return(false);
     }
 }
        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));
        }
Esempio n. 17
0
        public override String Coding()
        {
            StringBuilder builder = new StringBuilder();

            builder.AppendFormat("$-{0}{1}", CommonEnumerators.GetIndicatorRequestTypeCmd(base._requestDataType), Environment.NewLine);
            List <String> list  = new List <String>();
            List <String> list2 = new List <String>();

            for (int i = 0; i < base._indicatorList.Count; i++)
            {
                IndicatorEntity entity = base._indicatorList[i];
                list.Add(entity.ProductFunc);
                List <String> list3 = new List <String>();
                list3.Add(String.Format("$TableName={0}", base._customerIndicatorIdList[i]));
                Dictionary <String, object> dictionary  = base.BuildParamDictionary(entity.Parameters);
                Dictionary <String, object> dictionary2 = base.BuildParamDictionary(entity.ParaInfo);
                foreach (KeyValuePair <String, object> pair in dictionary)
                {
                    dictionary2[pair.Key] = dictionary[pair.Key];
                }
                foreach (KeyValuePair <String, object> pair2 in base.ParamDictionary)
                {
                    if (dictionary2.ContainsKey(pair2.Key.ToLower()))
                    {
                        dictionary2[pair2.Key.ToLower()] = pair2.Value;
                    }
                }
                if (!dictionary2.ContainsKey("period"))
                {
                    dictionary2["period"] = 1;
                }
                foreach (KeyValuePair <String, object> pair3 in dictionary2)
                {
                    list3.Add(String.Format("{0}={1}", pair3.Key, pair3.Value));
                }
                if (dictionary2.ContainsKey("startdate"))
                {
                    base.ParamDictionary["startdate"] = DateHelper.ResolveDate(dictionary2["startdate"].ToString());
                }
                if (dictionary2.ContainsKey("enddate"))
                {
                    base.ParamDictionary["enddate"] = DateHelper.ResolveDate(dictionary2["enddate"].ToString());
                }
                if (dictionary2.ContainsKey("period"))
                {
                    base.ParamDictionary["period"] = dictionary2["period"];
                }
                list2.Add(String.Join(",", list3.ToArray()));
            }
            builder.AppendFormat("$name={0}{1}", String.Join(",", list.ToArray()), Environment.NewLine);
            foreach (StockEntity entity2 in base._stockList)
            {
                if (!base._categoryStockCodeDict.ContainsKey(entity2.CategoryCode))
                {
                    base._categoryStockCodeDict[entity2.CategoryCode] = new List <String>();
                }
                base._categoryStockCodeDict[entity2.CategoryCode].Add(entity2.StockCode);
            }
            List <String> list4 = new List <String>();

            foreach (KeyValuePair <int, List <String> > pair4 in base._categoryStockCodeDict)
            {
                list4.Add(String.Format("{0}:{1}", pair4.Key, String.Join(",", pair4.Value.ToArray())));
            }
            builder.AppendFormat("$secucode={0}{1}", String.Join("#", list4.ToArray()), Environment.NewLine);
            builder.Append(String.Join(Environment.NewLine, list2.ToArray()));
            return(builder.ToString());
        }
 private void Calculate(IndicatorEntity indicator, DataTable accept)
 {
 }
        public override String Coding()
        {
            StringBuilder builder = new StringBuilder();

            builder.AppendFormat("$-{0}{1}", CommonEnumerators.GetIndicatorRequestTypeCmd(base._requestDataType), Environment.NewLine);
            List <String> list  = new List <String>();
            List <String> list2 = new List <String>();

            for (int i = 0; i < base._indicatorList.Count; i++)
            {
                String[]        strArray;
                IndicatorEntity entity = base._indicatorList[i];
                list.Add(entity.ProductFunc);
                List <String> list3 = new List <String>();
                list3.Add(String.Format("$TableName={0}", base._customerIndicatorIdList[i]));
                Dictionary <String, object> dictionary  = base.BuildParamDictionary(entity.Parameters);
                Dictionary <String, object> dictionary2 = base.BuildParamDictionary(entity.ParaInfo);
                foreach (KeyValuePair <String, object> pair in dictionary)
                {
                    dictionary2[pair.Key] = dictionary[pair.Key];
                }
                foreach (KeyValuePair <String, object> pair2 in base.ParamDictionary)
                {
                    if (dictionary2.ContainsKey(pair2.Key.ToLower()))
                    {
                        dictionary2[pair2.Key.ToLower()] = pair2.Value;
                    }
                }
                dictionary2["indicatorcode"] = entity.IndicatorCode;
                String   str = dictionary2["reportdate"].ToString();
                DateTime secuLatestReportDate = DataServiceHelper.GetSecuLatestReportDate(base._stockList[0].StockCode);
                if ((base.ParamDictionary.Count == 0) || str.ToUpper().Trim().Equals("N"))
                {
                    List <String> list4 = new List <String>();
                    list4.Add(new DateTime(secuLatestReportDate.Year - 5, 12, 0x1f).ToString("yyyy-MM-dd"));
                    list4.Add(new DateTime(secuLatestReportDate.Year - 4, 12, 0x1f).ToString("yyyy-MM-dd"));
                    list4.Add(new DateTime(secuLatestReportDate.Year - 3, 12, 0x1f).ToString("yyyy-MM-dd"));
                    list4.Add(new DateTime(secuLatestReportDate.Year - 2, 12, 0x1f).ToString("yyyy-MM-dd"));
                    list4.Add(new DateTime(secuLatestReportDate.Year - 1, 12, 0x1f).ToString("yyyy-MM-dd"));
                    String item = secuLatestReportDate.ToString("yyyy-MM-dd");
                    if (!list4.Contains(item))
                    {
                        list4.Add(item);
                    }
                    strArray = list4.ToArray();
                }
                else
                {
                    strArray = str.Split(new char[] { '|' }, StringSplitOptions.RemoveEmptyEntries);
                }
                List <String> list5 = new List <String>();
                foreach (String str3 in strArray)
                {
                    DateTime time2 = DateTime.Parse(str3);
                    if (time2.Date <= secuLatestReportDate.Date)
                    {
                        list5.Add(str3);
                        String s = String.Empty;
                        if (!base.DateList.Contains(time2))
                        {
                            base.DateList.Add(time2);
                        }
                        s = DateHelper.GetSameCompareReportDate(str3);
                        this._sameDateList.Add(DateTime.Parse(s));
                        list5.Add(s);
                        s = DateHelper.GetHuanCompareReportDate(str3);
                        this._huanDateList.Add(DateTime.Parse(s));
                        list5.Add(s);
                    }
                }
                base.DateList.Sort();
                base.DateList.Reverse();
                dictionary2["reportdate"] = String.Join("|", list5.ToArray());
                foreach (KeyValuePair <String, object> pair3 in dictionary2)
                {
                    list3.Add(String.Format("{0}={1}", pair3.Key, pair3.Value.ToString().Trim()));
                }
                list2.Add(String.Join(",", list3.ToArray()));
            }
            builder.AppendFormat("$name={0}{1}", String.Join(",", list.ToArray()), Environment.NewLine);
            foreach (StockEntity entity2 in base._stockList)
            {
                if (!base._categoryStockCodeDict.ContainsKey(entity2.CategoryCode))
                {
                    base._categoryStockCodeDict[entity2.CategoryCode] = new List <String>();
                }
                base._categoryStockCodeDict[entity2.CategoryCode].Add(entity2.StockCode);
            }
            List <String> list6 = new List <String>();

            foreach (KeyValuePair <int, List <String> > pair4 in base._categoryStockCodeDict)
            {
                list6.Add(String.Format("{0}:{1}", pair4.Key, String.Join(",", pair4.Value.ToArray())));
            }
            builder.AppendFormat("$secucode={0}{1}", String.Join("#", list6.ToArray()), Environment.NewLine);
            builder.Append(String.Join(Environment.NewLine, list2.ToArray()));
            return(builder.ToString());
        }
        public override String Coding()
        {
            this._customIndicatorDictionary = new Dictionary <int, IndicatorEntity>();
            foreach (IndicatorEntity entity in this.IndicatorList)
            {
                if (((entity.CustomIndicator == null) || (entity.CustomIndicator.IndicatorList == null)) || (entity.CustomIndicator.IndicatorList.Count == 0))
                {
                    this._customIndicatorDictionary[entity.CustomerId] = entity;
                }
                else
                {
                    foreach (IndicatorEntity entity2 in entity.CustomIndicator.IndicatorList)
                    {
                        this._customIndicatorDictionary[entity2.CustomerId] = entity2;
                    }
                }
            }
            StringBuilder builder = new StringBuilder();

            builder.AppendFormat("$-{0}{1}", CommonEnumerators.GetIndicatorRequestTypeCmd(this._requestDataType), Environment.NewLine);
            List <String> list  = new List <String>();
            List <String> list2 = new List <String>();

            foreach (KeyValuePair <int, IndicatorEntity> pair in this._customIndicatorDictionary)
            {
                IndicatorEntity entity3 = pair.Value;
                list.Add(entity3.IndicatorCode);
                List <String> list3 = new List <String>();
                list3.Add(String.Format("$TableName={0}", entity3.CustomerId));
                if (String.IsNullOrEmpty(entity3.Parameters) || entity3.Parameters.Equals("null"))
                {
                    list2.Add(String.Join(",", list3.ToArray()));
                    continue;
                }
                List <ParamterObject> indicatorParameterList = JSONHelper.DeserializeObject <List <ParamterObject> >(entity3.Parameters);
                base.ResolveObjectParameters(indicatorParameterList);
                foreach (ParamterObject obj2 in indicatorParameterList)
                {
                    if (obj2.Type.Equals("261"))
                    {
                        continue;
                    }
                    if (String.IsNullOrEmpty(obj2.Name))
                    {
                        if (obj2.Type != "279")
                        {
                            list3.Add(String.Format("FieldName={0}", obj2.DefaultValue));
                        }
                        else if (obj2.Name.Trim().Equals("type"))
                        {
                            String str = obj2.DefaultValue.ToString();
                            list3.Add(String.Format("type={0}", str.Substring(str.Length - 1, 1)));
                        }
                        continue;
                    }
                    if ((obj2.Name.Trim().Equals("type") && (obj2.Type != "115")) && (obj2.Type != "219"))
                    {
                        int    result = 0;
                        String s      = obj2.DefaultValue.ToString();
                        if (!int.TryParse(s, out result))
                        {
                            s = s.Substring(s.Length - 1, 1);
                        }
                        list3.Add(String.Format("type={0}", s));
                        continue;
                    }
                    list3.Add(String.Format("{0}={1}", obj2.Name.Trim(), obj2.DefaultValue));
                }
                list2.Add(String.Join(",", list3.ToArray()));
            }
            builder.AppendFormat("$name={0}{1}", String.Join(",", list.ToArray()), Environment.NewLine);
            foreach (StockEntity entity4 in this._stockList)
            {
                if (!this._categoryStockCodeDict.ContainsKey(entity4.CategoryCode))
                {
                    this._categoryStockCodeDict[entity4.CategoryCode] = new List <String>();
                }
                this._categoryStockCodeDict[entity4.CategoryCode].Add(entity4.StockCode);
            }
            List <String> list5 = new List <String>();

            foreach (KeyValuePair <int, List <String> > pair2 in this._categoryStockCodeDict)
            {
                list5.Add(String.Format("{0}:{1}", pair2.Key, String.Join(",", pair2.Value.ToArray())));
            }
            builder.AppendFormat("$secucode={0}{1}", String.Join("#", list5.ToArray()), Environment.NewLine);
            builder.Append(String.Join(Environment.NewLine, list2.ToArray()));
            return(builder.ToString());
        }
Esempio n. 21
0
        /// <summary>
        /// 获取指标数据
        /// </summary>
        /// <param name="indicatorCode"></param>
        /// <param name="blockType"></param>
        /// <param name="codes"></param>
        /// <returns></returns>
        public static IndicatorRootData GetIndicatorData(String indicatorCode, String blockType, String codes)
        {
            if (!IndicatorDataCore._IndicatorEntityDict.ContainsKey(indicatorCode))
            {
                IndicatorEntityDataPacket newEntity = new IndicatorEntityDataPacket(indicatorCode);
                ConnectManager.CreateInstance().Request(newEntity);
                int tick2 = 0;
                while (newEntity.ReserveFlag == 0 && tick2 < 100)
                {
                    tick2++;
                    Thread.Sleep(100);
                }
            }
            IndicatorRootData        rootData = new IndicatorRootData();
            List <IndicatorItemData> datas    = new List <IndicatorItemData>();

            rootData.items = datas;
            String[]        strs     = codes.Split(new String[] { "," }, StringSplitOptions.RemoveEmptyEntries);
            int             strsSize = strs.Length;
            IndicatorEntity entity   = IndicatorDataCore.GetIndicatorEntityByCategoryCode(indicatorCode);

            if (entity != null)
            {
                if (entity.Parameters != null)
                {
                    entity.Parameters = entity.Parameters.Replace("EmDataPara.", "dataquery.");
                    entity.Parameters = entity.Parameters.Replace("\"DefaultValue\":\"2013\"", "\"DefaultValue\":\"2016\"");
                    entity.Parameters = entity.Parameters.Replace("\"DefaultValue\":\"2014-04-21\"", "\"DefaultValue\":\"2017-03-27\"");
                }
                List <int> ids = new List <int>();
                ids.Add((int)entity.ID);
                Dictionary <String, String> codesMap = new Dictionary <String, String>();
                List <StockEntity>          stocks   = new List <StockEntity>();
                String idStr = entity.ID.ToString();
                for (int i = 0; i < strsSize; i++)
                {
                    StockEntity stock   = new StockEntity();
                    String[]    subStrs = strs[i].Split(new String[] { "," }, StringSplitOptions.RemoveEmptyEntries);
                    stock.StockCode = subStrs[0];
                    stocks.Add(stock);
                    codesMap[subStrs[0] + idStr] = subStrs[0];
                }
                IndicatorDataCore.SetCustomerIndicatorEntity((int)entity.ID, entity);
                IndicatorDataPacket2 indicatorDataPacket = new IndicatorDataPacket2(CommonEnumerators.IndicatorRequestType.Fun, stocks, ids);
                if (blockType == "Block")
                {
                    indicatorDataPacket = new IndicatorDataPacket2(CommonEnumerators.IndicatorRequestType.Blk, stocks, ids);
                }
                ConnectManager.CreateInstance().Request(indicatorDataPacket);
                int tick = 0;
                while (indicatorDataPacket.ReserveFlag == 0 && tick < 100)
                {
                    tick++;
                    Thread.Sleep(100);
                }
                Dictionary <String, double> _doubleIndicatorDict = IndicatorTableDataCore.DoubleIndicatorDict;
                Dictionary <String, float>  _floatIndicatorDict  = IndicatorTableDataCore.FloatIndicatorDict;
                Dictionary <String, int>    _intIndicatorDict    = IndicatorTableDataCore.Int32IndicatorDict;
                Dictionary <String, long>   _longIndicatorDict   = IndicatorTableDataCore.LongIndicatorDict;
                Dictionary <String, String> _strIndicatorDict    = IndicatorTableDataCore.StrIndicatorDict;
                StringBuilder sb = new StringBuilder();
                rootData.categoryName = entity.CategoryName;
                rootData.categoryCode = entity.CategoryCode;
                if (entity.Parameters != null)
                {
                    rootData.parameters = entity.Parameters;
                    sb.Append("参数:" + entity.Parameters + "\r\n");
                }
                foreach (String key in _strIndicatorDict.Keys)
                {
                    if (codesMap.ContainsKey(key))
                    {
                        datas.Add(new IndicatorItemData(codesMap[key], _strIndicatorDict[key]));
                    }
                }
                foreach (String key in _doubleIndicatorDict.Keys)
                {
                    if (codesMap.ContainsKey(key))
                    {
                        datas.Add(new IndicatorItemData(codesMap[key], _doubleIndicatorDict[key]));
                    }
                }
                foreach (String key in _floatIndicatorDict.Keys)
                {
                    if (codesMap.ContainsKey(key))
                    {
                        datas.Add(new IndicatorItemData(codesMap[key], _floatIndicatorDict[key]));
                    }
                }
                foreach (String key in _intIndicatorDict.Keys)
                {
                    if (codesMap.ContainsKey(key))
                    {
                        datas.Add(new IndicatorItemData(codesMap[key], _intIndicatorDict[key]));
                    }
                }
                foreach (String key in _longIndicatorDict.Keys)
                {
                    if (codesMap.ContainsKey(key))
                    {
                        datas.Add(new IndicatorItemData(codesMap[key], _longIndicatorDict[key]));
                    }
                }
                codesMap.Clear();
            }
            return(rootData);
        }