public OperationResult resetChallengeRequest(string tokenID)
        {
            IDbCommand      _cmd = null;
            OperationResult result;

            try
            {
                base.ConnectionString = DBConnectionString.ExpandSAFCore();
                _cmd = base.CreateCommand(TokensChallengeRequestDAO.spRESET_CHALLENGE_REQUEST_BY_TOKENID, CommandType.StoredProcedure);
                _cmd.Parameters.Add(base.AddParameter("@tkID", tokenID));
                base.Connection.Open();
                result = ((_cmd.ExecuteNonQuery() == 1) ? OperationResult.Success : OperationResult.Error);
            }
            catch (Exception ex)
            {
                SAFLOGGER.Write(SAFLOGGER.LOGGEREventID.EXCEPTION, "SAFCORE", new string[]
                {
                    "http://sfexpand.SAFCore.TokensChallengeRequestDAO.softfinanca.com/",
                    ex.ToString()
                });
                result = OperationResult.Error;
            }
            finally
            {
                if (_cmd != null)
                {
                    _cmd.Dispose();
                }
                if (base.Connection != null && base.Connection.State == ConnectionState.Open)
                {
                    base.Connection.Dispose();
                }
            }
            return(result);
        }
        public long clearChallengeRequestOverdue(string tokenID)
        {
            IDbCommand _cmd = null;
            long       result;

            try
            {
                base.ConnectionString = DBConnectionString.ExpandSAFCore();
                _cmd = base.CreateCommand(TokensChallengeRequestDAO.spCLEAR_OVERDUE_CHALLENGE_REQUEST, CommandType.StoredProcedure);
                base.Connection.Open();
                result = (long)_cmd.ExecuteNonQuery();
            }
            catch (Exception ex)
            {
                SAFLOGGER.Write(SAFLOGGER.LOGGEREventID.EXCEPTION, "SAFCORE", new string[]
                {
                    "http://sfexpand.SAFCore.TokensChallengeRequestDAO.softfinanca.com/",
                    ex.ToString()
                });
                result = -1L;
            }
            finally
            {
                if (_cmd != null)
                {
                    _cmd.Dispose();
                }
                if (base.Connection != null && base.Connection.State == ConnectionState.Open)
                {
                    base.Connection.Dispose();
                }
            }
            return(result);
        }
Exemple #3
0
        public OperationResult updateTokenStatus(string tokenID, TokenStatus tokenStatus)
        {
            IDbCommand      _cmd = null;
            OperationResult result;

            try
            {
                base.ConnectionString = DBConnectionString.ExpandSAFCore();
                _cmd = base.CreateCommand("PersistTokenStatus", CommandType.StoredProcedure);
                _cmd.Parameters.Add(base.AddParameter("@Param0", (byte)tokenStatus));
                _cmd.Parameters.Add(base.AddParameter("@tkID", tokenID));
                base.Connection.Open();
                int iRes = _cmd.ExecuteNonQuery();
                result = ((iRes == 1) ? OperationResult.Success : OperationResult.Error);
            }
            catch (Exception ex)
            {
                SAFLOGGER.Write(SAFLOGGER.LOGGEREventID.EXCEPTION, "SAFCORE", new string[]
                {
                    "http://sfexpand.SAFCore.TokensDAO.softfinanca.com/",
                    Assembly.GetExecutingAssembly().FullName.ToString(),
                    ex.ToString()
                });
                result = OperationResult.Error;
            }
            finally
            {
                if (_cmd != null)
                {
                    _cmd.Dispose();
                }
                base.CloseConnection();
            }
            return(result);
        }
        public OperationResult resetChallengeRequest(string tokenID)
        {
            IDbCommand      dbCommand = null;
            OperationResult result;

            try
            {
                base.ConnectionString = DBConnectionString.ExpandSAFCore();
                dbCommand             = base.CreateCommand(TokensChallengeRequestDAO.spRESET_CHALLENGE_REQUEST_BY_TOKENID, CommandType.StoredProcedure);
                dbCommand.Parameters.Add(base.AddParameter("@tkID", tokenID));
                base.Connection.Open();
                result = ((dbCommand.ExecuteNonQuery() == 1) ? OperationResult.Success : OperationResult.Error);
            }
            catch (Exception ex)
            {
                LOGGER.Write(LOGGER.LogCategory.ERROR, "SF.Expand.SAF.Core.TokensChallengeRequest::resetChallengeRequest[]\r\n" + ex.Message, null);
                result = OperationResult.Error;
            }
            finally
            {
                if (dbCommand != null)
                {
                    dbCommand.Dispose();
                }
                if (base.Connection != null && base.Connection.State == ConnectionState.Open)
                {
                    base.Connection.Dispose();
                }
            }
            return(result);
        }
        private string _loadFromDB(string value, string sqlExec)
        {
            IDbCommand dbCommand = null;
            string     result;

            try
            {
                base.ConnectionString = DBConnectionString.ExpandSAFCore();
                dbCommand             = base.CreateCommand(sqlExec, CommandType.StoredProcedure);
                dbCommand.Parameters.Add(base.AddParameter("@Param1", value));
                base.Connection.Open();
                object obj = dbCommand.ExecuteScalar();
                result = (string)obj;
            }
            catch (Exception logObject)
            {
                LOGGER.Write(LOGGER.LogCategory.EXCEPTION, "SF.Expand.SAF.Core.TokensDAO::_loadFromDB[" + sqlExec + "]", logObject);
                result = null;
            }
            finally
            {
                if (dbCommand != null)
                {
                    dbCommand.Dispose();
                }
                base.CloseConnection();
            }
            return(result);
        }
        public long clearChallengeRequestOverdue(string tokenID)
        {
            IDbCommand dbCommand = null;
            long       result;

            try
            {
                base.ConnectionString = DBConnectionString.ExpandSAFCore();
                dbCommand             = base.CreateCommand(TokensChallengeRequestDAO.spCLEAR_OVERDUE_CHALLENGE_REQUEST, CommandType.StoredProcedure);
                base.Connection.Open();
                result = (long)dbCommand.ExecuteNonQuery();
            }
            catch (Exception ex)
            {
                LOGGER.Write(LOGGER.LogCategory.ERROR, "SF.Expand.SAF.Core.TokensChallengeRequest::clearChallengeRequestOverdue[]\r\n" + ex.Message, null);
                result = -1L;
            }
            finally
            {
                if (dbCommand != null)
                {
                    dbCommand.Dispose();
                }
                if (base.Connection != null && base.Connection.State == ConnectionState.Open)
                {
                    base.Connection.Dispose();
                }
            }
            return(result);
        }
