コード例 #1
0
        /// <summary>
        /// </summary>
        /// <param name="context"></param>
        /// <returns></returns>
        public static string processRequest(object httpContext)
        {
            String[]      _confServerVarsKeys = null;
            StringBuilder _inputParameters    = new StringBuilder();

            if ((httpContext == null) || (httpContext.GetType() != typeof(HttpContext)))
            {
                throw new Exception("Object type not supported");
            }

            try
            {
                HttpContext context = (HttpContext)httpContext;
                _inputParameters.AppendFormat("ID|{0}", context.Request.QueryString.Get(SAFConfiguration.readParameterExternal(cTOKENDEPLOY_SERVICE_PUBLICNAME)));
                _confServerVarsKeys = SAFConfiguration.readParameterExternal(cHTTPREQUEST_SERVER_KEYS).Split('|');

                for (int i = 0; i < _confServerVarsKeys.Length; i++)
                {
                    _inputParameters.AppendFormat("|{0}|{1}", _confServerVarsKeys[i], context.Request.ServerVariables.Get(_confServerVarsKeys[i]));
                }

                return(processRequest(_inputParameters.ToString()));
            }
            catch
            {
                return(null);
            }
            finally
            {
                _confServerVarsKeys = null;
                _inputParameters    = null;
            }
        }
コード例 #2
0
        public AutenticationStatus Autenticate(string tokenInternalID, string password, string dataEntropy, out string newChallenge)
        {
            newChallenge = null;
            TokenCryptoData     _tkCryptoData = new TokensDAO().loadTokenCryptoData(tokenInternalID);
            AutenticationStatus result;

            if (_tkCryptoData.ID == null)
            {
                result = AutenticationStatus.TokenNotFoundOrCanceled;
            }
            else
            {
                if (_tkCryptoData.TokenBaseParams.MovingFactorType != TokenMovingFactorType.TransactionAuthenticationNumber)
                {
                    throw new Exception("Function not implemented for this type of token!!");
                }
                string currentChallenge = (string)new TokensChallengeRequestDAO().loadChallengeRequest(tokenInternalID);
                if (currentChallenge == null)
                {
                    result = AutenticationStatus.InvalidDataOnPasswordValidation;
                }
                else
                {
                    int      iRequest       = int.Parse(SAFConfiguration.readParameterExternal("TANRequestPositions"));
                    int      iDigitsByPos   = int.Parse(SAFConfiguration.readParameterExternal("TANDigitsByPosition"));
                    int      iFixPosOnFaill = int.Parse(SAFConfiguration.readParameterExternal("TANFixedPosOnFail"));
                    string   _otp           = string.Empty;
                    byte[]   _tkSeedOpen    = BaseFunctions.HexDecoder(_tkCryptoData.CryptoData.CryptoKey.Trim());
                    byte[]   _dataEntropy   = (dataEntropy == null || dataEntropy.Length < 1) ? new byte[0] : BaseFunctions.convertStringToByteArray(dataEntropy);
                    string[] _arrayPosValid = currentChallenge.Split(new char[]
                    {
                        '|'
                    });
                    string[] _arrayChallenge = BaseFunctions.DecodeFrom64(_tkCryptoData.CryptoData.SupportCryptoData.Trim()).Split(new char[]
                    {
                        ';'
                    });
                    for (int idx = 0; idx < _arrayPosValid.Length; idx++)
                    {
                        string[] _temp = _arrayPosValid[idx].Trim().Split(new char[]
                        {
                            ';'
                        });
                        _tkCryptoData.ResetMovingFactor(long.Parse(_arrayChallenge[(int)checked ((IntPtr)long.Parse(_temp[0]))]));
                        _otp += HOTPPwdGenerator.generate(_tkCryptoData, _tkSeedOpen, _dataEntropy).Substring(int.Parse(_temp[1]), 1);
                    }
                    if (password.Trim() == _otp)
                    {
                        if (OperationResult.Success == new TokensChallengeRequestDAO().resetChallengeRequest(tokenInternalID))
                        {
                            result = AutenticationStatus.Success;
                            return(result);
                        }
                    }
                    result = AutenticationStatus.TokenOrPasswordInvalid;
                }
            }
            return(result);
        }
