//Check if a PIN is valid and has been used private void CheckPIN(string text) { int digit = 0; try { digit = System.Convert.ToInt32(text); } catch { LoggerHelper.Warn("[" + text + "] is not a valid integer \r\n"); return; } if (DigitSet.UsedSet.Contains(digit)) { LoggerHelper.Info("[" + text + "] is a valid digit and has been used.\r\n"); } else { if (PINRegularExpression.IsValidDigit(digit, SystemConfiguration.RightNumberRegex, SystemConfiguration.ExceptionNumberRegex)) { LoggerHelper.Info("[" + text + "] has not been used and this is a valid digit.\r\n"); } else { LoggerHelper.Info("[" + text + "] has not been used and this is a invalid digit.\r\n"); } } }
/// <summary> /// judge if a digit is valid /// </summary> /// <param name="t"></param> /// <returns>true: valid; false:invalid</returns> private bool IsValidDigit(int t) { bool rtn = true; //used exceptionSet to know if a digit is invalid if (DigitSet.ExceptionSet.Contains(t)) { //invalid data rtn = false; } else { //used Regular Expression to check if a digit is invalid rtn = PINRegularExpression.IsValidDigit(t, SystemConfiguration.RightNumberRegex, SystemConfiguration.ExceptionNumberRegex); } return(rtn); }