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"); }
/// <summary> /// 更新最大Id记录 /// </summary> /// <param name="maxId">数据源中当前最大主键值</param> private void UpdateMaxId(string maxId) { var maxBll = new OracleTableMaxIdBll(); var maxModel = new OracleTableMaxId { MaxId = maxId, TableName = OracleTableName }; bool success; if (maxBll.Exists($"TableName='{OracleTableName}'")) { success = maxBll.Update(maxModel); } else { success = maxBll.Insert(maxModel).Id > 0; } if (success) { // 更新缓存 CacheManager.MaxIdCache.Add(maxModel); } }
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(); }
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"); }
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"); }