Exemple #7
0
        public OperationResult tokenStatus(string tokenID, out TokenStatus tokenStatus)
        {
            tokenStatus = TokenStatus.Undefined;
            IDbCommand      _cmd = null;
            OperationResult result;

            try
            {
                base.ConnectionString = DBConnectionString.ExpandSAFCore();
                _cmd = base.CreateCommand("TokenGetStatus", CommandType.StoredProcedure);
                _cmd.Parameters.Add(base.AddParameter("@tkID", tokenID));
                base.Connection.Open();
                tokenStatus = (TokenStatus)((byte)_cmd.ExecuteScalar());
                result      = OperationResult.Success;
            }
            catch (Exception ex)
            {
                SAFLOGGER.Write(SAFLOGGER.LOGGEREventID.EXCEPTION, "SAFCORE", new string[]
                {
                    "http://sfexpand.SAFCore.TokensDAO.softfinanca.com/",
                    Assembly.GetExecutingAssembly().FullName.ToString(),
                    ex.ToString()
                });
                result = OperationResult.Error;
            }
            finally
            {
                if (_cmd != null)
                {
                    _cmd.Dispose();
                }
                base.CloseConnection();
            }
            return(result);
        }
        public OperationResult tokenSeedsByParamIDWithNoSubLot(string tokenParamsID, out long numberOfSeeds)
        {
            numberOfSeeds = -1L;
            IDbCommand      dbCommand = null;
            OperationResult result;

            try
            {
                base.ConnectionString = DBConnectionString.ExpandSAFCore();
                dbCommand             = base.CreateCommand("CheckAvailableSeedsByTokenParamsID", CommandType.StoredProcedure);
                dbCommand.Parameters.Add(base.AddParameter("@Param0", tokenParamsID));
                base.Connection.Open();
                numberOfSeeds = (long)dbCommand.ExecuteNonQuery();
                result        = OperationResult.Success;
            }
            catch (Exception ex)
            {
                LOGGER.Write(LOGGER.LogCategory.ERROR, "SF.Expand.SAF.Core.TokensDAO::tokenSeedsByParamIDWithNoSubLot[]" + Environment.NewLine + ex.ToString(), null);
                result = OperationResult.Error;
            }
            finally
            {
                if (dbCommand != null)
                {
                    dbCommand.Dispose();
                }
                base.CloseConnection();
            }
            return(result);
        }
Exemple #9
0
        public long tokensSeedsBulkInsert(string pathFileName, TokenStatus tokenStatus, DateTime tokenExpiration)
        {
            IDbCommand _cmd = null;
            long       result;

            try
            {
                base.ConnectionString = DBConnectionString.ExpandSAFCore();
                _cmd = base.CreateCommand("TokenBulkInsert", CommandType.StoredProcedure);
                _cmd.Parameters.Add(base.AddParameter("@PathFileName", pathFileName));
                _cmd.Parameters.Add(base.AddParameter("@tkStatus", (int)tokenStatus));
                _cmd.Parameters.Add(base.AddParameter("@tkExpirationDate", tokenExpiration));
                base.Connection.Open();
                result = (long)_cmd.ExecuteNonQuery();
            }
            catch (Exception ex)
            {
                SAFLOGGER.Write(SAFLOGGER.LOGGEREventID.EXCEPTION, "SAFCORE", new string[]
                {
                    "http://sfexpand.SAFCore.TokensDAO.softfinanca.com/",
                    Assembly.GetExecutingAssembly().FullName.ToString(),
                    ex.ToString()
                });
                result = -1L;
            }
            finally
            {
                if (_cmd != null)
                {
                    _cmd.Dispose();
                }
                base.CloseConnection();
            }
            return(result);
        }
        public OperationResult seedsStatusBySupplierlLotID(out DataTable dataTable)
        {
            DataSet         dataSet   = new DataSet();
            IDbCommand      dbCommand = null;
            OperationResult result;

            try
            {
                base.ConnectionString = DBConnectionString.ExpandSAFCore();
                dbCommand             = base.CreateCommand("TokenSeedsCountBySubLotID", CommandType.StoredProcedure);
                base.CreateDataAdapter(dbCommand).Fill(dataSet);
                dataTable = dataSet.Tables[0];
                result    = OperationResult.Success;
            }
            catch (Exception ex)
            {
                dataTable = null;
                LOGGER.Write(LOGGER.LogCategory.ERROR, "SF.Expand.SAF.Core.TokensDAO::seedsStatusBySupplierlLotID[]" + Environment.NewLine + ex.ToString(), null);
                result = OperationResult.Error;
            }
            finally
            {
                if (dbCommand != null)
                {
                    dbCommand.Dispose();
                }
                if (dataSet != null)
                {
                    dataSet.Dispose();
                }
                base.CloseConnection();
            }
            return(result);
        }