コード例 #3
0
        /// <summary></summary>
        /// <returns></returns>
        private string _getTemplateFile()
        {
            string _fTemplateLocation = SAFConfiguration.readParameterExternal(cTEMPLATE_LOCATION);

            if (!File.Exists(_fTemplateLocation))
            {
                return(null);
            }
            return(_fTemplateLocation);
        }
コード例 #4
0
        public static OperationResult tokenTANFetchMatrixValues(LoteType loteType, string lotID, string TokenVendorID)
        {
            DataTable           _dt           = null;
            TokenTypeBaseParams _tkBaseParams = default(TokenTypeBaseParams);
            string            _masterKey      = SAFConfiguration.readMasterKey();
            string            _exportFilePath = SAFConfiguration.readParameterExternal("ExportFilePath");
            SAFLOGGERInMEMORY logger          = SAFLOGGERInMEMORY.GetLogString(_exportFilePath + "\\" + lotID.Trim() + ".DAT", false);

            logger.Clear();
            OperationResult result;

            try
            {
                _tkBaseParams = new TokenParamsDAO().loadTokenBaseParams(TokenVendorID);
                if (_tkBaseParams.TokenTypeBaseParamsID == null || _tkBaseParams.MovingFactorType != TokenMovingFactorType.TransactionAuthenticationNumber)
                {
                    result = OperationResult.Error;
                }
                else
                {
                    if (OperationResult.Error == new TokensDAO().loadTableWithTokensLot(loteType, lotID, TokenVendorID, TokenMovingFactorType.TransactionAuthenticationNumber, out _dt))
                    {
                        result = OperationResult.Error;
                    }
                    else
                    {
                        foreach (DataRow row in _dt.Rows)
                        {
                            TokenCryptoData _tkCryptoData = new TokenCryptoData(row[5].ToString(), row[0].ToString(), new CryptoData((long)row[1], row[2].ToString().Trim(), row[3].ToString().Trim(), (row[6] != null) ? row[6].ToString().Trim() : string.Empty), _tkBaseParams);
                            logger.Add(_tkCryptoData.SupplierSerialNumber + ";" + string.Join(";", TokensBaseFunctions.tokenTANMatrixArrayFetch(_tkCryptoData, _masterKey, null)));
                        }
                        logger.Persist();
                        result = OperationResult.Success;
                    }
                }
            }
            catch (Exception ex)
            {
                SAFLOGGER.Write(SAFLOGGER.LOGGEREventID.EXCEPTION, "SAFCORE", new string[]
                {
                    "http://sfexpand.SAFCore.TokensBaseFunctions.softfinanca.com/",
                    Assembly.GetExecutingAssembly().FullName.ToString(),
                    ex.ToString()
                });
                result = OperationResult.Error;
            }
            finally
            {
                _dt = null;
                //TokenCryptoData _tkCryptoData = default(TokenCryptoData);
                _tkBaseParams = default(TokenTypeBaseParams);
            }
            return(result);
        }
