public async Task BulkCreate_Test() { //Act var beijing = new Region2 { Name = "beijing" }; var xicheng = new Region2 { Name = "xicheng", ParentId = beijing.Id }; var dongcheng = new Region2 { Name = "dongcheng", ParentId = beijing.Id }; beijing.Children = new List <Region2> { xicheng, dongcheng }; await _generalRegion2TreeManager.BulkCreateAsync(beijing); //Assert var bj = GetRegion("beijing"); bj.ShouldNotBeNull(); bj.Name.ShouldBe("beijing"); bj.FullName.ShouldBe("beijing"); bj.Code.ShouldBe(GeneralTreeCodeGenerate.CreateCode(1)); bj.Level.ShouldBe(1); bj.ParentId.ShouldBeNull(); var xc = GetRegion("xicheng"); xc.ShouldNotBeNull(); xc.Name.ShouldBe("xicheng"); xc.FullName.ShouldBe("beijing-xicheng"); xc.Code.ShouldBe(GeneralTreeCodeGenerate.CreateCode(1, 1)); xc.Level.ShouldBe(beijing.Level + 1); xc.ParentId.ShouldBe(beijing.Id); var dc = GetRegion("dongcheng"); dc.ShouldNotBeNull(); dc.Name.ShouldBe("dongcheng"); dc.FullName.ShouldBe("beijing-dongcheng"); dc.Code.ShouldBe(GeneralTreeCodeGenerate.CreateCode(1, 2)); dc.Level.ShouldBe(beijing.Level + 1); dc.ParentId.ShouldBe(beijing.Id); }
private async Task <Region2> CreateRegion(string name, string parentId = null) { var region = new Region2 { Name = name, ParentId = parentId }; await _generalRegion2TreeManager.CreateAsync(region); return(region); }
//排产数据的添加 private void infoInsert() { string curUser = GetUser(); if (!string.IsNullOrEmpty(curUser)) { int isTempOrder = 0; if (CkeckBox_enabled.Checked) { isTempOrder = 1; } string ImgURL = label_hidden.Text; if (!filePhoto.HasFile) { ImgURL = "636195999216328808_84U58PICkTn.jpg";//设置默认图片 } string sqlCmd = "insert into [PLM_Product_OnLine] ([LineId],[BuildTime],[OnlineStatus],[OperUser] ,[PlanCount] ,[IsTemp] ,[OrderNo] ,[ItemParm] ,[ItemName],[ItemNo],[RedLineCount],[PreSetCount],[ItemTech])"; sqlCmd += " values ('" + ddl_line.SelectedValue + "','" + DateTime.Now + "',1,'" + curUser + "','" + numb_planCount.Text + "','" + isTempOrder + "',"; sqlCmd += "'" + txb_workNo.Text + "','" + TextArea_parm.Text + "','" + txb_itemName.Text + "','" + txb_itemNo.Text + "','" + numb_redCount.Text + "','" + numb_preSet.Text + "','" + txb_itemTech.Text + "')"; SqlSel.ExeSql(sqlCmd); sqlCmd = "select max(id) from PLM_Product_OnLine"; int onlineId = Convert.ToInt32(SqlSel.GetSqlScale(sqlCmd)); sqlCmd = "insert into PLM_Product_Image (OnlineId,ImgURL) values "; sqlCmd += "('" + onlineId + "','" + ImgURL + "')"; SqlSel.ExeSql(sqlCmd); //string find = ""; if (!CkeckBox_enabled.Checked)//如果不是临时插单,不插入关联信息 { for (int i = 0; i < Grid_hidden.Rows.Count; i++) { //获取合并的订单信息 int recId = Convert.ToInt32(Grid_hidden.Rows[i].Values[0]); int orderCount = Convert.ToInt32(Grid_hidden.Rows[i].Values[1]); //执行关联明细信息的数据插入 string sqlStr = "insert into PLM_Product_Rel (orderid,ProdId,PriLevel,OrderCount) values "; sqlStr += "('" + recId + "','" + onlineId + "',1,'" + orderCount + "')"; SqlSel.ExeSql(sqlStr); } } //表单重置 PageContext.RegisterStartupScript(Region2.GetResetReference()); Alert.ShowInTop("操作成功!"); } }
public async Task FullName_Hyphen_Test() { var uowManager = LocalIocManager.Resolve <IUnitOfWorkManager>(); using (var uow = uowManager.Begin()) { var repository = LocalIocManager.Resolve <IRepository <Region2, string> >(); var config = new GeneralTreeConfigurationWithReferenceType <Region2, string> { Hyphen = "->" }; var codeGenerate = new GeneralTreeCodeGenerate(new GeneralTreeCodeGenerateConfiguration()); var manager = new GeneralTreeManagerWithReferenceType <Region2, string>(codeGenerate, repository, config); //Act var beijing = new Region2 { Name = "beijing" }; await manager.CreateAsync(beijing); uowManager.Current.SaveChanges(); var xicheng = new Region2 { Name = "xicheng", ParentId = beijing.Id }; await manager.CreateAsync(xicheng); uowManager.Current.SaveChanges(); //Assert var xc = GetRegion("xicheng"); xc.ShouldNotBeNull(); xc.Name.ShouldBe("xicheng"); xc.FullName.ShouldBe("beijing->xicheng"); uow.Complete(); } }
public async Task Create_Test() { //Act var beijing = new Region2 { Name = "beijing" }; await _generalRegion2TreeManager.CreateAsync(beijing); //Assert var xc = GetRegion("beijing"); xc.ShouldNotBeNull(); xc.Name.ShouldBe("beijing"); xc.FullName.ShouldBe("beijing"); xc.Code.ShouldBe(GeneralTreeCodeGenerate.CreateCode(1)); xc.Level.ShouldBe(1); xc.ParentId.ShouldBeNull(); }
public async Task Update_Name_Child_FullName_ShouldBe_Update_Test() { await UsingDbContextAsync(async context => { //Arrange var region = new Region2 { Name = "beijing", FullName = "beijing", Code = "00001", Level = 1 }; context.Region2.Add(region); await context.SaveChangesAsync(); context.Region2.Add(new Region2 { Name = "xicheng", FullName = "beijing-xicheng", Code = "00001.00001", Level = 2, ParentId = region.Id }); await context.SaveChangesAsync(); //Act var beijing = context.Region2.First(x => x.Name == "beijing"); beijing.Name = "newbeijing"; await _generalRegion2TreeManager.UpdateAsync(beijing); await context.SaveChangesAsync(); }); UsingDbContext(context => { //Assert var xicheng = context.Region2.First(x => x.Name == "xicheng"); xicheng.FullName.ShouldBe("newbeijing-xicheng"); }); }
public async Task BulkCreate_ExistTree_Test() { //Arrange var hebei = new Region2 { Name = "hebei", FullName = "hebei", Code = "00001", Level = 1 }; await UsingDbContextAsync(async context => { context.Region2.Add(hebei); await context.SaveChangesAsync(); context.Region2.Add(new Region2 { Name = "shijiazhuang", FullName = "hebei-shijiazhuang", Code = "00001.00001", Level = 2, ParentId = hebei.Id }); await context.SaveChangesAsync(); }); var chengde = new Region2 { Name = "chengde", ParentId = hebei.Id, Children = new List <Region2> { new Region2 { Name = "shuangqiaoqu" }, new Region2 { Name = "shuangluanqu" } } }; await _generalRegion2TreeManager.BulkCreateAsync(chengde); //Assert chengde = GetRegion("chengde"); chengde.ShouldNotBeNull(); chengde.Name.ShouldBe("chengde"); chengde.FullName.ShouldBe("hebei-chengde"); chengde.Code.ShouldBe(GeneralTreeCodeGenerate.CreateCode(1, 2)); chengde.Level.ShouldBe(2); chengde.ParentId.ShouldBe(hebei.Id); var shuangqiaoqu = GetRegion("shuangqiaoqu"); shuangqiaoqu.ShouldNotBeNull(); shuangqiaoqu.Name.ShouldBe("shuangqiaoqu"); shuangqiaoqu.FullName.ShouldBe("hebei-chengde-shuangqiaoqu"); shuangqiaoqu.Code.ShouldBe(GeneralTreeCodeGenerate.CreateCode(1, 2, 1)); shuangqiaoqu.Level.ShouldBe(chengde.Level + 1); shuangqiaoqu.ParentId.ShouldBe(chengde.Id); var shuangluanqu = GetRegion("shuangluanqu"); shuangluanqu.ShouldNotBeNull(); shuangluanqu.Name.ShouldBe("shuangluanqu"); shuangluanqu.FullName.ShouldBe("hebei-chengde-shuangluanqu"); shuangluanqu.Code.ShouldBe(GeneralTreeCodeGenerate.CreateCode(1, 2, 2)); shuangluanqu.Level.ShouldBe(chengde.Level + 1); shuangluanqu.ParentId.ShouldBe(chengde.Id); }
public async Task FillUp_Test() { //Act var beijing = new Region2 { Name = "beijing" }; var xicheng = new Region2 { Name = "xicheng", ParentId = beijing.Id }; var dongcheng = new Region2 { Name = "dongcheng", ParentId = beijing.Id }; var balizhuang = new Region2 { Name = "balizhuang", ParentId = dongcheng.Id }; dongcheng.Children = new List <Region2> { balizhuang }; beijing.Children = new List <Region2> { xicheng, dongcheng }; await _generalRegion2TreeManager.FillUpAsync(beijing); //Assert beijing.FullName.ShouldBe("beijing"); beijing.Code.ShouldBe(GeneralTreeCodeGenerate.CreateCode(1)); beijing.Level.ShouldBe(1); beijing.ParentId.ShouldBeNull(); beijing.Children.Count.ShouldBe(2); xicheng.FullName.ShouldBe("beijing-xicheng"); xicheng.Code.ShouldBe(GeneralTreeCodeGenerate.CreateCode(1, 1)); xicheng.Level.ShouldBe(beijing.Level + 1); xicheng.ParentId.ShouldBe(beijing.Id); dongcheng.FullName.ShouldBe("beijing-dongcheng"); dongcheng.Code.ShouldBe(GeneralTreeCodeGenerate.CreateCode(1, 2)); dongcheng.Level.ShouldBe(beijing.Level + 1); dongcheng.ParentId.ShouldBe(beijing.Id); balizhuang.FullName.ShouldBe("beijing-dongcheng-balizhuang"); balizhuang.Code.ShouldBe(GeneralTreeCodeGenerate.CreateCode(1, 2, 1)); balizhuang.Level.ShouldBe(dongcheng.Level + 1); balizhuang.ParentId.ShouldBe(dongcheng.Id); }
public async Task FillUp_Test() { //Act var beijing = new Region2 { Name = "beijing" }; var xicheng = new Region2 { Name = "xicheng", ParentId = beijing.Id }; var dongcheng = new Region2 { Name = "dongcheng", ParentId = beijing.Id }; var balizhuang = new Region2 { Name = "balizhuang", ParentId = dongcheng.Id }; dongcheng.Children = new List <Region2> { balizhuang }; beijing.Children = new List <Region2> { xicheng, dongcheng }; var uowManager = LocalIocManager.Resolve <IUnitOfWorkManager>(); using (var uow = uowManager.Begin()) { await _generalRegion2TreeManager.FillUpAsync(beijing); uow.Complete(); } //Assert beijing.FullName.ShouldBe("beijing"); beijing.Code.ShouldBe(GeneralTreeCodeGenerate.CreateCode(1)); beijing.Level.ShouldBe(1); beijing.ParentId.ShouldBeNull(); beijing.Children.Count.ShouldBe(2); xicheng.FullName.ShouldBe("beijing-xicheng"); xicheng.Code.ShouldBe(GeneralTreeCodeGenerate.CreateCode(1, 1)); xicheng.Level.ShouldBe(beijing.Level + 1); xicheng.ParentId.ShouldBe(beijing.Id); dongcheng.FullName.ShouldBe("beijing-dongcheng"); dongcheng.Code.ShouldBe(GeneralTreeCodeGenerate.CreateCode(1, 2)); dongcheng.Level.ShouldBe(beijing.Level + 1); dongcheng.ParentId.ShouldBe(beijing.Id); balizhuang.FullName.ShouldBe("beijing-dongcheng-balizhuang"); balizhuang.Code.ShouldBe(GeneralTreeCodeGenerate.CreateCode(1, 2, 1)); balizhuang.Level.ShouldBe(dongcheng.Level + 1); balizhuang.ParentId.ShouldBe(dongcheng.Id); }