Exemple #11
0
        public OperationResult createSubLotByTokenVendor(long numberOfTokensInLot, string tokenParamsID, string subLotID, DateTime expirationDate, out long numberOfSeeds)
        {
            IDbCommand _cmdInfo  = null;
            IDbCommand _cmdBuild = null;

            numberOfSeeds = -1L;
            string          _lotNumber = BaseFunctions.GenerateSupplierLotNumber(numberOfTokensInLot.ToString(), null);
            OperationResult result;

            try
            {
                base.ConnectionString = DBConnectionString.ExpandSAFCore();
                _cmdInfo = base.CreateCommand("CheckAvailableSeedsByTokenParamsID", CommandType.StoredProcedure);
                _cmdInfo.Parameters.Add(base.AddParameter("@Param0", tokenParamsID));
                base.Connection.Open();
                numberOfSeeds = (long)((int)_cmdInfo.ExecuteScalar());
                if (numberOfSeeds < numberOfTokensInLot)
                {
                    SAFLOGGER.Write(SAFLOGGER.LOGGEREventID.WARNING, "SAFCORE", new string[]
                    {
                        "http://sfexpand.SAFCore.TokensDAO.softfinanca.com/createSubLotByTokenVendor",
                        OperationResult.TokenVendorSeedNotAvaliable.ToString()
                    });
                    result = OperationResult.TokenVendorSeedNotAvaliable;
                }
                else
                {
                    _cmdBuild = base.CreateCommand("CreateSupplierSubLot", CommandType.StoredProcedure);
                    _cmdBuild.Parameters.Add(base.AddParameter("@Param0", _lotNumber));
                    _cmdBuild.Parameters.Add(base.AddParameter("@Param1", expirationDate));
                    _cmdBuild.Parameters.Add(base.AddParameter("@Param2", tokenParamsID));
                    _cmdBuild.Parameters.Add(base.AddParameter("@top", (int)numberOfTokensInLot));
                    numberOfSeeds = (long)_cmdBuild.ExecuteNonQuery();
                    result        = OperationResult.Success;
                }
            }
            catch (Exception ex)
            {
                SAFLOGGER.Write(SAFLOGGER.LOGGEREventID.EXCEPTION, "SAFCORE", new string[]
                {
                    "http://sfexpand.SAFCore.TokensDAO.softfinanca.com/",
                    Assembly.GetExecutingAssembly().FullName.ToString(),
                    ex.ToString()
                });
                result = OperationResult.Error;
            }
            finally
            {
                if (_cmdInfo != null)
                {
                    _cmdInfo.Dispose();
                }
                if (_cmdBuild != null)
                {
                    _cmdBuild.Dispose();
                }
                base.CloseConnection();
            }
            return(result);
        }
Exemple #12
0
        public OperationResult tokenSeedsByParamIDWithNoSubLot(string tokenParamsID, out long numberOfSeeds)
        {
            numberOfSeeds = -1L;
            IDbCommand      _cmdInfo = null;
            OperationResult result;

            try
            {
                base.ConnectionString = DBConnectionString.ExpandSAFCore();
                _cmdInfo = base.CreateCommand("CheckAvailableSeedsByTokenParamsID", CommandType.StoredProcedure);
                _cmdInfo.Parameters.Add(base.AddParameter("@Param0", tokenParamsID));
                base.Connection.Open();
                numberOfSeeds = Convert.ToInt64(_cmdInfo.ExecuteScalar());
                result        = OperationResult.Success;
            }
            catch (Exception ex)
            {
                SAFLOGGER.Write(SAFLOGGER.LOGGEREventID.EXCEPTION, "SAFCORE", new string[]
                {
                    "http://sfexpand.SAFCore.TokensDAO.softfinanca.com/",
                    Assembly.GetExecutingAssembly().FullName.ToString(),
                    ex.ToString()
                });
                result = OperationResult.Error;
            }
            finally
            {
                if (_cmdInfo != null)
                {
                    _cmdInfo.Dispose();
                }
                base.CloseConnection();
            }
            return(result);
        }
        private OperationResult _updateTable(string tokenID, string commandText, object[] fieldValue)
        {
            IDbCommand      dbCommand = null;
            OperationResult result;

            try
            {
                base.ConnectionString = DBConnectionString.ExpandSAFCore();
                dbCommand             = base.CreateCommand(commandText, CommandType.StoredProcedure);
                dbCommand.Parameters.Add(base.AddParameter("@tkID", tokenID));
                for (int i = 0; i < fieldValue.Length; i++)
                {
                    dbCommand.Parameters.Add(base.AddParameter("@Param" + i.ToString(), fieldValue[i]));
                }
                base.Connection.Open();
                int num = dbCommand.ExecuteNonQuery();
                result = ((num == 1) ? OperationResult.Success : OperationResult.Error);
            }
            catch (Exception)
            {
                LOGGER.Write(LOGGER.LogCategory.ERROR, "SF.Expand.SAF.Core.TokensDAO::_updateTable[" + tokenID + "]", null);
                result = OperationResult.Error;
            }
            finally
            {
                if (dbCommand != null)
                {
                    dbCommand.Dispose();
                }
                base.CloseConnection();
            }
            return(result);
        }
