Exemple #1
0
        public Optional <FIDBase> FindFid(FIDMeta meta)
        {
            FIDBase fidFound = null;

            foreach (FIDBase fid in Fids)
            {
                if (fid.Children.Count == 0)
                {
                    if (fid.Id == meta.Id && fid.SubId == meta.SubId)
                    {
                        fidFound = fid;
                    }
                }
                else
                {
                    foreach (FIDBase fidChild in fid.Children)
                    {
                        if (fidChild.Id == meta.Id && fidChild.SubId == meta.SubId)
                        {
                            fidFound = fidChild;
                        }
                    }
                }
            }
            if (fidFound != null)
            {
                return(Optional <FIDBase> .Create(fidFound));
            }
            else
            {
                return(Optional <FIDBase> .CreateEmpty());
            }
        }
Exemple #2
0
 protected Optional <bool> GetBoolParameter(Dictionary <string, string> options, string parameter)
 {
     if (!options.ContainsKey(parameter))
     {
         return(Optional <bool> .CreateEmpty());
     }
     return(Optional <bool> .Create(bool.Parse(options[parameter])));
 }
Exemple #3
0
 protected Optional <sbyte> GetSbyteParameter(Dictionary <string, string> options, string parameter)
 {
     if (!options.ContainsKey(parameter))
     {
         return(Optional <sbyte> .CreateEmpty());
     }
     return(Optional <sbyte> .Create(sbyte.Parse(options[parameter])));
 }
Exemple #4
0
 protected Optional <int> GetIntParameter(Dictionary <string, string> options, string parameter)
 {
     if (!options.ContainsKey(parameter))
     {
         return(Optional <int> .CreateEmpty());
     }
     return(Optional <int> .Create(int.Parse(options[parameter])));
 }
Exemple #5
0
        public static Optional <string> getVanillaTpl(string mapIcon)
        {
            try
            {
                var result = from row in VanillaDatabase.getMapTable().AsEnumerable()
                             where row.Field <string>("Map Icon") == mapIcon
                             select row.Field <string>("Map Tpl");

                if (result.Any() && result.Distinct().Single() != null)
                {
                    return(Optional <string> .Create(result.Distinct().Single()));
                }
            }
            catch (IndexOutOfRangeException e) { }
            return(Optional <string> .CreateEmpty());
        }
