Exemple #1
0
        private void UpdateLogRecords(EmvApplication emv)
        {
            if (emv.LogRecords == null)
            {
                return;
            }

            // Initialize the output
            guiLogRecords.Columns.Clear();
            guiLogRecords.Items.Clear();

            // Set column names. If tag is known by tlvManager, its name is used instead of the tag number.
            guiLogRecords.Columns.Add("Record");
            foreach (var dol in emv.LogFormat.GetDataObjectDefinitions())
            {
                var tagStr = String.Format("{0:T}", dol);
                if (_tlvDictionary.Get(tagStr) != null)
                {
                    guiLogRecords.Columns.Add(_tlvDictionary.Get(tagStr).Name);
                }
                else
                {
                    guiLogRecords.Columns.Add(tagStr);
                }
            }

            // Fill the list view: 1 line (list view item) by record
            byte recordNumber = 0;

            foreach (var tlvDataList in emv.LogRecords)
            {
                recordNumber++;
                var item = new ListViewItem(String.Format("{0}", recordNumber));
                foreach (var tlvData in tlvDataList)
                {
                    // if tag is known by tlvManager, use the corresponding AbstractTLVObject else use BinaryTlvObject.
                    var tagStr = String.Format("{0:T}", tlvData);
                    if (_tlvDictionary.Get(tagStr) != null)
                    {
                        var tlvObject = _tlvDictionary.CreateInstance(tagStr);
                        tlvObject.Tlv = tlvData;
                        item.SubItems.Add(String.Format("{0}", tlvObject));
                    }
                    else
                    {
                        AbstractTlvObject tlvObject = new BinaryTlvObject();
                        tlvObject.Tlv = tlvData;
                        item.SubItems.Add(String.Format("{0}", tlvObject));
                    }
                }
                guiLogRecords.Items.Add(item);
            }
            guiLogRecords.AutoResizeColumns(ColumnHeaderAutoResizeStyle.ColumnContent);

            guiDoCardLogSave.Enabled = true;
        }
Exemple #2
0
        private static TreeNode ConvertTlvDataToTreeNode(TlvData tlv, TlvDictionary tlvManager)
        {
            TreeNode tlvNode;

            if (tlvManager != null && tlvManager.Get(String.Format("{0:T}", tlv)) != null)
            {
                var tlvObject = tlvManager.CreateInstance(tlv);
                tlvObject.Tlv = tlv;
                tlvNode       = new TreeNode(String.Format("{0:N}: {0}", tlvObject));
            }
            else
            {
                tlvNode = new TreeNode(String.Format("T:{0:T} L:{0:L} V:{0:Vh}", tlv));
            }
            foreach (var subTLV in tlv.InnerTlvs)
            {
                tlvNode.Nodes.Add(ConvertTlvDataToTreeNode(subTLV, tlvManager));
            }
            return(tlvNode);
        }