Exemple #14
0
        public TokenTypeBaseParams loadTokenBaseParams(string tokenParamsID)
        {
            IDataReader         dataReader = null;
            IDbCommand          dbCommand  = null;
            TokenTypeBaseParams result;

            try
            {
                base.ConnectionString = DBConnectionString.ExpandSAFCore();
                dbCommand             = base.CreateCommand("GetTokenBaseParams", CommandType.StoredProcedure);
                dbCommand.Parameters.Add(base.AddParameter("@Param1", tokenParamsID));
                base.Connection.Open();
                dataReader = dbCommand.ExecuteReader(CommandBehavior.CloseConnection);
                dataReader.Read();
                result = new TokenTypeBaseParams((int)((byte)dataReader[0]), (int)((byte)dataReader[1]), (int)dataReader[2], (long)dataReader[3], (TokenSeedType)((byte)dataReader[4]), (TokenMovingFactorType)((byte)dataReader[5]), (long)((int)dataReader[6]), tokenParamsID, (int)dataReader[7]);
            }
            catch (Exception ex)
            {
                LOGGER.Write(LOGGER.LogCategory.ERROR, "SF.Expand.SAF.Core.TokenParamsDAO::loadTokenBaseParams[]\r\n" + ex.Message, null);
                result = default(TokenTypeBaseParams);
            }
            finally
            {
                if (dataReader != null)
                {
                    dataReader.Dispose();
                }
                if (dbCommand != null)
                {
                    dbCommand.Dispose();
                }
                base.CloseConnection();
            }
            return(result);
        }
        private string _loadFromDB(string value, string sqlExec)
        {
            IDbCommand _cmd = null;
            string     result;

            try
            {
                base.ConnectionString = DBConnectionString.ExpandSAFCore();
                _cmd = base.CreateCommand(sqlExec, CommandType.StoredProcedure);
                _cmd.Parameters.Add(base.AddParameter("@Param1", value));
                base.Connection.Open();
                object res = _cmd.ExecuteScalar();
                result = (string)res;
            }
            catch (Exception ex)
            {
                SAFLOGGER.Write(SAFLOGGER.LOGGEREventID.EXCEPTION, "SAFCORE", new string[]
                {
                    "http://sfexpand.SAFCore.TokensValidatorDAO.softfinanca.com/",
                    Assembly.GetExecutingAssembly().FullName.ToString(),
                    ex.ToString()
                });
                result = null;
            }
            finally
            {
                if (_cmd != null)
                {
                    _cmd.Dispose();
                }
                base.CloseConnection();
            }
            return(result);
        }
        public OperationResult newTokenFromPreInsertedSeed(string tokenParamsID, out TokenInfoCore tokenInfoCore)
        {
            IDbCommand dbCommand = null;

            tokenInfoCore = new TokenInfoCore();
            OperationResult result;

            try
            {
                base.ConnectionString = DBConnectionString.ExpandSAFCore();
                dbCommand             = base.CreateCommand("FreeSeedUpdateForNewToken", CommandType.StoredProcedure);
                dbCommand.Parameters.Add(base.AddParameter("@Param0", 1));
                dbCommand.Parameters.Add(base.AddParameter("@Param1", 99));
                dbCommand.Parameters.Add(base.AddParameter("@Param2", tokenParamsID));
                base.Connection.Open();
                object obj = dbCommand.ExecuteScalar();
                if (obj == DBNull.Value)
                {
                    result = OperationResult.Error;
                }
                else
                {
                    if (obj.ToString() == "0")
                    {
                        result = OperationResult.TokenVendorSeedNotAvaliable;
                    }
                    else
                    {
                        tokenInfoCore = this.loadTokenInfoCore(obj.ToString());
                        result        = OperationResult.Success;
                    }
                }
            }
            catch (Exception ex)
            {
                LOGGER.Write(LOGGER.LogCategory.ERROR, string.Concat(new string[]
                {
                    "SF.Expand.SAF.Core.TokensDAO::newTokenFromPreInsertedSeed[",
                    tokenParamsID,
                    "]",
                    Environment.NewLine,
                    ex.ToString()
                }), null);
                result = OperationResult.Error;
            }
            finally
            {
                if (dbCommand != null)
                {
                    dbCommand.Dispose();
                }
                base.CloseConnection();
            }
            return(result);
        }
        public OperationResult createToken(string tokenParamsID, long movingFactor, DateTime expirationDate, string cryptoKey, string supplierSerialNumber, string internalSerialNumber, string creationLotID, string SupportCryptoData, out string tokenID)
        {
            tokenID = null;
            IDbCommand      dbCommand = null;
            OperationResult result;

            try
            {
                base.ConnectionString = DBConnectionString.ExpandSAFCore();
                dbCommand             = base.CreateCommand("InsertNewToken", CommandType.StoredProcedure);
                dbCommand.Parameters.Add(base.AddParameter("@tkStatus", 0));
                dbCommand.Parameters.Add(base.AddParameter("@tkParamsID", tokenParamsID));
                dbCommand.Parameters.Add(base.AddParameter("@tkMovingFactor", movingFactor));
                dbCommand.Parameters.Add(base.AddParameter("@tkExpirationDate", expirationDate));
                dbCommand.Parameters.Add(base.AddParameter("@tkCryptoKey", cryptoKey));
                dbCommand.Parameters.Add(base.AddParameter("@tkCreationLotID", creationLotID));
                dbCommand.Parameters.Add(base.AddParameter("@tkSupplierSerialNumber", supplierSerialNumber));
                dbCommand.Parameters.Add(base.AddParameter("@tkInternalSerialNumber", internalSerialNumber));
                dbCommand.Parameters.Add(base.AddParameter("@tkSupportCriptoData", SupportCryptoData));
                dbCommand.Parameters.Add(base.AddParameter("@tokenSubLotID", null));
                base.Connection.Open();
                long num = long.Parse(dbCommand.ExecuteScalar().ToString());
                if (num == 1L)
                {
                    tokenID = num.ToString();
                    result  = OperationResult.Success;
                }
                else
                {
                    result = OperationResult.Error;
                }
            }
            catch (Exception ex)
            {
                LOGGER.Write(LOGGER.LogCategory.ERROR, string.Concat(new string[]
                {
                    "SF.Expand.SAF.Core.TokensDAO::createToken[",
                    tokenParamsID,
                    "]",
                    Environment.NewLine,
                    ex.ToString()
                }), null);
                result = OperationResult.Error;
            }
            finally
            {
                if (dbCommand != null)
                {
                    dbCommand.Dispose();
                }
                base.CloseConnection();
            }
            return(result);
        }