Exemple #6
0
        public static Optional <UInt32> getBgmIdFromVanillaBackground(string background)
        {
            try
            {
                var result = from row in VanillaDatabase.getMapTable().AsEnumerable()
                             where row.Field <string>("Background") == background
                             select row.Field <UInt32>("Bgm Id");

                if (result.Any())
                {
                    return(Optional <UInt32> .Create(result.Distinct().Single()));
                }
            }
            catch (IndexOutOfRangeException e) { }
            return(Optional <UInt32> .CreateEmpty());
        }
        private static Optional <Tuple <TerminalSupportedKernelAidTransactionTypeCombination, CardKernelAidCombination> > AskCardHolderToSelect(List <Tuple <TerminalSupportedKernelAidTransactionTypeCombination, CardKernelAidCombination> > candidateList, IUICallbackProvider uiProvider)
        {
            List <String> candidatesStrings = candidateList.Select(x => Formatting.ByteArrayToASCIIString(x.Item2.ApplicationLabel.Value) + ":" + Formatting.ByteArrayToHexString(x.Item2.AdfNameTag.Value)).ToList();
            String        selected          = uiProvider.DisplayApplicationList(candidatesStrings);

            if (!string.IsNullOrEmpty(selected))
            {
                Tuple <TerminalSupportedKernelAidTransactionTypeCombination, CardKernelAidCombination> selectedTuple =
                    candidateList.Where(x => Formatting.ByteArrayToHexString(x.Item2.AdfNameTag.Value) == selected).First();
                return(Optional <Tuple <TerminalSupportedKernelAidTransactionTypeCombination, CardKernelAidCombination> > .Create(selectedTuple));
            }
            else
            {
                return(Optional <Tuple <TerminalSupportedKernelAidTransactionTypeCombination, CardKernelAidCombination> > .CreateEmpty());
            }
        }
        public DatabaseSupportManifest(JObject json)
        {
            this.SupportedExtensions = new List <string>();

            foreach (var ext in json["supported_file_types"].Value <JArray>())
            {
                this.SupportedExtensions.Add(ext.Value <string>());
            }

            switch (json["merge_mode"].Value <string>())
            {
            case "none":
                this.MergeMode = MergeMode.None;
                break;

            case "consecutive":
                this.MergeMode = MergeMode.Consecutive;
                break;

            case "any":
                this.MergeMode = MergeMode.Any;
                break;
            }

            this.MaxGames     = json["max_games"].Value <ulong>();
            this.MaxPositions = json["max_positions"].Value <ulong>();
            this.MaxInstancesOfSinglePosition = json["max_instances_of_single_position"].Value <ulong>();

            this.HasOneWayKey = json["has_one_way_key"].Value <bool>();
            if (this.HasOneWayKey)
            {
                this.EstimatedMaxCollisions = json["estimated_max_collisions"].Value <ulong>();
                this.EstimatedMaxPositionsWithNoCollisions = json["estimated_max_positions_with_no_collisions"].Value <ulong>();
            }

            this.HasCount = json["has_count"].Value <bool>();

            this.HasEloDiff = json["has_elo_diff"].Value <bool>();
            if (this.HasEloDiff)
            {
                this.MaxAbsEloDiff        = json["max_abs_elo_diff"].Value <ulong>();
                this.MaxAverageAbsEloDiff = json["max_average_abs_elo_diff"].Value <ulong>();
            }

            this.HasWhiteElo = json["has_white_elo"].Value <bool>();
            this.HasBlackElo = json["has_black_elo"].Value <bool>();
            if (this.HasWhiteElo || this.HasBlackElo)
            {
                this.MinElo          = json["min_elo"].Value <ulong>();
                this.MaxElo          = json["max_elo"].Value <ulong>();
                this.HasCountWithElo = json["has_count_with_elo"].Value <bool>();
            }

            this.HasFirstGame = json["has_first_game"].Value <bool>();
            this.HasLastGame  = json["has_last_game"].Value <bool>();

            this.AllowsFilteringTranspositions = json["allows_filtering_transpositions"].Value <bool>();
            this.HasReverseMove = json["has_reverse_move"].Value <bool>();

            this.AllowsFilteringByEloRange = json["allows_filtering_by_elo_range"].Value <bool>();
            this.EloFilterGranularity      = json["elo_filter_granularity"].Value <ulong>();

            this.AllowsFilteringByMonthRange = json["allows_filtering_by_month_range"].Value <bool>();
            this.MonthFilterGranularity      = json["month_filter_granularity"].Value <ulong>();

            this.MaxBytesPerPosition = json["max_bytes_per_position"].Value <ulong>();

            if (json.ContainsKey("estimated_average_bytes_per_position"))
            {
                this.EstimatedAverageBytesPerPosition = Optional <ulong> .Create(json["estimated_average_bytes_per_position"].Value <ulong>());
            }
            else
            {
                this.EstimatedAverageBytesPerPosition = Optional <ulong> .CreateEmpty();
            }
        }