コード例 #5
0
        public static OperationResult tokenTANFetchSupplierSerialNumber(LoteType loteType, string lotID, string TokenVendorID)
        {
            DataTable           _dt           = null;
            TokenTypeBaseParams _tkBaseParams = default(TokenTypeBaseParams);
            string            _exportFilePath = SAFConfiguration.readParameterExternal("ExportFilePath");
            SAFLOGGERInMEMORY logger          = SAFLOGGERInMEMORY.GetLogString(_exportFilePath + "\\" + lotID.Trim() + "SerialNumbers.TXT", false);

            logger.Clear();
            OperationResult result;

            try
            {
                _tkBaseParams = new TokenParamsDAO().loadTokenBaseParams(TokenVendorID);
                if (_tkBaseParams.TokenTypeBaseParamsID == null || _tkBaseParams.MovingFactorType != TokenMovingFactorType.TransactionAuthenticationNumber)
                {
                    result = OperationResult.Error;
                }
                else
                {
                    if (OperationResult.Error == new TokensDAO().tokenSupplierSerialNumbersByLot(loteType, lotID, out _dt))
                    {
                        result = OperationResult.Error;
                    }
                    else
                    {
                        foreach (DataRow row in _dt.Rows)
                        {
                            logger.Add(row[0].ToString().Trim());
                        }
                        logger.Persist();
                        result = OperationResult.Success;
                    }
                }
            }
            catch (Exception ex)
            {
                SAFLOGGER.Write(SAFLOGGER.LOGGEREventID.EXCEPTION, "SAFCORE", new string[]
                {
                    "http://sfexpand.SAFCore.TokensBaseFunctions.softfinanca.com/",
                    Assembly.GetExecutingAssembly().FullName.ToString(),
                    ex.ToString()
                });
                result = OperationResult.Error;
            }
            finally
            {
                _dt           = null;
                logger        = null;
                _tkBaseParams = default(TokenTypeBaseParams);
            }
            return(result);
        }
コード例 #6
0
        private string _getTemplateFile()
        {
            string _fTemplateLocation = SAFConfiguration.readParameterExternal("DEPLOYJ1WINMOBILEINFOSRV");
            string result;

            if (!File.Exists(_fTemplateLocation))
            {
                result = null;
            }
            else
            {
                result = _fTemplateLocation;
            }
            return(result);
        }