Exemple #18
0
        public OperationResult newTokenFromGivenSupplierSerialNumber(string tokenParamsID, string SupplierSerialNumber, out TokenInfoCore tokenInfoCore)
        {
            IDbCommand _cmd = null;

            tokenInfoCore = new TokenInfoCore();
            OperationResult result;

            try
            {
                base.ConnectionString = DBConnectionString.ExpandSAFCore();
                _cmd = base.CreateCommand("GivenSupplierSerialNumberUpdateForNewToken", CommandType.StoredProcedure);
                _cmd.Parameters.Add(base.AddParameter("@Param0", 1));
                _cmd.Parameters.Add(base.AddParameter("@Param1", 99));
                _cmd.Parameters.Add(base.AddParameter("@Param2", tokenParamsID));
                _cmd.Parameters.Add(base.AddParameter("@Param3", SupplierSerialNumber));
                base.Connection.Open();
                object _retID = _cmd.ExecuteScalar();
                if (_retID == DBNull.Value || (int)_retID == 0)
                {
                    SAFLOGGER.Write(SAFLOGGER.LOGGEREventID.WARNING, "SAFCORE", new string[]
                    {
                        "http://sfexpand.SAFCore.TokensDAO.softfinanca.com/newTokenFromGivenSupplierSerialNumber",
                        OperationResult.TokenVendorSeedNotAvaliable.ToString()
                    });
                    result = OperationResult.TokenVendorSeedNotAvaliable;
                }
                else
                {
                    tokenInfoCore = this.loadTokenInfoCore(_retID.ToString());
                    result        = OperationResult.Success;
                }
            }
            catch (Exception ex)
            {
                SAFLOGGER.Write(SAFLOGGER.LOGGEREventID.EXCEPTION, "SAFCORE", new string[]
                {
                    "http://sfexpand.SAFCore.TokensDAO.softfinanca.com/",
                    Assembly.GetExecutingAssembly().FullName.ToString(),
                    ex.ToString()
                });
                result = OperationResult.Error;
            }
            finally
            {
                if (_cmd != null)
                {
                    _cmd.Dispose();
                }
                base.CloseConnection();
            }
            return(result);
        }
Exemple #19
0
        public OperationResult createToken(string tokenParamsID, long movingFactor, DateTime expirationDate, string cryptoKey, string supplierSerialNumber, string internalSerialNumber, string creationLotID, string SupportCryptoData, out string tokenID)
        {
            tokenID = null;
            IDbCommand      _cmd = null;
            OperationResult result;

            try
            {
                base.ConnectionString = DBConnectionString.ExpandSAFCore();
                _cmd = base.CreateCommand("InsertNewToken", CommandType.StoredProcedure);
                _cmd.Parameters.Add(base.AddParameter("@tkStatus", 0));
                _cmd.Parameters.Add(base.AddParameter("@tkParamsID", tokenParamsID));
                _cmd.Parameters.Add(base.AddParameter("@tkMovingFactor", movingFactor));
                _cmd.Parameters.Add(base.AddParameter("@tkExpirationDate", expirationDate));
                _cmd.Parameters.Add(base.AddParameter("@tkCryptoKey", cryptoKey));
                _cmd.Parameters.Add(base.AddParameter("@tkCreationLotID", creationLotID));
                _cmd.Parameters.Add(base.AddParameter("@tkSupplierSerialNumber", supplierSerialNumber));
                _cmd.Parameters.Add(base.AddParameter("@tkInternalSerialNumber", internalSerialNumber));
                _cmd.Parameters.Add(base.AddParameter("@tkSupportCriptoData", SupportCryptoData));
                _cmd.Parameters.Add(base.AddParameter("@tokenSubLotID", null));
                base.Connection.Open();
                long _hResult = long.Parse(_cmd.ExecuteScalar().ToString());
                if (_hResult == 1L)
                {
                    tokenID = _hResult.ToString();
                    result  = OperationResult.Success;
                }
                else
                {
                    result = OperationResult.Error;
                }
            }
            catch (Exception ex)
            {
                SAFLOGGER.Write(SAFLOGGER.LOGGEREventID.EXCEPTION, "SAFCORE", new string[]
                {
                    "http://sfexpand.SAFCore.TokensDAO.softfinanca.com/",
                    Assembly.GetExecutingAssembly().FullName.ToString(),
                    ex.ToString()
                });
                result = OperationResult.Error;
            }
            finally
            {
                if (_cmd != null)
                {
                    _cmd.Dispose();
                }
                base.CloseConnection();
            }
            return(result);
        }
        public OperationResult createSubLotByTokenVendor(long numberOfTokensInLot, string tokenParamsID, string subLotID, DateTime expirationDate, out long numberOfSeeds)
        {
            IDbCommand dbCommand  = null;
            IDbCommand dbCommand2 = null;

            numberOfSeeds = -1L;
            string          value = BaseFunctions.GenerateSupplierLotNumber(numberOfTokensInLot.ToString(), null);
            OperationResult result;

            try
            {
                base.ConnectionString = DBConnectionString.ExpandSAFCore();
                base.Connection.Open();
                dbCommand = base.CreateCommand("CheckAvailableSeedsByTokenParamsID", CommandType.StoredProcedure);
                dbCommand.Parameters.Add(base.AddParameter("@Param0", tokenParamsID));
                numberOfSeeds = (long)((int)dbCommand.ExecuteScalar());
                if (numberOfSeeds < numberOfTokensInLot)
                {
                    result = OperationResult.TokenVendorSeedNotAvaliable;
                }
                else
                {
                    dbCommand2 = base.CreateCommand("CreateSupplierSubLot", CommandType.StoredProcedure);
                    dbCommand2.Parameters.Add(base.AddParameter("@Param0", value));
                    dbCommand2.Parameters.Add(base.AddParameter("@Param1", expirationDate));
                    dbCommand2.Parameters.Add(base.AddParameter("@Param2", tokenParamsID));
                    dbCommand2.Parameters.Add(base.AddParameter("@top", (int)numberOfTokensInLot));
                    numberOfSeeds = (long)dbCommand2.ExecuteNonQuery();
                    result        = OperationResult.Success;
                }
            }
            catch (Exception ex)
            {
                LOGGER.Write(LOGGER.LogCategory.ERROR, "SF.Expand.SAF.Core.TokensDAO::createNewTokenVendorSubLot[]" + Environment.NewLine + ex.ToString(), null);
                result = OperationResult.Error;
            }
            finally
            {
                if (dbCommand != null)
                {
                    dbCommand.Dispose();
                }
                if (dbCommand2 != null)
                {
                    dbCommand2.Dispose();
                }
                base.CloseConnection();
            }
            return(result);
        }
        public object loadChallengeRequest(string tokenID)
        {
            IDbCommand _cmd      = null;
            IDbCommand _cmdValid = null;
            object     result;

            try
            {
                base.ConnectionString = DBConnectionString.ExpandSAFCore();
                _cmdValid             = base.CreateCommand(TokensChallengeRequestDAO.spVALID_CHALLENGE_REQUEST_BY_TOKENID, CommandType.StoredProcedure);
                _cmdValid.Parameters.Add(base.AddParameter("@tkID", tokenID));
                base.Connection.Open();
                if (1 == (int)_cmdValid.ExecuteScalar())
                {
                    _cmdValid = base.CreateCommand(TokensChallengeRequestDAO.spGET_CHALLENGE_REQUEST_BY_TOKENID, CommandType.StoredProcedure);
                    _cmdValid.Parameters.Add(base.AddParameter("@tkID", tokenID));
                    result = _cmdValid.ExecuteScalar();
                }
                else
                {
                    result = null;
                }
            }
            catch (Exception ex)
            {
                SAFLOGGER.Write(SAFLOGGER.LOGGEREventID.EXCEPTION, "SAFCORE", new string[]
                {
                    "http://sfexpand.SAFCore.TokensChallengeRequestDAO.softfinanca.com/",
                    Assembly.GetExecutingAssembly().FullName.ToString(),
                    ex.ToString()
                });
                result = null;
            }
            finally
            {
                if (_cmdValid != null)
                {
                    _cmdValid.Dispose();
                }
                if (_cmd != null)
                {
                    _cmd.Dispose();
                }
                base.CloseConnection();
            }
            return(result);
        }
