Beispiel #1
0
        public async Task <ExchangeRate> CreateAsync(decimal rate)
        {
            string invoiceCurrency = await SettingProvider.GetOrNullAsync(FacCigoSettings.InvoiceCurrency);

            string pivotCurrency = await SettingProvider.GetOrNullAsync(FacCigoSettings.PivotCurrency);

            if (invoiceCurrency == null)
            {
                throw new InvoiceCurrencyNotSettledException(invoiceCurrency);
            }
            if (pivotCurrency == null)
            {
                throw new CurrencyNotPivotException(pivotCurrency);
            }
            Currency ci = await CurrencyRepository.GetAsync(invoiceCurrency);

            if (ci == null)
            {
                throw new InvoiceCurrencyNotSettledException(invoiceCurrency);
            }
            Currency cp = await CurrencyRepository.GetAsync(pivotCurrency);

            if (cp == null)
            {
                throw new CurrencyNotPivotException(pivotCurrency);
            }
            DateTime date = DateTime.Now;

            return(await Repository.InsertAsync(new ExchangeRate(GuidGenerator.Create(), cp.Id, ci.Id, date, rate)
                                                { CreationTime = date, IsActive = true }, autoSave : true));
        }
Beispiel #2
0
        public virtual async Task <PagedResultDto <SystemLogDto> > GetListAsync(string queryString, DateTime startTime,
                                                                                DateTime endTime, int maxResultCount, int skipCount)
        {
            var secretId = await _settingProvider.GetOrNullAsync(LoggingManagementTencentCloudClsSettings.SecretId);

            var secretKey = await _settingProvider.GetOrNullAsync(LoggingManagementTencentCloudClsSettings.SecretKey);

            var logSetId = await _settingProvider.GetOrNullAsync(LoggingManagementTencentCloudClsSettings.LogSetId);

            var topicId = await _settingProvider.GetOrNullAsync(LoggingManagementTencentCloudClsSettings.TopicId);

            var region = await _settingProvider.GetOrNullAsync(LoggingManagementTencentCloudClsSettings.Region);

            var isIntranet = await _settingProvider.IsTrueAsync(LoggingManagementTencentCloudClsSettings.IsIntranet);

            var endpoint      = GetEndPoint(region, isIntranet);
            var commonOptions = new AbpTencentCloudCommonOptions
            {
                SecretId  = secretId,
                SecretKey = secretKey
            };

            return(await InternalGetListAsync(logSetId, topicId, startTime, endTime, queryString, endpoint,
                                              commonOptions, maxResultCount, skipCount));
        }
        public async Task <object> GetAsync()
        {
            //Get a value as string.
            string host = await _settingProvider.GetOrNullAsync("Smtp.Host");

            //string host2 = await SettingProvider.GetOrNullAsync("Smtp.Host");

            //Get a bool value and fallback to the default value (false) if not set.
            bool enableSsl1 = await _settingProvider.GetAsync <bool>("Smtp.EnableSsl");

            //Get a bool value and fallback to the provided default value (true) if not set.
            bool enableSsl2 = await _settingProvider.GetAsync("Smtp.EnableSsl", defaultValue : true);

            //Get a bool value with the IsTrueAsync shortcut extension method
            bool enableSsl3 = await _settingProvider.IsTrueAsync("Smtp.EnableSsl");

            //Get an int value or the default value (0) if not set
            int port1 = await _settingProvider.GetAsync <int>("Smtp.Port");

            //Get an int value or null if not provided
            int?port2 = (await _settingProvider.GetOrNullAsync("Smtp.Port"))?.To <int>();

            string setting1 = await _settingProvider.GetOrNullAsync("Example.Setting1");

            string setting2 = await _settingProvider.GetOrNullAsync("Example.Setting2");

            string setting3 = await _settingProvider.GetOrNullAsync("Example.Setting3");

            return(new { host, enableSsl1, enableSsl2, enableSsl3, port1, port2, setting1, setting2, setting3 });
        }