コード例 #7
0
        /// <summary>
        /// </summary>
        /// <returns></returns>
        private string _getTempFolder()
        {
            string _fBaseFolder = SAFConfiguration.readParameterExternal(cTEMPWORKFOLDER);

            if (_fBaseFolder == null || _fBaseFolder.Length < 2)
            {
                _fBaseFolder = Path.GetTempPath();
            }

            string _fTempFolder = _fBaseFolder + (!_fBaseFolder.EndsWith(@"\") ? @"\" : "") + Path.GetFileNameWithoutExtension(Path.GetRandomFileName()) + @"\";

            if (!Directory.Exists(_fTempFolder))
            {
                Directory.CreateDirectory(_fTempFolder);
                return(_fTempFolder);
            }
            return(null);
        }
コード例 #8
0
        public static OperationResult tokenTANFetchMatrixValues(LoteType loteType, string lotID, string TokenVendorID)
        {
            DataTable           dataTable           = null;
            TokenTypeBaseParams tokenTypeBaseParams = default(TokenTypeBaseParams);
            string          str       = SAFConfiguration.readParameterExternal("ExportFilePath");
            InMemoryLogging logString = InMemoryLogging.GetLogString(str + "\\" + lotID.TrimEnd(new char[]
            {
                ' '
            }) + ".DAT", false);
            string          masterKey = SAFConfiguration.readMasterKey();
            OperationResult result;

            try
            {
                tokenTypeBaseParams = new TokenParamsDAO().loadTokenBaseParams(TokenVendorID);
                if (tokenTypeBaseParams.TokenTypeBaseParamsID == null || tokenTypeBaseParams.MovingFactorType != TokenMovingFactorType.TransactionAuthenticationNumber)
                {
                    result = OperationResult.Error;
                }
                else
                {
                    if (OperationResult.Error == new TokensDAO().loadTableWithTokensLot(loteType, lotID, TokenVendorID, TokenMovingFactorType.TransactionAuthenticationNumber, out dataTable))
                    {
                        result = OperationResult.Error;
                    }
                    else
                    {
                        foreach (DataRow dataRow in dataTable.Rows)
                        {
                            TokenCryptoData tokenCryptoData = new TokenCryptoData(dataRow[5].ToString(), dataRow[0].ToString(), new CryptoData((long)dataRow[1], dataRow[2].ToString().Trim(), dataRow[3].ToString().Trim(), (dataRow[6] != null) ? dataRow[6].ToString().Trim() : string.Empty), tokenTypeBaseParams);
                            logString.Add(tokenCryptoData.SupplierSerialNumber + ";" + string.Join(";", TokensBaseFunctions.tokenTANMatrixArrayFetch(tokenCryptoData, masterKey, null)));
                        }
                        logString.Persist();
                        result = OperationResult.Success;
                    }
                }
            }
            catch (Exception logObject)
            {
                LOGGER.Write(LOGGER.LogCategory.ERROR, "SF.Expand.SAF.Core::tokenTANFetchMatcrixValues[]", logObject);
                result = OperationResult.Error;
            }
            return(result);
        }
コード例 #9
0
        private string _getTempFolder()
        {
            string _fBaseFolder = SAFConfiguration.readParameterExternal("DEPLOYJ1WINMOBILEINFOSRV_TEMPFOLDER");

            if (_fBaseFolder == null || _fBaseFolder.Length < 2)
            {
                _fBaseFolder = Path.GetTempPath();
            }
            string _fTempFolder = _fBaseFolder + ((!_fBaseFolder.EndsWith("\\")) ? "\\" : "") + Path.GetFileNameWithoutExtension(Path.GetRandomFileName()) + "\\";
            string result;

            if (!Directory.Exists(_fTempFolder))
            {
                Directory.CreateDirectory(_fTempFolder);
                result = _fTempFolder;
            }
            else
            {
                result = null;
            }
            return(result);
        }
コード例 #10
0
        public static string processRequest(object httpContext)
        {
            StringBuilder _inputParameters = new StringBuilder();

            if (httpContext == null || httpContext.GetType() != typeof(HttpContext))
            {
                throw new Exception("Object type not supported");
            }
            string result;

            try
            {
                HttpContext context = (HttpContext)httpContext;
                _inputParameters.AppendFormat("ID|{0}", context.Request.QueryString.Get(SAFConfiguration.readParameterExternal("TOKENDEPLOY_SERVICE_PUBLICNAME")));
                string[] _confServerVarsKeys = SAFConfiguration.readParameterExternal("HTTPREQUEST_SERVER_KEYS").Split(new char[]
                {
                    '|'
                });
                for (int i = 0; i < _confServerVarsKeys.Length; i++)
                {
                    _inputParameters.AppendFormat("|{0}|{1}", _confServerVarsKeys[i], context.Request.ServerVariables.Get(_confServerVarsKeys[i]));
                }
                result = HttpDeployProcessor.processRequest(_inputParameters.ToString());
            }
            catch (Exception ex)
            {
                SAFLOGGER.Write(SAFLOGGER.LOGGEREventID.EXCEPTION, "SAFBUSINESSDEPLOY", new string[]
                {
                    "http://sfexpand.SAFDeploy.DEPLOYJ1JAVAINFOSRV.softfinanca.com/",
                    Assembly.GetExecutingAssembly().FullName.ToString(),
                    ex.ToString()
                });
                result = null;
            }
            finally
            {
            }
            return(result);
        }
コード例 #11
0
        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);
        }
コード例 #12
0
 public static void Export(APPEVENTSDeff appeventDeff, int appEventID, string appMODName, string[] appMessages)
 {
     SAFInternalEvents.Export(SAFConfiguration.readParameterExternal(appeventDeff.ToString()), appeventDeff, appEventID, appMODName, appMessages);
 }
コード例 #13
0
        public OperationResult AfterStartServerAuthentication(string applicationUser, string tokenID, string baseNotifyMessage, string newPassword, TokenMovingFactorType tokenMovingFactorType, TokenSeedType tokenSeedType)
        {
            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("SMS.TEMPLATE.ON.STARTSERVERAUTH");

            notifMsg = string.Format(notifMsg.Replace("{tm}", DateTime.Now.ToShortDateString()).Replace("{dt}", DateTime.Now.ToShortTimeString()), _params);
            return(SMSSender.Send(applicationUser, tokenID, null, notifMsg));
        }
