public static void CreateCarItem(S_NodeInfo nodeInfo, string type) { var user = FormulaHelper.GetUserInfo(); var entities = FormulaHelper.GetEntities <DocConstEntities>(); if (nodeInfo.ConfigInfo == null) { throw new Formula.Exceptions.BusinessException("未能找到文件【" + nodeInfo.ID + "】的配置对象信息"); } var carInfo = entities.Set <S_CarInfo>().FirstOrDefault(d => d.NodeID == nodeInfo.ID && d.State == "New" && d.UserID == user.UserID && d.Type == type && d.DataType == nodeInfo.ConfigInfo.Name); if (carInfo == null) { carInfo = new S_CarInfo { ID = FormulaHelper.CreateGuid(), UserID = user.UserID, UserName = user.UserName, Name = nodeInfo.CreateCarName(), Code = nodeInfo.DataEntity.GetValue("DocumentCode"), DataType = nodeInfo.ConfigInfo.Name, Type = type, NodeID = nodeInfo.ID, NodeName = nodeInfo.Name, State = ItemState.New.ToString(), CreateDate = DateTime.Now, CreateUser = user.UserName, CreateUserID = user.UserID, ConfigID = nodeInfo.ConfigInfo.ID, SpaceID = nodeInfo.Space.ID }; entities.Set <S_CarInfo>().Add(carInfo); } }
private void addParentNode(S_NodeInfo rootNode, S_NodeInfo leafNode, List <Dictionary <string, object> > addList) { if (leafNode.ID == rootNode.ID) { return; } else { if (addList.FirstOrDefault(a => a.GetValue("UID") == leafNode.ID) == null) { var pDic = new Dictionary <string, object>(); pDic.Add("ID", ""); pDic.Add("UID", leafNode.ID); pDic.Add("ParentUID", leafNode.ParentID); pDic.Add("RelateID", leafNode.ID); pDic.Add("Name", leafNode.Name); pDic.Add("Code", leafNode.DataEntity.GetValue("DocumentCode")); pDic.Add("SpaceID", leafNode.Space.ID); pDic.Add("SpaceName", leafNode.Space.Name); pDic.Add("DataType", leafNode.ConfigInfo.Name); pDic.Add("DetailType", NodeType.Node.ToString()); addList.Add(pDic); } addParentNode(rootNode, leafNode.Parent, addList); } }
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); } }
public JsonResult ArchiveReorganize(string FileList, string SpaceID, string TargetNodeID) { //直接归档 var docSpace = DocConfigHelper.CreateConfigSpaceByID(SpaceID); S_NodeInfo node = S_NodeInfo.GetNode(TargetNodeID, SpaceID); var list = JsonHelper.ToList(FileList); StringBuilder sb = new StringBuilder(); foreach (var item in list) { var archFileID = item.GetValue("ArchiveFileID"); if (string.IsNullOrEmpty(archFileID)) { //新增档案文件记录 S_FileInfo fileInfo = archFile(item, node, item.GetValue("ConfigID")); archFileID = fileInfo.ID; item.SetValue("ArchiveFileID", archFileID); } else { //移动文件 S_FileInfo fileInfo = new S_FileInfo(archFileID, docSpace); fileInfo.MoveTo(TargetNodeID, item.GetValue("ConfigID")); } var sql = "update S_R_Reorganize_DocumentList set ReorganizePath='{1}',ReorganizeFullID='{2}',ArchiveFileID='{3}',ReorganizeConfigID='{4}' where id='{0}'"; sql = string.Format(sql, item.GetValue("ID"), item.GetValue("ReorganizePath"), item.GetValue("ReorganizeFullID"), archFileID, item.GetValue("ConfigID")); sb.AppendLine(sql); } if (sb.Length > 0) { this.SqlHelper.ExecuteNonQuery(sb.ToString()); } return(Json(list)); }
protected override void AfterSave(S_NodeInfo node, Dictionary <string, object> row, bool isNew) { string ReorganizeID = GetQueryString("ReorganizeID"); if (!isNew) { node.SynchronizeAttr(); } node.DataEntity["HasFile"] = 0;//是否可以添加文件(整编区,整编界面右侧树增加节点需要此配置)' if (node.ConfigInfo.S_DOC_FileNodeRelation.Count > 0) { //node.DataEntity["HasFile"] = 1; node.DataEntity["HasFile"] = string.Join(",", node.ConfigInfo.S_DOC_FileNodeRelation.Select(a => a.FileID)); } if (!string.IsNullOrEmpty(ReorganizeID)) { var Reorganize = FormulaHelper.GetEntities <DocConstEntities>().S_R_PhysicalReorganize.Where(a => a.ID.Equals(ReorganizeID)).ToList(); if (Reorganize.Count > 0) { new DocSystem.Areas.Reorganize.Controllers.PhysicalController().saveRootNodes(node.FullPathID, "", ReorganizeID, node.Space.ID);//实物存储 } else { new DocSystem.Areas.Reorganize.Controllers.MainController().saveRootNodes(node.FullPathID, "", ReorganizeID, node.Space.ID);//电子存储 } } }
public JsonResult getnodefiletabs() { string ID = this.GetQueryString("ID"); var arraylist = new ArrayList(); var fileRelations = this.Config.S_DOC_FileNodeRelation.OrderBy(d => d.Sort).ToList(); var node = S_NodeInfo.GetNode(ID, this.SpaceID); foreach (var item in fileRelations) { var fileconfig = item.S_DOC_File; var url = "../FileManager/List?SpaceID=" + this.SpaceID + "&ConfigID=" + fileconfig.ID + "&NodeID=" + ID + "&FullPathID=" + node.FullPathID; if (String.IsNullOrEmpty(fileconfig.PreCondition)) { arraylist.Add(createTab(item.S_DOC_File.Name, url)); } else { string sql = "select count(0) from S_NodeInfo where ID='" + ID + "' and " + fileconfig.PreCondition; var dt = this.InstanceDB.ExecuteDataTable(sql); if (dt != null && dt.Rows.Count > 0) { arraylist.Add(createTab(item.S_DOC_File.Name, url)); } } } return(Json(arraylist, JsonRequestBehavior.AllowGet)); }
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); } } }
private void SetDefualtValue(Dictionary <string, object> result, string attrAttrField, string attrDefaultValue, S_NodeInfo parent) { var attrs = this.Config.S_DOC_NodeAttr.Where(d => !String.IsNullOrEmpty(d.DefaultValue)); foreach (var attr in attrs) { if (attr.DefaultValue.IndexOf("{") >= 0) { var defaultStr = attr.DefaultValue.Replace("{", "").Replace("}", ""); if (defaultStr == "Now") { result.SetValue(attr.AttrField, DateTime.Now); } else if (defaultStr == "UserID") { result.SetValue(attr.AttrField, CurrentUserInfo.UserID); } else if (defaultStr == "UserName") { result.SetValue(attr.AttrField, CurrentUserInfo.UserName); } else if (parent != null) { var defaultValue = attr.DefaultValue.Replace("{", "").Replace("}", "").Split(':'); if (defaultValue.Length > 1) { var nodePositon = defaultValue[0]; var defaultField = defaultValue[1]; if (nodePositon == "Root") { if (parent.RootNode.DataEntity.ContainsKey(defaultField)) { result.SetValue(attr.AttrField, parent.RootNode.DataEntity[defaultField]); } } else { S_NodeInfo node = _getParentNode(parent, nodePositon.Split('.').Length); if (node.DataEntity.ContainsKey(defaultField)) { result.SetValue(attr.AttrField, node.DataEntity[defaultField]); } } } } } else { result.SetValue(attr.AttrField, attr.DefaultValue); } } }
public JsonResult MoveDown(string ID, string SpaceID, string TargetNodeID) { var space = DocConfigHelper.CreateConfigSpaceByID(SpaceID); if (space == null) { throw new BusinessException("未指定档案实体空间,无法获取数据访问对象"); } var node = new S_NodeInfo(ID, space); node.MoveDown(TargetNodeID); return(Json("")); }
void SetAttr(S_NodeInfo node, Dictionary <string, object> dic) { foreach (string key in dic.Keys) { if (key == "ID" || key == "ParentID" || key == "FullPathID" || key == "SpaceID" || key == "ConfigID" || key == "State" || key == "BorrowState" || key == "BorrowUserID" || key == "BorrowUserName") { continue; } node.DataEntity.SetValue(key, dic.GetValue(key)); } }
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 virtual JsonResult GetModel(string id) { Dictionary <string, object> result = new Dictionary <string, object>(); bool isNew = false; if (String.IsNullOrEmpty(id)) { isNew = true; var nodeID = this.Request["NodeID"]; if (String.IsNullOrEmpty(nodeID)) { nodeID = this.GetQueryString("NodeID"); } result.SetValue("NodeID", nodeID); result.SetValue("ConfigID", this.ConfigID); var node = S_NodeInfo.GetNode(nodeID, this.SpaceID); var attrs = this.Config.S_DOC_FileAttr.Where(d => !String.IsNullOrEmpty(d.DefaultValue)); foreach (var attr in attrs) { if (attr.DefaultValue.Split(',').Length > 0 && attr.InputType.IndexOf(ControlType.ButtonEdit.ToString()) >= 0) { SetDefualtValue(result, attr.FileAttrField, attr.DefaultValue.Split(',')[0], node); SetDefualtValue(result, attr.FileAttrField + "Name", attr.DefaultValue.Split(',')[1], node); } else { SetDefualtValue(result, attr.FileAttrField, attr.DefaultValue, node); } } } else { var file = new S_FileInfo(id, this.Space); result = file.DataEntity; if (file.CurrentAttachment != null) { result["MainFile"] = file.CurrentAttachment.DataEntity.GetValue("MainFile"); result["Attachments"] = file.CurrentAttachment.DataEntity.GetValue("Attachments"); result["PdfFile"] = file.CurrentAttachment.DataEntity.GetValue("PDFFile"); result["PlotFile"] = file.CurrentAttachment.DataEntity.GetValue("PlotFile"); result["XrefFile"] = file.CurrentAttachment.DataEntity.GetValue("XrefFile"); result["DwfFile"] = file.CurrentAttachment.DataEntity.GetValue("DwfFile"); result["TiffFile"] = file.CurrentAttachment.DataEntity.GetValue("TiffFile"); result["SignPdfFile"] = file.CurrentAttachment.DataEntity.GetValue("SignPdfFile"); result["AtlasFile"] = JsonHelper.ToList(file.CurrentAttachment.DataEntity.GetValue("AtlasFile")); } } this.AfterGetMode(result, isNew); return(Json(result)); }
public virtual void forbidden() { string listIDs = Request["ID"]; foreach (var ID in listIDs.Split(',')) { if (Tool.IsNullOrEmpty(ID)) { continue; } var node = S_NodeInfo.GetNode(ID, this.SpaceID); node.Recover(); } }
public void applynodeborrow(List <Dictionary <string, object> > nodes) { var docConstEntities = FormulaHelper.GetEntities <DocConstEntities>(); var list = nodes; foreach (var item in list) { var space = DocConfigHelper.CreateConfigSpaceByID(item.GetValue("SpaceID")); // var FileInfo = docConstEntities.T_Borrow_FileInfo.FirstOrDefault(d => d.T_BorrowID == item.GetValue("BorrowID") && d.FileName == item.GetValue("Name")); S_NodeInfo nodeInfo = new S_NodeInfo(item.GetValue("RelateID"), space); if (nodeInfo == null) { continue; } if (nodeInfo.ConfigInfo == null) { throw new Formula.Exceptions.BusinessException("未能找到文件【" + nodeInfo.ID + "】的配置对象信息"); } var carInfo = docConstEntities.S_CarInfo.FirstOrDefault(d => d.UserID == this.CurrentUserInfo.UserID && d.NodeID == nodeInfo.ID && d.State == "New" && d.Type == "Borrow" && d.DataType == nodeInfo.ConfigInfo.Name); if (carInfo == null) { carInfo = new S_CarInfo(); carInfo.ID = FormulaHelper.CreateGuid();; carInfo.Name = nodeInfo.CreateCarName(); //nodeInfo.Name; carInfo.NodeID = nodeInfo.ID; carInfo.NodeName = nodeInfo.Name; carInfo.SpaceID = item.GetValue("SpaceID"); carInfo.State = "New"; carInfo.Type = ItemType.Borrow.ToString(); carInfo.UserID = this.CurrentUserInfo.UserID; carInfo.UserName = this.CurrentUserInfo.UserName; //carInfo.Code = nodeInfo.; carInfo.ConfigID = nodeInfo.ConfigInfo.ID; carInfo.CreateDate = DateTime.Now; carInfo.CreateUser = this.CurrentUserInfo.UserName; carInfo.CreateUserID = this.CurrentUserInfo.UserID; carInfo.DataType = nodeInfo.ConfigInfo.Name; docConstEntities.S_CarInfo.Add(carInfo); } else if (list.Count == 1) { throw new Formula.Exceptions.BusinessException("【" + nodeInfo.Name + "】已在借阅车中,请前往借阅车申请借阅"); } } docConstEntities.SaveChanges(); }
private S_NodeInfo _getParentNode(S_NodeInfo parent, int len) { var node = parent; if (len == 1) { return(node); } else { for (int i = 0; i < len - 2; i++) { if (parent.Parent != null) { node = parent.Parent; } } } return(node); }
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); } } }
public static void CreateInventoryLedger(S_NodeInfo node, InventoryType type, int totalAmount, int inventoryAmount, string relateDetailInfoID, string targetUserID = "", string targetUserName = "", string detail = "") { DocConstEntities entities = FormulaHelper.GetEntities <DocConstEntities>(); var currentUser = FormulaHelper.GetUserInfo(); var InventoryLedger = new S_A_InventoryLedger { CarItemName = "", CreateDate = System.DateTime.Now, CreateUserID = currentUser.UserID, CreateUserName = currentUser.UserName, SpaceID = node.Space.ID, Type = type.ToString(), Detail = detail, CreateDept = currentUser.UserDeptNames, InventoryAmount = inventoryAmount, TotalAmount = totalAmount, RelateID = node.ID, RelateName = node.Name, RelateType = ListConfigType.File.ToString(), RelateDetailInfoID = relateDetailInfoID, TargetUserID = targetUserID, TargetUserName = targetUserName }; var qNum = int.Parse(string.IsNullOrEmpty(node.DataEntity.GetValue("Quantity")) ? "0" : node.DataEntity.GetValue("Quantity")) + totalAmount; node.DataEntity.SetValue("Quantity", qNum); var sNum = int.Parse(string.IsNullOrEmpty(node.DataEntity.GetValue("StorageNum")) ? "0" : node.DataEntity.GetValue("StorageNum")) + inventoryAmount; node.DataEntity.SetValue("StorageNum", sNum); if (qNum < 0 || sNum < 0) { throw new Formula.Exceptions.BusinessException("遗失份数大于库存,请重新填写"); } node.Save(false); entities.Set <S_A_InventoryLedger>().Add(InventoryLedger); entities.SaveChanges(); }
public virtual JsonResult GetModel(string id) { var db = SQLHelper.CreateSqlHelper(this.Space.SpaceKey, this.Space.ConnectString); var entityDic = new Dictionary <string, object>(); bool isNew = false; if (String.IsNullOrEmpty(id)) { isNew = true; string parentID = this.Request["ParentID"]; string configID = this.Request["ConfigID"]; entityDic["ParentID"] = parentID; entityDic["ConfigID"] = configID; S_NodeInfo parent = null; if (!string.IsNullOrEmpty(parentID)) { parent = S_NodeInfo.GetNode(parentID, this.SpaceID); } var attrs = this.Config.S_DOC_NodeAttr.Where(d => !String.IsNullOrEmpty(d.DefaultValue)); foreach (var attr in attrs) { if (attr.DefaultValue.Split(',').Length > 0 && attr.InputType.IndexOf(ControlType.ButtonEdit.ToString()) >= 0) { SetDefualtValue(entityDic, attr.AttrField, attr.DefaultValue.Split(',')[0], parent); SetDefualtValue(entityDic, attr.AttrField + "Name", attr.DefaultValue.Split(',')[1], parent); } else { SetDefualtValue(entityDic, attr.AttrField, attr.DefaultValue, parent); } } } else { var node = new S_NodeInfo(id, this.Space); entityDic = node.DataEntity; } this.AfterGetMode(entityDic, isNew); return(Json(entityDic)); }
//保存时对比数据是否修改 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 virtual JsonResult gettreelist(bool isPublished = false) { string nodeID = this.Request["ID"]; var node = S_NodeInfo.GetNode(nodeID, this.SpaceID); var root = node.RootNode; string sql = @"select {0},case when ParentID='' or ParentID is null then 'Root' else 'Child' end as Type from S_NodeInfo where 1=1 " + (isPublished ? "and State='Published'" : "") + " and FullPathID like '" + root.FullPathID + "%' and SpaceID='" + this.SpaceID + "' {1}"; var treeConfig = this.Space.S_DOC_TreeConfig.FirstOrDefault(); if (treeConfig != null) { sql = String.Format(sql, treeConfig.GetDisplayStr(), treeConfig.GetOrderByStr()); } else { sql = String.Format(sql, treeConfig.GetDisplayStr(), ""); } var dt = this.InstanceDB.ExecuteDataTable(sql); return(Json(dt, JsonRequestBehavior.AllowGet)); }
private List <Dictionary <string, object> > getChildNodeList(S_NodeInfo nodeInfo, List <Dictionary <string, object> > listData, Dictionary <string, object> row) { var nodeList = new List <Dictionary <string, object> >(); foreach (var childNode in nodeInfo.Children) { var newItem = listData.FirstOrDefault(a => a.GetValue("UID") == childNode.ID && a.GetValue("ParentID") == row.GetValue("ID")); if (newItem == null) { newItem = new Dictionary <string, object>(); newItem.Add("ID", ""); newItem.Add("Name", childNode.Name); newItem.Add("Code", childNode.DataEntity.GetValue("DocumentCode")); newItem.Add("SpaceID", childNode.Space.ID); newItem.Add("SpaceName", childNode.Space.Name); newItem.Add("DataType", childNode.ConfigInfo.Name); newItem.Add("DetailType", NodeType.Node.ToString()); newItem.Add("RelateID", childNode.ID); newItem.Add("ConfigID", childNode.ConfigInfo.ID); newItem.Add("LendNumber", ""); newItem.Add("ParentID", row.GetValue("ID")); } newItem.SetValue("UID", childNode.ID); newItem.SetValue("ParentUID", childNode.ParentID); newItem.SetValue("ApplyNumber", row.GetValue("ApplyNumber")); newItem.SetValue("Quantity", childNode.DataEntity.GetValue("Quantity")); newItem.SetValue("StorageNumber", childNode.DataEntity.GetValue("StorageNum")); var thisFileList = getFileList(childNode, listData, row); var thisChildNodeList = getChildNodeList(childNode, listData, row); thisChildNodeList.AddRange(thisFileList); newItem.SetValue("children", thisChildNodeList); nodeList.Add(newItem); } return(nodeList); }
public JsonResult ApplyNodeBorrow(string nodes, string SpaceID) { var space = DocConfigHelper.CreateConfigSpaceByID(SpaceID); if (space == null) { throw new Formula.Exceptions.BusinessException("为找到【ID】为【" + SpaceID + "】的图档实例库"); } var list = JsonHelper.ToList(nodes); foreach (var item in list) { S_NodeInfo nodeInfo = new S_NodeInfo(item.GetValue("ID"), space); if (nodeInfo == null) { continue; } CarFO.CreateCarItem(nodeInfo, ItemType.Borrow.ToString()); } this.entities.SaveChanges(); return(Json(new { })); }
//遗失损毁校验 public void LostDamageVerifica(Dictionary <string, string> dic, List <Dictionary <string, object> > lostReplenishList) { 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() : "";//遗失损毁状态 } int lostReplenishCount = lostReplenishCount = Convert.ToInt32(lostReplenishDetail["LoseCount"]); if (relateDocType.ToLower() == "node") { S_NodeInfo node = new S_NodeInfo(relateID, space); object storageNum = null; node.DataEntity.TryGetValue("StorageNum", out storageNum); if (lostReplenishCount > Convert.ToInt32(storageNum)) { throw new Formula.Exceptions.BusinessException("遗失份数大于库存,请重新填写"); } continue; } else { S_FileInfo file = new S_FileInfo(relateID, space); object storageNum = null; file.DataEntity.TryGetValue("StorageNum", out storageNum); if (lostReplenishCount > Convert.ToInt32(storageNum)) { throw new Formula.Exceptions.BusinessException("遗失份数大于库存,请重新填写"); } continue; } } }
public static void CreateNewInventoryLedger(S_NodeInfo node, string detail = "", InventoryType type = InventoryType.StorageIn) { DocConstEntities entities = FormulaHelper.GetEntities <DocConstEntities>(); var currentUser = FormulaHelper.GetUserInfo(); var InventoryLedger = new S_A_InventoryLedger { SpaceID = node.Space.ID, RelateID = node.ID, RelateName = node.Name, RelateType = InventoryRelateType.Node.ToString(), RelateDetailInfoID = "", CarItemName = "", Type = type.ToString(), Detail = detail, CreateDept = currentUser.UserDeptNames, CreateDate = System.DateTime.Now, CreateUserID = currentUser.UserID, CreateUserName = currentUser.UserName, TargetUserID = "", TargetUserName = "" }; if (!string.IsNullOrEmpty(node.DataEntity.GetValue("Quantity"))) { var num = 0; if (int.TryParse(node.DataEntity.GetValue("Quantity"), out num)) { InventoryLedger.TotalAmount = num; InventoryLedger.InventoryAmount = num; } if (num == 0) { return; } } entities.Set <S_A_InventoryLedger>().Add(InventoryLedger); entities.SaveChanges(); }
public JsonResult GetBorrowDetailTree(string ListData) { var listData = JsonHelper.ToList(ListData); var tree = new List <Dictionary <string, object> >(); foreach (var item in listData) { if (item.GetValue("_level") == "0") { tree.Add(item); var space = DocConfigHelper.CreateConfigSpaceByID(item.GetValue("SpaceID")); if (item.GetValue("DetailType") == NodeType.Node.ToString()) { var nodeInfo = new S_NodeInfo(item.GetValue("RelateID"), space); var fileList = getFileList(nodeInfo, listData, item); var childList = getChildNodeList(nodeInfo, listData, item); childList.AddRange(fileList); item.SetValue("children", childList); } } } return(Json(tree)); }
public virtual JsonResult Save() { string json = Request.Form["FormData"]; bool isNew = false; var row = JsonHelper.ToObject <Dictionary <string, object> >(json); S_NodeInfo node; if (!row.ContainsKey("ID") || Tool.IsNullOrEmpty(row["ID"])) { isNew = true; node = new S_NodeInfo(this.SpaceID, this.ConfigID); } else { node = new S_NodeInfo(row["ID"].ToString(), this.Space); } node.SetData(row); BeforeSave(node, row, isNew); node.Save(); AfterSave(node, row, isNew); return(Json(node.DataEntity)); }
public JsonResult ReturnNode() { var ids = this.GetQueryString("ListIDs").Split(','); if (ids.Length == 0) { ids = this.GetQueryString("ID").Split(','); } var spaceID = this.GetQueryString("SpaceID"); var user = FormulaHelper.GetUserInfo(); var space = DocConfigHelper.CreateConfigSpaceByID(spaceID); foreach (var nodeID in ids) { var node = new S_NodeInfo(nodeID, space); node.DataEntity.SetValue("BorrowState", ""); node.DataEntity.SetValue("BorrowUserID", ""); node.DataEntity.SetValue("BorrowUserName", ""); node.Save(false); } var list = this.BusinessEntities.Set <S_BorrowDetail>().Where(a => ids.Contains(a.RelateID)).ToList(); foreach (var item in list) { if (item.BorrowState == BorrowReturnState.Return.ToString()) { continue; } item.ReturnDate = DateTime.Now; item.ReturnUserID = user.UserID; item.ReturnUser = user.UserName; item.BorrowState = BorrowReturnState.Return.ToString(); } this.BusinessEntities.SaveChanges(); return(Json("")); }
public virtual JsonResult Delete() { string listIDs = Request["ListIDs"]; foreach (var ID in listIDs.Split(',')) { var node = new S_NodeInfo(ID, this.Space); BeforeDelete(node); node.Delete(); AfterDelete(node); } //清空S_R_PhysicalReorganize_NodeDetail中的归档目录 string[] archiveIDs = listIDs.Split(new char[] { ',' }); var nodeDetailEntity = FormulaHelper.GetEntities <DocConstEntities>().S_R_PhysicalReorganize_NodeDetail.Where(a => archiveIDs.Contains(a.ArchiveVolumnID)).Select(a => a).ToList(); foreach (var nodeDetail in nodeDetailEntity) { nodeDetail.ReorganizeFullID = ""; nodeDetail.ReorganizePath = ""; nodeDetail.ArchiveVolumnID = ""; } FormulaHelper.GetEntities <DocConstEntities>().SaveChanges(); return(Json("")); }
private List <Dictionary <string, object> > getFileList(S_NodeInfo nodeInfo, List <Dictionary <string, object> > listData, Dictionary <string, object> row) { var fileList = new List <Dictionary <string, object> >(); foreach (var fileInfo in nodeInfo.FileInfos) { if (fileInfo.DataEntity.GetValue("State") != DocState.Published.ToString()) { continue; } var newItem = listData.FirstOrDefault(a => a.GetValue("UID") == fileInfo.ID && a.GetValue("ParentID") == row.GetValue("ID")); if (newItem == null) { newItem = new Dictionary <string, object>(); newItem.Add("ID", ""); newItem.Add("Name", fileInfo.Name); newItem.Add("Code", fileInfo.DataEntity.GetValue("Code")); newItem.Add("SpaceID", fileInfo.Space.ID); newItem.Add("SpaceName", fileInfo.Space.Name); newItem.Add("DataType", fileInfo.ConfigInfo.Name); newItem.Add("DetailType", NodeType.File.ToString()); newItem.Add("RelateID", fileInfo.ID); newItem.Add("ConfigID", fileInfo.ConfigInfo.ID); newItem.Add("LendNumber", ""); newItem.Add("ParentID", row.GetValue("ID")); } newItem.SetValue("UID", fileInfo.ID); newItem.SetValue("ParentUID", nodeInfo.ID); newItem.SetValue("ApplyNumber", row.GetValue("ApplyNumber")); newItem.SetValue("Quantity", fileInfo.DataEntity.GetValue("Quantity")); newItem.SetValue("StorageNumber", fileInfo.DataEntity.GetValue("StorageNum")); fileList.Add(newItem); } return(fileList); }