public OperationResult newTokenFromGivenSupplierSerialNumber(string tokenParamsID, string SupplierSerialNumber, out TokenInfoCore tokenInfoCore)
        {
            IDbCommand dbCommand = null;

            tokenInfoCore = new TokenInfoCore();
            OperationResult result;

            try
            {
                base.ConnectionString = DBConnectionString.ExpandSAFCore();
                dbCommand             = base.CreateCommand("GivenSupplierSerialNumberUpdateForNewToken", CommandType.StoredProcedure);
                dbCommand.Parameters.Add(base.AddParameter("@Param0", 1));
                dbCommand.Parameters.Add(base.AddParameter("@Param1", 99));
                dbCommand.Parameters.Add(base.AddParameter("@Param2", tokenParamsID));
                dbCommand.Parameters.Add(base.AddParameter("@Param3", SupplierSerialNumber));
                base.Connection.Open();
                object obj = dbCommand.ExecuteScalar();
                if (obj == DBNull.Value)
                {
                    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::newTokenFromGivvenSupplierSerialNumber[",
                    tokenParamsID,
                    "]",
                    Environment.NewLine,
                    ex.ToString()
                }), null);
                result = OperationResult.Error;
            }
            finally
            {
                if (dbCommand != null)
                {
                    dbCommand.Dispose();
                }
                base.CloseConnection();
            }
            return(result);
        }
Beispiel #2
0
        public OperationResult createToken(string tokenParamsID, long movingFactor, DateTime expirationDate, string cryptoKey, string supplierSerialNumber, string internalSerialNumber, string creationLotID, string SupportCryptoData, out TokenInfoCore tokenInfoCore)
        {
            string          tokenID = null;
            IDbCommand      _cmd    = null;
            OperationResult result;

            tokenInfoCore = new TokenInfoCore();

            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());
                tokenID       = _hResult.ToString();
                tokenInfoCore = this.loadTokenInfoCore(tokenID);
                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 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);
        }
Beispiel #4
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 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);
        }
        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 OperationResult seedsStatusSublotBySupplierLotID(string supplierLotID, out DataTable dataTable)
        {
            DataSet         dataSet   = new DataSet();
            IDbCommand      dbCommand = null;
            OperationResult result;

            try
            {
                base.ConnectionString = DBConnectionString.ExpandSAFCore();
                if (supplierLotID != null || supplierLotID.Trim().Length > 1)
                {
                    dbCommand = base.CreateCommand("TokenSeedsCountBySubLotIDBySupplierLotID", CommandType.StoredProcedure);
                    dbCommand.Parameters.Add(base.AddParameter("@Param0", supplierLotID));
                }
                else
                {
                    dbCommand = base.CreateCommand("TokenSeedsCountBySupplierLotID", 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::seedsStatusSublotBySupplierLotID[]" + Environment.NewLine + ex.ToString(), null);
                result = OperationResult.Error;
            }
            finally
            {
                if (dbCommand != null)
                {
                    dbCommand.Dispose();
                }
                if (dataSet != null)
                {
                    dataSet.Dispose();
                }
                base.CloseConnection();
            }
            return(result);
        }
Beispiel #9
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);
        }
Beispiel #10
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);
        }
Beispiel #11
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);
        }
Beispiel #12
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);
        }
Beispiel #13
0
        public OperationResult updateTokenStatus(string tokenID, TokenStatus tokenStatus)
        {
            IDbCommand      dbCommand = null;
            OperationResult result;

            try
            {
                base.ConnectionString = DBConnectionString.ExpandSAFCore();
                dbCommand             = base.CreateCommand("PersistTokenStatus", CommandType.StoredProcedure);
                dbCommand.Parameters.Add(base.AddParameter("@Param0", (byte)tokenStatus));
                dbCommand.Parameters.Add(base.AddParameter("@tkID", tokenID));
                base.Connection.Open();
                int num = dbCommand.ExecuteNonQuery();
                result = ((num == 1) ? OperationResult.Success : OperationResult.Error);
            }
            catch (Exception ex)
            {
                LOGGER.Write(LOGGER.LogCategory.ERROR, string.Concat(new string[]
                {
                    "SF.Expand.SAF.Core.TokensDAO::updateTokenStatus[",
                    tokenID,
                    ";",
                    tokenStatus.ToString(),
                    "]",
                    Environment.NewLine,
                    ex.ToString()
                }), null);
                result = OperationResult.Error;
            }
            finally
            {
                if (dbCommand != null)
                {
                    dbCommand.Dispose();
                }
                base.CloseConnection();
            }
            return(result);
        }
