Beispiel #1
0
        /// <summary>
        /// 获取板块项
        /// </summary>
        /// <returns>板块项</returns>
        public List <DMBlockItem> GetBlockItems()
        {
            String             code  = "";
            long               time  = 0;
            List <DMBlockItem> items = new List <DMBlockItem>();

            while (true)
            {
                DMRetOutput dm1      = UpdateBlockTree(time, 1, 0, code);
                DMBlockItem lastItem = null;
                using (MemoryStream ms = new MemoryStream(dm1.ptr))
                {
                    using (BinaryReader br = new BinaryReader(ms))
                    {
                        int size = dm1.size;
                        for (int i = 0; i < size; i++)
                        {
                            DMBlockItem item = new DMBlockItem();
                            item.innerCode  = GetBytesString(br, 16);
                            item.code       = GetBytesString(br, 50);
                            item.name       = GetBytesString(br, 200);
                            item.parentcode = GetBytesString(br, 50);
                            item.typcode    = GetBytesString(br, 10);
                            item.typname    = GetBytesString(br, 200);
                            item.tmpl       = GetBytesString(br, 10);
                            item.order      = br.ReadInt32();
                            item.timestamp  = br.ReadInt64();
                            items.Add(item);
                            lastItem = item;
                        }
                    }
                }
                if (!dm1.last)
                {
                    if (lastItem != null)
                    {
                        code = lastItem.code;
                        time = lastItem.timestamp;
                    }
                }
                if (dm1.last)
                {
                    break;
                }
            }
            code = "";
            time = 0;
            return(items);
        }
Beispiel #2
0
        /// <summary>
        /// 选中板块树事件
        /// </summary>
        /// <param name="sender">调用者</param>
        /// <param name="e">参数</param>
        private void tvBlocks_AfterSelect(object sender, TreeViewEventArgs e)
        {
            TreeNode tn = e.Node;

            if (tn.Nodes.Count == 0)
            {
                DMBlockItem blockItem = tn.Tag as DMBlockItem;
                if (blockDetailItems.ContainsKey(blockItem.code))
                {
                    List <DMBlockDetailItem> items = blockDetailItems[blockItem.code];
                    StringBuilder            sb    = new StringBuilder();
                    int itemsSize = items.Count;
                    for (int i = 0; i < itemsSize; i++)
                    {
                        sb.Append(items[i].code);
                        if (i != itemsSize - 1)
                        {
                            sb.Append(",");
                        }
                    }
                    rtbCodes.Text = sb.ToString();
                }
            }
        }
