Exemple #1
0
        private IEnumerable <MontioringParameterConfig> BindParameters(ServiceMonitorConfig entity)
        {
            string methodName = MethodBase.GetCurrentMethod().Name;
            IEnumerable <MontioringParameterConfig> config = null;

            using (var connection = CreateConnection())
            {
                try
                {
                    connection.Open();
                    var query = @"SELECT m.* FROM ServiceMonitorConfig s INNER JOIN ServiceMonitorParametersConfig sm ON s.Id = sm.ServiceMonitorId INNER JOIN MonitoringParameterConfig m ON m.Id = sm.MonitoringParameterId WHERE s.Id = @ServiceMonitorConfigId;";
                    var param = new { @ServiceMonitorConfigId = entity.Id };
                    config = connection.Query <MontioringParameterConfig>(query, param);
                }
                catch (Exception ex)
                {
                    Log?.Error(className, methodName, ex.ToString());
                }
                finally
                {
                    connection.Close();
                }
            }

            return(config);
        }
Exemple #2
0
        public ServiceMonitorConfig ReadServiceMonitorConfiguration()
        {
            string methodName           = MethodBase.GetCurrentMethod().Name;
            ServiceMonitorConfig entity = null;

            using (var connection = CreateConnection())
            {
                try
                {
                    connection.Open();
                    var query = "SELECT * FROM ServiceMonitorConfig ORDER BY Id LIMIT 1;";
                    entity            = connection.Query <ServiceMonitorConfig>(query).FirstOrDefault();
                    entity.Parameters = BindParameters(entity);
                    //entity.SmtpSettings = BindSmtpConfiguration(entity);
                }
                catch (Exception ex)
                {
                    Log?.Error(className, methodName, ex.ToString());
                }
                finally
                {
                    connection.Close();
                }
            }

            return(entity);
        }
        public static ServiceMonitorServiceConfiguration Map(ServiceMonitorConfig entity)
        {
            var obj = Mapper.Map <ServiceMonitorServiceConfiguration>(entity);

            return(obj);
        }