示例#1
0
        private void setCurPlateID(int plateID)
        {
            this.curPlateID = plateID;
            List <Security> securities = new List <Security>();
            string          lblText    = "当前板块是:";

            if (!this._op.PlateDict.ContainsKey(plateID))
            {
                List <Security> temp = new List <Security>();
                foreach (Plate plate in this._op.PlateDict.Values)
                {
                    temp.AddRange(plate.Securities);
                }
                securities.AddRange(temp.Distinct());
                lblText += "全部";
            }
            else
            {
                Plate plate = this._op.PlateDict[plateID];
                securities = plate.Securities;
                lblText   += plate.Name;
            }
            DataTable dtSecurities = new SecurityDataTable();

            foreach (Security secur in securities)
            {
                DataRow dr = dtSecurities.NewRow();
                dr["Symbol"]     = secur.Symbol;
                dr["Name"]       = secur.Name;
                dr["IncPercent"] = string.Format("{0:N2}", secur.IncPercent);
                dr["Price"]      = string.Format("{0:N2}", secur.Price);
                if (secur.UpLimited)
                {
                    dr["UpLimited"] = "是";
                }
                else
                {
                    dr["UpLimited"] = "";
                }
                dr["HotPlateCount"] = secur.HotPlateCount;
                if (secur.Matched)
                {
                    dr["Matched"] = "是";
                }
                else
                {
                    dr["Matched"] = "";
                }
                dtSecurities.Rows.Add(dr);
            }
            dtSecurities.DefaultView.Sort = "IncPercent DESC";

            this.RefreshLabel(this.lblPlateName, lblText);
            this.RefreshStockData(dgvStocks, dtSecurities);
        }
示例#2
0
        //读取版块和证券信息
        public void ReadPlatesAndSecurities()
        {
            Dictionary <string, string> symbolNameDict = this.getSymbolNameDict();
            FileStream fs = null;

            try
            {
                if (Properties.Settings.Default.tbEasyMoneyPath != "")
                {
                    this.EastMoneyPath = Properties.Settings.Default.tbEasyMoneyPath;
                }
                string filePath = this.EastMoneyPath + @"\bklist_new_xx.dat";
                fs = new FileStream(filePath, FileMode.Open, FileAccess.Read);
                StreamReader reader = new StreamReader(fs, Encoding.Default);
                string       text;
                string[]     markets = new string[2] {
                    "SZSE", "SHSE"
                };
                while (!reader.EndOfStream)
                {
                    text = reader.ReadLine();
                    int pos = text.LastIndexOf(";");
                    if (pos < 0)
                    {
                        continue;
                    }
                    string symbolListString = text.Substring(pos + 1);
                    if (symbolListString.Length <= 0)
                    {
                        continue;
                    }
                    string   plateInfoString = text.Substring(0, pos);
                    string[] plateInfoArray  = plateInfoString.Split(new char[] { ';' });
                    Plate    plate           = new Plate();
                    plate.ID   = int.Parse(plateInfoArray[0]);
                    plate.Type = int.Parse(plateInfoArray[1]);
                    plate.Name = plateInfoArray[5];
                    string[] symbolArray = symbolListString.Split(new char[] { ':' });
                    foreach (string symbol in symbolArray)
                    {
                        if (symbol.Length < 3)
                        {
                            continue;
                        }
                        int      marketNo  = int.Parse(symbol.Substring(0, 1));
                        string   newSymbol = markets[marketNo] + "." + symbol.Substring(2);
                        Security curSecurity;
                        if (!this.SecurityDict.TryGetValue(newSymbol, out curSecurity))
                        {
                            curSecurity        = new Security();
                            curSecurity.Symbol = newSymbol;
                            symbolNameDict.TryGetValue(newSymbol, out curSecurity.Name);
                            this.SecurityDict.Add(newSymbol, curSecurity);
                        }
                        curSecurity.Plates.Add(plate);
                        plate.Securities.Add(curSecurity);
                    }
                    this.PlateDict.Add(plate.ID, plate);
                }
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.Message);
            }
            finally
            {
                if (fs != null)
                {
                    fs.Close();
                }
            }
        }