コード例 #14
0
        public OperationResult ChallengeRequest(string tokenInternalID, string dataEntropy, out string newChallenge)
        {
            TokenCryptoData _tkCryptoData = new TokensDAO().loadTokenCryptoData(tokenInternalID);
            OperationResult result;

            if (_tkCryptoData.ID == null)
            {
                newChallenge = null;
                result       = OperationResult.Error;
            }
            else
            {
                if (_tkCryptoData.TokenBaseParams.MovingFactorType != TokenMovingFactorType.TransactionAuthenticationNumber && _tkCryptoData.TokenBaseParams.MovingFactorType != TokenMovingFactorType.EventBase && _tkCryptoData.TokenBaseParams.SeedType == TokenSeedType.ActivactionKey)
                {
                    throw new Exception("Function not implemented for this type of token!!");
                }
                string currentChallenge = (string)new TokensChallengeRequestDAO().loadChallengeRequest(tokenInternalID);
                if (currentChallenge != null)
                {
                    newChallenge = this.formatChallenge(currentChallenge.Trim());
                    result       = OperationResult.Success;
                }
                else
                {
                    int      _idx                  = 0;
                    int      iRequest              = int.Parse(SAFConfiguration.readParameterExternal("TANRequestPositions"));
                    int      iDigitsByPos          = int.Parse(SAFConfiguration.readParameterExternal("TANDigitsByPosition"));
                    int[]    _array                = new int[iRequest];
                    string   _lastRequest          = string.Empty;
                    DateTime _lastRequestValidThru = (_tkCryptoData.TokenBaseParams.ChallengeRequestValidUntil > 0) ? DateTime.Now.AddSeconds((double)_tkCryptoData.TokenBaseParams.ChallengeRequestValidUntil) : DateTime.MaxValue;
                    while (_idx != iRequest)
                    {
                        bool _flag;
                        do
                        {
                            _flag = false;
                            Random rndArray = new Random();
                            _array[_idx] = rndArray.Next(0, _tkCryptoData.TokenBaseParams.OTPValidationWindow);
                            for (int _idx2 = 0; _idx2 < _idx; _idx2++)
                            {
                                if (_array[_idx] == _array[_idx2])
                                {
                                    _flag = true;
                                    break;
                                }
                            }
                        }while (_flag);
                        Random rndPos = new Random();
                        string text   = _lastRequest;
                        _lastRequest = string.Concat(new string[]
                        {
                            text,
                            _array[_idx].ToString().Trim(),
                            ";",
                            rndPos.Next(0, _tkCryptoData.TokenBaseParams.OTPTotalDigits).ToString().Trim(),
                            "|"
                        });
                        _idx++;
                    }
                    newChallenge = this.formatChallenge(_lastRequest.Substring(0, _lastRequest.Length - 1).Trim());
                    result       = new TokensChallengeRequestDAO().persistChallengeRequest(tokenInternalID, _lastRequest.Substring(0, _lastRequest.Length - 1).Trim(), _lastRequestValidThru);
                }
            }
            return(result);
        }
コード例 #15
0
        public static void Export(string eventHandlerTypeName, APPEVENTSDeff appeventDeff, int appEventID, string appMODName, string[] appMessages)
        {
            object retVAL = null;

            try
            {
                ISAFEvents safEvents = SAFEventsFactory.LoadAssembly((eventHandlerTypeName == null || eventHandlerTypeName.Length < 1) ? SAFConfiguration.readParameterExternal("SAFAPPEventHandler") : eventHandlerTypeName);
                if (safEvents != null)
                {
                    safEvents.Export(appeventDeff, appEventID, appMODName, appMessages, out retVAL);
                }
            }
            finally
            {
            }
        }