Beispiel #4
0
        public async Task <object> PayAsync(OrderPayRequestDto input)
        {
            var order = await Repository.Include(x => x.OrderItems).FirstOrDefaultAsync(x => x.Id == input.OrderId);

            var appName = _httpContextAccessor?.HttpContext.Request.Headers["AppName"].FirstOrDefault();

            var app = await _appProvider.GetOrNullAsync(appName);

            var appid = app["appid"] ?? throw new AbpException($"App:{appName} appid未设置");

            var mchId = await _setting.GetOrNullAsync(MallManagementSetting.PayMchId);

            var mchKey = await _setting.GetOrNullAsync(MallManagementSetting.PayKey);

            var notifyUrl = await _setting.GetOrNullAsync(MallManagementSetting.PayNotify);

            var result = await _payApi.UnifiedOrderAsync(
                appid,
                mchId,
                mchKey,
                body : order.OrderItems.First().SpuName,
                outTradeNo : $"{mchId}{DateTime.Now:yyyyMMddHHmmss}{StringExt.BuildRandomStr(6)}",
                totalFee : Convert.ToInt32(order.PriceOriginal * 100),
                notifyUrl : notifyUrl,
                tradeType : Consts.TradeType.JsApi,
                openId : input.openid,
                billCreateIp : _httpContext.HttpContext.Connection.RemoteIpAddress.ToString()
                );

            return(result);
        }
 public async Task <AccountSettingsDto> GetAllSettingsAsync()
 {
     return(new AccountSettingsDto
     {
         IsSelfRegistrationEnabled = Convert.ToBoolean(await _settingProvider.GetOrNullAsync(AccountSettingNames.IsSelfRegistrationEnabled)),
         EnableLocalLogin = Convert.ToBoolean(await _settingProvider.GetOrNullAsync(AccountSettingNames.EnableLocalLogin)),
     });
 }
    public async Task Should_Get_From_Store_For_Current_User()
    {
        _currentUserId = _testData.User1Id;
        (await _settingProvider.GetOrNullAsync("MySetting2")).ShouldBe("user1-store-value");

        _currentUserId = _testData.User2Id;
        (await _settingProvider.GetOrNullAsync("MySetting2")).ShouldBe("user2-store-value");
    }
Beispiel #7
0
        public async Task <object> MiniAuth(WeChatMiniProgramAuthenticateModel loginModel)
        {
            var appid = await _setting.GetOrNullAsync(MallManagementSetting.MiniAppId);

            var appSec = await _setting.GetOrNullAsync(MallManagementSetting.MiniAppSecret);

            return(await _weixinAppService.MiniAuth(loginModel, appid, appSec));
        }
        protected virtual async Task OverrideOptionsAsync(LoginPageOptions options)
        {
            options.Title = await _settingProvider.GetOrNullAsync(ThemesSettingNames.LoginPageOptions.Title);

            options.Description = await _settingProvider.GetOrNullAsync(ThemesSettingNames.LoginPageOptions.Description);

            options.Footer = await _settingProvider.GetOrNullAsync(ThemesSettingNames.LoginPageOptions.Footer);
        }
