/// <summary> /// 获取板块明细 /// </summary> /// <returns></returns> public Dictionary <String, List <DMBlockDetailItem> > GetBlockDetailItems() { Dictionary <String, List <DMBlockDetailItem> > list = new Dictionary <String, List <DMBlockDetailItem> >(); String code = ""; long time = 0; while (true) { DMRetOutput dm1 = UpdateBlockDetail(time, code, 0, 1, true); DMBlockDetailItem lastItem = null; using (MemoryStream ms = new MemoryStream(dm1.ptr)) { using (BinaryReader br = new BinaryReader(ms)) { int size = dm1.size; br.ReadBytes(50); 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(); if (!list.ContainsKey(item.bkcode)) { list[item.bkcode] = new List <DMBlockDetailItem>(); } list[item.bkcode].Add(item); lastItem = item; } } } if (!dm1.last) { if (lastItem != null) { code = lastItem.code.Replace("\0", ""); time = lastItem.timestamp; } } if (dm1.last) { dm1.ptr = null; break; } else { dm1.ptr = null; } } code = ""; time = 0; #region Delete NON_IMPORTANT //while (true) //{ // DMRetOutput dm1 = UpdateBlockDetail(time, code, 0, 1, false); // DMBlockDetailItem lastItem = null; // using (MemoryStream ms = new MemoryStream(dm1.ptr)) // { // using (BinaryReader br = new BinaryReader(ms)) // { // int size = dm1.size; // br.ReadBytes(50); // 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(); // if (!list.ContainsKey(item.bkcode)) // { // list[item.bkcode] = new List<DMBlockDetailItem>(); // } // list[item.bkcode].Add(item); // lastItem = item; // } // } // } // if (!dm1.last) // { // if (lastItem != null) // { // code = lastItem.code.Replace("\0", ""); // time = lastItem.timestamp; // } // } // if (dm1.last) // { // dm1.ptr = null; // break; // } // else // { // dm1.ptr = null; // } //} #endregion return(list); }
/*获取数据*/ /// <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); }