예제 #1
0
        protected void BtnVerizonTestMessageSend_OnClick(object sender, EventArgs e)
        {
            try
            {
                SMSProvider smsProvider = this.SMSService.GetSMSProviderBySystemKeyword("SMSPROVIDERS_VERIZON");
                if (smsProvider == null)
                {
                    ShowError(GetLocaleResourceString("Admin.SMSProviders.Verizon.TestMessage.Failed"));
                    return;
                }

                ISMSProvider iSMSProvider = smsProvider.Instance;
                if (iSMSProvider == null)
                {
                    ShowError(GetLocaleResourceString("Admin.SMSProviders.Verizon.TestMessage.Failed"));
                    return;
                }

                if (!iSMSProvider.SendSMS(txtVerizonTestMessageText.Text))
                {
                    ShowError(GetLocaleResourceString("Admin.SMSProviders.Verizon.TestMessage.Failed"));
                    return;
                }
                ShowMessage(GetLocaleResourceString("Admin.SMSProviders.Verizon.TestMessage.Success"));
            }
            catch (Exception exc)
            {
                ProcessException(exc);
            }
        }
예제 #2
0
        public async Task <IActionResult> Mobile([FromServices] ISMSProvider provider, string phone, string code)
        {
            var auth = provider.Validate(phone, code);

            HttpContext.Log(phone, auth);
            if (auth)
            {
                var user = UserHelper.Retrieves().FirstOrDefault(u => u.UserName == phone);
                if (user == null)
                {
                    user = new User()
                    {
                        ApprovedBy   = "Mobile",
                        ApprovedTime = DateTime.Now,
                        DisplayName  = "手机用户",
                        UserName     = phone,
                        Password     = code,
                        Icon         = "default.jpg",
                        Description  = "手机用户",
                        App          = provider.Option.App
                    };
                    UserHelper.Save(user);

                    // 根据配置文件设置默认角色
                    var roles = RoleHelper.Retrieves().Where(r => provider.Option.Roles.Any(rl => rl.Equals(r.RoleName, StringComparison.OrdinalIgnoreCase))).Select(r => r.Id);
                    RoleHelper.SaveByUserId(user.Id, roles);
                }
            }
            return(auth ? await SignInAsync(phone, true, MobileSchema) : RedirectLogin());
        }
예제 #3
0
 public BulkMessageSender(
     IResultRegistrar registrar,
     ISMSProvider sender)
 {
     ResultRegistrar = registrar;
     Sender          = sender;
 }
 public CommunicationsService(ICommunicationsRepository communicationsRepository,
                              IStudentRepository studentRepository,
                              IParentRepository parentRepository,
                              ITeacherRepository teacherRepository,
                              IImageProvider imageProvider,
                              IPushNotificationProvider pushNotificationProvider,
                              IMessagingProvider messagingProvider,
                              ISMSProvider smsProvider,
                              ITranslationProvider translationProvider,
                              ICustomParametersProvider customParametersProvider,
                              IDateProvider dateProvider,
                              ICollection <IMessageProvider> messageProviders,
                              IStaffRepository staffRepository)
 {
     _communicationsRepository = communicationsRepository;
     _studentRepository        = studentRepository;
     _parentRepository         = parentRepository;
     _teacherRepository        = teacherRepository;
     _imageProvider            = imageProvider;
     _pushNotificationProvider = pushNotificationProvider;
     _messagingProvider        = messagingProvider;
     _smsProvider              = smsProvider;
     _translationProvider      = translationProvider;
     _customParametersProvider = customParametersProvider;
     _dateProvider             = dateProvider;
     _messageProviders         = messageProviders;
     _staffRepository          = staffRepository;
 }
예제 #5
0
        protected void BtnClickatellTestMessageSend_OnClick(object sender, EventArgs e)
        {
            try
            {
                SMSProvider smsProvider = SMSManager.GetSMSProviderBySystemKeyword("SMSPROVIDERS_CLICKATELL");
                if (smsProvider == null)
                {
                    ShowError(GetLocaleResourceString("Admin.SMSProviders.Clickatell.TestMessage.Failed"));
                    return;
                }

                ISMSProvider iSMSProvider = smsProvider.Instance;
                if (iSMSProvider == null)
                {
                    ShowError(GetLocaleResourceString("Admin.SMSProviders.Clickatell.TestMessage.Failed"));
                    return;
                }

                if (!iSMSProvider.SendSMS(txtClickatellTestMessageText.Text))
                {
                    ShowError(GetLocaleResourceString("Admin.SMSProviders.Clickatell.TestMessage.Failed"));
                    return;
                }
                ShowMessage(GetLocaleResourceString("Admin.SMSProviders.Clickatell.TestMessage.Success"));
            }
            catch (Exception exc)
            {
                ProcessException(exc);
            }
        }
