Ejemplo n.º 1
0
        /// <summary>
        /// 监控配置文件变化
        /// </summary>
        /// <param name="config"></param>
        public void WatchConfig(IBaraMapper baraMapper)
        {
            var config = baraMapper.BaraMapConfig;

            var ConfigFileInfo = FileLoader.GetFileInfo(config.Path);

            ///监控Config
            FileWatcherLoader.Instance.Watch(ConfigFileInfo, () =>
            {
                _logger.LogInformation("配置文件改变,重新加载配置文件");
                var changedConfig = Load(config.Path, config.BaraMapper);
                config.BaraMapper.LoadConfig(changedConfig);
            });
            ///监控BaraMap
            foreach (var baraMap in config.BaraMaps)
            {
                var baraMapperFileInfo = FileLoader.GetFileInfo(baraMap.Path);
                FileWatcherLoader.Instance.Watch(baraMapperFileInfo, () =>
                {
                    var baraMapStream     = LoadConfigStream(baraMap.Path);
                    var changedBaraMapper = LoadBaraMap(baraMapStream, config);
                    baraMap.Scope         = changedBaraMapper.Scope;
                    baraMap.Statements    = changedBaraMapper.Statements;

                    config.ClearMappedStatements();
                });
            }
        }
Ejemplo n.º 2
0
        //总加载器
        //1初始化配置文件(BaraMapConfig),2监控文件BaraMapper   调用器
        public override BaraMapConfig Load(String filePath, IBaraMapper baraMapper)
        {
            _logger.LogDebug($"加载配置文件{filePath}");
            var configStream = LoadConfigStream(filePath);
            var Config       = LoadConfig(configStream, baraMapper);

            foreach (var baraMapSource in Config.BaraMapSources)
            {
                if (baraMapSource.Type == BaraMapSource.ResourceType.File)
                {
                    LoadBaraMap(baraMapSource.Path, Config);
                }
                else if (baraMapSource.Type == BaraMapSource.ResourceType.Directory)
                {
                    var files = Directory.EnumerateFiles(baraMapSource.Path, "*.xml");
                    foreach (var file in files)
                    {
                        LoadBaraMap(file, Config);
                    }
                }
                else
                {
                    throw new BaraException("Cant't Load Unknown Type:" + baraMapSource.Type);
                }
            }
            baraMapper.LoadConfig(Config);
            if (Config.Settings.IsWatchConfigFile)
            {
                //监控
                WatchConfig(baraMapper);
            }
            return(Config);
        }
Ejemplo n.º 3
0
 public CacheManager(IBaraMapper baraMapper)
 {
     this.BaraMapper      = baraMapper;
     RequestQueue         = new Queue <RequestContext>();
     MappedLastFlushTimes = new Dictionary <String, DateTime>();
     MappedStatements     = BaraMapper.BaraMapConfig.MappedStatements;
 }
Ejemplo n.º 4
0
 public CacheManager(ILoggerFactory loggerFactory, IBaraMapper baraMapper)
 {
     this._logger         = loggerFactory.CreateLogger <CacheManager>();
     this.BaraMapper      = baraMapper;
     RequestQueue         = new Queue <RequestContext>();
     MappedLastFlushTimes = new Dictionary <String, DateTime>();
     MappedStatements     = BaraMapper.BaraMapConfig.MappedStatements;
 }
Ejemplo n.º 5
0
 public BaraMapConfig LoadConfig(ConfigStream ConfigStream, IBaraMapper baraMapper)
 {
     using (ConfigStream.Stream)
     {
         XmlSerializer xmlSeralizer = new XmlSerializer(typeof(BaraMapConfig));
         BaraMapConfig config       = xmlSeralizer.Deserialize(ConfigStream.Stream) as BaraMapConfig;
         config.Path       = ConfigStream.Path;
         config.BaraMapper = baraMapper;
         config.BaraMaps   = new List <BaraMap> {
         };
         return(config);
     }
 }