Beispiel #9
0
        public async Task <string> GetAccessToken(string appid)
        {
            var appId = await _setting.GetOrNullAsync(WeixinManagementSetting.MiniAppId);

            var appSec = await _setting.GetOrNullAsync(WeixinManagementSetting.MiniAppSecret);

            var token = await _weixinManager.GetAccessTokenAsync(appId, appSec);

            return(token);
        }
        public async Task <object> PayAsync(OrderPayRequestDto input)
        {
            var productOrder = await Repository.Include(x => x.OrderItems).FirstOrDefaultAsync(x => x.Id == input.OrderId);

            if (productOrder == null)
            {
                throw new UserFriendlyException("NotFind");
            }

            var appName = _httpContextAccessor?.GetAppName();
            var app     = await _appProvider.GetOrNullAsync(appName);

            var appid = app["appid"] ?? throw new AbpException($"App:{appName} appid未设置");

            var mchId = await _setting.GetOrNullAsync(MallManagementSetting.PayMchId);

            var mchKey = await _setting.GetOrNullAsync(MallManagementSetting.PayKey);

            var notifyUrl = await _setting.GetOrNullAsync(MallManagementSetting.PayNotify);


            var payorder = new PayOrder();

            payorder.CreatWxPayFromProductOrder(id: GuidGenerator.Create(),
                                                productOrder: productOrder,
                                                mchId: mchId,
                                                openid: input.openid,
                                                appName: appName,
                                                shareFromUserId: null,
                                                partnerId: null
                                                );

            var insertPayOrder = await _payOrderRepository.InsertAsync(payorder, autoSave : true);

            productOrder.SetBillNo(insertPayOrder.Id, insertPayOrder.BillNo);

            var unifiedResult = await _payApi.UnifiedOrderAsync(
                appid,
                mchId,
                mchKey,
                body : productOrder.OrderItems.First().SpuName,
                outTradeNo : insertPayOrder.BillNo,
                totalFee : Convert.ToInt32(productOrder.PriceOriginal * 100),
                notifyUrl : notifyUrl.EnsureEndsWith('/') + appName,
                tradeType : Consts.TradeType.JsApi,
                openId : input.openid,
                billCreateIp : _httpContext.HttpContext.Connection.RemoteIpAddress.ToString()
                );

            _rabbit.PushDelyMessage(new PayOrderLisenerData {
                Type = "PayOrder", Data = insertPayOrder
            }, MallConsts.PayAutoCancelTime, "SoMall_DelayQueue");                                                                                          // 半小时内未支付删除

            return(unifiedResult);
        }
        protected async Task TencentCloudSmsMessageAsync(TencentCloudSmsMessage smsMessage)
        {
            /* 实例化一个请求对象,根据调用的接口和实际情况,可以进一步设置请求参数
             * 你可以直接查询SDK源码确定SendSmsRequest有哪些属性可以设置
             * 属性可能是基本类型,也可能引用了另一个数据结构
             * 推荐使用IDE进行开发,可以方便的跳转查阅各个接口和数据结构的文档说明 */
            SendSmsRequest req = new SendSmsRequest();

            req.SmsSdkAppid = await SettingProvider.GetOrNullAsync(TencentCloudSmsSettingNames.AppId);

            /* 短信签名内容: 使用 UTF-8 编码,必须填写已审核通过的签名,签名信息可登录 [短信控制台] 查看 */
            req.Sign = string.IsNullOrEmpty(smsMessage.Sign)? await SettingProvider.GetOrNullAsync(TencentCloudSmsSettingNames.Sign) : smsMessage.Sign;

            /* 短信码号扩展号: 默认未开通,如需开通请联系 [sms helper] */
            //req.ExtendCode = "x";
            /* 国际/港澳台短信 senderid: 国内短信填空,默认未开通,如需开通请联系 [sms helper] */
            //req.SenderId = "";
            /* 用户的 session 内容: 可以携带用户侧 ID 等上下文信息,server 会原样返回 */
            //req.SessionContext = "";

            /* 下发手机号码,采用 e.164 标准,+[国家或地区码][手机号]
             * 示例如:+8613711112222, 其中前面有一个+号 ,86为国家码,13711112222为手机号,最多不要超过200个手机号*/
            req.PhoneNumberSet = new String[] { smsMessage.PhoneNumber };
            /* 模板 ID: 必须填写已审核通过的模板 ID。模板ID可登录 [短信控制台] 查看 */
            req.TemplateID = smsMessage.TemplateID;
            /* 模板参数: 若无模板参数,则设置为空*/
            req.TemplateParamSet = smsMessage.TemplateParamSet.Split(";");

            Credential cred = new Credential
            {
                SecretId  = await SettingProvider.GetOrNullAsync(TencentCloudSmsSettingNames.SecretId),
                SecretKey = await SettingProvider.GetOrNullAsync(TencentCloudSmsSettingNames.SecretKey)
            };
            ClientProfile clientProfile = new ClientProfile();
            HttpProfile   httpProfile   = new HttpProfile();

            httpProfile.Timeout       = 60;
            httpProfile.Endpoint      = "sms.tencentcloudapi.com";
            clientProfile.HttpProfile = httpProfile;
            var region = await SettingProvider.GetOrNullAsync(TencentCloudSmsSettingNames.Region);

            if (string.IsNullOrWhiteSpace(region))
            {
                region = "ap-guangzhou";
            }
            SmsClient client = new SmsClient(cred, region, clientProfile);
            //return client;

            SendSmsResponse resp = await client.SendSms(req);

            //TODO:记录服务器发送信息

            // 输出json格式的字符串回包
            //Console.WriteLine(AbstractModel.ToJsonString(resp));
        }
