示例#1
0
        public void OnLR()
        {
            NamedPipeClientStream ClientPipe = new NamedPipeClientStream(".", "__YiYi_Dance__", PipeDirection.InOut);

            ClientPipe.Connect();

            my_header myheader = new my_header();

            myheader._lCommandID  = (UInt32)EXCEL_PROTOCOL_ID.ONLY_HEAD;
            myheader._lPackSize   = 0;
            myheader._lExtendData = new UInt32[] { (UInt32)EXCEL_PROTOCOL_ID.REPORT_STOCK, 0, 0 };

            byte[] buffer = StructToBytes(myheader);
            ClientPipe.Write(buffer, 0, buffer.Length);

            //ums_block_index

            byte[]    headerbyte   = new byte[20];
            int       readCount    = 0;
            my_header myheaderrecv = new my_header();

            if ((readCount = ClientPipe.Read(headerbyte, 0, 20)) > 0)
            {
                myheaderrecv = (my_header)BytesToStruct(headerbyte, myheaderrecv.GetType());
            }
            byte[] datebyte = new byte[8613];
            while (true)
            {
                readCount = ClientPipe.Read(datebyte, 0, 8613);
                if (readCount < 0)
                {
                    break;
                }
                ums_rptfunc functemp = new ums_rptfunc();
                functemp = (ums_rptfunc)BytesToStruct(datebyte, functemp.GetType());
                rptfuncs.Add(functemp);
                if (rptfuncs.Count == myheaderrecv._lExtendData[0])
                {
                    break;
                }
            }

            rptfuncs.TrimToSize();
            ClientPipe.Close();
        }
示例#2
0
        public void ReadReportType()
        {
            NamedPipeClientStream ClientPipe = new NamedPipeClientStream(".", "__YiYi_Dance__", PipeDirection.InOut);

            ClientPipe.Connect();

            my_header myheader = new my_header();

            myheader._lCommandID  = (UInt32)EXCEL_PROTOCOL_ID.ONLY_HEAD;
            myheader._lPackSize   = 0;
            myheader._lExtendData = new UInt32[] { (UInt32)EXCEL_PROTOCOL_ID.REPORT_TYPE, 0, 0 };

            byte[] buffer = StructToBytes(myheader);
            ClientPipe.Write(buffer, 0, buffer.Length);

            int bytesize = Marshal.SizeOf(typeof(my_header));

            byte[]    headerbyte   = new byte[bytesize];
            int       readCount    = 0;
            my_header myheaderrecv = new my_header();

            if ((readCount = ClientPipe.Read(headerbyte, 0, bytesize)) > 0)
            {
                myheaderrecv = (my_header)BytesToStruct(headerbyte, myheaderrecv.GetType());
            }
            bytesize = Marshal.SizeOf(typeof(ums_rpttype));
            byte[] datebyte = new byte[bytesize];
            while (true)
            {
                if (rpttypes.Count == myheaderrecv._lExtendData[0])
                {
                    break;
                }
                readCount = ClientPipe.Read(datebyte, 0, bytesize);
                if (readCount < 0)
                {
                    break;
                }
                ums_rpttype functemp = new ums_rpttype();
                functemp = (ums_rpttype)BytesToStruct(datebyte, functemp.GetType());
                rpttypes.Add(functemp);
            }
            rpttypes.TrimToSize();
            ClientPipe.Close();
        }