/// <summary> /// 注册对象间属性关联赋值请求 /// </summary> /// <param name="setter"></param> public void RegisterSetterBetween(SetterBetween setter) { try { _execSeq.Add(setter); } catch(Exception) { throw; } }
/// <summary> /// 创建Rework,检查Product List中所有Product是否可以做Rework,若不可以,则提示用户,放弃后续操作。 /// </summary> /// <returns></returns> public string CreateRework(IList<string> productIDList,string editor) { string userKey = Guid.NewGuid().ToString(); //string reworkCode; Rework rework = new Rework(); try { //insert ProductIDListForRework(UserKey,ProductID) values(?,?) productRepository.CreateTempProductIDList(productIDList, userKey); //select count(1) //from IMES_GetData.dbo.TempProductID a // join IMES_FA.dbo.Rework_Product b on a.ProductID = b.ProductID // join IMES_FA.dbo.Rework c on b.ReworkCode=c.ReworkCode //where Rework.Status<>3 and a.UserKey=? int count1 = productRepository.GetUnitExistsCountByUserKey(userKey); //select count(1) //from IMES_GetData.dbo.TempProductID a // join IMES_FA.dbo.ProductStatus b on a.ProductID = b.ProductID // join IMES_GetData.dbo.ReworkRejectStation c on b.Station =c.Station and b.Status=c.Status //where a.UserKey=? int count2 = productRepository.GetInvalidUnitCountByUserKey(userKey); List<string> erpara = new List<string>(); if (count1 > 0) { //存在Unit存在Rework_Product表且ReworkCode对应的Rework.Status<>3 FisException ex1 = new FisException("DMT023", erpara); throw ex1; } if (count2 > 0) { //存在unit的Product.Station and Status存在于ReworkRejectStation表 FisException ex2 = new FisException("DMT024", erpara); throw ex2; } rework.Status = "0"; rework.Editor = editor; rework.Cdt = DateTime.Now; rework.Udt = DateTime.Now; UnitOfWork uow = new UnitOfWork(); //创建Rework记录,Rework.Status=0(Create) productRepository.CreateReworkDefered(uow, rework); //将对应ProductStatus表中的ReworkCode栏位设置为新产生的Rework Code。 ReworkObj rwkObj = new ReworkObj(); SetterBetween stbt = new SetterBetween(rework, "ReworkCodeProperty", rwkObj, "ReworkCodeProperty"); uow.RegisterSetterBetween(stbt); productRepository.UpdateProductStatusReworkCodeByUserKeyDefered(uow, userKey, rwkObj); uow.Commit(); } catch (Exception e) { logger.Debug(e.Message); throw e; } finally { //delete ProductIDListForRework where UserKey=? productRepository.DeleteProductIDListByUserKey(userKey); } return rework.ReworkCode; }