예제 #1
0
        private async Task SendVnptBranchNameAsync(SendOtpInput input)
        {
            var vnptBranchSetting = new VNPTBranchSetting()
            {
                ServerAddress  = await _systemConfigServices.GetValueAsync(SmsVNPTBranchGateway.ConfigServerAddress),
                AGENTID        = await _systemConfigServices.GetValueAsync(SmsVNPTBranchGateway.ConfigAGENTID),
                APIPASS        = await _systemConfigServices.GetValueAsync(SmsVNPTBranchGateway.ConfigAPIPASS),
                APIUSER        = await _systemConfigServices.GetValueAsync(SmsVNPTBranchGateway.ConfigAPIUSER),
                CONTRACTID     = await _systemConfigServices.GetValueAsync(SmsVNPTBranchGateway.ConfigCONTRACTID),
                CONTRACTTYPEID = await _systemConfigServices.GetValueAsync(SmsVNPTBranchGateway.ConfigCONTRACTTYPEID),
                LABELID        = await _systemConfigServices.GetValueAsync(SmsVNPTBranchGateway.ConfigLABELID),
                TEMPLATEID     = await _systemConfigServices.GetValueAsync(SmsVNPTBranchGateway.ConfigTEMPLATEID),
                USERNAME       = await _systemConfigServices.GetValueAsync(SmsVNPTBranchGateway.ConfigUSERNAME)
            };
            List <VnptDirectParam> directParams = new List <VnptDirectParam>()
            {
                new VnptDirectParam()
                {
                    NUM = 1, CONTENT = input.Otp
                },
                new VnptDirectParam()
                {
                    NUM = 2, CONTENT = input.Time
                },
            };

            SmsVNPTBranchGateway.SendMessage(vnptBranchSetting, directParams, input.Mobile);
        }
예제 #2
0
        private async Task SendDefaultOtpAsync(SendOtpInput input)
        {
            var notificationTypes = await _notificationTypeService.GetListAsync("SendOtp");

            foreach (var notificationType in notificationTypes)
            {
                string subject      = ReplaceUtility.ReplaceTextProps(notificationType.Description, input);
                string body         = ReplaceUtility.ReplaceTextProps(notificationType.Template, input);
                var    notification = Notification.Create(notificationType.Id,
                                                          notificationType.ModuleCode, null, input.UserId,
                                                          null, string.Empty, subject, body);
                _notificationRepository.Add(notification);
            }
        }
예제 #3
0
        private async Task SendQuickAsync(SendOtpInput input)
        {
            var smsServerUrl = await _systemConfigServices.GetValueAsync(SmsGateway.ServerUrlConfigKey);

            var smsOtpTemplate = await _systemConfigServices.GetValueAsync("SmsOtpTemplate");

            // prepare
            SmsSendRequest smsSendRequest = new SmsSendRequest();

            smsSendRequest.ServerUrl    = smsServerUrl;
            smsSendRequest.MobileNumber = input.Mobile;
            smsSendRequest.Text         = smsOtpTemplate
                                          .Replace("{otp}", input.Otp)
                                          .Replace("{time}", input.Time);
            smsSendRequest.IsUnicode = false;
            await SmsGateway.SendQuick_Send(smsSendRequest);
        }
예제 #4
0
        public async Task SendOtpAsync(SendOtpInput input)
        {
            switch (input.SendOtpType.ToLower())
            {
            case "sendquick":
                await SendQuickAsync(input);

                return;

            case "vnptbranch":
                await SendVnptBranchNameAsync(input);

                return;

            default:
                await SendDefaultOtpAsync(input);

                return;
            }
        }