Beispiel #12
0
        private async Task <UpYun> GetUploader()
        {
            var bucketName = await _setting.GetOrNullAsync(OssManagementSettings.BucketName);

            var domain = await _setting.GetOrNullAsync(OssManagementSettings.DomainHost);

            var pwd = await _setting.GetOrNullAsync(OssManagementSettings.AccessKey);

            var username = await _setting.GetOrNullAsync(OssManagementSettings.AccessId);

            return(new UpYun(bucketName, username,
                             pwd, domain));
        }
            public virtual async Task Handle(RefundAgreeEvent request, CancellationToken cancellationToken)
            {
                var refundLog = await _refundLogRepository.FirstOrDefaultAsync(x => x.Id == request.RefundLogId, cancellationToken : cancellationToken);

                Check.NotNull(refundLog, nameof(refundLog));

                var payOrder = await _payOrderRepository.FirstOrDefaultAsync(x => x.BillNo == refundLog.BillNo, cancellationToken : cancellationToken);

                Check.NotNull(payOrder, nameof(payOrder));

                var app = await _appProvider.GetOrNullAsync(payOrder.AppName);

                var appid = app["appid"] ?? throw new AbpException($"App:{payOrder.AppName} appid未设置");

                var mchId = await _settingProvider.GetOrNullAsync(MallManagementSetting.PayMchId);

                var mchKey = await _settingProvider.GetOrNullAsync(MallManagementSetting.PayKey);


                var result = await _payApi.RefundAsync(
                    appid,
                    mchId,
                    mchKey : mchKey,
                    "",
                    "",
                    transactionId : null,
                    outTradeNo : payOrder.BillNo,
                    outRefundNo : refundLog.Id.ToShortString(),
                    totalFee : payOrder.TotalPrice,
                    refundFee : refundLog.Price,
                    refundDesc : refundLog.Reason,
                    refundAccount : "REFUND_SOURCE_RECHARGE_FUNDS"
                    );

                if (result)
                {
                    refundLog.RefundComplate();
                    payOrder.RefundComplate(refundLog.Price);

                    var productOrder = await _productOrderRepository.Where(x => x.BillNo == refundLog.BillNo).ToListAsync();

                    foreach (var p in productOrder)
                    {
                        p.RefundComplate();
                    }
                }

                Log.Warning(request.ToString());

                await Task.CompletedTask;
            }
Beispiel #14
0
        public async Task <object> GetSignature(string data)
        {
            var password = await _setting.GetOrNullAsync(OssManagementSettings.AccessKey);

            if (password.IsNullOrEmptyOrWhiteSpace())
            {
                throw new UserFriendlyException("Oss AccessKey is Empty");
            }

            var hmac      = new HMACSHA1(Encoding.UTF8.GetBytes(password.GetMd5()));
            var hashBytes = hmac.ComputeHash(Encoding.UTF8.GetBytes(data));

            return(await Task.FromResult(new { signature = Convert.ToBase64String(hashBytes) }));
        }
 public InvoiceInputViewModel(IInvoiceAppService appService,
                              IPatientAppService patientApp, ICategoryAppService categoryApp,
                              IEventAggregator eventAggregator, ISettingProvider setting, IExchangeRateAppService exchangeRateApp, IServiceProvider serviceProvider)
 {
     SettingProvider          = setting;
     EventAggregator          = eventAggregator;
     _serviceProvider         = serviceProvider;
     PatientService           = patientApp;
     AppService               = appService;
     rateAppService           = exchangeRateApp;
     CategoryService          = categoryApp;
     CreateCommand            = new DelegateCommand <ICloseable>(Create);
     AddPatientCommand        = new DelegateCommand(CreatePatient);
     DeleteInvoiceLineCommand = new DelegateCommand(OnInvoiceLineDeleted);
     SelectedCommand          = new DelegateCommand <object[]>(OnItemSelected);
     AddExamCommand           = new DelegateCommand <ExamDto>(AddExam);
     Patients = new ObservableCollection <PatientDto>();
     Patients.AddRange(PatientService.GetListAsync().Result);
     Currency          = SettingProvider.GetOrNullAsync(FacCigoSettings.InvoiceCurrency).Result;
     Model             = new InvoiceModel();
     Model.ReferenceNo = AppService.NextReferenceNo(Model.InvoiceDate.Year).Result;
     Categories        = new ObservableCollection <CategoryDto>();
     Categories.AddRange(CategoryService.GetListAsync().Result);
     EventAggregator.GetEvent <PatientAddedEvent>().Subscribe(PatientAdded);
     ExchangeRate = rateAppService.CurrentExchangeRate().Result;
 }