コード例 #16
0
        public static OperationResult Send(string applicationUser, string tokenID, string phoneNumber, string smsMessage)
        {
            long   tokenEventID     = -1L;
            int    smsGatewayStatus = 0;
            string emailAddr        = null;
            NotifyOperationResult notifyProcessorResult = NotifyOperationResult.Error;
            OperationResult       result;

            if (phoneNumber == null)
            {
                SMSSender.getTokenUserEmailAndPhone(applicationUser, tokenID, out phoneNumber, out emailAddr);
                if (phoneNumber == null)
                {
                    result = OperationResult.Error;
                    return(result);
                }
            }
            string defaultSMSProcessor = SAFConfiguration.readParameterExternal("SAFSMSAssemblyProcessor");

            if (defaultSMSProcessor == null || defaultSMSProcessor.Trim().Length < 1)
            {
                SAFLOGGER.Write(SAFLOGGER.LOGGEREventID.ERROR, "SAFBUSINESS", new string[]
                {
                    "http://sfexpand.SAFBusiness.SMSSender.softfinanca.com/",
                    Assembly.GetExecutingAssembly().FullName.ToString(),
                    "Invalid or inexistent SMS channel processor!"
                });
                result = OperationResult.Error;
            }
            else
            {
                INotifyChannelProcessor notifyProcessor = NotifyChannelProcessorFactory.LoadSMSAssembly(defaultSMSProcessor);
                if (notifyProcessor == null)
                {
                    SAFLOGGER.Write(SAFLOGGER.LOGGEREventID.ERROR, "SAFBUSINESS", new string[]
                    {
                        "http://sfexpand.SAFBusiness.SMSSender.softfinanca.com/",
                        Assembly.GetExecutingAssembly().FullName.ToString(),
                        "[CHANNEL PROCESSOR] [" + defaultSMSProcessor + "]",
                        "Invalid or inexistent SMS channel processor!"
                    });
                    result = OperationResult.Error;
                }
                else
                {
                    string defaultSMSGateway = SAFConfiguration.readParameterExternal("SAFSMSDefaultGateway");
                    if (defaultSMSGateway == null || defaultSMSGateway.Trim().Length < 1)
                    {
                        SAFLOGGER.Write(SAFLOGGER.LOGGEREventID.ERROR, "SAFBUSINESS", new string[]
                        {
                            "http://sfexpand.SAFBusiness.SMSSender.softfinanca.com/",
                            Assembly.GetExecutingAssembly().FullName.ToString(),
                            "Sms default gateway invalid!"
                        });
                        result = OperationResult.Error;
                    }
                    else
                    {
                        int defaultSMSGatewayTimeout = -1;
                        int.TryParse(SAFConfiguration.readParameterExternal("SAFSMSDefaultGatewayTimeout"), out defaultSMSGatewayTimeout);
                        try
                        {
                            NotificationEvent _event = NotificationEvent.loadNotificationEvent(0L, "SAFBUSINESS", "SAFBUSINESS", phoneNumber.Trim(), smsMessage, null, NotificationChannel.loadNotificationChannel(0, "", defaultSMSProcessor, defaultSMSGatewayTimeout, "SMS", 300L, true, defaultSMSGateway));
                            try
                            {
                                new TokensBusinessEventsDAO().insertTokenEvent(tokenID, 151, (int)notifyProcessorResult, applicationUser, out tokenEventID);
                                notifyProcessorResult = notifyProcessor.SendNotification(_event, out smsGatewayStatus);
                                if (tokenEventID > 0L)
                                {
                                    new TokensBusinessEventsDAO().updateEventStatus(tokenEventID.ToString(), (byte)notifyProcessorResult);
                                }
                                result = ((notifyProcessorResult == NotifyOperationResult.Success) ? OperationResult.Success : OperationResult.Error);
                            }
                            catch (Exception ex)
                            {
                                SAFLOGGER.Write(SAFLOGGER.LOGGEREventID.EXCEPTION, "SAFBUSINESS", new string[]
                                {
                                    "http://sfexpand.SAFBusiness.SMSSender.softfinanca.com/",
                                    Assembly.GetExecutingAssembly().FullName.ToString(),
                                    ex.ToString()
                                });
                                result = OperationResult.Error;
                            }
                        }
                        catch (Exception ex)
                        {
                            SAFLOGGER.Write(SAFLOGGER.LOGGEREventID.EXCEPTION, "SAFBUSINESS", new string[]
                            {
                                "http://sfexpand.SAFBusiness.SMSSender.softfinanca.com/",
                                Assembly.GetExecutingAssembly().FullName.ToString(),
                                ex.ToString()
                            });
                            result = OperationResult.Error;
                        }
                        finally
                        {
                        }
                    }
                }
            }
            return(result);
        }
コード例 #17
0
        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);
        }