public static TokensUser LoadTokensUser(string tokenApplicationID, TokenInfo[] tokensInfo) { return new TokensUser { ApplicationID = tokenApplicationID, TokensInfo = tokensInfo }; }
public static TokenInfo loadTokenInfo(TokenStatus status, byte typeID, int internalID, string typeDescription, string applicationUser, string phoneNumberUser, string emailAddressUser, DateTime registeredTimeStamp, string internalSerialNumber, DateTime lastStatusTimeStamp, TokenInfoCore tokenInfoCore) { TokenInfo _newTkInfoBus = new TokenInfo(); _newTkInfoBus.Status = status; _newTkInfoBus.TypeDescription = ((typeDescription == null) ? null : typeDescription.Trim()); _newTkInfoBus.ApplicationUser = ((applicationUser == null) ? null : applicationUser.Trim()); _newTkInfoBus.PhoneNumberUser = ((phoneNumberUser == null) ? null : phoneNumberUser.Trim()); _newTkInfoBus.EmailAddressUser = ((emailAddressUser == null) ? null : emailAddressUser.Trim()); _newTkInfoBus.RegisteredTimeStamp = registeredTimeStamp; _newTkInfoBus.LastStatusChangedTimeStamp = lastStatusTimeStamp; if (tokenInfoCore.InternalID == 0) { _newTkInfoBus.tokenInfoCore = TokenInfoCore.loadTokenInfoCore(typeID, internalID, null, null, internalSerialNumber, registeredTimeStamp, null, status); } else { _newTkInfoBus.tokenInfoCore = tokenInfoCore; } return _newTkInfoBus; }
public OperationResult AfterCreate(string applicationUser, string applicationUseruserPhone, string applicationEmail, string tokenVendorID, string expirationDate, string supplierSerialNumber, string creationLotID, string pin, string baseNotifyMessage, int tokenInternalID, long businessEventID, TokenStatus tokenStatus) { TokenInfo tokenInfo = new TokenInfo(); OperationResult operationResult = OperationResult.Error; TokenInfo[] array = new TokenBusinessDAO().loadTokenUserByType(applicationUser, tokenVendorID); OperationResult result; if (array == null) { result = OperationResult.PostValidationRulesFail; } else { for (int i = 0; i < array.Length; i++) { if (tokenInternalID == array[i].tokenInfoCore.InternalID) { tokenInfo = array[i]; operationResult = OperationResult.Success; } else { switch (array[i].tokenInfoCore.TypeID) { case 1: if (array[i].Status == TokenStatus.Enabled) { operationResult = SAFBaseFunctions.tokenDisable(array[i].ApplicationUser, array[i].tokenInfoCore.InternalID.ToString(), string.Empty); } break; case 2: if (array[i].Status == TokenStatus.Enabled || array[i].Status == TokenStatus.Disabled) { operationResult = SAFBaseFunctions.tokenCancel(array[i].ApplicationUser, array[i].tokenInfoCore.InternalID.ToString(), string.Empty); } break; case 3: if (array[i].Status == TokenStatus.Enabled || array[i].Status == TokenStatus.Disabled) { operationResult = SAFBaseFunctions.tokenCancel(array[i].ApplicationUser, array[i].tokenInfoCore.InternalID.ToString(), string.Empty); } break; } } } if (operationResult != OperationResult.Success) { result = operationResult; } else { string text = SAFConfiguration.readParameterExternal((tokenStatus == TokenStatus.ReadyToDeploy) ? "OP.SMS.NOTIFY.ON.CREATE.DEPLOY" : "OP.SMS.NOTIFY.ON.CREATE"); text = ((text.Trim().Length < 1) ? null : text.Trim()); string smsMessage; if (0 >= (text ?? "").IndexOf("[0]")) { smsMessage = (((baseNotifyMessage ?? "").Length > 1) ? baseNotifyMessage : text).Replace("{dt}", DateTime.Now.ToShortDateString()).Replace("{tm}", DateTime.Now.ToShortTimeString()).Replace("{dpl}", businessEventID.ToString().Trim()); } else { smsMessage = ((text != null) ? string.Format(text, baseNotifyMessage.Split(new char[] { '|' })) : string.Join("", baseNotifyMessage.Split(new char[] { '|' })).Trim()); } result = SMSSender.Send(tokenInfo.ApplicationUser, tokenInfo.tokenInfoCore.InternalID.ToString(), tokenInfo.PhoneNumberUser, smsMessage); } } return result; }
public static OperationResult tokenCreate(string applicationUser, string applicationUseruserPhone, string applicationEmail, string tokenVendorID, string expirationDate, string supplierSerialNumber, string creationLotID, string pin, string baseNotifyMessage, out TokenInfo tokenInfo) { long tokenEventID = 0L; OperationResult _hResult = OperationResult.Error; ITokenRules _TKRules = TokenRulesFactory.LoadAssembly(SAFConfiguration.readParameterExternal("SAFClientBusinessRules")); DateTime _dtExpiration; if (!DateTime.TryParse(expirationDate, out _dtExpiration)) { _dtExpiration = DateTime.MaxValue; } OperationResult result; try { if (_TKRules != null) { if (OperationResult.Success != (_hResult = _TKRules.BeforeCreate(applicationUser, applicationUseruserPhone, applicationEmail, tokenVendorID, expirationDate, supplierSerialNumber, creationLotID, pin, baseNotifyMessage))) { new TokensBusinessEventsDAO().insertTokenEvent("0", 100, (int)_hResult, applicationUser, out tokenEventID); tokenInfo = new TokenInfo(); result = _hResult; return result; } } TokenInfoCore _tkInfoCore; if (OperationResult.Success == (_hResult = new PREProcessorTokens().Create(tokenVendorID, _dtExpiration, supplierSerialNumber, creationLotID, pin, out _tkInfoCore))) { if (OperationResult.Success != (_hResult = new TokenBusinessDAO().insertTokenUser(_tkInfoCore, applicationUser, applicationUseruserPhone, applicationEmail, out tokenInfo, out tokenEventID))) { SAFBaseFunctions._logger(SAFLOGGER.LOGGEREventID.ERROR, "SAFBUSINESS", new string[] { "http://sfexpand.SAFBusiness.DBConnectionString.softfinanca.com/", Assembly.GetExecutingAssembly().FullName.ToString(), "unable to create token on [business] DB" }); if (OperationResult.Success != (_hResult = new PREProcessorTokens().UndoCreate(_tkInfoCore.InternalID.ToString()))) { SAFBaseFunctions._logger(SAFLOGGER.LOGGEREventID.WARNING, "SAFBUSINESS", new string[] { "http://sfexpand.SAFBusiness.DBConnectionString.softfinanca.com/", "unable to undoCreate token on [core] DB" }); } } else { if (_TKRules != null) { result = _TKRules.AfterCreate(applicationUser, applicationUseruserPhone, applicationEmail, tokenVendorID, expirationDate, supplierSerialNumber, creationLotID, pin, baseNotifyMessage + "|" + tokenEventID.ToString(), _tkInfoCore.InternalID, tokenEventID, _tkInfoCore.InternalStatus); return result; } _hResult = OperationResult.Success; result = _hResult; return result; } } else { SAFBaseFunctions._logger(SAFLOGGER.LOGGEREventID.ERROR, "SAFBUSINESS", new string[] { "http://sfexpand.SAFBusiness.DBConnectionString.softfinanca.com/", Assembly.GetExecutingAssembly().FullName.ToString(), "unable to create token on [core] DB" }); } new TokensBusinessEventsDAO().insertTokenEvent("0", 100, (int)_hResult, applicationUser, out tokenEventID); tokenInfo = new TokenInfo(); _hResult = (result = OperationResult.Error); } catch (Exception ex) { SAFBaseFunctions._logger(SAFLOGGER.LOGGEREventID.EXCEPTION, "SAFBUSINESS", new string[] { "http://sfexpand.SAFBusiness.DBConnectionString.softfinanca.com/", Assembly.GetExecutingAssembly().FullName.ToString(), "unable to create token!", ex.ToString() }); tokenInfo = new TokenInfo(); _hResult = (result = OperationResult.Error); } finally { APPEVENTSDeff arg_294_0 = APPEVENTSDeff.OPERATIONS_EXECUTED; int arg_294_1 = 100; string arg_294_2 = "SAFBUSINESS"; string[] array = new string[2]; array[0] = TokenEventOperation.cTOKEN_CREATED.ToString(); string[] arg_291_0 = array; int arg_291_1 = 1; int num = (int)_hResult; arg_291_0[arg_291_1] = num.ToString(); SAFInternalEvents.Export(arg_294_0, arg_294_1, arg_294_2, array); } return result; }
public TokenInfo getTokenInfo(string tokenID, TokenInfoCore tokenInfoCore) { IDataReader _dr = null; IDbCommand _cmd = null; TokenInfo result; try { base.ConnectionString = DBConnectionString.ExpandSecureBusiness(); _cmd = base.CreateCommand("GetTokenInfo", CommandType.StoredProcedure); _cmd.Parameters.Add(base.AddParameter("@Param1", tokenID)); base.OpenConnection(); (_dr = _cmd.ExecuteReader(CommandBehavior.CloseConnection)).Read(); result = TokenInfo.loadTokenInfo((TokenStatus)((byte)_dr[2]), (byte)_dr[7], (int)_dr[0], (_dr[5] == DBNull.Value) ? "" : ((string)_dr[5]), (string)_dr[1], (_dr[3] == DBNull.Value) ? "" : ((string)_dr[3]), (_dr[6] == DBNull.Value) ? "" : ((string)_dr[6]), (DateTime)_dr[4], (string)_dr[8], (DateTime)_dr[11], tokenInfoCore); } catch (Exception ex) { SAFLOGGER.Write(SAFLOGGER.LOGGEREventID.EXCEPTION, "SAFBUSINESS", new string[] { "http://sfexpand.SAFBusiness.TokenBusinessDAO.softfinanca.com/", Assembly.GetExecutingAssembly().FullName.ToString(), ex.ToString() }); result = new TokenInfo(); } finally { if (_dr != null) { _dr.Dispose(); } if (_cmd != null) { _cmd.Dispose(); } base.CloseConnection(); } return result; }
public OperationResult getTokenByUserBySupplierSNAndParamID(string tokenUserApplicationID, string SupplierSerialNumber, int tokenParamsID, out TokenInfo tokenInfo) { tokenInfo = new TokenInfo(); OperationResult result; try { base.ConnectionString = DBConnectionString.ExpandSecureBusiness(); IDbCommand _cmd = base.CreateCommand("GetTokenByUserBySupplierSNAndParamID", CommandType.StoredProcedure); _cmd.Parameters.Add(base.AddParameter("@Param1", tokenUserApplicationID)); _cmd.Parameters.Add(base.AddParameter("@Param2", SupplierSerialNumber)); _cmd.Parameters.Add(base.AddParameter("@Param3", tokenParamsID)); base.Connection.Open(); IDataReader _dr = _cmd.ExecuteReader(CommandBehavior.CloseConnection); if (!_dr.Read()) { result = OperationResult.Error; } else { tokenInfo = TokenInfo.loadTokenInfo((TokenStatus)((byte)_dr[2]), (byte)_dr[7], (int)_dr[0], (string)_dr[5], (string)_dr[1], (_dr[3] == DBNull.Value) ? "" : ((string)_dr[3]), (_dr[6] == DBNull.Value) ? "" : ((string)_dr[6]), (DateTime)_dr[4], (string)_dr[8], (DateTime)_dr[11], new TokenInfoCore()); result = OperationResult.Success; } } catch (Exception ex) { SAFLOGGER.Write(SAFLOGGER.LOGGEREventID.EXCEPTION, "SAFBUSINESS", new string[] { "http://sfexpand.SAFBusiness.TokenBusinessDAO.softfinanca.com/", Assembly.GetExecutingAssembly().FullName.ToString(), ex.ToString() }); result = OperationResult.Error; } return result; }
public OperationResult insertTokenUser(TokenInfoCore tokenInfoCore, string applicationUser, string applicationPhoneNumber, string applicationEmail, out TokenInfo tokenInfo, out long tokenEventID) { tokenEventID = 0L; IDbCommand _cmd = null; tokenInfo = new TokenInfo(); OperationResult result; try { base.ConnectionString = DBConnectionString.ExpandSecureBusiness(); _cmd = base.CreateCommand("TokenUserInsert", CommandType.StoredProcedure); _cmd.Parameters.Add(base.AddParameter("@param1", tokenInfoCore.InternalID)); _cmd.Parameters.Add(base.AddParameter("@param2", tokenInfoCore.TypeID)); _cmd.Parameters.Add(base.AddParameter("@param3", tokenInfoCore.InternalStatus)); _cmd.Parameters.Add(base.AddParameter("@param4", applicationUser)); _cmd.Parameters.Add(base.AddParameter("@param5", applicationPhoneNumber)); _cmd.Parameters.Add(base.AddParameter("@param6", applicationEmail)); _cmd.Parameters.Add(base.AddParameter("@param7", tokenInfoCore.InternalSerialNumber)); _cmd.Parameters.Add(base.AddParameter("@param8", tokenInfoCore.SupplierSerialNumber)); _cmd.Parameters.Add(base.AddParameter("@param9", tokenInfoCore.SupplierLotID)); base.Connection.Open(); base.TransactionBegin(IsolationLevel.ReadCommitted); _cmd.Transaction = base.Transaction; if (1 == _cmd.ExecuteNonQuery()) { if (OperationResult.Success == this._insertTokenEvent(tokenInfoCore.InternalID.ToString(), 100, 0, applicationUser, out tokenEventID)) { if (tokenInfoCore.InternalStatus == TokenStatus.ReadyToDeploy) { if (OperationResult.Success != this._insertTokenEvent(tokenInfoCore.InternalID.ToString(), 98, 0, applicationUser, out tokenEventID)) { result = OperationResult.Error; return result; } } base.TransactionCommit(); tokenInfo = this.getTokenInfo(tokenInfoCore.InternalID.ToString(), tokenInfoCore); result = OperationResult.Success; return result; } } result = OperationResult.Error; } catch (Exception ex) { SAFLOGGER.Write(SAFLOGGER.LOGGEREventID.EXCEPTION, "SAFBUSINESS", new string[] { "http://sfexpand.SAFBusiness.TokenBusinessDAO.softfinanca.com/", Assembly.GetExecutingAssembly().FullName.ToString(), ex.ToString() }); result = OperationResult.Error; } finally { if (_cmd != null) { _cmd.Dispose(); } base.CloseConnection(); } return result; }
public OperationResult AfterCreate(string applicationUser, string applicationUseruserPhone, string applicationEmail, string tokenVendorID, string expirationDate, string supplierSerialNumber, string creationLotID, string pin, string baseNotifyMessage, int tokenInternalID, long businessEventID, TokenStatus tokenStatus) { TokenInfo _lastInsertedToken = new TokenInfo(); OperationResult _hResult = OperationResult.Error; TokenInfo[] _tkInfo = new TokenBusinessDAO().loadTokenUserByType(applicationUser, tokenVendorID); OperationResult result; if (_tkInfo == null) { result = OperationResult.PostValidationRulesFail; } else { for (int i = 0; i < _tkInfo.Length; i++) { if (tokenInternalID == _tkInfo[i].tokenInfoCore.InternalID) { _lastInsertedToken = _tkInfo[i]; _hResult = OperationResult.Success; } else { switch (_tkInfo[i].tokenInfoCore.TypeID) { case 1: if (_tkInfo[i].Status == TokenStatus.Enabled) { _hResult = SAFBaseFunctions.tokenDisable(_tkInfo[i].ApplicationUser, _tkInfo[i].tokenInfoCore.InternalID.ToString(), string.Empty); } break; case 2: if (_tkInfo[i].Status == TokenStatus.Enabled || _tkInfo[i].Status == TokenStatus.Disabled || _tkInfo[i].Status == TokenStatus.ReadyToDeploy || _tkInfo[i].Status == TokenStatus.DeployCompleted) { _hResult = SAFBaseFunctions.tokenCancel(_tkInfo[i].ApplicationUser, _tkInfo[i].tokenInfoCore.InternalID.ToString(), string.Empty); } break; case 3: if (_tkInfo[i].Status == TokenStatus.Enabled || _tkInfo[i].Status == TokenStatus.Disabled) { _hResult = SAFBaseFunctions.tokenCancel(_tkInfo[i].ApplicationUser, _tkInfo[i].tokenInfoCore.InternalID.ToString(), string.Empty); } break; } } } if (_hResult != OperationResult.Success) { result = _hResult; } else { string[] _arrayNotifMsg = (baseNotifyMessage ?? "").Split(new char[] { '|' }); string[] _params = new string[_arrayNotifMsg.Length - 1]; Array.Copy(_arrayNotifMsg, 1, _params, 0, _params.Length); string notifMsg = ((_arrayNotifMsg[0] ?? "").Length > 1) ? _arrayNotifMsg[0] : SAFConfiguration.readParameterExternal((tokenStatus == TokenStatus.ReadyToDeploy) ? "SMS.TEMPLATE.ON.CREATE.DEPLOY" : "SMS.TEMPLATE.ON.CREATE"); notifMsg = string.Format(notifMsg.Replace("{tm}", DateTime.Now.ToShortDateString()).Replace("{dt}", DateTime.Now.ToShortTimeString()), _params); result = SMSSender.Send(_lastInsertedToken.ApplicationUser, _lastInsertedToken.tokenInfoCore.InternalID.ToString(), _lastInsertedToken.PhoneNumberUser, notifMsg); } } return result; }