Beispiel #16
0
        private async Task <Tuple <string, string> > GetPath()
        {
            var curDirectory = Directory.GetCurrentDirectory();
            var root         = "wwwroot";
            var baseUrl      = await _settingProvider.GetOrNullAsync("App.UploadFiles.BaseUrl");

            var time    = DateTime.Now;
            var year    = time.Year.ToString();
            var month   = time.Month.ToString();
            var day     = time.Day.ToString();
            var discUrl = Path.Combine(curDirectory, root, baseUrl, year, month, day);
            var webUrl  = "/" + baseUrl + "/" + year + "/" + month + "/" + day;

            Directory.CreateDirectory(discUrl);
            return(new Tuple <string, string>(discUrl, webUrl));
        }
        public async Task HandleEventAsync(EntityCreatedEventData <UserEto> eventData)
        {
            // 获取默认语言
            var userDefaultCultureName = await _settingProvider.GetOrNullAsync(LocalizationSettingNames.DefaultLanguage);

            if (userDefaultCultureName.IsNullOrWhiteSpace())
            {
                userDefaultCultureName = CultureInfo.CurrentUICulture.Name;
                // CultureInfo.CurrentCulture = CultureInfo.GetCultureInfo(userDefaultCultureName);
            }
            using (CultureHelper.Use(userDefaultCultureName, userDefaultCultureName))
            {
                // 订阅用户欢迎消息
                await _notificationStore.InsertUserSubscriptionAsync(eventData.Entity.TenantId,
                                                                     eventData.Entity.Id, UserNotificationNames.WelcomeToApplication);

                var userWelcomeNotifiction = new NotificationInfo
                {
                    CreationTime         = DateTime.Now,
                    Name                 = UserNotificationNames.WelcomeToApplication,
                    NotificationSeverity = NotificationSeverity.Info,
                    NotificationType     = NotificationType.System,
                    TenantId             = eventData.Entity.TenantId
                };
                userWelcomeNotifiction.Data.Properties["message"] = L("WelcomeToApplicationFormUser", eventData.Entity.UserName);

                await _notificationDispatcher.DispatcheAsync(userWelcomeNotifiction);
            }
        }
