public UserController(IUserLogic UserLogic, AppConfigurtaionServices AppConfigurtaionServices, ILogger Logger, IHttpContextAccessor accessor, IRedisClient redisClient) : base(redisClient) { _UserLogic = UserLogic; this._AppConfigurtaionServices = AppConfigurtaionServices; this._Logger = Logger; this._accessor = accessor; }
public static RabbitMq CreateConfigDomInstance(string key) { var appconfig = new AppConfigurtaionServices(); var mqConfig = appconfig.GetAppSettings <RabbitMq>(key); return(mqConfig); }
/// <summary> /// SetSession /// </summary> /// <param name="context"></param> /// <param name="key"></param> /// <param name="value"></param> public static void SetSession(HttpContext context, string key, byte[] value) { key = AppConfigurtaionServices.GetAppSettingsString("SystemPreFix") + key; context.Session.Remove(key); context.Session.Set(key, value); }
public ActionResult GetConfig() { //读取Appsettings节点配置 var config = AppConfigurtaionServices.GetSectionObject <Appsettings>("Appsettings"); return(new JsonResult(config)); //返回:{"systemName":"PDF .NET CORE","date":"2017-07-23T00:00:00","author":"PDF"} }
public ActionResult GetAllConfig() { //读取整个配置文件的配置 var config = AppConfigurtaionServices.GetSectionObject <AppsettingConfig>(); return(new JsonResult(config)); //返回:{"connectionStrings":{"cxyOrder":"Server=LAPTOP-AQUL6MDE\\MSSQLSERVERS;Database=CxyOrder;User ID=sa;Password=123456;Trusted_Connection=False;"},"appsettings":{"systemName":"PDF .NET CORE","date":"2017-07-23T00:00:00","author":"PDF"},"serviceUrl":"https://www.baidu.com/getnews"} }
protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder) { if (!optionsBuilder.IsConfigured) { var config = AppConfigurtaionServices.GetAppSettings <AppConfigurtaionModel>("ConnectionStrings", $"appsettings.json").TestDataBaseContext; optionsBuilder.UseSqlServer(config); } }
public UserController(IHttpClientFactory clientFactory, IUserLogic UserLogic, AppConfigurtaionServices AppConfigurtaionServices, ILogger Logger, IHttpContextAccessor accessor, IRedisClient redisClient, SampleInterface sampleInterface) : base(redisClient) { this._clientFactory = clientFactory; _UserLogic = UserLogic; this._AppConfigurtaionServices = AppConfigurtaionServices; this._Logger = Logger; this._accessor = accessor; this.sampleInterface = sampleInterface; }
/// <summary> /// /// </summary> /// <returns></returns> protected static string GetConnectionStringFromConfig() { string Result = AppConfigurtaionServices.GetConnectionString("conn"); if (Result == null) { Result = ""; } return(Result); }
public DbContextOptions <IdentityServerConfigurationDbContext> GetDbContextOption() { var builder = new DbContextOptionsBuilder <IdentityServerConfigurationDbContext>(); //var configuration = AppConfigurations.Get(WebContentDirectoryFinder.CalculateContentRootFolder()); //MyDocumentManageDbContextConfigurer.Configure(builder, configuration.GetConnectionString("mydb")); IdentityServerDbContextConfigurer.Configure(builder, AppConfigurtaionServices.GetAppSettings()["ConnectionStrings:mydb"]); return(builder.Options); }
public RedisClient(AppConfigurtaionServices AppConfigurtaionServices) { this._AppConfigurtaionServices = AppConfigurtaionServices; if (string.IsNullOrEmpty(_redisConnectionString)) { _redisConnectionString = string.Concat(_AppConfigurtaionServices.GetAppSettings <AppSettings>("AppSettings").CacheIP, ",password="******"AppSettings").CachePassWord, ",allowAdmin=true"); } if (string.IsNullOrEmpty(_redisCustomKey)) { _redisCustomKey = _AppConfigurtaionServices.GetAppSettings <AppSettings>("AppSettings").RedisCustomKey; } }
/// <summary> /// /// </summary> /// <param name="key"></param> /// <returns></returns> public static object GetCache(string key) { key = AppConfigurtaionServices.GetAppSettingsString("SystemPreFix") + key; var exists = _cache.TryGetValue(key, out object value); if (!exists) { return(null); } return(value); }
private static bool Read_IsCloseMethod_Shove_FilteSqlInfusion() { bool result = false; string str = AppConfigurtaionServices.GetAppSettingsString("IsCloseMethod_Shove_FilteSqlInfusion"); if (string.IsNullOrEmpty(str)) { str = "false"; } Boolean.TryParse(str, out result); return(result); }
public RedisClient(AppConfigurtaionServices AppConfigurtaionServices, IConfiguration configuration) { this._AppConfigurtaionServices = AppConfigurtaionServices; this.configuration = configuration; if (string.IsNullOrEmpty(_redisConnectionString)) { _redisConnectionString = string.Concat(configuration.GetValue <string>("AppSettings:CacheIP"), ",password="******"AppSettings:CachePassWord"), ",allowAdmin=true"); } if (string.IsNullOrEmpty(_redisCustomKey)) { //_redisCustomKey = _AppConfigurtaionServices.GetAppSettings<AppSettings>("AppSettings").RedisCustomKey; _redisCustomKey = configuration.GetValue <string>("AppSettings:RedisCustomKey"); } }
/// <summary> /// 工信部实时域名备案状态查询(通过英迈思的备案系统接口) /// </summary> /// <param name="domainName"></param> /// <returns></returns> public static string IcpBeianQueryRealTime(string domainName) { var binding = new BasicHttpBinding(); binding.MaxReceivedMessageSize = 2147483647; var endpoint = new EndpointAddress(AppConfigurtaionServices.GetAppSettingsString("Icp_GatewayServiceUrl")); var service = new GatewaySoapClient(binding, endpoint); var v = service.IcpBeianQueryRealTimeAsync("eimslab", domainName); v.Wait(); return(v.Result.Body.IcpBeianQueryRealTimeResult); }
/// <summary> /// 发送短信。如果 App.Config 或者 Web.Config 的 AppSetting 中没有 Key="I3kmSMS_GatewayServiceUrl" value="" 的设置,将使用默认的网关地址。 /// </summary> /// <param name="regCode"></param> /// <param name="regKey"></param> /// <param name="content"></param> /// <param name="to"></param> /// <param name="sendTime">指定的发送时间,可以实现按指定的发送时间再进行发送的功能</param> /// <returns></returns> public static ArrayOfXElement SendSMS(string regCode, string regKey, string content, string to, DateTime sendTime) { var binding = new BasicHttpBinding(); binding.MaxReceivedMessageSize = 2147483647; var endpoint = new EndpointAddress(AppConfigurtaionServices.GetAppSettingsString("I3kmSMS_GatewayServiceUrl")); var service = new sms_gatewaySoapClient(binding, endpoint); DateTime timeStamp = DateTime.Now; string sign = Shove.Security.Encrypt.MD5(regCode + timeStamp.ToString() + content + to + sendTime.ToString("yyyyMMdd HHmmss") + regKey); var v = service.SendSMS_2Async(regCode, timeStamp.ToString(), sign, content, to, sendTime); v.Wait(); return(v.Result); }
/// <summary> /// 查询短信账户余额。如果 App.Config 或者 Web.Config 的 AppSetting 中没有 Key="I3kmSMS_GatewayServiceUrl" value="" 的设置,将使用默认的网关地址。 /// </summary> /// <param name="regCode"></param> /// <param name="regKey"></param> /// <returns></returns> public static ArrayOfXElement GetBalance(string regCode, string regKey) { var binding = new BasicHttpBinding(); binding.MaxReceivedMessageSize = 2147483647; var endpoint = new EndpointAddress(AppConfigurtaionServices.GetAppSettingsString("I3kmSMS_GatewayServiceUrl")); var service = new sms_gatewaySoapClient(binding, endpoint); DateTime TimeStamp = DateTime.Now; string sign = Shove.Security.Encrypt.MD5(regCode + TimeStamp.ToString() + regKey); var v = service.QueryBalanceAsync(regCode, TimeStamp.ToString(), sign); v.Wait(); return(v.Result); }
/// <summary> /// /// </summary> /// <param name="key"></param> /// <param name="value"></param> /// <param name="cacheSeconds"></param> public static void SetCache(string key, object value, int cacheSeconds) { key = AppConfigurtaionServices.GetAppSettingsString("SystemPreFix") + key; RemoveCache(key); if (cacheSeconds <= 0) { return; } var entry = _cache.CreateEntry(key); entry.Value = value; entry.SetAbsoluteExpiration(DateTime.Now.AddSeconds(cacheSeconds)); }
/// <summary> /// 获取连接数据库字符串 /// </summary> /// <param name="dbName"></param> /// <returns></returns> private string GetKernelConnectionStringWithDbName(string dbName) { string result = ""; var kOption = new DbOption { DbType = AppConfigurtaionServices.GetConfig(string.Format("DbOption:{0}:DbType", "Kernel")), ConnectionString = AppConfigurtaionServices.GetConfig(string.Format("DbOption:{0}:ConnectionString", "Kernel")) }; if (!string.IsNullOrEmpty(kOption.ConnectionString)) { var dbKernel = ConnectionFactory.CreateConnection(kOption.DbType, kOption.ConnectionString); DynamicParameters dyParameter = new DynamicParameters(); dyParameter.Add("Name", dbName, DbType.String); var dbInfo = dbKernel.QueryFirst <Model.KernelDbInfoModel>("select * from v_DbInfo where Name=@Name", param: dyParameter); if (dbInfo == null) { throw new Exception(string.Format("The database ({0}) connection configuration is not defined.", dbName)); } result = string.Format(result, new object[] { dbInfo.ServerName, dbInfo.RealName, dbInfo.DbUserName, dbInfo.PassWord }); } return(result); }
/// <summary> /// 自定义一些注入规则 /// </summary> /// <param name="container"></param> private static AppSettings InitCustomIoc(ContainerBuilder container) { //appsettings var appsettingsJson = File.ReadAllText("appsettings.json"); var appSettings = JsonConvert.DeserializeObject <AppSettings>(appsettingsJson); var appConfigurtaionServices = new AppConfigurtaionServices(null) { AppSettings = appSettings }; container.RegisterInstance(appConfigurtaionServices).As <IAppConfigurtaionServices>(); //RedisConfig var configuration = ConfigurationOptions.Parse(appSettings.RedisConfig.ServerList, true); configuration.ResolveDns = true; var redis = ConnectionMultiplexer.Connect(configuration); container.RegisterInstance(redis).As <ConnectionMultiplexer>(); container.RegisterType <RedisProvider>().As <ICacheProvider>(); //IHttpClient container.RegisterType <HttpContextAccessor>().As <IHttpContextAccessor>().SingleInstance(); container.RegisterType <StandardHttpClient>().As <IHttpClient>().SingleInstance(); return(appSettings); }
/// <summary> /// GetSession /// </summary> /// <param name="context"></param> /// <param name="key"></param> /// <returns></returns> public static byte[] GetSession(HttpContext context, string key) { key = AppConfigurtaionServices.GetAppSettingsString("SystemPreFix") + key; if (context.Session.TryGetValue(key, out byte[] r))
/// <summary> /// /// </summary> /// <param name="key"></param> public static void RemoveCache(string key) { key = AppConfigurtaionServices.GetAppSettingsString("SystemPreFix") + key; _cache.Remove(key); }
public HomeController(IUserAppService userAppService, IConfiguration configuration, AppConfigurtaionServices appConfigurtaionServices) { _userAppService = userAppService; _configuration = configuration; _appConfigurtaionServices = appConfigurtaionServices; }
/// <summary> /// /// </summary> /// <param name="key"></param> /// <param name="value"></param> public static void SetCache(string key, object value) { int CacheSeconds = AppConfigurtaionServices.GetAppSettingsInt("CacheSeconds", 0); SetCache(key, value, CacheSeconds); }
public Logger(AppConfigurtaionServices AppConfigurtaionServices, IConfiguration configuration) { this._AppConfigurtaionServices = AppConfigurtaionServices; this.configuration = configuration; }
public Startup(IConfiguration configuration, IHostingEnvironment env) { Configuration = configuration; AppConfigurtaionServices.SetConfiguration(Configuration); }
public Logger(AppConfigurtaionServices AppConfigurtaionServices) { this._AppConfigurtaionServices = AppConfigurtaionServices; }