Exemple #22
0
        public OperationResult loadTableWithTokensLot(LoteType loteType, string loteId, string TokenVendorID, TokenMovingFactorType tokenMovingFactorType, out DataTable dataTable)
        {
            DataSet         _ds  = new DataSet();
            IDbCommand      _cmd = null;
            OperationResult result;

            try
            {
                base.ConnectionString = DBConnectionString.ExpandSAFCore();
                _cmd = base.CreateCommand((loteType == LoteType.SupplierLot) ? "TokenGetByLot" : "TokenGetBySubLot", CommandType.StoredProcedure);
                _cmd.Parameters.Add(base.AddParameter("@Param0", (byte)tokenMovingFactorType));
                _cmd.Parameters.Add(base.AddParameter("@Param1", TokenVendorID));
                _cmd.Parameters.Add(base.AddParameter("@Param2", loteId));
                base.CreateDataAdapter(_cmd).Fill(_ds);
                dataTable = _ds.Tables[0];
                result    = OperationResult.Success;
            }
            catch (Exception ex)
            {
                dataTable = null;
                SAFLOGGER.Write(SAFLOGGER.LOGGEREventID.EXCEPTION, "SAFCORE", new string[]
                {
                    "http://sfexpand.SAFCore.TokensDAO.softfinanca.com/",
                    Assembly.GetExecutingAssembly().FullName.ToString(),
                    ex.ToString()
                });
                result = OperationResult.Error;
            }
            finally
            {
                if (_cmd != null)
                {
                    _cmd.Dispose();
                }
                if (_ds != null)
                {
                    _ds.Dispose();
                }
                base.CloseConnection();
            }
            return(result);
        }
        public TokenCryptoData loadTokenCryptoData(string tokenID)
        {
            IDataReader     dataReader = null;
            IDbCommand      dbCommand  = null;
            TokenCryptoData result;

            try
            {
                base.ConnectionString = DBConnectionString.ExpandSAFCore();
                dbCommand             = base.CreateCommand("GetTokenByID", CommandType.StoredProcedure);
                dbCommand.Parameters.Add(base.AddParameter("@tkID", tokenID));
                base.Connection.Open();
                dataReader = dbCommand.ExecuteReader(CommandBehavior.CloseConnection);
                dataReader.Read();
                result = new TokenCryptoData(dataReader[5].ToString(), dataReader[0].ToString(), new CryptoData((long)dataReader[1], dataReader[2].ToString().Trim(), dataReader[3].ToString().Trim(), (dataReader[6] != DBNull.Value) ? dataReader[6].ToString().Trim() : string.Empty), new TokenParamsDAO().loadTokenBaseParams(((byte)dataReader[4]).ToString()));
            }
            catch (Exception ex)
            {
                LOGGER.Write(LOGGER.LogCategory.ERROR, string.Concat(new string[]
                {
                    "SF.Expand.SAF.Core.TokensDAO::loadTokenCryptoData[",
                    tokenID,
                    "]",
                    Environment.NewLine,
                    ex.ToString()
                }), null);
                result = new TokenCryptoData(null, null, default(CryptoData), default(TokenTypeBaseParams));
            }
            finally
            {
                if (dataReader != null)
                {
                    dataReader.Dispose();
                }
                if (dbCommand != null)
                {
                    dbCommand.Dispose();
                }
                base.CloseConnection();
            }
            return(result);
        }
        public OperationResult loadSupplierLots(string tokenParamsID, out DataTable dataTable)
        {
            DataSet         dataSet   = new DataSet();
            IDbCommand      dbCommand = null;
            OperationResult result;

            try
            {
                base.ConnectionString = DBConnectionString.ExpandSAFCore();
                if (tokenParamsID != null || tokenParamsID.Trim().Length > 1)
                {
                    dbCommand = base.CreateCommand("TokenSupplierLotCountByTokenParamsID", CommandType.StoredProcedure);
                    dbCommand.Parameters.Add(base.AddParameter("@Param0", tokenParamsID));
                }
                else
                {
                    dbCommand = base.CreateCommand("TokenSupplierLot", CommandType.StoredProcedure);
                }
                base.CreateDataAdapter(dbCommand).Fill(dataSet);
                dataTable = dataSet.Tables[0];
                result    = OperationResult.Success;
            }
            catch (Exception ex)
            {
                dataTable = null;
                LOGGER.Write(LOGGER.LogCategory.ERROR, "SF.Expand.SAF.Core.TokensDAO::loadSupplierLots[]" + Environment.NewLine + ex.ToString(), null);
                result = OperationResult.Error;
            }
            finally
            {
                if (dbCommand != null)
                {
                    dbCommand.Dispose();
                }
                if (dataSet != null)
                {
                    dataSet.Dispose();
                }
                base.CloseConnection();
            }
            return(result);
        }
        public object loadChallengeRequest(string tokenID)
        {
            IDbCommand dbCommand  = null;
            IDbCommand dbCommand2 = null;
            object     result;

            try
            {
                base.ConnectionString = DBConnectionString.ExpandSAFCore();
                dbCommand2            = base.CreateCommand(TokensChallengeRequestDAO.spVALID_CHALLENGE_REQUEST_BY_TOKENID, CommandType.StoredProcedure);
                dbCommand2.Parameters.Add(base.AddParameter("@tkID", tokenID));
                base.Connection.Open();
                if (1 == (int)dbCommand2.ExecuteScalar())
                {
                    dbCommand2 = base.CreateCommand(TokensChallengeRequestDAO.spGET_CHALLENGE_REQUEST_BY_TOKENID, CommandType.StoredProcedure);
                    dbCommand2.Parameters.Add(base.AddParameter("@tkID", tokenID));
                    result = dbCommand2.ExecuteScalar();
                }
                else
                {
                    result = null;
                }
            }
            catch (Exception ex)
            {
                LOGGER.Write(LOGGER.LogCategory.ERROR, "SF.Expand.SAF.Core::loadChallengeRequest[]\r\n" + ex.Message, null);
                result = null;
            }
            finally
            {
                if (dbCommand2 != null)
                {
                    dbCommand2.Dispose();
                }
                if (dbCommand != null)
                {
                    dbCommand.Dispose();
                }
                base.CloseConnection();
            }
            return(result);
        }
        public TokenInfoCore loadTokenInfoCore(string tokenID)
        {
            IDataReader   dataReader = null;
            IDbCommand    dbCommand  = null;
            TokenInfoCore result;

            try
            {
                base.ConnectionString = DBConnectionString.ExpandSAFCore();
                dbCommand             = base.CreateCommand("GetTokenInfoByID", CommandType.StoredProcedure);
                dbCommand.Parameters.Add(base.AddParameter("@tkID", tokenID));
                base.OpenConnection();
                dataReader = dbCommand.ExecuteReader(CommandBehavior.CloseConnection);
                dataReader.Read();
                result = TokenInfoCore.loadTokenInfoCore((byte)dataReader[0], (int)dataReader[1], (string)dataReader[2], (string)dataReader[3], (string)dataReader[4], (dataReader[5] != DBNull.Value) ? ((DateTime)dataReader[5]) : DateTime.MinValue, (string)dataReader[7], (TokenStatus)((byte)dataReader[6]));
            }
            catch (Exception ex)
            {
                LOGGER.Write(LOGGER.LogCategory.ERROR, string.Concat(new string[]
                {
                    "SF.Expand.SAF.Core.TokensDAO::loadTokenInfo[",
                    tokenID,
                    "]",
                    Environment.NewLine,
                    ex.ToString()
                }), null);
                result = new TokenInfoCore();
            }
            finally
            {
                if (dataReader != null)
                {
                    dataReader.Dispose();
                }
                if (dbCommand != null)
                {
                    dbCommand.Dispose();
                }
                base.CloseConnection();
            }
            return(result);
        }