Beispiel #18
0
        public async Task HandleEventAsync(EntityCreatedEventData <UserEto> eventData)
        {
            // 获取默认语言
            var userDefaultCultureName = await _settingProvider.GetOrNullAsync(LocalizationSettingNames.DefaultLanguage);

            if (userDefaultCultureName.IsNullOrWhiteSpace())
            {
                userDefaultCultureName = CultureInfo.CurrentUICulture.Name;
                // CultureInfo.CurrentCulture = CultureInfo.GetCultureInfo(userDefaultCultureName);
            }
            using (CultureHelper.Use(userDefaultCultureName, userDefaultCultureName))
            {
                var userIdentifer = new UserIdentifier(eventData.Entity.Id, eventData.Entity.UserName);
                // 订阅用户欢迎消息
                await _notificationSubscriptionManager.SubscribeAsync(eventData.Entity.TenantId,
                                                                      userIdentifer, UserNotificationNames.WelcomeToApplication);

                // Store未检查已订阅
                //await _notificationStore.InsertUserSubscriptionAsync(eventData.Entity.TenantId,
                //    userIdentifer, UserNotificationNames.WelcomeToApplication);

                var userWelcomeNotifictionData = NotificationData.CreateUserNotificationData(eventData.Entity.Id, eventData.Entity.UserName);

                userWelcomeNotifictionData.WriteStandardData(
                    L("WelcomeToApplicationFormUser", eventData.Entity.Name ?? eventData.Entity.UserName),
                    L("WelcomeToApplicationFormUser", eventData.Entity.Name ?? eventData.Entity.UserName),
                    DateTime.Now, eventData.Entity.UserName);

                // 换成用户名称,而不是用户名
                // userWelcomeNotifictionData.Properties["message"] = L("WelcomeToApplicationFormUser", eventData.Entity.Name);

                var noticeNormalizerName = NotificationNameNormalizer.NormalizerName(UserNotificationNames.WelcomeToApplication);
                await _notificationDispatcher.DispatchAsync(noticeNormalizerName, userWelcomeNotifictionData, eventData.Entity.TenantId);
            }
        }
Beispiel #19
0
        //Task<Invoice>
        public async Task <Invoice> CreateAsync(Invoice invoice)
        {
            string invoiceCurrency = await SettingProvider.GetOrNullAsync(FacCigoSettings.InvoiceCurrency);

            if (invoiceCurrency == null)
            {
                throw new InvoiceCurrencyNotSettledException(invoiceCurrency);
            }
            Currency currency = await CurrencyRepository.GetAsync(invoiceCurrency);

            if (currency == null)
            {
                throw new InvoiceCurrencyNotSettledException(invoiceCurrency);
            }
            invoice.ChangeCurrency(currency.Id);
            ExchangeRate exchange = await ExchangeRateRepository.FirstOrDefaultAsync(c => c.CurrencyId == currency.Id && c.IsActive);

            if (exchange == null)
            {
                throw new ExchangeRateNotExisting();
            }
            invoice.ChangeExchange(exchange.Id);
            foreach (InvoiceLine line in invoice.InvoiceLines)
            {
                Exam exam = await ExamRepository.GetAsync(line.ExamId);

                if (exam == null)
                {
                    throw new ExamNotExisting(line.ExamId);
                }
                line.ChangeAmount(exam.Price);
                line.ChangeCurrency(exam.CurrencyId);
            }
            return(await Repository.InsertAsync(invoice, autoSave : true));
        }
        public async Task <object> PayAsync(OrderPayRequestDto input)
        {
            var productOrder = await Repository.Include(x => x.OrderItems).FirstOrDefaultAsync(x => x.Id == input.OrderId);

            var appName = _httpContextAccessor?.HttpContext.Request.Headers["AppName"].FirstOrDefault();
            var app     = await _appProvider.GetOrNullAsync(appName);

            var appid = app["appid"] ?? throw new AbpException($"App:{appName} appid未设置");

            var mchId = await _setting.GetOrNullAsync(MallManagementSetting.PayMchId);

            var mchKey = await _setting.GetOrNullAsync(MallManagementSetting.PayKey);

            var notifyUrl = await _setting.GetOrNullAsync(MallManagementSetting.PayNotify);


            var payorder = new PayOrder();

            payorder.CreatWxPayFromProductOrder(id: GuidGenerator.Create(),
                                                productOrder: productOrder,
                                                mchId: mchId,
                                                openid: input.openid,
                                                appName: appName,
                                                shareFromUserId: null,
                                                partnerId: null
                                                );

            var insertAsync = await _payOrderRepository.InsertAsync(payorder, autoSave : true);

            productOrder.SetBillNo(insertAsync.Id, insertAsync.BillNo);

            var result = await _payApi.UnifiedOrderAsync(
                appid,
                mchId,
                mchKey,
                body : productOrder.OrderItems.First().SpuName,
                outTradeNo : insertAsync.BillNo,
                totalFee : Convert.ToInt32(productOrder.PriceOriginal * 100),
                notifyUrl : notifyUrl,
                tradeType : Consts.TradeType.JsApi,
                openId : input.openid,
                billCreateIp : _httpContext.HttpContext.Connection.RemoteIpAddress.ToString()
                );


            return(result);
        }
