Ejemplo n.º 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;
        }
Ejemplo n.º 2
0
 /// <summary>
 ///
 /// </summary>
 /// <param name="tagId"></param>
 /// <param name="tlv"></param>
 /// <param name="tagsManager"></param>
 private static void WriteTlv(UInt32 tagId, TlvData tlv, TlvDictionary tagsManager)
 {
     Console.WriteLine("  >> Contains tag {0:X2}: {1} [ {2} ]", tagId, tlv.HasTag(tagId), tlv.GetTag(tagId));
     if (tlv.HasTag(tagId) && (tagsManager.CreateInstance(tlv.GetTag(tagId)) != null))
     {
         Console.ForegroundColor = ConsoleColor.Blue;
         Console.WriteLine("     >> {0:N}: {0}", tagsManager.CreateInstance(tlv.GetTag(tagId)));
         Console.ForegroundColor = ConsoleColor.Gray;
     }
 }
Ejemplo n.º 3
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="tagId"></param>
        /// <param name="tlv"></param>
        /// <param name="tagsManager"></param>
        private void WriteTlv(UInt32 tagId, TlvData tlv, TlvDictionary tagsManager)
        {
            gui.guiDetailedLogs.AppendText(String.Format("  >> TLV {0:X2}: [ {1} ]\n", tagId, tlv.GetTag(tagId)));

            if (!tlv.HasTag(tagId) || (tagsManager.CreateInstance(tlv.GetTag(tagId)) == null))
            {
                return;
            }

            gui.guiDetailedLogs.SelectionColor = highlightColor;
            gui.guiDetailedLogs.AppendText(String.Format("     >> {0:N}: {0}\n", tagsManager.CreateInstance(tlv.GetTag(tagId))));
            gui.guiDetailedLogs.SelectionColor = standardColor;
        }
Ejemplo n.º 4
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);
        }
Ejemplo n.º 5
0
        private void AfterPseRead(Object sender, EmvEventArgs eventArgs)
        {
            var pse = sender as PaymentSystemEnvironment;

            if (pse == null)
            {
                throw new ArgumentException("sender is not a PaymentSystemEnvironment");
            }

            Console.WriteLine();
            Console.WriteLine("= = = = = = P S E   R e a d");
            Console.WriteLine();

            foreach (var record in pse.TlvRecords)
            {
                foreach (TlvData tlv in record.GetTags())
                {
                    xmlRoot.Elements().Last().Add(tlv.ToXmlNode(xmlDoc));
                    WriteTlv(tlv.Tag, tlv, tagsManager);
                }
            }

            Console.WriteLine();
            Console.WriteLine("=========== P S E   A p p l i c a t i o n s   f o u n d");
            Console.WriteLine();

            foreach (var emvFound in pse.GetApplications())
            {
                Console.WriteLine("  >> Application '{0}' [ {1} ] found", emvFound.Aid, tagsManager.CreateInstance(emvFound.TlvFromPSE.GetTag(0x50)));
            }
        }
Ejemplo n.º 6
0
        public void AfterPseRead(Object sender, EmvEventArgs eventArgs)
        {
            var pse = sender as PaymentSystemEnvironment;

            if (pse == null)
            {
                throw new ArgumentException("sender is not a PaymentSystemEnvironment");
            }

            foreach (var record in pse.TlvRecords)
            {
                foreach (TlvData tlv in record.GetTags())
                {
                    WriteTlv(tlv.Tag, tlv, TlvDictionary);
                }
            }

            gui.guiDetailedLogs.AppendText("\n");
            gui.guiDetailedLogs.AppendText("PSE Applications found:\n");

            foreach (var emvFound in pse.GetApplications())
            {
                gui.guiDetailedLogs.AppendText(String.Format("  >> Application '{0}' [ {1} ] found\n", emvFound.Aid, TlvDictionary.CreateInstance(emvFound.TlvFromPSE.GetTag(0x50))));
            }
        }