示例#1
0
        /// <summary>
        /// 发送ISV手机验证码(只有发送验证码可用,发送其他短信不要用此接口)
        /// </summary>
        public bool SendISVMobileValCode(int tenantId, string isv, string channelId, string content, string toPhone, SMSType type, string templateMessageText)
        {
            if (string.IsNullOrEmpty(channelId))
            {
                AppConnectLogHelper.Error(new SMSSendException("短信通道未配置"));
                return(false);
            }

            var smsInvokeProvider = PlatformServiceFactory <ISMSMailProvider> .Instance();

            if (smsInvokeProvider == null)
            {
                AppConnectLogHelper.Error(new ESBServiceNotFoundException("SMS ESB Service Is null"));
                return(false);
            }

            var smsBatch      = new SMSBatch();
            var shortMessages = new List <ShortMessage>()
            {
                new ShortMessage()
                {
                    PhoneNumber         = toPhone,
                    MessageText         = content,
                    TemplateMessageText = templateMessageText
                }
            };

            var messageCollection = new MessageCollection(shortMessages.ToArray());

            smsBatch.SystemId = channelId;
            if (tenantId == 0)
            {
                tenantId = 2;
            }
            smsBatch.TenantId      = tenantId;
            smsBatch.TenantName    = "ISV业务短信";
            smsBatch.ShortMessages = messageCollection;
            smsBatch.UserId        = 0;
            ArgumentHelper.IsValid(smsBatch, true);

            var  sendInfo  = smsInvokeProvider.SMS_SendSMSByTime(smsBatch);
            bool isSuccess = CheckResult(sendInfo);

            if (isSuccess)
            {
                return(true);
            }
            AppConnectLogHelper.Error("短信发送失败:" + sendInfo);
            return(false);
        }