Beispiel #3
0
        /*获取数据*/
        /// <summary>
        /// 分析返回数据
        /// </summary>
        /// <param name="retOutput">返回数据</param>
        public DataTable AnalysisDMRetOutput(DMRetOutput retOutput)
        {
            DataTable result = new DataTable();

            if (retOutput.itemid == SDATA_TYPE_KEYSPRITE_IMPORTANT ||
                retOutput.itemid == SDATA_TYPE_KEYSPRITE_NOTIMPORTANT)
            {
                // Generate return table.
                result.Columns.Add("code");
                result.Columns.Add("name");
                result.Columns.Add("pingyin");
                result.Columns.Add("marketcode");
                result.Columns.Add("state");
                result.Columns.Add("innercode");
                result.Columns.Add("type");
                result.Columns.Add("timestamp");
                if (retOutput.ptr != null)
                {
                    List <DMSecuItem> items = new List <DMSecuItem>();
                    using (MemoryStream ms = new MemoryStream(retOutput.ptr))
                    {
                        using (BinaryReader br = new BinaryReader(ms))
                        {
                            int size = retOutput.size;

                            for (int i = 0; i < size; i++)
                            {
                                DMSecuItem item = new DMSecuItem();
                                item.code       = GetBytesString(br, 20);
                                item.name       = GetBytesString(br, 100);
                                item.pingyin    = GetBytesString(br, 100);
                                item.marketcode = GetBytesString(br, 40);
                                item.state      = br.ReadInt32();
                                item.innercode  = br.ReadInt32();
                                item.type       = br.ReadInt32();
                                item.timestamp  = br.ReadInt64();
                                items.Add(item);
                            }
                            for (int i = 0; i < size; i++)
                            {
                                DataRow r = result.NewRow();
                                r[0] = items[i].code;
                                r[1] = items[i].name;
                                r[2] = items[i].pingyin;
                                r[3] = items[i].marketcode;
                                r[4] = items[i].state;
                                r[5] = items[i].innercode;
                                r[6] = items[i].type;
                                r[7] = items[i].timestamp;
                                result.Rows.Add(r);
                            }
                        }
                    }
                }
            }
            else if (retOutput.itemid == SDATA_TYPE_KEYSPRITE_DELETE_IMPT ||
                     retOutput.itemid == SDATA_TYPE_KEYSPRITE_DELETE_NOTIMPT)
            {
                // Generate return table.
                result.Columns.Add("code");
                result.Columns.Add("timestamp");
                if (retOutput.ptr != null)
                {
                    List <DMSecuItemDelete> items = new List <DMSecuItemDelete>();
                    using (MemoryStream ms = new MemoryStream(retOutput.ptr))
                    {
                        using (BinaryReader br = new BinaryReader(ms))
                        {
                            int size = retOutput.size;
                            for (int i = 0; i < size; i++)
                            {
                                DMSecuItemDelete item = new DMSecuItemDelete();
                                item.code      = GetBytesString(br, 20);
                                item.timestamp = br.ReadInt64();
                                items.Add(item);
                            }
                            for (int i = 0; i < size; i++)
                            {
                                DataRow r = result.NewRow();
                                r[0] = items[i].code;
                                r[1] = items[i].timestamp;
                                result.Rows.Add(r);
                            }
                        }
                    }
                }
            }
            else if (retOutput.itemid == SDATA_TYPE_BLOCKDATATREE)
            {
                // Generate return table.
                result.Columns.Add("code");
                result.Columns.Add("name");
                result.Columns.Add("parentcode");
                result.Columns.Add("typcode");
                result.Columns.Add("typname");
                result.Columns.Add("tmpl");
                result.Columns.Add("order");
                result.Columns.Add("timestamp");
                if (retOutput.ptr != null)
                {
                    List <DMBlockItem> items = new List <DMBlockItem>();
                    using (MemoryStream ms = new MemoryStream(retOutput.ptr))
                    {
                        using (BinaryReader br = new BinaryReader(ms))
                        {
                            int size = retOutput.size;
                            for (int i = 0; i < size; i++)
                            {
                                DMBlockItem item = new DMBlockItem();
                                item.innerCode  = GetBytesString(br, 16);
                                item.code       = GetBytesString(br, 50);
                                item.name       = GetBytesString(br, 200);
                                item.parentcode = GetBytesString(br, 50);
                                item.typcode    = GetBytesString(br, 10);
                                item.typname    = GetBytesString(br, 200);
                                item.tmpl       = GetBytesString(br, 10);
                                item.order      = br.ReadInt32();
                                item.timestamp  = br.ReadInt64();
                                items.Add(item);
                            }
                            for (int i = 0; i < size; i++)
                            {
                                DataRow r = result.NewRow();
                                r[0] = items[i].code;
                                r[1] = items[i].name;
                                r[2] = items[i].parentcode;
                                r[3] = items[i].typcode;
                                r[4] = items[i].typname;
                                r[5] = items[i].tmpl;
                                r[6] = items[i].order;
                                r[7] = items[i].timestamp;
                                result.Rows.Add(r);
                            }
                        }
                    }
                }
            }
            else if (retOutput.itemid == SDATA_TYPE_BLOCKDETAIL_IMPT ||
                     retOutput.itemid == SDATA_TYPE_BLOCKDETAIL_NOTIMPT)
            {
                if (retOutput.requestid == 0 || retOutput.requestid == 1)
                {
                    // Generate return table.
                    result.Columns.Add("bkcode");
                    result.Columns.Add("code");
                    result.Columns.Add("innercode");
                    result.Columns.Add("timestamp");
                    if (retOutput.ptr != null)
                    {
                        List <DMBlockDetailItem> items = new List <DMBlockDetailItem>();
                        using (MemoryStream ms = new MemoryStream(retOutput.ptr))
                        {
                            using (BinaryReader br = new BinaryReader(ms))
                            {
                                br.ReadBytes(50);
                                int size = retOutput.size;
                                for (int i = 0; i < size; i++)
                                {
                                    DMBlockDetailItem item = new DMBlockDetailItem();
                                    item.bkcode    = GetBytesString(br, 50);
                                    item.code      = GetBytesString(br, 22);
                                    item.innercode = br.ReadInt32();
                                    item.timestamp = br.ReadInt64();
                                    items.Add(item);
                                }
                                for (int i = 0; i < size; i++)
                                {
                                    DataRow r = result.NewRow();
                                    r[0] = items[i].bkcode;
                                    r[1] = items[i].code;
                                    r[2] = items[i].innercode;
                                    r[3] = items[i].timestamp;
                                    result.Rows.Add(r);
                                }
                            }
                        }
                    }
                }
                else if (retOutput.requestid == 2)
                {
                    // Generate return table.
                    result.Columns.Add("code");
                    if (retOutput.ptr != null)
                    {
                        List <DMBlockData> items = new List <DMBlockData>();
                        using (MemoryStream ms = new MemoryStream(retOutput.ptr))
                        {
                            using (BinaryReader br = new BinaryReader(ms))
                            {
                                int size = retOutput.size;
                                for (int i = 0; i < size; i++)
                                {
                                    DMBlockData item = new DMBlockData();
                                    item.code = GetBytesString(br, 20);
                                    items.Add(item);
                                }
                                for (int i = 0; i < size; i++)
                                {
                                    DataRow r = result.NewRow();
                                    r[0] = items[i].code;

                                    result.Rows.Add(r);
                                }
                            }
                        }
                    }
                }
            }
            else if (retOutput.itemid == SDATA_TYPE_BKZSDYGX)
            {
                // Generate return table.
                result.Columns.Add("cPUBLISHCODE");
                result.Columns.Add("cSTR_EMCODE");
                result.Columns.Add("cSTR_LX");
                result.Columns.Add("innercode");
                if (retOutput.ptr != null)
                {
                    //SDM_IND_BKZSDYGX_TEST
                    List <SDM_IND_BKZSDYGX_TEST> items = new List <SDM_IND_BKZSDYGX_TEST>();
                    using (MemoryStream ms = new MemoryStream(retOutput.ptr))
                    {
                        using (BinaryReader br = new BinaryReader(ms))
                        {
                            int size = retOutput.size;
                            for (int i = 0; i < size; i++)
                            {
                                SDM_IND_BKZSDYGX_TEST item = new SDM_IND_BKZSDYGX_TEST();
                                item.cPUBLISHCODE = GetBytesString(br, 50);
                                item.cSTR_EMCODE  = GetBytesString(br, 60);
                                item.cSTR_LX      = GetBytesString(br, 22);
                                item.innerCode    = br.ReadInt32();
                                items.Add(item);
                            }
                            for (int i = 0; i < size; i++)
                            {
                                DataRow r = result.NewRow();
                                r[0] = items[i].cPUBLISHCODE;
                                r[1] = items[i].cSTR_EMCODE;
                                r[2] = items[i].cSTR_LX;
                                r[3] = items[i].innerCode;
                                result.Rows.Add(r);
                            }
                        }
                    }
                }
            }
            else if (retOutput.itemid == SDATA_TYPE_MAININDEX)
            {
                // Generate return table.
                result.Columns.Add("nINT_PAIXU");
                result.Columns.Add("cSTR_EMCODE");
                if (retOutput.ptr != null)
                {
                    List <sIND_MAININDEX> items = new List <sIND_MAININDEX>();
                    using (MemoryStream ms = new MemoryStream(retOutput.ptr))
                    {
                        using (BinaryReader br = new BinaryReader(ms))
                        {
                            int size = retOutput.size;
                            for (int i = 0; i < size; i++)
                            {
                                sIND_MAININDEX item = new sIND_MAININDEX();
                                item.nINT_PAIXU  = br.ReadInt32();
                                item.cSTR_EMCODE = GetBytesString(br, 60);
                                items.Add(item);
                            }

                            for (int i = 0; i < size; i++)
                            {
                                DataRow r = result.NewRow();
                                r[0] = items[i].nINT_PAIXU;
                                r[1] = items[i].cSTR_EMCODE;

                                result.Rows.Add(r);
                            }
                        }
                    }
                }
            }
            else if (retOutput.itemid == SDATA_TYPE_AREAINDGNLISH)
            {
                // Generate return table.
                result.Columns.Add("cSECURITYVARIETYCODE");
                result.Columns.Add("cSECURITYVARIETYCODEDC");
                result.Columns.Add("cSECURITYVARIETYCODEDY");
                if (retOutput.ptr != null)
                {
                    List <sDM_SPE_AREAINDGNLISH> items = new List <sDM_SPE_AREAINDGNLISH>();
                    using (MemoryStream ms = new MemoryStream(retOutput.ptr))
                    {
                        using (BinaryReader br = new BinaryReader(ms))
                        {
                            int size = retOutput.size;
                            for (int i = 0; i < size; i++)
                            {
                                sDM_SPE_AREAINDGNLISH item = new sDM_SPE_AREAINDGNLISH();
                                item.cSECURITYVARIETYCODE   = GetBytesString(br, 50);
                                item.cSECURITYVARIETYCODEDC = GetBytesString(br, 50);
                                item.cSECURITYVARIETYCODEDY = GetBytesString(br, 50);
                                items.Add(item);
                            }
                            for (int i = 0; i < size; i++)
                            {
                                DataRow r = result.NewRow();
                                r[0] = items[i].cSECURITYVARIETYCODE;
                                r[1] = items[i].cSECURITYVARIETYCODEDC;
                                r[2] = items[i].cSECURITYVARIETYCODEDY;

                                result.Rows.Add(r);
                            }
                        }
                    }
                }
            }
            else if (retOutput.itemid == SDATA_TYPE_AREAINDGNLISH_GN)
            {
                // Generate return table.
                result.Columns.Add("cSECURITYVARIETYCODE");
                result.Columns.Add("cSECURITYVARIETYCODEGN");
                if (retOutput.ptr != null)
                {
                    List <sDM_SPE_AREAINDGNLISH_GN> items = new List <sDM_SPE_AREAINDGNLISH_GN>();
                    using (MemoryStream ms = new MemoryStream(retOutput.ptr))
                    {
                        using (BinaryReader br = new BinaryReader(ms))
                        {
                            int size = retOutput.size;
                            for (int i = 0; i < size; i++)
                            {
                                sDM_SPE_AREAINDGNLISH_GN item = new sDM_SPE_AREAINDGNLISH_GN();
                                item.cSECURITYVARIETYCODE   = GetBytesString(br, 50);
                                item.cSECURITYVARIETYCODEGN = GetBytesString(br, 50);
                                items.Add(item);
                            }
                            for (int i = 0; i < size; i++)
                            {
                                DataRow r = result.NewRow();
                                r[0] = items[i].cSECURITYVARIETYCODE;
                                r[1] = items[i].cSECURITYVARIETYCODEGN;

                                result.Rows.Add(r);
                            }
                        }
                    }
                }
            }
            else if (retOutput.itemid == SDATA_TYPE_URL)
            {
                // Generate return table.
                result.Columns.Add("code");
                result.Columns.Add("url");
                result.Columns.Add("timestamp");
                if (retOutput.ptr != null)
                {
                    List <EMUrlItem> items = new List <EMUrlItem>();
                    using (MemoryStream ms = new MemoryStream(retOutput.ptr))
                    {
                        using (BinaryReader br = new BinaryReader(ms))
                        {
                            int size = retOutput.size;
                            for (int i = 0; i < size; i++)
                            {
                                EMUrlItem item = new EMUrlItem();
                                item.code      = GetBytesString(br, 20);
                                item.url       = GetBytesString(br, 200);
                                item.timestamp = br.ReadInt64();
                                items.Add(item);
                            }
                            for (int i = 0; i < size; i++)
                            {
                                DataRow r = result.NewRow();
                                r[0] = items[i].code;
                                r[1] = items[i].url;
                                r[2] = items[i].timestamp;
                                result.Rows.Add(r);
                            }
                        }
                    }
                }
            }
            else if (retOutput.itemid == SDATA_TYPE_URL_DELETE)
            {
                // Generate return table.
                result.Columns.Add("code");

                result.Columns.Add("timestamp");
                if (retOutput.ptr != null)
                {
                    List <UrlItemDel> items = new List <UrlItemDel>();
                    using (MemoryStream ms = new MemoryStream(retOutput.ptr))
                    {
                        using (BinaryReader br = new BinaryReader(ms))
                        {
                            int size = retOutput.size;
                            for (int i = 0; i < size; i++)
                            {
                                UrlItemDel item = new UrlItemDel();
                                item.code      = GetBytesString(br, 10);
                                item.timestamp = br.ReadInt64();
                                items.Add(item);
                            }
                            for (int i = 0; i < size; i++)
                            {
                                DataRow r = result.NewRow();
                                r[0] = items[i].code;
                                r[1] = items[i].timestamp;
                                result.Rows.Add(r);
                            }
                        }
                    }
                }
            }
            else if (retOutput.itemid == SDATA_TYPE_TYPE)
            {
                // Generate return table.
                result.Columns.Add("type");
                result.Columns.Add("typeCode");
                result.Columns.Add("typeCount");
                if (retOutput.ptr != null)
                {
                    List <sDMTyItem> items = new List <sDMTyItem>();
                    using (MemoryStream ms = new MemoryStream(retOutput.ptr))
                    {
                        using (BinaryReader br = new BinaryReader(ms))
                        {
                            int size = retOutput.size;
                            for (int i = 0; i < size; i++)
                            {
                                sDMTyItem item = new sDMTyItem();
                                item.type      = GetBytesString(br, 40);
                                item.typeCode  = GetBytesString(br, 40);
                                item.typeCount = br.ReadInt32();
                                items.Add(item);
                            }
                            for (int i = 0; i < size; i++)
                            {
                                DataRow r = result.NewRow();
                                r[0] = items[i].type;
                                r[1] = items[i].typeCode;
                                r[2] = items[i].typeCount;

                                result.Rows.Add(r);
                            }
                        }
                    }
                }
            }
            else if (retOutput.itemid == SDATA_TYPE_FUNDCOMPCODE)
            {
                // Generate return table.
                result.Columns.Add("pulishcode");
                result.Columns.Add("compcode");
                if (retOutput.ptr != null)
                {
                    List <sDMFundCompcode> items = new List <sDMFundCompcode>();
                    using (MemoryStream ms = new MemoryStream(retOutput.ptr))
                    {
                        using (BinaryReader br = new BinaryReader(ms))
                        {
                            int size = retOutput.size;
                            for (int i = 0; i < size; i++)
                            {
                                sDMFundCompcode item = new sDMFundCompcode();
                                item.pulishcode = GetBytesString(br, 50);
                                item.compcode   = GetBytesString(br, 10);
                                items.Add(item);
                            }
                            for (int i = 0; i < size; i++)
                            {
                                DataRow r = result.NewRow();
                                r[0] = items[i].pulishcode;
                                r[1] = items[i].compcode;

                                result.Rows.Add(r);
                            }
                        }
                    }
                }
            }
            else if (retOutput.itemid == SDATA_TYPE_STATE)
            {
                result.Columns.Add("nversion");
                result.Columns.Add("cversion");
                result.Columns.Add("nper");
                if (retOutput.ptr != null)
                {
                    using (MemoryStream ms = new MemoryStream(retOutput.ptr))
                    {
                        using (BinaryReader br = new BinaryReader(ms))
                        {
                            DataRow r = result.NewRow();
                            r[0] = br.ReadInt32();
                            r[1] = br.ReadInt32();
                            r[2] = br.ReadInt32();
                            result.Rows.Add(r);
                        }
                    }
                }
            }
            return(result);
        }