예제 #6
0
 public PaymentController(IHostingEnvironment env, ApplicationDbContext context,
                          UserManager <UserApplication> _UserManager, IEmailSender emailSender, ISMSProvider _sMSSender)
 {
     _context     = context;
     _userManager = _UserManager;
     _env         = env;
     _emailSender = emailSender;
     _SMSSender   = _sMSSender;
 }
 public AbscencesThresholdAlertProvider(IAlertRepository alertRepository, ICustomParametersProvider customParametersProvider, ITypesRepository typesRepository, IMessagingProvider messagingProvider, IUrlProvider urlProvider, IImageProvider imageProvider, ISMSProvider smsProvider)
 {
     _alertRepository          = alertRepository;
     _customParametersProvider = customParametersProvider;
     _messagingProvider        = messagingProvider;
     _urlProvider     = urlProvider;
     _imageProvider   = imageProvider;
     _smsProvider     = smsProvider;
     _typesRepository = typesRepository;
 }
예제 #8
0
        /// <summary>构造函数</summary>
        public SMSService()
        {
            // 创建对象构建器(Spring.NET)
            string springObjectFile = SMSConfigurationView.Instance.Configuration.Keys["SpringObjectFile"].Value;

            SpringObjectBuilder objectBuilder = SpringObjectBuilder.Create(SMSConfiguration.ApplicationName, springObjectFile);

            this.provider = objectBuilder.GetObject <ISMSProvider>(typeof(ISMSProvider));

            this.client = (IShortMessageClientProvider)KernelContext.CreateObject(SMSConfigurationView.Instance.ClientProvider);
        }
예제 #9
0
        public SenderTests()
        {
            var container = new WindsorContainer();

            container.Register(
                Component.For <ISMSProvider>().ImplementedBy <AtiehSMSProvider>());
            container.Register(
                Component.For <ISMSConfiguration>().ImplementedBy <AtiehSMSConfiguration>());
            container.Register(
                Component.For <IResultRegistrar>().ImplementedBy <MockResultRegistrar>());
            container.Register(
                Component.For <BulkMessageSender>().ImplementedBy <BulkMessageSender>());
            sender = container.Resolve <ISMSProvider>();
        }
예제 #10
0
        public Task <IActionResult> Lock([FromServices] ISMSProvider provider, string userName, string password, string authType)
        {
            // 根据不同的登陆方式
            Task <IActionResult> ret;

            if (authType == MobileSchema)
            {
                ret = Mobile(provider, userName, password);
            }
            else
            {
                ret = Login(userName, password, string.Empty);
            }
            return(ret);
        }
예제 #11
0
        public static void Start(SchemaBuilder sb, DynamicQueryManager dqm, ISMSProvider provider, Func <SMSConfigurationEmbedded> getConfiguration)
        {
            if (sb.NotDefined(MethodInfo.GetCurrentMethod()))
            {
                CultureInfoLogic.AssertStarted(sb);

                SMSLogic.getConfiguration = getConfiguration;
                SMSLogic.Provider         = provider;

                sb.Include <SMSMessageEntity>()
                .WithQuery(dqm, () => m => new
                {
                    Entity = m,
                    m.Id,
                    Source = m.From,
                    m.DestinationNumber,
                    m.State,
                    m.SendDate,
                    m.Template
                });

                sb.Include <SMSTemplateEntity>()
                .WithQuery(dqm, () => t => new
                {
                    Entity = t,
                    t.Id,
                    t.Name,
                    IsActive = t.IsActiveNow(),
                    Source   = t.From,
                    t.AssociatedType,
                    t.StartDate,
                    t.EndDate,
                });

                SMSMessageGraph.Register();
                SMSTemplateGraph.Register();

                Validator.PropertyValidator <SMSTemplateEntity>(et => et.Messages).StaticPropertyValidation += (t, pi) =>
                {
                    if (!t.Messages.Any(m => m.CultureInfo.Is(SMSLogic.Configuration.DefaultCulture)))
                    {
                        return(SMSTemplateMessage.ThereMustBeAMessageFor0.NiceToString().FormatWith(SMSLogic.Configuration.DefaultCulture.EnglishName));
                    }

                    return(null);
                };
            }
        }
