Ejemplo n.º 1
0
        /// <summary>
        /// Builds UDR to be used with STORE DATA command for given processing options.
        /// </summary>
        /// <param name="sequenceModel"></param>
        /// <returns></returns>
        public string BuildDgi(TagValuesSequenceModel sequenceModel)
        {
            var command = String.Empty;

            if (sequenceModel.Fields != null)
            {
                command = sequenceModel.Fields
                          .Select(t => BuildDgi(new TagModel {
                    Tag = t
                }))
                          .Aggregate(String.Empty, (c, s) => c + s);
            }

            return(String.Format("{0}{1}{2}", sequenceModel.Dgi, TlvDataHelper.ToBerEncodedL((uint)command.Length / 2).ToHexa('\0'), command));
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Builds DGI to be used with STORE DATA command for given FCI .
        /// </summary>
        /// <param name="fciModel"></param>
        /// <returns></returns>
        public string BuildDgi(FciModel fciModel)
        {
            var fields = new List <TagModel>();

            if (fciModel.Tags != null)
            {
                fields.AddRange(fciModel.Tags);
            }

            var tagModel = new TagModel {
                Tag = "A5", Fields = fields
            };
            var command = BuildDgi(tagModel);

            return($"{fciModel.Dgi}{TlvDataHelper.ToBerEncodedL((uint)command.Length / 2).ToHexa('\0')}{command}");
        }
Ejemplo n.º 3
0
        /// <summary>
        /// Builds UDR to be used with STORE DATA command for given FCI .
        /// </summary>
        /// <param name="fciModel"></param>
        /// <returns></returns>
        public string BuildDgi(FciModel fciModel)
        {
            var fields = new List <TagModel>();

            if (fciModel.Tags != null)
            {
                fields.AddRange(fciModel.Tags);
            }

            var tagModel = new TagModel {
                Tag = "A5", Fields = fields
            };
            var command = BuildDgi(tagModel);

            return(String.Format("{0}{1}{2}", fciModel.Dgi, TlvDataHelper.ToBerEncodedL((uint)command.Length / 2).ToHexa('\0'), command));
        }
Ejemplo n.º 4
0
        /// <summary>
        /// Builds DGI to be used with STORE DATA command for given records having the same index.
        /// </summary>
        /// <param name="sfi"></param>
        /// <param name="index"></param>
        /// <param name="records"></param>
        /// <returns></returns>
        public string BuildDgi(byte sfi, byte index, IEnumerable <PseRecord> records)
        {
            var tlv70 = new TlvData(0x70, new List <TlvData>());

            foreach (var record in records)
            {
                var tlvs = new List <TlvData> {
                    new TlvData {
                        Tag = 0x4F, Value = record.AdfName.FromHexa()
                    },
                    new TlvData {
                        Tag = 0x50, Value = record.ApplicationLabel.FromString()
                    }
                };

                if (!String.IsNullOrWhiteSpace(record.PreferredName))
                {
                    tlvs.Add(new TlvData {
                        Tag = 0x9F12, Value = record.PreferredName.FromString()
                    });
                }

                if (record.PriorityIndicator.HasValue)
                {
                    tlvs.Add(new TlvData {
                        Tag = 0x87, Value = record.PriorityIndicator.Value.ToByteArray()
                    });
                }

                if (!String.IsNullOrWhiteSpace(record.DiscretionaryData))
                {
                    tlvs.Add(new TlvData {
                        Tag = 0x73, Value = record.DiscretionaryData.FromHexa()
                    });
                }

                var tlv61 = new TlvData(0x61, tlvs);
                tlv70.InnerTlvs.Add(tlv61);
            }

            var dgiLength = TlvDataHelper.ToBerEncodedL((uint)tlv70.Length / 2);

            return($"{sfi:X2}{index:X2}{dgiLength.ToHexa('\0')}{tlv70.ToByteArray().ToHexa()}");
        }
Ejemplo n.º 5
0
        /// <summary>
        /// Builds UDR to be used with PUT DATA command for given record .
        /// </summary>
        /// <param name="recordModel"></param>
        /// <returns></returns>
        public string BuildDgi(RecordModel recordModel)
        {
            var fields = new List <TagModel>();

            if (recordModel.Fields != null)
            {
                fields.AddRange(recordModel.Fields.Select(t => new TagModel {
                    Tag = t
                }));
            }

            var tagModel = new TagModel {
                Tag = "70", Fields = fields
            };
            var command = BuildDgi(tagModel);

            return(String.Format("{0:X2}{1:X2}{2}{3}", recordModel.Sfi, recordModel.Index, TlvDataHelper.ToBerEncodedL((uint)command.Length / 2).ToHexa('\0'), command));
        }