Beispiel #4
0
        /// <summary>
        /// 加载板块
        /// </summary>
        private void LoadBlocks()
        {
            DataTable dt  = DataCache.QuerySpeicalTopicCatory();
            DataTable dt2 = DataCache.QuerySpecialTopic();
            Dictionary <String, TreeNode> nodesMap2 = new Dictionary <String, TreeNode>();
            int nodesSzie = dt.Rows.Count;

            for (int i = 0; i < nodesSzie; i++)
            {
                DataRow  node     = dt.Rows[i];
                String   id       = node[0].ToString();
                String   text     = node[1].ToString();
                String   parentID = node[2].ToString();
                TreeNode tn2      = new TreeNode(id);
                tn2.Name = id;
                tn2.Text = text;
                if (nodesMap2.ContainsKey(parentID))
                {
                    nodesMap2[parentID].Nodes.Add(tn2);
                    nodesMap2[id] = tn2;
                }
                else
                {
                    tvList.Nodes.Add(tn2);
                    nodesMap2[id] = tn2;
                }
            }
            List <DMBlockItem> blocks = BlockService.Blocks;
            int blocksSize            = blocks.Count;
            Dictionary <String, TreeNode> nodesMap = new Dictionary <String, TreeNode>();
            Dictionary <String, String>   roots    = new Dictionary <String, String>();
            TreeNode tn = new TreeNode("沪深股票");

            tvBlocks.Nodes.Add(tn);
            nodesMap["1"] = tn;
            for (int i = 0; i < blocksSize; i++)
            {
                DMBlockItem blockItem = blocks[i];
                if (blockItem.name == "沪深股票")
                {
                    continue;
                }
                if (nodesMap.ContainsKey(blockItem.parentcode))
                {
                    TreeNode treeNode = new TreeNode(blockItem.name);
                    treeNode.Tag = blockItem;
                    nodesMap[blockItem.parentcode].Nodes.Add(treeNode);
                    nodesMap[blockItem.code] = treeNode;
                }
                else
                {
                    TreeNode treeNode = new TreeNode(blockItem.name);
                    treeNode.Tag = blockItem;
                    tvBlocks.Nodes.Add(treeNode);
                    nodesMap[blockItem.code] = treeNode;
                }
            }
            blockDetailItems = BlockService.BlockDetails;
            nodesMap.Clear();
            System.GC.Collect();
        }