Exemple #1
0
        private void CreateMsg()
        {
            FTParserUtil util = new FTParserUtil(allBuffer);
            var root = util.Parser();

            //root.CreateMsg()
        }
Exemple #2
0
        private void ProcessTransferBuffer()
        {
            var length = 0;
            foreach (byte[] temp in allBuffer)
            {
                length += temp.Length;
            }

            byte[] buffer = new byte[length];
            length = 0;
            foreach (byte[] temp in allBuffer)
            {
                Array.Copy(temp, 0, buffer, length, temp.Length);
                length += temp.Length;
            }

            GenerateTransferBinFile(buffer, oldTransferBin);

            GenerateTransferTxtFile(buffer, oldTransferTxt);

            FTParserUtil parserUtil = new FTParserUtil(allBuffer);
            FTMessageTreeRoot root = parserUtil.Parser();

            GenerateMessageBin(root);

            GenerateMessageTransferTxtFile();

            using (FileStream readerCom = new FileStream(oldTransferBin, FileMode.Open))
            {
                using (FileStream readerAfterWriter = new FileStream(newTransferBin, FileMode.Open))
                {
                    int readed = 0;
                    while (true)
                    {
                        if (readerCom.Length == readerCom.Position || readerAfterWriter.Length == readerAfterWriter.Position)
                        {
                            break;
                        }

                        var b1 = readerCom.ReadByte();
                        var b2 = readerAfterWriter.ReadByte();
                        readed++;

                        Assert.AreNotSame(b1, b2, string.Format("In index [2], oldByte:[0] is not equal newByte [1]", b1, b2, readed));
                    }
                }
            }

            IList<IFTTransferUnit> allTransferUnit = new List<IFTTransferUnit>();
            root.GetAllTransferUnit(allTransferUnit);

            int allUnitCount = 0;
            foreach (IFTTransferUnit unit in allTransferUnit)
            {
                allUnitCount += unit.BytesCount;
            }

            Assert.AreNotSame(allUnitCount, root.BytesCount, string.Format("allUnitCountByte:[0] is not equal message all Bytes:[1]", allUnitCount, root.BytesCount));
            Assert.AreNotSame(allUnitCount, length, string.Format("after parse, the bytes count:[0] is not equal old bin file length:[1].", allUnitCount, length));

            GenerateStreamByMessage(allTransferUnit);
        }