Beispiel #21
0
        public virtual async Task SendAsync(SmsMessage smsMessage)
        {
            var request = new SendSmsRequest(
                new[] { smsMessage.PhoneNumber },
                GetStringProperty(smsMessage, AbpSmsTencentCloudConsts.TemplateIdPropertyName),
                GetStringProperty(smsMessage, AbpSmsTencentCloudConsts.SmsSdkAppidPropertyName,
                                  await _settingProvider.GetOrNullAsync(AbpSmsTencentCloudSettings.DefaultSmsSdkAppid)),
                GetStringProperty(smsMessage, AbpSmsTencentCloudConsts.SignPropertyName,
                                  await _settingProvider.GetOrNullAsync(AbpSmsTencentCloudSettings.DefaultSign)),
                GetTemplateParamSet(smsMessage),
                GetStringProperty(smsMessage, AbpSmsTencentCloudConsts.ExtendCodePropertyName,
                                  await _settingProvider.GetOrNullAsync(AbpSmsTencentCloudSettings.DefaultExtendCode)),
                GetStringProperty(smsMessage, AbpSmsTencentCloudConsts.SessionContextPropertyName),
                GetStringProperty(smsMessage, AbpSmsTencentCloudConsts.SenderIdPropertyName,
                                  await _settingProvider.GetOrNullAsync(AbpSmsTencentCloudSettings.DefaultSenderId))
                );

            var commonOptions = new AbpTencentCloudCommonOptions
            {
                SecretId  = await _settingProvider.GetOrNullAsync(AbpSmsTencentCloudSettings.DefaultSecretId),
                SecretKey = await _settingProvider.GetOrNullAsync(AbpSmsTencentCloudSettings.DefaultSecretKey)
            };

            await _requester.SendRequestAsync <SendSmsResponse>(request,
                                                                await _settingProvider.GetOrNullAsync(AbpSmsTencentCloudSettings.EndPoint), commonOptions);
        }
Beispiel #22
0
        public async Task <string> Next()
        {
            if (long.TryParse(await _settingProvider.GetOrNullAsync(HDShopSettings.OrderCodeMachine), out long _OrderCodeMachine))
            {
                workerId = _OrderCodeMachine;
            }
            if (int.TryParse(await _settingProvider.GetOrNullAsync(HDShopSettings.OrderCodeMachineBit), out int _OrderCodeMachineBit))
            {
                workerIdBits = _OrderCodeMachineBit;
            }
            if (int.TryParse(await _settingProvider.GetOrNullAsync(HDShopSettings.OrderCodeSequenceBit), out int _OrderCodeSequenceBit))
            {
                sequenceBits = _OrderCodeSequenceBit;
            }

            if (workerId > maxWorkerId || workerId < 0)
            {
                throw new Exception(string.Format("worker Id can't be greater than {0} or less than 0 ", workerId));
            }
            lock (this)
            {
                long timestamp = timeGen();
                if (this.lastTimestamp == timestamp)
                {                                                                                       //同一微妙中生成ID
                    CodeGenerator.sequence = (CodeGenerator.sequence + 1) & CodeGenerator.sequenceMask; //用&运算计算该微秒内产生的计数是否已经到达上限
                    if (CodeGenerator.sequence == 0)
                    {
                        //一微妙内产生的ID计数已达上限,等待下一微妙
                        timestamp = tillNextMillis(this.lastTimestamp);
                    }
                }
                else
                {                               //不同微秒生成ID
                    CodeGenerator.sequence = 0; //计数清0
                }
                if (timestamp < lastTimestamp)
                { //如果当前时间戳比上一次生成ID时时间戳还小,抛出异常,因为不能保证现在生成的ID之前没有生成过
                    throw new Exception(string.Format("Clock moved backwards.  Refusing to generate id for {0} milliseconds",
                                                      this.lastTimestamp - timestamp));
                }
                this.lastTimestamp = timestamp; //把当前时间戳保存为最后生成ID的时间戳
                long nextId = (timestamp - twepoch << timestampLeftShift) | CodeGenerator.workerId << CodeGenerator.workerIdShift | CodeGenerator.sequence;
                return(nextId.ToString());
            }
        }
