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);
        }
Ejemplo n.º 2
0
        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);
        }
        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);
        }