Beispiel #14
0
        private OperationResult _updateTable(string tokenID, string commandText, object[] fieldValue)
        {
            IDbCommand      _cmd = null;
            OperationResult result;

            try
            {
                base.ConnectionString = DBConnectionString.ExpandSAFCore();
                _cmd = base.CreateCommand(commandText, CommandType.StoredProcedure);
                _cmd.Parameters.Add(base.AddParameter("@tkID", tokenID));
                for (int _idx = 0; _idx < fieldValue.Length; _idx++)
                {
                    _cmd.Parameters.Add(base.AddParameter("@Param" + _idx.ToString(), fieldValue[_idx]));
                }
                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);
        }
Beispiel #15
0
        public OperationResult undoUpdateForNewToken(string tokenID)
        {
            IDbCommand      _cmd = null;
            OperationResult result;

            try
            {
                base.ConnectionString = DBConnectionString.ExpandSAFCore();
                _cmd = base.CreateCommand("UndoUpdateForNewToken", CommandType.StoredProcedure);
                _cmd.Parameters.Add(base.AddParameter("@Param0", 99));
                _cmd.Parameters.Add(base.AddParameter("@Param1", 1));
                _cmd.Parameters.Add(base.AddParameter("@Param2", tokenID));
                _cmd.Parameters.Add(base.AddParameter("@Param3", 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);
        }
Beispiel #16
0
        public OperationResult tokenStatus(string tokenID, out TokenStatus tokenStatus)
        {
            tokenStatus = TokenStatus.Undefined;
            IDbCommand      dbCommand = null;
            OperationResult result;

            try
            {
                base.ConnectionString = DBConnectionString.ExpandSAFCore();
                dbCommand             = base.CreateCommand("TokenGetStatus", CommandType.StoredProcedure);
                dbCommand.Parameters.Add(base.AddParameter("@tkID", tokenID));
                base.Connection.Open();
                tokenStatus = (TokenStatus)((byte)dbCommand.ExecuteScalar());
                result      = OperationResult.Success;
            }
            catch (Exception ex)
            {
                LOGGER.Write(LOGGER.LogCategory.ERROR, string.Concat(new string[]
                {
                    "SF.Expand.SAF.Core.TokensDAO::tokenStatus[",
                    tokenID,
                    "]",
                    Environment.NewLine,
                    ex.ToString()
                }), null);
                result = OperationResult.Error;
            }
            finally
            {
                if (dbCommand != null)
                {
                    dbCommand.Dispose();
                }
                base.CloseConnection();
            }
            return(result);
        }
        public OperationResult persistChallengeRequest(string tokenID, string challengeRequest, DateTime challengeRequestValidThru)
        {
            IDbCommand      _cmd = null;
            OperationResult result;

            try
            {
                base.ConnectionString = DBConnectionString.ExpandSAFCore();
                _cmd = base.CreateCommand(TokensChallengeRequestDAO.spINSERT_NEW_CHALLENGE_REQUEST, CommandType.StoredProcedure);
                _cmd.Parameters.Add(base.AddParameter("@tkID", tokenID));
                _cmd.Parameters.Add(base.AddParameter("@param1", challengeRequest));
                _cmd.Parameters.Add(base.AddParameter("@param2", challengeRequestValidThru));
                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);
        }
Beispiel #18
0
        public OperationResult loadTableWithTokensLot(LoteType loteType, string loteId, string TokenVendorID, TokenMovingFactorType tokenMovingFactorType, out DataTable dataTable)
        {
            dataTable = null;
            DataSet         dataSet   = new DataSet();
            IDbCommand      dbCommand = null;
            OperationResult result;

            try
            {
                base.ConnectionString = DBConnectionString.ExpandSAFCore();
                dbCommand             = base.CreateCommand((loteType == LoteType.SupplierLot) ? "TokenGetByLot" : "TokenGetBySubLot", CommandType.StoredProcedure);
                dbCommand.Parameters.Add(base.AddParameter("@Param0", (byte)tokenMovingFactorType));
                dbCommand.Parameters.Add(base.AddParameter("@Param1", TokenVendorID));
                dbCommand.Parameters.Add(base.AddParameter("@Param2", loteId));
                base.CreateDataAdapter(dbCommand).Fill(dataSet);
                dataTable = dataSet.Tables[0];
                result    = OperationResult.Success;
            }
            catch (Exception ex)
            {
                LOGGER.Write(LOGGER.LogCategory.ERROR, "SF.Expand.SAF.Core.TokensDAO::loadTableWithTokensLot[]" + Environment.NewLine + ex.ToString(), null);
                result = OperationResult.Error;
            }
            finally
            {
                if (dbCommand != null)
                {
                    dbCommand.Dispose();
                }
                if (dataSet != null)
                {
                    dataSet.Dispose();
                }
                base.CloseConnection();
            }
            return(result);
        }
Beispiel #19
0
        public long tokensSeedsBulkInsert(string pathFileName, TokenStatus tokenStatus, DateTime tokenExpiration)
        {
            IDbCommand dbCommand = null;
            long       result;

            try
            {
                base.ConnectionString = DBConnectionString.ExpandSAFCore();
                dbCommand             = base.CreateCommand("TokenBulkInsert", CommandType.StoredProcedure);
                dbCommand.Parameters.Add(base.AddParameter("@param0", pathFileName));
                dbCommand.Parameters.Add(base.AddParameter("@param1", (int)tokenStatus));
                dbCommand.Parameters.Add(base.AddParameter("@param2", tokenExpiration));
                base.Connection.Open();
                result = (long)dbCommand.ExecuteNonQuery();
            }
            catch (Exception ex)
            {
                LOGGER.Write(LOGGER.LogCategory.ERROR, string.Concat(new string[]
                {
                    "SF.Expand.SAF.Core.TokensDAO::tokensSeedsBulkInsert[",
                    pathFileName,
                    "]",
                    Environment.NewLine,
                    ex.ToString()
                }), null);
                result = -1L;
            }
            finally
            {
                if (dbCommand != null)
                {
                    dbCommand.Dispose();
                }
                base.CloseConnection();
            }
            return(result);
        }
Beispiel #20
0
        public string tokenKeyByTokenVendorID(string tokenVendorID)
        {
            IDbCommand _cmd = null;
            DataSet    _ds  = new DataSet();
            DataTable  dataTable;
            string     tokenCriptoData = null;

            try
            {
                base.ConnectionString = DBConnectionString.ExpandSAFCore();
                _cmd = base.CreateCommand("TokenKeyByTokenVendorID", CommandType.StoredProcedure);
                _cmd.Parameters.Add(base.AddParameter("@TokenVendorID", tokenVendorID));
                base.CreateDataAdapter(_cmd).Fill(_ds);
                dataTable = _ds.Tables[0];

                tokenCriptoData = (string)dataTable.Rows[0].ItemArray[0];
            }
            catch (Exception ex)
            {
                SAFLOGGER.Write(SAFLOGGER.LOGGEREventID.EXCEPTION, "SAFCORE", new string[]
                {
                    "http://sfexpand.SAFCore.TokensDAO.softfinanca.com/",
                    Assembly.GetExecutingAssembly().FullName.ToString(),
                    ex.ToString()
                });
            }
            finally
            {
                if (_cmd != null)
                {
                    _cmd.Dispose();
                }
                base.CloseConnection();
            }
            return(tokenCriptoData);
        }
Beispiel #21
0
        public OperationResult tokenSupplierSerialNumbersByLot(LoteType loteType, string loteId, out DataTable dataTable)
        {
            dataTable = null;
            DataSet         dataSet   = new DataSet();
            IDbCommand      dbCommand = null;
            OperationResult result;

            try
            {
                base.ConnectionString = DBConnectionString.ExpandSAFCore();
                string commandText = (loteType == LoteType.SupplierLot) ? "GetTokensSupplierSerialnumberBySupplierLot" : "GetTokensSupplierSerialnumberBySubLotID";
                dbCommand = base.CreateCommand(commandText, CommandType.StoredProcedure);
                dbCommand.Parameters.Add(base.AddParameter("@Param0", loteId));
                base.CreateDataAdapter(dbCommand).Fill(dataSet);
                dataTable = dataSet.Tables[0];
                result    = OperationResult.Success;
            }
            catch (Exception ex)
            {
                LOGGER.Write(LOGGER.LogCategory.ERROR, "SF.Expand.SAF.Core.TokensDAO::tokenSupplierSerialNumbersByLot[]" + Environment.NewLine + ex.ToString(), null);
                result = OperationResult.Error;
            }
            finally
            {
                if (dbCommand != null)
                {
                    dbCommand.Dispose();
                }
                if (dataSet != null)
                {
                    dataSet.Dispose();
                }
                base.CloseConnection();
            }
            return(result);
        }