Exemple #1
0
        /// <summary>
        /// 根据表名创建对应的bll层实体对象
        /// </summary>
        /// <param name="tableName">目标表名称</param>
        /// <returns>继承自BaseBll类型的子类对象</returns>
        public static object GetBllInstance(string tableName)
        {
            var assemblyName = "Guoli.Bll";
            var fullName     = $"{assemblyName}.{tableName}Bll";

            return(ReflectorHelper.GetInstance(assemblyName, fullName));
        }
Exemple #2
0
        protected BaseBll()
        {
            var assembly = "Guoli.Fs.Dal";
            var fullName = $"Guoli.Fs.Dal.{typeof(T).Name}Dal";

            Dal = ReflectorHelper.GetInstance(assembly, fullName) as BaseDal <T>;
        }
Exemple #3
0
        private Dictionary <string, object> GetTableData(List <DbUpdateLog> dbLog)
        {
            var results = new Dictionary <string, object>();

            var tables = Utils.GetServer2ClientTables();
            var groups = dbLog.GroupBy(o => o.TableName);

            foreach (var g in groups)
            {
                var name = g.Key;
                if (!tables.Contains(name))
                {
                    continue;
                }

                var log       = g.ToList();
                var idList    = log.Select(o => o.TargetId);
                var condition = $" Id IN ({string.Join(",", idList)})";
                var bll       = ReflectorHelper.GetInstance("Guoli.Bll", $"Guoli.Bll.{name}Bll") as IBll;
                var data      = bll.QueryList(condition);
                if (data.Any())
                {
                    results.Add(name, data);
                }
            }

            return(results);
        }
        public void TestGetInstance()
        {
            var instance = ReflectorHelper.GetInstance("Guoli.UtilitiesTest", "Guoli.UtilitiesTest.Helpers.TestClass");

            instance.Should()
            .BeOfType <TestClass>("because the fullname of the class is Guoli.UtilitiesTest.Helpers.TestClass");
        }
Exemple #5
0
        /// <summary>
        /// 创建导入过程中所需要的实例
        /// </summary>
        private void BuildInstance()
        {
            CacheManager = CacheManager.GetInstance();

            OracleBaseBll =
                ReflectorHelper.GetInstance("Guoli.Bll", $"Guoli.Bll.{OracleTableName}Bll") as BaseBll <TOracle>;

            SqlserverBaseBll =
                ReflectorHelper.GetInstance("Guoli.Bll", $"Guoli.Bll.{SqlserverTableName}Bll") as BaseBll <TSqlserver>;
        }
        /// <summary>
        /// 获取配置文件中的待执行数据同步的任务列表
        /// 我们约定配置文件中的配置项以不变量类<see cref="Constants"/>中的前缀字符串开头
        /// 如:
        ///     <add key="_migration_DepartmentMigration" value="Guoli.DataMigration.DepartmentMigration" />
        /// </summary>
        /// <returns>返回获取到的任务列表或者空列表</returns>
        private static List <IMigration> GetSyncTasks()
        {
            var tasks = new List <IMigration>();

            try
            {
                var assemblyName = MethodBase.GetCurrentMethod().DeclaringType.Namespace;
                var appSettings  = ConfigurationManager.AppSettings;
                var configKeys   = appSettings.AllKeys.Where(key => key.StartsWith(Constants.PrefixOfMigrationTasks));
                tasks.AddRange(
                    configKeys.Select(key => ReflectorHelper.GetInstance($"{assemblyName}", appSettings[key]))
                    .Cast <IMigration>());
            }
            catch (Exception ex)
            {
                // Ignore
            }

            return(tasks);
        }