Esempio n. 1
0
        public void TestImportNewData()
        {
            var importInstance = new PostMigragion();

            importInstance.ImportNewData();

            var posts = new PostsBll().QueryAll();

            posts.Should()
            .HaveCount(192, "because there are only 192 rows data in the table j_jcyy_basepost of data source");

            var dbUpdateLogs = new DbUpdateLogBll().QueryAll();

            dbUpdateLogs.Should().HaveCount(192, "because I just insert 192 rows data to the table Posts");

            var relations = new PrimaryIdRelationBll().QueryAll();

            relations.Should()
            .HaveCount(192, "becaust there are only 192 rows data in the table j_jcyy_basepost of data source");

            var maxId = new OracleTableMaxIdBll().QuerySingle($"TableName='{nameof(J_JCYY_BASEPOST)}'");

            maxId.Should().NotBeNull();
            maxId?.MaxId.Should().Be("226");
        }
Esempio n. 2
0
        /// <summary>
        /// 更新数据源对应的表之间的关系(将同时更新数据库及缓存)
        /// </summary>
        /// <param name="oracleModel">oracle数据实体对象</param>
        /// <param name="sqlserverModel">sqlserver数据实体对象</param>
        protected bool UpdatePrimaryRelation(TOracle oracleModel, TSqlserver sqlserverModel)
        {
            if (!NeedToCachePrimaryRelation)
            {
                return(true);
            }

            // 更新oracle与sqlserver对应表的主键关系,用作缓存
            var relationBll = new PrimaryIdRelationBll();
            var relation    = new PrimaryIdRelation
            {
                OracleTableName = OracleTableName,
                OraclePrimaryId = ReflectorHelper.GetPropertyValue(oracleModel, OracleTablePrimaryKeyName)?.ToString(),
                SqlTableName    = SqlserverTableName,
                SqlPrimaryId    = ReflectorHelper.GetPropertyValue(sqlserverModel, SqlserverTablePrimaryKeyName)?.ToString()
            };

            var success = relationBll.Insert(relation).Id > 0;

            if (success)
            {
                // 将新的主键关系加入缓存中
                CacheManager.PrimaryIdCache.Add(relation);
            }

            return(success);
        }
Esempio n. 3
0
        static CacheManager()
        {
            _instance = new CacheManager();

            var maxIdBll     = new OracleTableMaxIdBll();
            var primaryIdBll = new PrimaryIdRelationBll();

            var condition = "IsDelete=0";

            MaxIdCache     = maxIdBll.QueryList(condition).ToList();
            PrimaryIdCache = primaryIdBll.QueryList(condition).ToList();
        }
Esempio n. 4
0
        public void TestImportNewData()
        {
            // 导入员工之前必须先导入部门、岗位
            var departImport = new DepartmentMigration();

            departImport.ImportNewData();

            var postImport = new PostMigragion();

            postImport.ImportNewData();

            var testInstance = new StaffMigration();

            testInstance.ImportNewData();

            var totalCount = 7063;
            var allStaff   = new PersonInfoBll().QueryAll().ToList();

            allStaff.Should().HaveCount(totalCount, $"because the total count of the data source is {totalCount}");

            var single = allStaff.Find(p => p.WorkNo == "2920133");

            single.Should().NotBeNull();
            single.Name.Should().Be("杨凤山");
            single.BirthDate.Should().Be(new DateTime(1960, 12, 1, 12, 0, 0));
            single.Password.Should().Be("0133".GetMd5());

            var dbLogs = new DbUpdateLogBll().QueryList($"TableName='{nameof(PersonInfo)}'");

            dbLogs.Should().HaveCount(totalCount);

            var relations = new PrimaryIdRelationBll().QueryAll();

            relations.Should().HaveCount(totalCount);

            var maxId = new OracleTableMaxIdBll().QuerySingle($"TableName='{nameof(Z_JCYY_BASEPERSONNEL)}'");

            maxId.Should().NotBeNull();
            maxId?.MaxId.Should().NotBeNullOrEmpty()
            .And.Subject.Should().Be("404990019");
        }
Esempio n. 5
0
        public void TestImportNewData()
        {
            TestSuite.CleanTestDb();

            var importInstance = new DepartmentMigration();

            importInstance.ImportNewData();

            var departBll = new DepartInfoBll();
            var departs   = departBll.QueryAll().ToList();

            departs.Should().HaveCount(37, "because the table 'Y_JCYY_BASEDEPARTMENT' in oracle has 37 rows.");
            //departs.Should().Contain(depart => depart.DepartmentName == "集宁机务段");

            var jnDepot = departs.Find(d => d.DepartmentName == "集宁机务段");

            jnDepot.Should().NotBeNull();
            jnDepot?.DepartmentName.Should().NotBeNullOrEmpty().And.Be("集宁机务段");
            jnDepot?.ParentId.Should().Be(0);

            var jnyyc = departs.Find(d => d.DepartmentName == "集宁运用车间");

            jnyyc.Should().NotBeNull();
            jnyyc?.ParentId.Should().Be(jnDepot?.Id);

            var dbupdateLogBll = new DbUpdateLogBll();
            var dbupdateLogs   = dbupdateLogBll.QueryList($"TableName='{nameof(DepartInfo)}'").ToList();

            dbupdateLogs.Should().HaveCount(37);

            var relationBll = new PrimaryIdRelationBll();
            var relations   = relationBll.QueryAll().ToList();

            relations.Should().HaveCount(37);

            var maxBll     = new OracleTableMaxIdBll();
            var maxIdModel = maxBll.QuerySingle($"TableName='Y_JCYY_BASEDEPARTMENT'");

            maxIdModel.Should().NotBeNull();
            maxIdModel.MaxId.Should().Be("404100000");
        }