//*************************************************************
        private void ReadDiff()
        {
            string xText = "";

            string[] xArr = null;
            MMTP_Parser.Entity.MMTP.DIFF.Header xHeader = new MMTP_Parser.Entity.MMTP.DIFF.Header();
            Byte[] xArrFirstSub = new Byte[95];
            if (Config._ReadFromMMTPLogMessage.Nvl(0) == 0)
            {
                _NetStream.Read(xArrFirstSub, 0, xArrFirstSub.Length);
            }
            else
            {
                xText = _StreamReader.ReadLine();
                if (xText == null)
                {
                }
                xArr = xText.Split(',');

                for (int i = 0; i < xArrFirstSub.Length; i++)
                {
                    xArrFirstSub[i] = Convert.ToByte(xArr[i]);
                }
            }
            xHeader.FillFirstSub(xArrFirstSub);
            if (xHeader._IsFirstSubFiled)
            {
                Byte[] xArrSecondSub = new Byte[xHeader._ObsFields.GetFieldFromObs("Business_Data_Length")._Numerical.Nvl(0) + 1];
                if (Config._ReadFromMMTPLogMessage.Nvl(0) == 0)
                {
                    _NetStream.Read(xArrSecondSub, 0, xArrSecondSub.Length);
                }
                else
                {
                    for (int i = 95; i < xArrSecondSub.Length; i++)
                    {
                        xArrSecondSub[i - 95] = Convert.ToByte(xArr[i]);
                    }
                }
                xHeader.FillSecondSub(xArrSecondSub);
                if (xHeader._BusinessDataHeader._IsValedMessage)
                {
                    if (Config._WriteMMTPLogMessageUnReadable.Nvl(0) == 1)
                    {
                        Tool.WriteToTxtMmtpUnReadable(xArrFirstSub, xArrSecondSub);
                    }
                    if (Config._WriteMMTPLogMessageReadable.Nvl(0) == 1)
                    {
                        Tool.WriteToTxtMmtpDiffReadable(xHeader);
                    }
                    _ObsMessageDiff.Add(xHeader);
                }
            }
        }
Example #2
0
        //*************************************************************
        public static void WriteToTxtMmtpDiffReadable(MMTP_Parser.Entity.MMTP.DIFF.Header vHeader)
        {
            string xMessageReadable = "";

            xMessageReadable = vHeader._BusinessDataHeader._InstrumentCharacteristicHeader._ObsFields.GetFieldFromObs("Message_Type_Code")._Alphanumerical + "," + vHeader._BusinessDataHeader._InstrumentCharacteristicHeader._ObsFields.GetFieldFromObs("CValMne")._Alphanumerical + ",";
            foreach (var item in vHeader._BusinessDataHeader._MessageContents._ObsFields)
            {
                xMessageReadable += item._Name + "==>";
                try
                {
                    switch (item._Type)
                    {
                    case FieldType.Alphanumerical:
                        xMessageReadable += item._Alphanumerical + ",";
                        break;

                    case FieldType.Numerical:
                        xMessageReadable += item._Numerical + ",";
                        break;

                    case FieldType.Binary:
                        xMessageReadable += ",";
                        break;

                    case FieldType.QtmX:
                        xMessageReadable += item._QtmX._Amount + ",";
                        break;

                    case FieldType.BusinessDataHeader:
                        xMessageReadable += ",";
                        break;

                    default:
                        break;
                    }
                }
                catch (Exception)
                {
                    xMessageReadable += ",";
                }
            }
            xMessageReadable = xMessageReadable.Remove(xMessageReadable.Length - 1);
            using (FileStream fs = new FileStream(string.Format("MMTP-Readable-" + DateTime.Now.Year + "-" + DateTime.Now.Month + "-" + DateTime.Now.Day + ".log"), FileMode.Append, FileAccess.Write))
                using (StreamWriter sw = new StreamWriter(fs))
                {
                    sw.Write(xMessageReadable + "\n");
                }
        }