Ejemplo n.º 6
0
        /// <summary>
        /// 加载配置文件
        /// </summary>
        /// <param name="filePath">配置文件路径</param>
        /// <param name="baraMapper">Bara核心</param>
        /// <returns></returns>
        public BaraMapConfig LoadConfig(String filePath, IBaraMapper baraMapper)
        {
            //反序列化config
            XmlSerializer serializer = new XmlSerializer(typeof(BaraMapConfig));
            BaraMapConfig config     = null;

            using (var configStream = FileLoader.Load(filePath))
            {
                config            = serializer.Deserialize(configStream) as BaraMapConfig;
                config.Path       = filePath;
                config.BaraMapper = baraMapper;
                // config.BaraMapConfig
            }

            return(config);
        }
Ejemplo n.º 7
0
 public SqlToExcel()
 {
     _baraMapper = MapperContainer.Instance.GetBaraMapper();
 }
Ejemplo n.º 8
0
 public DataAccess(ILoggerFactory loggerFactory, String baraMapConfigPath = "BaraMapConfig.xml")
 {
     baraMapper = MapperContainer.Instance.GetBaraMapper(loggerFactory, baraMapConfigPath);
     InitScope();
 }
Ejemplo n.º 9
0
 public DataAccess(IBaraMapper BaraMapper)
 {
     this.baraMapper = BaraMapper;
     InitScope();
 }
Ejemplo n.º 10
0
 public SqlToExcel(IBaraMapper baraMapper)
 {
     _baraMapper = baraMapper;
 }
Ejemplo n.º 11
0
 public DataAccess(String baraMapConfigPath = "BaraMapConfig.xml")
 {
     baraMapper = MapperContainer.Instance.GetBaraMapper(baraMapConfigPath);
     InitScope();
 }
Ejemplo n.º 12
0
 public DataAccessGeneric(IBaraMapper baraMapper) : base(baraMapper)
 {
 }
Ejemplo n.º 13
0
 public SqlExecutor(ILoggerFactory loggerFactory, ISqlBuilder sqlBuilder, IBaraMapper baraMapper)
 {
     _logger     = loggerFactory.CreateLogger <SqlExecutor>();
     _sqlBuilder = sqlBuilder;
     _baraMapper = baraMapper;
 }
Ejemplo n.º 14
0
 public SqlExecutor(ISqlBuilder sqlBuilder, IBaraMapper baraMapper)
 {
     _sqlBuilder = sqlBuilder;
     _baraMapper = baraMapper;
 }
Ejemplo n.º 15
0
 public abstract BaraMapConfig Load(string filePath, IBaraMapper baraMapper);
Ejemplo n.º 16
0
 public MoviesDataAccess(IBaraMapper baraMapper)
 {
     this._baraMapper = baraMapper;
 }
Ejemplo n.º 17
0
 public DataSourceManager(IBaraMapper baraMapper)
 {
     this.BaraMapper = baraMapper;
 }
Ejemplo n.º 18
0
 public DataSourceManager(ILoggerFactory loggerFactory, IBaraMapper baraMapper)
 {
     this._logger    = loggerFactory.CreateLogger <DataSourceManager>();
     this.BaraMapper = baraMapper;
 }
Ejemplo n.º 19
0
 public T_TestDataAccess(IBaraMapper baraMapper) : base(baraMapper)
 {
     this._baraMapper = baraMapper;
 }
Ejemplo n.º 20
0
 public HomeController(IBaraMapper baraMapper)
 {
     this._baraMapper = baraMapper;
 }
Ejemplo n.º 21
0
 public TestBase()
 {
     _baraMapper = MapperContainer.Instance.GetBaraMapper();
 }
Ejemplo n.º 22
0
 public SqlBuilder(ILoggerFactory loggerFactory, IBaraMapper baraMapper)
 {
     this._logger     = loggerFactory.CreateLogger <SqlBuilder>();
     this._baraMapper = baraMapper;
 }
Ejemplo n.º 23
0
 public SqlBuilder(IBaraMapper baraMapper)
 {
     this._baraMapper = baraMapper;
 }
Ejemplo n.º 24
0
 public TestBase()
 {
     this._baraMapper = new BaraMapper();
 }