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); } }
protected override void OnFlowEnd(S_I_DestroyApply entity, S_WF_InsTaskExec taskExec, S_WF_InsDefRouting routing) { var state = IdentifyState.Finish.ToString(); var infoIDs = entity.S_I_DestroyApply_DetailInfo.Select(a => a.IdentifyInfoID).ToArray(); var IdentifyApplyDetailInfoIDs = entity.S_I_DestroyApply_DetailInfo.Select(a => a.IdentifyApplyDetailInfoID).ToArray(); this.BusinessEntities.Set <S_I_IdentifyApply_DetailInfo>().Where(a => IdentifyApplyDetailInfoIDs.Contains(a.ID)).Update(a => a.HandleResult = state); var apply = this.BusinessEntities.Set <S_I_IdentifyApply>().FirstOrDefault(a => a.ID == entity.IdentifyApplyID); if (apply != null) { if (apply.S_I_IdentifyApply_DetailInfo.Count(a => !IdentifyApplyDetailInfoIDs.Contains(a.ID) && a.HandleResult != state) == 0) { apply.HandleState = HandleState.Finish.ToString(); } else { apply.HandleState = HandleState.Part.ToString(); } } var updateDic = new Dictionary <S_DOC_Space, StringBuilder>(); var infos = this.BusinessEntities.Set <S_I_IdentifyInfo>().Where(a => infoIDs.Contains(a.ID)).ToList(); foreach (var info in infos) { info.State = state; var space = DocConfigHelper.CreateConfigSpaceByID(info.SpaceID); var nodeInfo = new S_NodeInfo(info.NodeID, space); if (!updateDic.ContainsKey(space)) { updateDic.Add(space, new StringBuilder()); } updateDic[space].AppendLine(string.Format(@" update S_NodeInfo set [State] = '{0}' where FullPathID like '{1}%' update S_FileInfo set [State] = '{0}' where FullNodeID like '{1}%'", DocState.Invalid.ToString(), nodeInfo.FullPathID)); } foreach (var item in updateDic.Keys) { var instanceDB = SQLHelper.CreateSqlHelper(item.SpaceKey, item.ConnectString); instanceDB.ExecuteNonQuery(updateDic[item].ToString()); } //添加销毁记录 var IdentifyApplyDetails = this.BusinessEntities.Set <S_I_IdentifyApply_DetailInfo>().Where(a => IdentifyApplyDetailInfoIDs.Contains(a.ID)).Select(a => a).ToList(); 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))); InventoryFO.CreateNewInventoryLedger(node, "", InventoryType.Destroy); } }
private void Return(Dictionary <string, object> row) { var returnNumber = 0; int.TryParse(row.GetValue("ReturnNumber"), out returnNumber); var id = row.GetValue("ID"); var borrowDetail = this.entities.Set <S_BorrowDetail>().FirstOrDefault(a => a.ID == id); if (returnNumber > 0 && borrowDetail != null) { borrowDetail.ReturnUserID = row.GetValue("ReturnUserID"); borrowDetail.ReturnUser = row.GetValue("ReturnUser"); borrowDetail.ReturnDeptID = row.GetValue("ReturnDeptID"); borrowDetail.ReturnDeptName = row.GetValue("ReturnDeptName"); borrowDetail.ReturnNumber = (borrowDetail.ReturnNumber ?? 0) + returnNumber; borrowDetail.ReturnDate = Convert.ToDateTime(row.GetValue("ReturnDate")); var isFinish = ((borrowDetail.LendNumber ?? 0) - (borrowDetail.ReturnNumber ?? 0) - (borrowDetail.LostNumber ?? 0)) == 0; if (isFinish) { borrowDetail.BorrowState = BorrowDetailState.Finish.ToString(); } if (borrowDetail.DetailType == NodeType.Node.ToString()) { var space = DocConfigHelper.CreateConfigSpaceByID(borrowDetail.SpaceID); var nodeInfo = new S_NodeInfo(borrowDetail.RelateID, space); InventoryFO.CreateInventoryLedger(nodeInfo, InventoryType.Return, 0, returnNumber, borrowDetail.ID, borrowDetail.ReturnUserID, borrowDetail.ReturnUser, EnumBaseHelper.GetEnumDescription(InventoryType.Return.GetType(), InventoryType.Return.ToString()) + "份数:" + returnNumber + "份"); if (isFinish) { nodeInfo.DataEntity.SetValue("BorrowState", BorrowReturnState.Return.ToString()); } nodeInfo.Save(false); } else { var space = DocConfigHelper.CreateConfigSpaceByID(borrowDetail.SpaceID); var fileInfo = new S_FileInfo(borrowDetail.RelateID, space); InventoryFO.CreateInventoryLedger(fileInfo, InventoryType.Return, 0, returnNumber, borrowDetail.ID, borrowDetail.ReturnUserID, borrowDetail.ReturnUser, EnumBaseHelper.GetEnumDescription(InventoryType.Return.GetType(), InventoryType.Return.ToString()) + "份数:" + returnNumber + "份"); if (isFinish) { fileInfo.DataEntity.SetValue("BorrowState", BorrowReturnState.Return.ToString()); } fileInfo.Save(false); } } }
protected override void BeforeSave(S_FileInfo file, Dictionary <string, object> row, bool isNew) { if (isNew) { var isPhys = row.GetValue("StorageType") == "Physical"; var node = S_NodeInfo.GetNode(row.GetValue("NodeID"), row.GetValue("SpaceID")); if (isPhys && node.ConfigInfo.IsPhysicalBox != "True") { throw new Formula.Exceptions.BusinessException("当前编目节点不能保存实物文件"); } if (!isPhys && node.ConfigInfo.IsElectronicBox != "True") { throw new Formula.Exceptions.BusinessException("当前编目节点不能保存电子档文件"); } } else { string detail = string.Empty; S_FileInfo oldFile = new S_FileInfo(file.ID, file.Space); var fileAttrs = file.ConfigInfo.S_DOC_FileAttr.Select(a => a); foreach (S_DOC_FileAttr fileAttr in fileAttrs) { if (fileAttr.InputType.Equals("ButtonEdit"))//弹出选择 { detail += file.DataEntity.GetValue(fileAttr.FileAttrField + "Name") == oldFile.DataEntity.GetValue(fileAttr.FileAttrField + "Name") ? "" : "\"" + fileAttr.FileAttrName + ":" + oldFile.DataEntity.GetValue(fileAttr.FileAttrField + "Name") + "\"修改为\"" + file.DataEntity.GetValue(fileAttr.FileAttrField + "Name") + "\";"; } else if (fileAttr.InputType.Equals("Combobox"))//枚举 { var enums = EnumBaseHelper.GetEnumDef(fileAttr.EnumKey).EnumItem; var enumNameOld = enums.FirstOrDefault(a => a.Code.Equals(oldFile.DataEntity.GetValue(fileAttr.FileAttrField))); string oldName = enumNameOld != null?enumNameOld.Name:""; var enumName = enums.FirstOrDefault(a => a.Code.Equals(file.DataEntity.GetValue(fileAttr.FileAttrField))); detail += file.DataEntity.GetValue(fileAttr.FileAttrField) == oldFile.DataEntity.GetValue(fileAttr.FileAttrField) ? "" : "\"" + fileAttr.FileAttrName + ":" + oldName + "\"修改为\"" + enumName.Name + "\";"; } else { if (fileAttr.FileAttrField.Equals("SortIndex") || fileAttr.FileAttrField.Equals("DocIndexID")) { continue; } detail += file.DataEntity.GetValue(fileAttr.FileAttrField) == oldFile.DataEntity.GetValue(fileAttr.FileAttrField) ? "" : "\"" + fileAttr.FileAttrName + ":" + oldFile.DataEntity.GetValue(fileAttr.FileAttrField) + "\"修改为\"" + file.DataEntity.GetValue(fileAttr.FileAttrField) + "\";"; } } if (!string.IsNullOrEmpty(detail)) { //修改,详情说明 InventoryFO.CreateNewInventoryLedger(oldFile, detail, InventoryType.Update); } } }
public override void Save(bool withDefaultAttr = true) { this.SetNodeFileCount(); if (this.IsValidateDataAttr)//整编文件唯一验证不调用此处方法 { this.ValidateDataAttr(this.IsNewModel); } if (this.DataEntity.ContainsKey("DocIndexID")) //作为hubbledotnet的检索键,不参与任何更新操作 { this.DataEntity.Remove("DocIndexID"); } if (this.IsNewModel) { if (withDefaultAttr) { this.FillConfigDefaultAttr(); } if (String.IsNullOrEmpty(this.ID)) { this.ID = FormulaHelper.CreateGuid(); } base.Save(); if (!this.IsValidateDataAttr) { InventoryFO.CreateNewInventoryLedger(this, "整编入库"); //整编入库添加 } else { InventoryFO.CreateNewInventoryLedger(this, "新增登记");//新增添加 } foreach (var item in Attachments) { this.InstanceDB.ExecuteNonQuery(" update S_Attachment set CurrentVersion='False' where FileID='" + this.ID + "' "); item.FileID = this.ID; item.NodeID = this.NodeID; item.CurrentVersion = "True"; item.Version = this.getMaxAttachVersion(); item.DataEntity.SetValue("State", DocState.Normal.ToString()); item.Save(); } } else { //if (withDefaultAttr) this.FillConfigDefaultAttr(); base.Save(); this.InstanceDB.ExecuteNonQuery(" update S_Attachment set NodeID='" + this.NodeID + "' where FileID='" + this.ID + "' "); CheckFulltextProp(); } }
public override void Delete() { this.ClearAttachment(); this.DataEntity.DeleteDB(this.InstanceDB, TableName, this.ID); var constDB = SQLHelper.CreateSqlHelper(ConnEnum.DocConst); var sql = @" update S_R_Reorganize_DocumentList set ReorganizePath='',ReorganizeFullID='',ArchiveFileID='',ArchiveFileAttrs='' where ArchiveFileID ='{0}' update S_R_PhysicalReorganize_FileDetail set ReorganizePath='',ReorganizeFullID='',ArchiveFileID='' where ArchiveFileID ='{0}'"; constDB.ExecuteNonQuery(string.Format(sql, this.ID)); InventoryFO.Delete(this.ID); }
protected override void OnFlowEnd(T_D_DownloadApply entity, Workflow.Logic.Domain.S_WF_InsTaskExec taskExec, Workflow.Logic.Domain.S_WF_InsDefRouting routing) { var carIds = entity.T_D_DownloadApply_DetailInfo.Select(a => a.CarInfoID).ToArray(); var carItems = this.BusinessEntities.Set <S_CarInfo>().Where(a => carIds.Contains(a.ID)); foreach (var item in entity.T_D_DownloadApply_DetailInfo.ToList()) { var carItem = carItems.FirstOrDefault(a => a.ID == item.CarInfoID); carItem.State = ItemState.Finish.ToString(); #region 创建S_DownloadDetail int downloadExpireDate = 7; var DocDownloadExpireDays = System.Configuration.ConfigurationManager.AppSettings["DocDownloadExpireDays"]; if (!string.IsNullOrEmpty(DocDownloadExpireDays)) { downloadExpireDate = Convert.ToInt32(DocDownloadExpireDays); } S_DownloadDetail downloadDetail = new S_DownloadDetail { ID = FormulaHelper.CreateGuid(), DownloadID = entity.ID, Name = item.Name, Code = item.Code, SpaceID = carItem.SpaceID, ConfigID = carItem.ConfigID, FileID = carItem.FileID, CreateUserID = entity.ApplyUser, CreateUserName = entity.ApplyUserName, CreateDate = DateTime.Now, UserDeptID = entity.ApplyDept, UserDeptName = entity.ApplyDeptName, PassDate = DateTime.Now, DownloadState = ItemState.Finish.ToString(), DownloadExpireDate = Convert.ToDateTime(DateTime.Now.AddDays(downloadExpireDate).ToShortDateString() + " 23:59:59") }; this.BusinessEntities.Set <S_DownloadDetail>().Add(downloadDetail); #endregion S_FileInfo file = new S_FileInfo(carItem.FileID, FormulaHelper.GetEntities <DocConfigEntities>().S_DOC_Space.FirstOrDefault(a => a.ID.Equals(carItem.SpaceID))); InventoryFO.CreateNewInventoryLedger(file, "", InventoryType.DownLoad); } this.BusinessEntities.SaveChanges(); }
protected override void OnFlowEnd(S_SU_DocumentRelieveSeal entity, S_WF_InsTaskExec taskExec, S_WF_InsDefRouting routing) { var detailIst = entity.S_SU_DocumentRelieveSeal_DetailList.ToList(); var spaceList = new List <S_DOC_Space>(); var spaceIDs = detailIst.Where(a => !string.IsNullOrEmpty(a.SpaceID)).Select(a => a.SpaceID).ToList(); foreach (var spaceID in spaceIDs) { var nodeIds = detailIst.Where(a => a.SpaceID == spaceID && !string.IsNullOrEmpty(a.RelateID)).Select(a => a.RelateID); StringBuilder sb = new StringBuilder(); var space = spaceList.FirstOrDefault(a => a.ID == spaceID); if (space == null) { space = DocConfigHelper.CreateConfigSpaceByID(spaceID); spaceList.Add(space); } var db = SQLHelper.CreateSqlHelper(space.SpaceKey, space.ConnectString); foreach (var nodeid in nodeIds) { sb.AppendLine("update S_NodeInfo set State = '" + DocState.Normal.ToString() + "',RackNumber='" + entity.RelieveSealRackNumber + "',RackNumberName='" + entity.RelieveSealRackNumberName + "',StorageRoom='" + entity.RelieveSealStorageRoom + "',StorageRoomName='" + entity.RelieveSealStorageRoomName + "' where FullPathID like '%" + nodeid + "%'"); sb.AppendLine("update S_FileInfo set State = '" + DocState.Normal.ToString() + "' where FullNodeID like '%" + nodeid + "%'"); } if (sb.Length > 0) { db.ExecuteNonQuery(sb.ToString()); } } foreach (var detail in detailIst) { if (detail.RelateType.Equals("Node")) { S_NodeInfo node = new S_NodeInfo(detail.RelateID, Formula.FormulaHelper.GetEntities <DocConfigEntities>().S_DOC_Space.FirstOrDefault(a => a.ID.Equals(detail.SpaceID))); InventoryFO.CreateNewInventoryLedger(node, "\"库房\"修改为:\"" + entity.RelieveSealStorageRoomName + "\";\"货架号\"修改为:\"" + entity.RelieveSealRackNumberName + "\"", InventoryType.RelieveSeal); } else { S_FileInfo file = new S_FileInfo(detail.RelateID, Formula.FormulaHelper.GetEntities <DocConfigEntities>().S_DOC_Space.FirstOrDefault(a => a.ID.Equals(detail.SpaceID))); InventoryFO.CreateNewInventoryLedger(file, "\"库房\"修改为:\"" + entity.RelieveSealStorageRoomName + "\";\"货架号\"修改为:\"" + entity.RelieveSealRackNumberName + "\"", InventoryType.RelieveSeal); } } }
protected override void OnFlowEnd(T_B_BorrowApply entity, Workflow.Logic.Domain.S_WF_InsTaskExec taskExec, Workflow.Logic.Domain.S_WF_InsDefRouting routing) { var carIds = entity.T_B_BorrowApply_DetailInfo.Select(a => a.CarInfoID).ToArray(); var carItems = this.BusinessEntities.Set <S_CarInfo>().Where(a => carIds.Contains(a.ID)); foreach (var item in entity.T_B_BorrowApply_DetailInfo.ToList()) { var carItem = carItems.FirstOrDefault(a => a.ID == item.CarInfoID); if (carItem != null) { carItem.State = ItemState.Finish.ToString(); #region 创建S_BorrowDetail S_BorrowDetail borrowDetail = new S_BorrowDetail { ID = FormulaHelper.CreateGuid(), BorrowID = entity.ID, SpaceID = carItem.SpaceID, SpaceName = item.SpaceName, DataType = carItem.DataType, DetailType = string.IsNullOrEmpty(item.FileID) ? NodeType.Node.ToString() : NodeType.File.ToString(), RelateID = string.IsNullOrEmpty(item.FileID) ? item.NodeID : item.FileID, ConfigID = carItem.ConfigID, Name = item.Name, Code = item.Code, CreateUserID = entity.ApplyUser, CreateUserName = entity.ApplyUserName, CreateDeptID = entity.ApplyDept, CreateDeptName = entity.ApplyDeptName, CreateDate = DateTime.Now, ApplyNumber = item.ApplyAmount, BorrowState = BorrowDetailState.ToLend.ToString() }; this.BusinessEntities.Set <S_BorrowDetail>().Add(borrowDetail); #endregion } S_FileInfo file = new S_FileInfo(item.FileID, FormulaHelper.GetEntities <DocConfigEntities>().S_DOC_Space.FirstOrDefault(a => a.ID.Equals(item.SpaceID))); InventoryFO.CreateNewInventoryLedger(file, "", InventoryType.BorrowFile); } this.BusinessEntities.SaveChanges(); }
//保存时对比数据是否修改 protected override void BeforeSave(S_NodeInfo node, Dictionary <string, object> row, bool isNew) { string detail = string.Empty; if (!isNew) { S_NodeInfo oldNode = new S_NodeInfo(node.ID, node.Space); var nodeAttrs = node.ConfigInfo.S_DOC_NodeAttr.Select(a => a); var enumList = EnumBaseHelper.GetEnumDef("DocConst.KeepYear").EnumItem; foreach (S_DOC_NodeAttr nodeAttr in nodeAttrs) { if (nodeAttr.InputType.Equals("ButtonEdit")) { detail += node.DataEntity.GetValue(nodeAttr.AttrField + "Name") == oldNode.DataEntity.GetValue(nodeAttr.AttrField + "Name") ? "" : "\"" + nodeAttr.AttrName + ":" + oldNode.DataEntity.GetValue(nodeAttr.AttrField + "Name") + "\"修改为\"" + node.DataEntity.GetValue(nodeAttr.AttrField + "Name") + "\";"; } else if (nodeAttr.InputType.Equals("Combobox")) { var enums = EnumBaseHelper.GetEnumDef(nodeAttr.EnumKey).EnumItem; var enumNameOld = enums.FirstOrDefault(a => a.Code.Equals(oldNode.DataEntity.GetValue(nodeAttr.AttrField))); string oldName = enumNameOld != null ? enumNameOld.Name : ""; var enumName = enums.FirstOrDefault(a => a.Code.Equals(node.DataEntity.GetValue(nodeAttr.AttrField))); detail += node.DataEntity.GetValue(nodeAttr.AttrField) == oldNode.DataEntity.GetValue(nodeAttr.AttrField) ? "" : "\"" + nodeAttr.AttrName + ":" + oldName + "\"修改为\"" + enumName.Name + "\";"; } else { if (nodeAttr.AttrField.Equals("SortIndex") || nodeAttr.AttrField.Equals("DocIndexID")) { continue; } detail += node.DataEntity.GetValue(nodeAttr.AttrField) == oldNode.DataEntity.GetValue(nodeAttr.AttrField) ? "" : "\"" + nodeAttr.AttrName + ":" + oldNode.DataEntity.GetValue(nodeAttr.AttrField) + "\"修改为\"" + node.DataEntity.GetValue(nodeAttr.AttrField) + "\";"; } } if (!string.IsNullOrEmpty(detail)) { //修改,详情说明 InventoryFO.CreateNewInventoryLedger(oldNode, detail, InventoryType.Update); } } }
public JsonResult BrownFile(string FileID, string SpaceID) { var space = DocConfigHelper.CreateConfigSpaceByID(SpaceID); var file = new S_FileInfo(FileID, space); if (file.CurrentAttachment == null || String.IsNullOrEmpty(file.CurrentAttachment.DataEntity.GetValue("MainFile"))) { throw new Formula.Exceptions.BusinessException("没有上传附件,无法进行浏览!"); } var fileDB = SQLHelper.CreateSqlHelper(ConnEnum.FileStore); var docType = file.CurrentAttachment.DataEntity.GetValue("FileType"); var fileID = file.CurrentAttachment.DataEntity.GetValue("MainFile").Split('_')[0]; if (String.IsNullOrEmpty(fileID)) { fileID = file.CurrentAttachment.DataEntity.GetValue("PDFFile").Split('_')[0]; } var constEntities = Formula.FormulaHelper.GetEntities <DocConstEntities>(); var log = constEntities.S_DocumentLog.Create(); log.ID = Formula.FormulaHelper.CreateGuid(); log.Name = file.Name; log.LogType = "Browse"; log.NodeID = file.NodeID; log.SpaceID = file.Space.ID; log.FileID = file.ID; log.FullNodeID = file.FullNodeID; log.ConfigID = file.ConfigInfo.ID; log.CreateDate = DateTime.Now; log.CreateUserID = this.CurrentUserInfo.UserID; log.CreateUserName = this.CurrentUserInfo.UserName; constEntities.S_DocumentLog.Add(log); constEntities.SaveChanges(); InventoryFO.CreateNewInventoryLedger(file, "", InventoryType.View); return(Json(new { DocType = docType, SWFFileID = fileID })); }
public override void Save(bool withDefaultAttr = true) { this.SetNodeFileCount(); this.ValidateDataAttr(this.IsNewModel); if (this.IsNewModel) { if (this.IsRoot) { if (String.IsNullOrEmpty(this.ID)) { this.ID = FormulaHelper.CreateGuid(); } this.DataEntity["FullPathID"] = this.ID; this.DataEntity["FullPathName"] = this.Name;; if (!this.DataEntity.ContainsKey("SpaceID") || Tool.IsNullOrEmpty(this.DataEntity["SpaceID"])) { throw new Formula.Exceptions.BusinessException("未指定档案空间ID,无法新增编目节点数据"); } this.DataEntity["State"] = "Normal"; if (this.DataEntity.ContainsKey("SortIndex") && Tool.IsNullOrEmpty(this.DataEntity["SortIndex"])) { this.SortIndex = 0; } this.DataEntity.InsertDB(this.InstanceDB, TableName, this.ID); } else { if (this.Parent == null) { if (!this.DataEntity.ContainsKey("SpaceID") || Tool.IsNullOrEmpty(this.DataEntity["SpaceID"])) { throw new Formula.Exceptions.BusinessException("未指定档案空间ID,无法新增编目节点数据"); } if (String.IsNullOrEmpty(this.ID)) { this.ID = FormulaHelper.CreateGuid(); } this.DataEntity["FullPathID"] = this.ID; this.DataEntity["FullPathName"] = this.Name; this.DataEntity["State"] = "Normal"; if (this.DataEntity.ContainsKey("SortIndex") && Tool.IsNullOrEmpty(this.DataEntity["SortIndex"])) { this.SortIndex = 0; } this.DataEntity.InsertDB(this.InstanceDB, TableName, this.ID); } else { this.Parent.AddChild(this, withDefaultAttr); } } if (!this.IsValidateDataAttr) { InventoryFO.CreateNewInventoryLedger(this, "整编入库");//整编入库添加 } else { InventoryFO.CreateNewInventoryLedger(this, "新增添加");//新增添加 } } else { //if (withDefaultAttr) this.FillConfigDefaultAttr(); this.DataEntity.UpdateDB(this.InstanceDB, TableName, this.ID); //更新全路径FullPathName字段 //UpdateAllChildrenFullPathName(); //当前对象存在全文检索属性,则变更全文检索文件状态,以便重新插入Es CheckFulltextProp(); } }
protected void remove() { this.ClearFiles(); this.DataEntity.DeleteDB(this.InstanceDB, TableName, this.ID); InventoryFO.Delete(this.ID); }
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(); }
private void Lend(Dictionary <string, object> row) { var lendNumber = 0; int.TryParse(row.GetValue("LendNumber"), out lendNumber); var id = row.GetValue("ID"); var borrowDetail = this.entities.Set <S_BorrowDetail>().FirstOrDefault(a => a.ID == id); var isNew = false; if (lendNumber > 0) { #region 部分借阅 if (borrowDetail == null) { if (string.IsNullOrEmpty(id)) { id = FormulaHelper.CreateGuid(); } borrowDetail = new S_BorrowDetail { ID = id, SpaceID = row.GetValue("SpaceID"), SpaceName = row.GetValue("SpaceName"), DataType = row.GetValue("DataType"), DetailType = row.GetValue("DetailType"), RelateID = row.GetValue("RelateID"), ConfigID = row.GetValue("ConfigID"), Name = row.GetValue("Name"), Code = row.GetValue("Code"), LendUserID = row.GetValue("LendUserID"), LendUserName = row.GetValue("LendUserName"), LendDeptID = row.GetValue("LendDeptID"), LendDeptName = row.GetValue("LendDeptName"), ParentID = row.GetValue("ParentID") }; var applyNumber = 0; int.TryParse(row.GetValue("ApplyNumber"), out applyNumber); borrowDetail.ApplyNumber = applyNumber; this.entities.Set <S_BorrowDetail>().Add(borrowDetail); isNew = true; var parent = this.entities.Set <S_BorrowDetail>().FirstOrDefault(a => a.ID == borrowDetail.ParentID); if (parent != null) { parent.HasChild = TrueOrFalse.True.ToString(); } } #endregion borrowDetail.LendUserID = row.GetValue("LendUserID"); borrowDetail.LendUserName = row.GetValue("LendUserName"); borrowDetail.LendDeptID = row.GetValue("LendDeptID"); borrowDetail.LendDeptName = row.GetValue("LendDeptName"); borrowDetail.LendNumber = (borrowDetail.LendNumber ?? 0) + lendNumber; if (borrowDetail.LendDate == null) { borrowDetail.LendDate = Convert.ToDateTime(row.GetValue("LendDate")); borrowDetail.BorrowExpireDate = Convert.ToDateTime(row.GetValue("BorrowExpireDate")); } borrowDetail.BorrowState = BorrowDetailState.ToReturn.ToString(); if (borrowDetail.DetailType == NodeType.Node.ToString()) { var space = DocConfigHelper.CreateConfigSpaceByID(borrowDetail.SpaceID); var nodeInfo = new S_NodeInfo(borrowDetail.RelateID, space); InventoryFO.CreateInventoryLedger(nodeInfo, InventoryType.Lend, 0, (0 - lendNumber), borrowDetail.ID, borrowDetail.LendUserID, borrowDetail.LendUserName, EnumBaseHelper.GetEnumDescription(InventoryType.Lend.GetType(), InventoryType.Lend.ToString()) + "份数:" + lendNumber + "份"); nodeInfo.DataEntity.SetValue("BorrowState", BorrowReturnState.Borrow.ToString()); nodeInfo.Save(false); if (isNew) { borrowDetail.Name = nodeInfo.CreateCarName(); } } else { var space = DocConfigHelper.CreateConfigSpaceByID(borrowDetail.SpaceID); var fileInfo = new S_FileInfo(borrowDetail.RelateID, space); InventoryFO.CreateInventoryLedger(fileInfo, InventoryType.Lend, 0, (0 - lendNumber), borrowDetail.ID, borrowDetail.LendUserID, borrowDetail.LendUserName, EnumBaseHelper.GetEnumDescription(InventoryType.Lend.GetType(), InventoryType.Lend.ToString()) + "份数:" + lendNumber + "份"); fileInfo.DataEntity.SetValue("BorrowState", BorrowReturnState.Borrow.ToString()); fileInfo.Save(false); if (isNew) { borrowDetail.Name = fileInfo.CreateCarName(); } } } else if (borrowDetail != null) { if (borrowDetail.LendDate == null) { borrowDetail.LendDate = Convert.ToDateTime(row.GetValue("LendDate")); } if (borrowDetail.BorrowExpireDate == null) { borrowDetail.BorrowExpireDate = Convert.ToDateTime(row.GetValue("BorrowExpireDate")); } } }