Beispiel #23
0
        protected virtual async Task <Currency> GetEffectiveCurrencyAsync()
        {
            var currencyCode = Check.NotNullOrWhiteSpace(
                await _settingProvider.GetOrNullAsync(OrdersSettings.CurrencyCode),
                nameof(OrdersSettings.CurrencyCode)
                );

            return(Currency.FromCode(currencyCode));
        }
Beispiel #24
0
        public async Task <object> GetSignature(string data)
        {
            var password = await _setting.GetOrNullAsync(OssManagementSettings.AccessKey);

            var hmac      = new HMACSHA1(Encoding.UTF8.GetBytes(password.GetMd5()));
            var hashBytes = hmac.ComputeHash(Encoding.UTF8.GetBytes(data));

            return(await Task.FromResult(new { signature = Convert.ToBase64String(hashBytes) }));
        }
Beispiel #25
0
        public async Task <object> GetConfig()
        {
            var UploadHost = await _setting.GetOrNullAsync(OssManagementSettings.UploadHost);

            var BucketName = await _setting.GetOrNullAsync(OssManagementSettings.BucketName);

            var DomainHost = await _setting.GetOrNullAsync(OssManagementSettings.DomainHost);

            var AccessId = await _setting.GetOrNullAsync(OssManagementSettings.AccessId);

            return(new
            {
                UploadHost, BucketName, DomainHost, AccessId
            });
        }
Beispiel #26
0
        public static async Task <T> GetAsync <T>([NotNull] this ISettingProvider settingProvider, [NotNull] string name, T defaultValue = default)
            where T : struct
        {
            Check.NotNull(settingProvider, nameof(settingProvider));
            Check.NotNull(name, nameof(name));

            var value = await settingProvider.GetOrNullAsync(name);

            return(value?.To <T>() ?? defaultValue);
        }
Beispiel #27
0
        private async Task <ApplicationSettingConfigurationDto> GetSettingConfigAsync()
        {
            var result = new ApplicationSettingConfigurationDto
            {
                Values = new Dictionary <string, string>()
            };

            foreach (var settingDefinition in _settingDefinitionManager.GetAll())
            {
                if (!settingDefinition.IsVisibleToClients)
                {
                    continue;
                }

                result.Values[settingDefinition.Name] = await _settingProvider.GetOrNullAsync(settingDefinition.Name);
            }

            return(result);
        }
Beispiel #28
0
        public static async Task <bool> IsTrueAsync([NotNull] this ISettingProvider settingProvider, [NotNull] string name)
        {
            Check.NotNull(settingProvider, nameof(settingProvider));
            Check.NotNull(name, nameof(name));

            return(string.Equals(
                       await settingProvider.GetOrNullAsync(name),
                       "true",
                       StringComparison.OrdinalIgnoreCase
                       ));
        }
Beispiel #29
0
        public static async Task <List <DataDictionary> > GetDataDictionariesAsync([NotNull] this ISettingProvider settingProvider, [NotNull] string name)
        {
            Check.NotNull(settingProvider, nameof(settingProvider));
            Check.NotNull(name, nameof(name));

            var dataDictionaries = JsonSerializer.Deserialize <List <DataDictionary> >(
                await settingProvider.GetOrNullAsync(name)
                );

            return(dataDictionaries);
        }
    public virtual async Task SeedStoresAsync()
    {
        var storeName = await _settingProvider.GetOrNullAsync(StoresSettings.DefaultStoreName);

        if (await _storeRepository.AnyAsync(x => x.Name == storeName))
        {
            return;
        }

        await _storeRepository.InsertAsync(new Store(_guidGenerator.Create(), _currentTenant.Id, storeName), true);
    }