예제 #12
0
 public AssignmentThresholdAlertProvider(IAlertRepository alertRepository,
                                         ICustomParametersProvider customParametersProvider,
                                         ITypesRepository typesRepository,
                                         IMessagingProvider messagingProvider,
                                         IUrlProvider urlProvider,
                                         IImageProvider imageProvider,
                                         ISMSProvider smsProvider,
                                         IPushNotificationProvider pushNotificationProvider,
                                         ITranslationProvider translationProvider)
 {
     _alertRepository          = alertRepository;
     _customParametersProvider = customParametersProvider;
     _messagingProvider        = messagingProvider;
     _urlProvider              = urlProvider;
     _imageProvider            = imageProvider;
     _smsProvider              = smsProvider;
     _typesRepository          = typesRepository;
     _pushNotificationProvider = pushNotificationProvider;
     _translationProvider      = translationProvider;
 }
예제 #13
0
 public UnreadMessagesAlertProvider(IAlertRepository alertRepository,
                                    ICustomParametersProvider customParametersProvider,
                                    ITypesRepository typesRepository,
                                    IMessagingProvider messagingProvider,
                                    IUrlProvider urlProvider,
                                    IImageProvider imageProvider,
                                    ISMSProvider smsProvider,
                                    IApplicationSettingsProvider applicationSettingsProvider,
                                    IPushNotificationProvider pushNotificationProvider,
                                    ITranslationProvider translationProvider)
 {
     _alertRepository          = alertRepository;
     _customParametersProvider = customParametersProvider;
     _messagingProvider        = messagingProvider;
     _urlProvider                 = urlProvider;
     _imageProvider               = imageProvider;
     _smsProvider                 = smsProvider;
     _typesRepository             = typesRepository;
     _applicationSettingsProvider = applicationSettingsProvider;
     _pushNotificationProvider    = pushNotificationProvider;
     _translationProvider         = translationProvider;
 }
예제 #14
0
        public async Task <IActionResult> Mobile([FromServices] ISMSProvider provider, string phone, string code)
        {
            if (string.IsNullOrEmpty(phone) || string.IsNullOrEmpty(code))
            {
                return(RedirectLogin());
            }

            var auth = provider.Validate(phone, code);

            HttpContext.Log(phone, auth);
            if (auth)
            {
                var user = UserHelper.Retrieves().FirstOrDefault(u => u.UserName == phone);
                if (user == null)
                {
                    user = new User()
                    {
                        ApprovedBy   = "Mobile",
                        ApprovedTime = DateTime.Now,
                        DisplayName  = "手机用户",
                        UserName     = phone,
                        Password     = code,
                        Icon         = "default.jpg",
                        Description  = "手机用户",
                        App          = provider.Options.App
                    };
                    if (UserHelper.Save(user) && !string.IsNullOrEmpty(user.Id))
                    {
                        // 根据配置文件设置默认角色
                        var roles = RoleHelper.Retrieves().Where(r => provider.Options.Roles.Any(rl => rl.Equals(r.RoleName, StringComparison.OrdinalIgnoreCase))).Select(r => r.Id);
#nullable disable
                        RoleHelper.SaveByUserId(user.Id, roles);
#nullable restore
                    }
                }
            }
예제 #15
0
 public SmsMessageProvider(ISMSProvider smsProvider)
 {
     _smsProvider = smsProvider;
 }
예제 #16
0
 public SMSController(ISMSProvider sendMessageProvider)
 {
     _sendMessageProvider = sendMessageProvider;
 }
예제 #17
0
 public async Task <SMSResult> Put([FromServices] ISMSProvider provider, [FromQuery] string phone) => string.IsNullOrEmpty(phone) ? new SMSResult()
 {
     Result = false, Msg = "手机号不可为空"
 } : await provider.SendCodeAsync(phone);
예제 #18
0
 public async Task <bool> Put([FromServices] ISMSProvider provider, [FromQuery] string phone) => string.IsNullOrEmpty(phone) ? false : await provider.SendCodeAsync(phone);
예제 #19
0
 public SmsProvider(IConfigurationProvider configurationProvider)
 {
     _smsProvider           = new SMSProviderService().GetSMSProvider(ProviderType.WorldText);
     _configurationProvider = configurationProvider;
     _smsConfigs            = configurationProvider.SMSConfigs;
 }