Exemple #9
0
 private void cmdCancelTx_Clicked(object sender, EventArgs e)
 {
     Stop();
     txResult = TxResult.Cancelled;
     SetTxFinalResultLabel("");
     SetStatusLabel(new UIMessageEventArgs(MessageIdentifiersEnum.ClearDisplay, StatusEnum.EndProcessing), InterFaceType.Cancelled);
     TxCompleted?.Invoke(this, new TxCompletedEventArgs(txResult, InterFaceType.Cancelled, Optional <TLV> .CreateEmpty(), Optional <QRDEList> .CreateEmpty()));
 }
        CreateCandidateListByDirMethod(CardQProcessor cardInterfaceManager)
        {
            List <Tuple <TerminalSupportedKernelAidTransactionTypeCombination, CardKernelAidCombination> > candidateList = new List <Tuple <TerminalSupportedKernelAidTransactionTypeCombination, CardKernelAidCombination> >();

            foreach (TerminalSupportedKernelAidTransactionTypeCombination kc in TerminalSupportedKernelAidTransactionTypeCombinations.SupportedContactCombinations)
            {
                string finalAdfName = Enum.GetName(typeof(AIDEnum), ((TerminalSupportedContactKernelAidTransactionTypeCombination)kc).AIDEnum);
                #region 12.3.3 Step 1
                ApduResponse cardResponse = cardInterfaceManager.SendCommand(new EMVSelectApplicationRequest(finalAdfName)) as EMVSelectApplicationResponse;
                #endregion
                if (!(cardResponse is EMVSelectApplicationResponse))
                {
                    throw new EMVProtocolException("Pre-processing transmit error: try again");
                }

                EMVSelectApplicationResponse response = (EMVSelectApplicationResponse)cardResponse;

NextAID:
                #region 12.3.3 Step 2
                if (response.SW1 == 0x6A && response.SW2 == 0x81) //card blocked
                {
                    throw new Exception("Card blocked");
                }
                if (response.SW1 == 0x6A && response.SW2 == 0x81) //command not supported
                {
                    throw new Exception("Select command not supported");
                }
                if (response.SW1 == 0x6A && response.SW2 == 0x82) //file not found
                {
                    continue;
                }
                #endregion

                if (!response.Succeeded && !(response.SW1 == 0x62 && response.SW2 == 0x83))
                {
                    throw new Exception("Select command failed");
                }

                if (response.GetDFName() == finalAdfName)
                {
                    //full match
                    if (response.Succeeded) //i.e. app not blocked 0x6283
                    {
                        TLV            adfNameTag = response.GetDFNameTag();
                        TLV            applicationPriorityIndicatorTag = response.GetApplicationPriorityindicatorTag();
                        TLV            preferedName         = response.GetPreferredNameTag();
                        TLV            appLabel             = response.GetApplicationLabelTag();
                        Optional <TLV> extendedSelectionTag = Optional <TLV> .CreateEmpty();

                        candidateList.Add(Tuple.Create(kc, new CardKernelAidCombination()
                        {
                            AdfNameTag = adfNameTag,
                            ApplicationPriorityIndicatorTag = applicationPriorityIndicatorTag,
                            ApplicationPreferredName        = preferedName,
                            ApplicationLabel     = appLabel,
                            ExtendedSelectionTag = extendedSelectionTag,
                        }));
                        continue;
                    }
                }
                if (response.GetDFName().StartsWith(finalAdfName))
                {
                    //partial match
                    if (((TerminalSupportedContactKernelAidTransactionTypeCombination)kc).ApplicationSelectionIndicator)
                    {
                        if (response.Succeeded) //i.e. app not blocked 0x6283
                        {
                            TLV            adfNameTag = response.GetDFNameTag();
                            TLV            applicationPriorityIndicatorTag = response.GetApplicationPriorityindicatorTag();
                            TLV            preferedName         = response.GetPreferredNameTag();
                            TLV            appLabel             = response.GetApplicationLabelTag();
                            Optional <TLV> extendedSelectionTag = Optional <TLV> .CreateEmpty();

                            candidateList.Add(Tuple.Create(kc, new CardKernelAidCombination()
                            {
                                AdfNameTag = adfNameTag,
                                ApplicationPriorityIndicatorTag = applicationPriorityIndicatorTag,
                                ExtendedSelectionTag            = extendedSelectionTag,
                                ApplicationPreferredName        = preferedName,
                                ApplicationLabel = appLabel,
                            }));
                            continue;
                        }
                        else
                        {
                            ApduResponse cardResponseNext = cardInterfaceManager.SendCommand(new EMVSelectApplicationRequest(finalAdfName, true)) as EMVSelectApplicationResponse;
                            if (!(cardResponse is EMVSelectApplicationResponse))
                            {
                                throw new EMVProtocolException("Pre-processing transmit error: try again");
                            }

                            response = (EMVSelectApplicationResponse)cardResponse;
                            if (response.Succeeded || response.SW1 == 0x62 || response.SW1 == 0x63)
                            {
                                goto NextAID;
                            }
                        }
                    }
                }
            }
            return(candidateList);
        }