Exemple #27
0
        public OperationResult loadSubLots(string creationLotID, string tokenParamsID, out DataTable dataTable)
        {
            DataSet         _ds  = new DataSet();
            IDbCommand      _cmd = null;
            OperationResult result;

            try
            {
                base.ConnectionString = DBConnectionString.ExpandSAFCore();
                _cmd = base.CreateCommand("TokenSubLot", CommandType.StoredProcedure);
                _cmd.Parameters.Add(base.AddParameter("@CreationLotID", creationLotID));
                _cmd.Parameters.Add(base.AddParameter("@TokenParamsID", tokenParamsID));
                base.CreateDataAdapter(_cmd).Fill(_ds);
                dataTable = _ds.Tables[0];
                result    = OperationResult.Success;
            }
            catch (Exception ex)
            {
                dataTable = null;
                SAFLOGGER.Write(SAFLOGGER.LOGGEREventID.EXCEPTION, "SAFCORE", new string[]
                {
                    "http://sfexpand.SAFCore.TokensDAO.softfinanca.com/",
                    Assembly.GetExecutingAssembly().FullName.ToString(),
                    ex.ToString()
                });
                result = OperationResult.Error;
            }
            finally
            {
                if (_cmd != null)
                {
                    _cmd.Dispose();
                }
                if (_ds != null)
                {
                    _ds.Dispose();
                }
                base.CloseConnection();
            }
            return(result);
        }
