/// <summary> /// /// </summary> public override void Config() { base.Config(); var config = ConfigurationManage.GetConfiguration(Id).DeserializeJson <Configuration>(); _config = config; }
public RabbitMqManage() { var config = ConfigurationManage.GetConfiguration($"configuration:{Id}"); Configuration cg = null; if (config == null) { IList <ConfigurationModel> configurations = new List <ConfigurationModel>(); var configuration = new ConfigurationModel { Runtime = Environment.GetEnvironmentVariable("Runtime"), Description = "rabbitmq", Content = new Configuration { ConnectString = "amqp://192.168.137.2:5672/", User = "******", Password = "******" }.SerializeJson(), }; configurations.Add(configuration); ConfigurationManage.SetConfiguration($"configuration:{Id}", configurations); cg = configuration.Content.DeserializeJson <Configuration>(); } else { cg = config.DeserializeJson <Configuration>(); } var rabbitMqHelper = new RabbitMqHelper(cg.ConnectString, cg.User, cg.Password, cg.Vhost); SingletonUtility.AddSingleton(rabbitMqHelper); }
/// <summary> /// 创建运行SQL信息 /// </summary> /// <param name="sqlQuery"></param> /// <param name="timeElapsed">消耗时间</param> /// <param name="isSuccess">是否成功</param> /// <param name="dbType">数据库类型</param> /// <param name="dataBaseName">数据库名字</param> /// <returns></returns> private static RuntimeSqlModel Create(SqlQuery sqlQuery, double timeElapsed, bool isSuccess, string dbType = null, string dataBaseName = null) { var runtimeSqlModel = new RuntimeSqlModel { FExecutedTime = DateTimeUtil.Now, FIsSuccess = isSuccess, FProjectName = ConfigurationManage.GetValue($"MQMonitor:ProjectInfo:ProjectName"), FRequestGuid = AsyncLocalUtil.CurrentGID, FServerMac = ComputerUtil.MacAddress, FSource = ConfigurationManage.GetValue <int>($"MQMonitor:ProjectInfo:FSource"), FSqlDbType = dbType, FSqlText = sqlQuery.CommandText, FTimeElapsed = timeElapsed, FMemberName = WebHttpContext.AbsoluteUrl, FDatabaseName = dataBaseName }; if (sqlQuery.ParameterList != null && sqlQuery.ParameterList.Any()) { runtimeSqlModel.ParameterList = new List <SqlParameterModel>(); foreach (var item in sqlQuery.ParameterList) { runtimeSqlModel.ParameterList.Add(new SqlParameterModel { FName = item.ParameterName, FSize = item.Size, FValue = item.Value?.ToString() }); } } return(runtimeSqlModel); }
public CacheManage() { var config = ConfigurationManage.GetConfiguration($"configuration:{Id}"); RedisHelper redis = new RedisHelper(config); SingletonUtility.AddSingleton(redis); }
/// <summary> /// 根据配置名字获取连接信息 /// </summary> /// <param name="connectionSettingName">配置名字</param> /// <returns>连接信息</returns> private static DatabaseConnection GetDbConnection(string connectionSettingName) { DatabaseConnection dbConnection = new DatabaseConnection(); dbConnection.ConnectionString = ConfigurationManage.GetValue($"ConnectionStrings:{connectionSettingName}:ConnectionString"); dbConnection.DatabaseType = ConfigurationManage.GetValue <DatabaseType>($"ConnectionStrings:{connectionSettingName}:DatabaseType"); return(dbConnection); }
public Startup(IHostingEnvironment hostingEnvironment) { var builder = new ConfigurationBuilder() .SetBasePath(hostingEnvironment.ContentRootPath) .AddJsonFile("appsettings.json", true, true) .AddJsonFile("rabbitmq.json", true, true) ; Configuration = builder.Build(); ConfigurationManage.SetConfiguration(Configuration); }
protected virtual void Config() { var config = ConfigurationManage.GetConfiguration($"configuration:6D5AD3FC-EB8E-403E-8C2A-426E87FA7CFA"); if (config == null) { throw new Exception("日志配置未找到!"); } ILoggerRepository repository = LogManager.CreateRepository("SysLogger"); XmlConfigurator.Configure(repository, config.ToStream()); log = LogManager.GetLogger(repository.Name, "SysLogger"); }
public void Log <TState>(LogLevel logLevel, EventId eventId, TState state, Exception exception, Func <TState, Exception, string> formatter) { if (!IsEnabled(logLevel)) { return; } var message = formatter(state, exception); var projectName = ConfigurationManage.GetValue($"MQMonitor:ProjectInfo:ProjectName"); var source = ConfigurationManage.GetValue <int>($"MQMonitor:ProjectInfo:FSource"); var messageInfo = MessageInfo.Create(message, ConvertLogLevel(logLevel), projectName, source); MessageSendUtil._MessageQueue.EnqueueMessage(messageInfo);; }
/// <summary> /// 获取配置信息 /// </summary> /// <param name="key">Key</param> /// <returns></returns> public static MQConfig GetConfig(string key) { var hostName = ConfigurationManage.GetValue($"{key}:MQ:HostName"); var userName = ConfigurationManage.GetValue($"{key}:MQ:UserName"); var pwd = ConfigurationManage.GetValue($"{key}:MQ:Password"); var virtualHost = ConfigurationManage.GetValue($"{key}:MQ:VirtualHost"); var requestedHeartbeat = ConfigurationManage.GetValue <ushort>($"{key}:MQ:RequestedHeartbeat"); return(new MQConfig(hostName, userName, pwd) { VirtualHost = virtualHost }); }
/// <summary> /// 创建运行SQL信息 /// </summary> /// <param name="MemberName">调用方法名字</param> /// <param name="timeElapsed">消耗时间</param> /// <param name="isSuccess">是否成功</param> /// <param name="dbType">数据库类型</param> /// <param name="dataBaseName">数据库名字</param> /// <returns></returns> private static RuntimeSqlModel Create(string MemberName, double timeElapsed, bool isSuccess, string dbType = null, string dataBaseName = null) { var runtimeSqlModel = new RuntimeSqlModel { FExecutedTime = DateTimeUtil.Now, FIsSuccess = isSuccess, FProjectName = ConfigurationManage.GetValue($"MQMonitor:ProjectInfo:ProjectName"), FRequestGuid = AsyncLocalUtil.CurrentGID, FServerMac = ComputerUtil.MacAddress, FSource = ConfigurationManage.GetValue <int>($"MQMonitor:ProjectInfo:FSource"), FSqlDbType = dbType, FSqlText = MemberName, FTimeElapsed = timeElapsed, FMemberName = WebHttpContext.AbsoluteUrl, FDatabaseName = dataBaseName }; return(runtimeSqlModel); }
public bool IsEnabled(LogLevel logLevel) { var catergoryName = ConfigurationManage.GetValue($"MQMonitor:ProjectInfo:CategoryName"); if (!string.IsNullOrWhiteSpace(catergoryName)) { var catergoryNameList = catergoryName.Split(','); var isMatched = false; foreach (var item in catergoryNameList) { if (_categoryName.IsMatch(item)) { isMatched = true; break; } } return(isMatched); } return(false); }
public LoggerManage() { var config = ConfigurationManage.GetConfiguration($"configuration:{Id}"); if (config == null) { var cg = new ConfigurationModel { Content = File.ReadAllText("log4net.config"), Runtime = Environment.GetEnvironmentVariable("Runtime"), Description = "日志" }; IList <ConfigurationModel> cgl = new List <ConfigurationModel>(); cgl.Add(cg); config = cg.Content; ConfigurationManage.SetConfiguration($"configuration:{Id}", cgl); } ILoggerRepository repository = LogManager.CreateRepository("SysLogger"); XmlConfigurator.Configure(repository, config.ToStream()); ILog log = LogManager.GetLogger(repository.Name, "SysLogger"); SingletonUtility.AddSingleton(log); }
/// <summary> /// 获取ip文件的路径 /// </summary> /// <returns></returns> private static string GetIpdataPath() { return(PathUtil.GetCurrentDirectory().CombinePath(ConfigurationManage.GetValue("IPDataPath"))); }
public RpcConfig GetConfig() { return(ConfigurationManage.GetOption <RpcConfig>()); }
/// <summary> /// 异步发送邮件(smtp协议) /// </summary> /// <param name="to">接收人</param> /// <param name="subject">发送主题</param> /// <param name="content">发送内容</param> /// <returns></returns> public static Task <ValueTuple <bool, string> > SendEmailAsync(string to, string subject, string content) { return(EmailUtil.SendEmailAsync(new string[] { to }, subject, content, ConfigurationManage.GetValue(_ConfigKey_ServiceMailAddress), ConfigurationManage.GetValue(_ConfigKey_ServiceMailPwd))); }
public void testConfig() { ConfigurationManage.GetValue("RedisConfig:Connection"); }
/// <summary> /// 登录页面 /// </summary> /// <returns></returns> public IActionResult Index() { LogUtil.Debug(ConfigurationManage.GetValue("ConnectionStrings")); return(View()); }