예제 #1
0
        /*
         * We parse this Zoned-Decimal format by Hex Value
         */
        protected override Decimal getTypedValue(byte[] bytes, Dictionary <string, string> settings)
        {
            string input = ElementExtend.BytesToHex(bytes);

            var  numbers  = input.ToUpper().Replace("F", "").Replace("D", "");
            bool negative = this.IsSigned && input.ToUpper().Contains("D");

            return(Decimal.Parse((negative ? "-" : "") + numbers) / (decimal)BigInteger.Pow(10, this.DecimalPlaces));
        }
예제 #2
0
        protected override Decimal getTypedValue(byte[] bytes, Dictionary <string, string> settings)
        {
            string input = ElementExtend.BytesToHex(bytes);

            if (input.EndsWith("D"))
            {
                input = "-" + input;
            }
            input = input.Replace("F", "").Replace("D", "");

            return(Decimal.Parse(input) / (decimal)BigInteger.Pow(10, this.DecimalPlaces));
        }
예제 #3
0
        static void Main(string[] args)
        {
            Console.WriteLine("Hello World!");
            using (var stream = File.Open(args[0], FileMode.Open))
            {
                var group = CopybookParser.parse("test", stream);
                PrintElement(group, 1);

                dynamic record = new Data(group);


                Console.WriteLine(record.Name);
                Console.WriteLine(record.CLIRTVO_REC.Name);
                Console.WriteLine(record.CLIRTVO_REC.MESSAGE_HEADER.Name);

                record.CLIRTVO_REC.MESSAGE_HEADER.MSGIDA = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
                Console.WriteLine(ElementExtend.BytesToHex(record.CLIRTVO_REC.MESSAGE_HEADER.MSGIDA.GetBytes()));

                string result = record.CLIRTVO_REC.MESSAGE_HEADER.MSGIDA;
                Console.WriteLine(result);

                record.CLIRTVO_REC.MESSAGE_HEADER.MSGLNG = 12345;
                Console.WriteLine(ElementExtend.BytesToHex(record.CLIRTVO_REC.MESSAGE_HEADER.MSGLNG.GetBytes()));
                decimal msglng = record.CLIRTVO_REC.MESSAGE_HEADER.MSGLNG;
                Console.WriteLine(msglng);

                record.CLIRTVO_REC.MESSAGE_HEADER.MSGCNT = -123.456;
                Console.WriteLine(ElementExtend.BytesToHex(record.CLIRTVO_REC.MESSAGE_HEADER.MSGCNT.GetBytes()));
                decimal msgcnt = record.CLIRTVO_REC.MESSAGE_HEADER.MSGCNT;
                Console.WriteLine(msgcnt);

                record.CLIRTVO_REC.MESSAGE_DATA.BGEN_XXXXX[0].BGEN_XXXXX_TRANS_NO1 = 1234;
                Console.WriteLine(ElementExtend.BytesToHex(record.CLIRTVO_REC.MESSAGE_DATA.BGEN_XXXXX[0].BGEN_XXXXX_TRANS_NO1.GetBytes()));
                decimal tran_no1 = record.CLIRTVO_REC.MESSAGE_DATA.BGEN_XXXXX[0].BGEN_XXXXX_TRANS_NO1;
                Console.WriteLine(tran_no1);


                record.CLIRTVO_REC.MESSAGE_DATA.BGEN_XXXXX[1].BGEN_XXXXX_TRANS_NO3 = -123.12;
                Console.WriteLine(ElementExtend.BytesToHex(record.CLIRTVO_REC.MESSAGE_DATA.BGEN_XXXXX[1].BGEN_XXXXX_TRANS_NO3.GetBytes()));
                decimal tran_no3 = record.CLIRTVO_REC.MESSAGE_DATA.BGEN_XXXXX[1].BGEN_XXXXX_TRANS_NO3;
                Console.WriteLine(tran_no3);


                //record.CLIRTVO_REC.MESSAGE_HEADER.MSGIDA = Encoding.UTF32.GetBytes("香港湾仔");
            }
        }