Esempio n. 1
0
        // non-printing fields >= HiddenColumnCount
        private static void AssignColumnKey(SortedList <int, RevCol> revCols,
                                            int column, EDataSource source, Enum field, bool export)
        {
            if (column < 0)
            {
                column = MAX_FIELDS + HiddenColumnCount++;
            }

            revCols.Add(column, new RevCol(source, field, export));
        }
Esempio n. 2
0
 public ColumnKey(EDataSource source, Enum value)
 {
     key = new [] { source, value };
 }
Esempio n. 3
0
        //private List<KeyValuePair<RealtimeData, RecvRealtimeData>> ltRddRd = new List<KeyValuePair<RealtimeData, RecvRealtimeData>>();

        /*
         * 两种创建方式:唯一实例,这也是推荐的使用方式;也可以在某些特殊情况下使用普通new(即手动调用构造函数)
         */
        static public RealtimeDataCenter getInstance(int thCount = 8, string codes = null, EDataSource ds = EDataSource.sinajs)
        {
            if (null == s_instance)
            {
                s_instance = new RealtimeDataCenter(thCount, codes, ds);
            }

            return(s_instance);
        }
Esempio n. 4
0
 public RevCol(EDataSource source, Enum index, bool export)
 {
     Source     = source;
     this.index = index;
     Export     = export;
 }
Esempio n. 5
0
        public RealtimeDataCenter(int thCount = 8, string codes = null, EDataSource ds = EDataSource.sinajs)
        {
#if (!LOCAL_TEST)
            if (thCount <= 0 ||
                thCount > 100)
            {
                throw new Exception("invalid thCount");
            }

            List <string> ltCode = new List <string>();
            if (null == codes)
            {
                /*
                 * StreamReader srCodes = new StreamReader(Program.ramdisk + "\\George\\sql\\objCode.txt", Encoding.Default);
                 * string line;
                 * while (null != (line = srCodes.ReadLine()))
                 * {
                 *  string[] arrCodes = line.Split(new char[] { ',' }, StringSplitOptions.RemoveEmptyEntries);
                 *  foreach (var item in arrCodes)
                 *  { ltCode.Add(item); }
                 * }
                 */
                DBDataContext db = new DBDataContext();
                var           q  = from n in db.tbObjs
                                   select new { n.code };
                foreach (var item in q)
                {
                    ltCode.Add(item.code);
                }
            }
            else
            {
                string[] arrCodes = codes.Split(new char[] { ',' }, StringSplitOptions.RemoveEmptyEntries);
                foreach (var item in arrCodes)
                {
                    ltCode.Add(item);
                }
            }

            if (ltCode.Count <= 0)
            {
                throw new Exception("null code");
            }

            if (ltCode.Count < thCount)
            {
                thCount = ltCode.Count;
            }

            int countPlanPerTh = ltCode.Count / thCount;
            int countCurrentTh = countPlanPerTh;
            for (int i = 0; i < thCount; i++)
            {
                if (i == thCount - 1) //lastTh
                {
                    countCurrentTh = ltCode.Count - countPlanPerTh * (thCount - 1);
                }

                string[] arrCodes = new string[countCurrentTh];
                ltCode.CopyTo(i * countPlanPerTh, arrCodes, 0, countCurrentTh);
                foreach (var item in arrCodes)
                {
                    this.dcCodeIdxThObj.Add(item, i);
                }

                if (EDataSource.sinajs == ds)
                {
                    var to = new ThreadGetDataFromHttp2(arrCodes, this);
                    var th = new Thread(to.GetData)
                    {
                        IsBackground = true
                    };
                    this.ltTh.Add(th);
                    this.ltThObj.Add(to);

                    th.Start();
                }
                else if (EDataSource.tradeX == ds)
                {
                    var to = new ThreadGetDataFromTradeX(arrCodes, this);
                    var th = new Thread(to.GetData)
                    {
                        IsBackground = true
                    };
                    this.ltTh.Add(th);
                    this.ltThObj.Add(to);

                    th.Start();
                }

                System.Threading.Thread.Sleep(10);
            }

            this.thSendRd2Interface = new Thread(this.sendRd2Interface)
            {
                IsBackground = true
            };
            this.thSendRd2Interface.Start();
#endif
        }