Esempio n. 1
0
        /// <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);
        }
Esempio n. 2
0
        /// <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);
        }
Esempio n. 3
0
        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);;
        }
Esempio n. 4
0
        /// <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
            });
        }
Esempio n. 5
0
        /// <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);
        }
Esempio n. 6
0
        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);
        }
Esempio n. 7
0
 /// <summary>
 /// 获取ip文件的路径
 /// </summary>
 /// <returns></returns>
 private static string GetIpdataPath()
 {
     return(PathUtil.GetCurrentDirectory().CombinePath(ConfigurationManage.GetValue("IPDataPath")));
 }
Esempio n. 8
0
 public void testConfig()
 {
     ConfigurationManage.GetValue("RedisConfig:Connection");
 }
Esempio n. 9
0
 /// <summary>
 /// 登录页面
 /// </summary>
 /// <returns></returns>
 public IActionResult Index()
 {
     LogUtil.Debug(ConfigurationManage.GetValue("ConnectionStrings"));
     return(View());
 }
Esempio n. 10
0
 /// <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)));
 }