Exemple #28
0
        public TokenCryptoData loadTokenCryptoData(string tokenID)
        {
            IDataReader     _rd  = null;
            IDbCommand      _cmd = null;
            TokenCryptoData result;

            try
            {
                base.ConnectionString = DBConnectionString.ExpandSAFCore();
                _cmd = base.CreateCommand("GetTokenByID", CommandType.StoredProcedure);
                _cmd.Parameters.Add(base.AddParameter("@tkID", tokenID));
                base.Connection.Open();
                _rd = _cmd.ExecuteReader(CommandBehavior.CloseConnection);
                _rd.Read();
                result = new TokenCryptoData(_rd[5].ToString(), _rd[0].ToString(), new CryptoData((long)_rd[1], _rd[2].ToString().Trim(), _rd[3].ToString().Trim(), (_rd[6] != DBNull.Value) ? _rd[6].ToString().Trim() : string.Empty), new TokenParamsDAO().loadTokenBaseParams(((byte)_rd[4]).ToString()));
            }
            catch (Exception ex)
            {
                SAFLOGGER.Write(SAFLOGGER.LOGGEREventID.EXCEPTION, "SAFCORE", new string[]
                {
                    "http://sfexpand.SAFCore.TokensDAO.softfinanca.com/",
                    Assembly.GetExecutingAssembly().FullName.ToString(),
                    ex.ToString()
                });
                result = new TokenCryptoData(null, null, default(CryptoData), default(TokenTypeBaseParams));
            }
            finally
            {
                if (_rd != null)
                {
                    _rd.Dispose();
                }
                if (_cmd != null)
                {
                    _cmd.Dispose();
                }
                base.CloseConnection();
            }
            return(result);
        }
Exemple #29
0
        public TokenInfoCore loadTokenInfoCore(string tokenID)
        {
            IDataReader   _rd  = null;
            IDbCommand    _cmd = null;
            TokenInfoCore result;

            try
            {
                base.ConnectionString = DBConnectionString.ExpandSAFCore();
                _cmd = base.CreateCommand("GetTokenInfoByID", CommandType.StoredProcedure);
                _cmd.Parameters.Add(base.AddParameter("@tkID", tokenID));
                base.OpenConnection();
                _rd = _cmd.ExecuteReader(CommandBehavior.CloseConnection);
                _rd.Read();
                result = TokenInfoCore.loadTokenInfoCore((byte)_rd[0], (int)_rd[1], (_rd[2] != DBNull.Value) ? ((string)_rd[2]) : "", (_rd[3] != DBNull.Value) ? ((string)_rd[3]) : "", (string)_rd[4], (_rd[5] != DBNull.Value) ? ((DateTime)_rd[5]) : DateTime.MinValue, (_rd[7] == DBNull.Value) ? null : _rd[7].ToString(), (TokenStatus)((byte)_rd[6]));
            }
            catch (Exception ex)
            {
                SAFLOGGER.Write(SAFLOGGER.LOGGEREventID.EXCEPTION, "SAFCORE", new string[]
                {
                    "http://sfexpand.SAFCore.TokensDAO.softfinanca.com/",
                    Assembly.GetExecutingAssembly().FullName.ToString(),
                    ex.ToString()
                });
                result = new TokenInfoCore();
            }
            finally
            {
                if (_rd != null)
                {
                    _rd.Dispose();
                }
                if (_cmd != null)
                {
                    _cmd.Dispose();
                }
                base.CloseConnection();
            }
            return(result);
        }
Exemple #30
0
        public TokenTypeBaseParams loadTokenBaseParams(string tokenParamsID)
        {
            IDataReader         _rd  = null;
            IDbCommand          _cmd = null;
            TokenTypeBaseParams result;

            try
            {
                base.ConnectionString = DBConnectionString.ExpandSAFCore();
                _cmd = base.CreateCommand("GetTokenBaseParams", CommandType.StoredProcedure);
                _cmd.Parameters.Add(base.AddParameter("@Param1", tokenParamsID));
                base.Connection.Open();
                _rd = _cmd.ExecuteReader(CommandBehavior.CloseConnection);
                _rd.Read();
                result = new TokenTypeBaseParams((int)((byte)_rd[0]), (int)((byte)_rd[1]), (int)_rd[2], (long)_rd[3], (TokenSeedType)((byte)_rd[4]), (TokenMovingFactorType)((byte)_rd[5]), (long)((int)_rd[6]), tokenParamsID, (int)_rd[7]);
            }
            catch (Exception ex)
            {
                SAFLOGGER.Write(SAFLOGGER.LOGGEREventID.EXCEPTION, "SAFCORE", new string[]
                {
                    "http://sfexpand.SAFCore.TokenParamsDAO.softfinanca.com/",
                    Assembly.GetExecutingAssembly().FullName.ToString(),
                    ex.ToString()
                });
                result = default(TokenTypeBaseParams);
            }
            finally
            {
                if (_rd != null)
                {
                    _rd.Dispose();
                }
                if (_cmd != null)
                {
                    _cmd.Dispose();
                }
                base.CloseConnection();
            }
            return(result);
        }