protected override void BeforeSave(Dictionary <string, string> dic, Base.Logic.Domain.S_UI_Form formInfo, bool isNew) { List <Dictionary <string, object> > lostReplenishList = null; List <Dictionary <string, object> > replenishList = new List <Dictionary <string, object> >(); S_NodeInfo nodeInfo = null; S_FileInfo fileInfo = null; //遗失登记 if (dic.ContainsKey("LostDetail")) { lostReplenishList = JsonHelper.ToList(dic["LostDetail"]); //遗失损毁数量校验 LostDamageVerifica(dic, lostReplenishList); } else { lostReplenishList = JsonHelper.ToList(dic["Detail"]);//补录 } if (lostReplenishList.Count <= 0) { throw new Formula.Exceptions.BusinessException("请添加内容之后,再保存!"); } var entities = Formula.FormulaHelper.GetEntities <DocConstEntities>(); InventoryType stateType = new InventoryType(); foreach (var lostReplenishDetail in lostReplenishList) { string relateID = lostReplenishDetail.ContainsKey("RelateDocID") ? lostReplenishDetail["RelateDocID"].ToString() : "";//文件或节点ID string spaceID = lostReplenishDetail.ContainsKey("SpaceID") ? lostReplenishDetail["SpaceID"].ToString() : ""; S_DOC_Space space = Formula.FormulaHelper.GetEntities <DocConfigEntities>().S_DOC_Space.FirstOrDefault(a => a.ID.Equals(spaceID)); string relateDocType = lostReplenishDetail.ContainsKey("RelateDocType") ? lostReplenishDetail["RelateDocType"].ToString() : "";//文件或结点 string state = ""; if (dic.ContainsKey("LostDetail")) { state = lostReplenishDetail.ContainsKey("LoseDamageState") ? lostReplenishDetail["LoseDamageState"].ToString() : "";//遗失损毁状态 } //遗失或损毁补录份数 #region 库存数量的增减 int LostReplenishCount = 0; int datilCount = 0;//补录份数可能为负数 if (state.Equals(InventoryType.Destroy.ToString()) || state.Equals(InventoryType.Lose.ToString())) { stateType = state.Equals(InventoryType.Destroy.ToString()) ? InventoryType.Destroy : InventoryType.Lose; LostReplenishCount = Convert.ToInt32(lostReplenishDetail["LoseCount"]); LostReplenishCount = -LostReplenishCount; } else { stateType = InventoryType.Replenish; LostReplenishCount = Convert.ToInt32(lostReplenishDetail["ReplenishCount"]); } datilCount = stateType == InventoryType.Replenish? LostReplenishCount:-LostReplenishCount; if (relateDocType == "Node") { nodeInfo = new S_NodeInfo(relateID, space); InventoryFO.CreateInventoryLedger(nodeInfo, stateType, LostReplenishCount, LostReplenishCount, "", "", "", EnumBaseHelper.GetEnumDescription(stateType.GetType(), stateType.ToString()) + "份数:" + datilCount + "份");//入库 } else { fileInfo = new S_FileInfo(relateID, space); InventoryFO.CreateInventoryLedger(fileInfo, stateType, LostReplenishCount, LostReplenishCount, "", "", "", EnumBaseHelper.GetEnumDescription(stateType.GetType(), stateType.ToString()) + "份数:" + datilCount + "份"); } #endregion if (dic.ContainsKey("LostDetail")) { AddLostDamage(dic, lostReplenishDetail, entities);//遗失 } else { AddReplenish(dic, lostReplenishDetail, entities, ref replenishList);//补录 } } if (dic.ContainsKey("Detail")) { dic["Detail"] = JsonHelper.ToJson(replenishList).ToString(); } entities.SaveChanges(); }
protected override void OnFlowEnd(S_I_IdentifyApply entity, S_WF_InsTaskExec taskExec, S_WF_InsDefRouting routing) { var state = IdentifyState.Identified.ToString(); var infoIDs = entity.S_I_IdentifyApply_DetailInfo.Select(a => a.IdentifyInfoID).ToArray(); this.BusinessEntities.Set <S_I_IdentifyInfo>().Where(a => infoIDs.Contains(a.ID)).Update(a => a.State = state); //添加鉴定记录 var IdentifyApplyDetails = entity.S_I_IdentifyApply_DetailInfo.Select(a => a).ToList(); InventoryType type = new InventoryType(); foreach (var IdentifyApplyDetail in IdentifyApplyDetails) { var identifyInfo = this.BusinessEntities.Set <S_I_IdentifyInfo>().FirstOrDefault(b => b.ID.Equals(IdentifyApplyDetail.IdentifyInfoID)); S_NodeInfo node = new S_NodeInfo(identifyInfo.NodeID, FormulaHelper.GetEntities <DocConfigEntities>().S_DOC_Space.FirstOrDefault(b => b.ID.Equals(identifyInfo.SpaceID))); if (IdentifyApplyDetail.IdentifyResult.Equals(InventoryType.Destroy.ToString())) { type = InventoryType.Destroy; } else { type = InventoryType.ChangePeriod; } InventoryFO.CreateNewInventoryLedger(node, "鉴定结果为:" + EnumBaseHelper.GetEnumDescription(type.GetType(), type.ToString()), type); } }