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);
     }
 }
Ejemplo n.º 2
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);
     }
 }
Ejemplo n.º 3
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);
     }
 }
Ejemplo n.º 4
0
 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);
     }
 }
Ejemplo n.º 5
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);
         }
     }
 }
Ejemplo n.º 6
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);
        }
Ejemplo n.º 7
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);
     }
 }
Ejemplo n.º 8
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);
        }
        public override bool Decoding(byte[] bytes)
        {
            if (((bytes != null) && (bytes.Length != 0)) && bytes[0].ToString().Equals("48"))
            {
                return(false);
            }
            bool flag = true;

            try
            {
                List <NodeData> nodeList  = new List <NodeData>();
                char[]          separator = new char[] { '}' };
                String[]        strArray  = Encoding.UTF8.GetString(bytes).Split(separator, StringSplitOptions.RemoveEmptyEntries);
                for (int i = 0; i < strArray.Length; i++)
                {
                    NodeData data1;
                    char[]   chArray2  = new char[] { '◎' };
                    String[] strArray2 = strArray[i].Split(chArray2, StringSplitOptions.RemoveEmptyEntries);
                    if (this.Browser == BrowserType.STOCK)
                    {
                        if (!strArray2[0].StartsWith("101004"))
                        {
                            goto Label_015E;
                        }
                        continue;
                    }
                    if (this.Browser == BrowserType.New3Board)
                    {
                        if (strArray2[0].StartsWith("101004"))
                        {
                            goto Label_015E;
                        }
                        continue;
                    }
                    if (this.Browser == BrowserType.BLOCKSEQUENCE)
                    {
                        if (strArray2[0].StartsWith("110009"))
                        {
                            goto Label_015E;
                        }
                        continue;
                    }
                    if (this.Browser == BrowserType.BrokerageFinancial)
                    {
                        if (strArray2[0].StartsWith("102002"))
                        {
                            goto Label_015E;
                        }
                        continue;
                    }
                    if (this.Browser == BrowserType.SunshinePrivate)
                    {
                        if (strArray2[0].StartsWith("102003"))
                        {
                            goto Label_015E;
                        }
                        continue;
                    }
                    if (this.Browser == BrowserType.InsuranceFinancial)
                    {
                        if (strArray2[0].StartsWith("102004"))
                        {
                            goto Label_015E;
                        }
                        continue;
                    }
                    if (this.Browser == BrowserType.BankFinancial)
                    {
                        if (strArray2[0].StartsWith("102005"))
                        {
                            goto Label_015E;
                        }
                        continue;
                    }
                    if ((this.Browser == BrowserType.TrustFinancial) && !strArray2[0].StartsWith("102006"))
                    {
                        continue;
                    }
Label_015E:
                    data1           = new NodeData();
                    data1.Id        = strArray2[0];
                    data1.ParentId  = strArray2[1];
                    data1.Name      = strArray2[2];
                    data1.SortIndex = int.Parse(strArray2[3]);
                    data1.IsCatalog = !strArray2[4].Equals("0");
                    data1.HasLeaf   = strArray2[4].Equals("1");
                    NodeData item = data1;
                    nodeList.Add(item);
                }
                if (nodeList.Count > 0)
                {
                    IndicatorDataCore.SetCategoryValue(this.Browser, nodeList);
                }
            }
            catch (Exception exception)
            {
                //LogUtility.LogMessage("获取指标分类解包失败," + exception.ToString());
                flag = false;
            }
            return(flag);
        }