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 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); }
public static string processRequest(string httpParamters) { string appBase64Data = null; string appContentType = null; string _deployProcessorTypeName = null; long requestDeployEventID = 0L; string[] _inParams = httpParamters.Split(new char[] { '|' }); string result; if (_inParams.Length % 2 != 0 || _inParams.Length < 4) { result = null; } else { DataTable _dTableEvent; if (OperationResult.Error == new TokensBusinessEventsDAO().loadDeployEventInfo(_inParams[1], out _dTableEvent)) { result = null; } else { if (_dTableEvent.Rows.Count != 1) { result = null; } else { TokenCryptoData _tokenCryptoData = new TokensDAO().loadTokenCryptoData(_dTableEvent.Rows[0][0].ToString()); if (_tokenCryptoData.ID == null) { result = null; } else { if (OperationResult.Success != HttpDeployProcessor._processTokenEvents(_dTableEvent.Rows[0][0].ToString(), _dTableEvent.Rows[0][2].ToString(), httpParamters, out requestDeployEventID)) { result = null; } else { new DeployTokenDAO().loadDeployProcessor(_dTableEvent.Rows[0][1].ToString(), _inParams[3].Trim(), out _deployProcessorTypeName); if (_deployProcessorTypeName == null) { new TokensBusinessEventsDAO().updateEventStatus(requestDeployEventID.ToString(), 1); result = null; } else { try { IDeployToken _deployProcessor = DeployTokenFactory.LoadAssembly(_deployProcessorTypeName); if (OperationResult.Success == _deployProcessor.AssembleTokenApplication(BaseFunctions.HexDecoder(_tokenCryptoData.CryptoData.SupportCryptoData), out appContentType, out appBase64Data)) { if (OperationResult.Success == SAFBaseFunctions.tokenEnable(_dTableEvent.Rows[0][2].ToString(), _dTableEvent.Rows[0][0].ToString(), null)) { result = appContentType + "|" + appBase64Data; return(result); } } new TokensBusinessEventsDAO().updateEventStatus(requestDeployEventID.ToString(), 1); result = null; } catch (Exception ex) { SAFLOGGER.Write(SAFLOGGER.LOGGEREventID.EXCEPTION, "SAFBUSINESSDEPLOY", new string[] { "http://sfexpand.SAFDeploy.DEPLOYJ1JAVAINFOSRV.softfinanca.com/", Assembly.GetExecutingAssembly().FullName.ToString(), ex.ToString() }); new TokensBusinessEventsDAO().updateEventStatus(requestDeployEventID.ToString(), 1); result = null; } finally { } } } } } } } return(result); }
/// <summary> /// </summary> /// <param name="httpParamters"></param> /// <returns></returns> public static string processRequest(string httpParamters) { string appBase64Data = null; string appContentType = null; string _deployProcessorTypeName = null; long requestDeployEventID = 0; DataTable _dTableEvent; IDeployToken _deployProcessor = null; string[] _inParams = httpParamters.Split(new char[] { '|' }); if (_inParams.Length % 2 != 0 || _inParams.Length < 4) { return(null); } if (OperationResult.Error == new TokensBusinessEventsDAO().loadDeployEventInfo(_inParams[1], out _dTableEvent)) { return(null); } if (_dTableEvent.Rows.Count != 1) { return(null); } TokenCryptoData _tokenCryptoData = new TokensDAO().loadTokenCryptoData(_dTableEvent.Rows[0][0].ToString()); if (_tokenCryptoData.ID == null) { return(null); } if (OperationResult.Success != _processTokenEvents(_dTableEvent.Rows[0][0].ToString(), _dTableEvent.Rows[0][2].ToString(), httpParamters, out requestDeployEventID)) { return(null); } new DeployTokenDAO().loadDeployProcessor(_dTableEvent.Rows[0][1].ToString(), _inParams[3].Trim(), out _deployProcessorTypeName); if (_deployProcessorTypeName == null) { new TokensBusinessEventsDAO().updateEventStatus(requestDeployEventID.ToString(), (byte)1); return(null); } try { _deployProcessor = DeployTokenFactory.LoadAssembly(_deployProcessorTypeName); if (OperationResult.Success == _deployProcessor.AssembleTokenApplication(BaseFunctions.HexDecoder(_tokenCryptoData.CryptoData.SupportCryptoData), out appContentType, out appBase64Data)) { if (OperationResult.Success == SAFBaseFunctions.tokenEnable(_dTableEvent.Rows[0][2].ToString(), _dTableEvent.Rows[0][0].ToString(), null)) { return(appContentType + "|" + appBase64Data); } } new TokensBusinessEventsDAO().updateEventStatus(requestDeployEventID.ToString(), (byte)1); return(null); } catch { new TokensBusinessEventsDAO().updateEventStatus(requestDeployEventID.ToString(), (byte)1); return(null); } finally { _deployProcessor = null; } }