//移除实物整编结点 public JsonResult RemoveReorganizeNode(string nodeID, string ReorganizeID) { string spaceID = GetQueryString("SpaceID"); var space = FormulaHelper.GetEntities <DocConfigEntities>().S_DOC_Space.FirstOrDefault(a => a.ID == spaceID); List <S_R_Reorganize_DocumentList> fileDetailList = entities.Set <S_R_Reorganize_DocumentList>().Where(a => a.S_R_ReorganizeID == ReorganizeID && a.ReorganizeFullID.Contains(nodeID)).ToList(); if (fileDetailList.Count > 0) { throw new Formula.Exceptions.BusinessException("有归档文件,不可移除"); } S_R_Reorganize PhysicalData = entities.Set <S_R_Reorganize>().FirstOrDefault(a => a.ID == ReorganizeID); List <string> nodeIDs = PhysicalData.SelectNodeIDs.Split(new char[] { ',' }, StringSplitOptions.RemoveEmptyEntries).ToList <string>();//全部路径ID string fullIDSql = "select FullPathID from S_NodeInfo where ID='" + nodeID + "'"; SQLHelper sqlHelper = SQLHelper.CreateSqlHelper(space.SpaceKey, space.ConnectString); string fullID = sqlHelper.ExecuteScalar(fullIDSql).ToString(); //得到移除节点的全路径 string sql = @"select ID from S_NodeInfo where FullPathID like '" + fullID + "%'"; //得到移除节点及子节点ID DataRowCollection rows = sqlHelper.ExecuteDataTable(sql).Rows; List <string> listIDs = new List <string>(); foreach (DataRow row in rows) { listIDs.Add(row["ID"].ToString()); } nodeIDs.RemoveWhere(a => listIDs.Contains(a.ToString())); PhysicalData.SelectNodeIDs = string.Join(",", nodeIDs); entities.SaveChanges(); return(Json("")); }
//在整编操作页面,修改签收登记下的归档目录选择 public void saveRootNodes(string FullPathIDs, string names, string ReorganizeID, string spaceID) { S_R_Reorganize PhysicalReorganize = FormulaHelper.GetEntities <DocConstEntities>().S_R_Reorganize.FirstOrDefault(a => a.ID == ReorganizeID); string nodeIds = string.Empty; var space = FormulaHelper.GetEntities <DocConfigEntities>().S_DOC_Space.FirstOrDefault(a => a.ID.Equals(spaceID)); //得到选中节点的子节点id FullPathIDs = FullPathIDs.TrimEnd(','); string sqlNodeId = "select ID from S_NodeInfo where FullPathID like '" + FullPathIDs.Replace(",", "% or FullPathID like") + "%'"; string nodeFullPathIDs = string.Empty; sqlNodeId = string.Format(sqlNodeId); SQLHelper helper = SQLHelper.CreateSqlHelper(space.SpaceKey, space.ConnectString); DataRowCollection Rows = helper.ExecuteDataTable(sqlNodeId).Rows; string nodeChildrenId = string.Empty; foreach (DataRow row in Rows) { nodeChildrenId += row["ID"] + ","; } if (!string.IsNullOrEmpty(PhysicalReorganize.SelectNodeIDs)) { FullPathIDs += "," + PhysicalReorganize.SelectNodeIDs; } if (!string.IsNullOrEmpty(nodeChildrenId)) { FullPathIDs += "," + nodeChildrenId.TrimEnd(','); } List <string> fullPathNodeIDs = GetUniqFullPathIDs(FullPathIDs); //string defaultNodesIds = string.Empty; PhysicalReorganize.SelectNodeIDs = string.Join(",", fullPathNodeIDs); FormulaHelper.GetEntities <DocConstEntities>().SaveChanges(); }
public JsonResult GetNodeTreeList(QueryBuilder qb) { var reorganizeID = GetQueryString("ReorganizeID"); S_R_Reorganize Reorganize = FormulaHelper.GetEntities <DocConstEntities>().S_R_Reorganize.FirstOrDefault(a => a.ID.Equals(reorganizeID)); // string[] defaultNodes = Reorganize.DefaultNodes.Split(new char[] { ',' }, StringSplitOptions.RemoveEmptyEntries); //var sql = @"select * from S_R_Reorganize where ID='" + reorganizeID + "'"; //var reogDetailList = this.SqlHelper.ExecuteList<S_R_Reorganize>(sql); //var ids = string.Join(",", reogDetailList.Where(a => !string.IsNullOrEmpty(a.DefaultNodes)) // .Select(a => a.DefaultNodes).Distinct().ToArray()); //ids = ids.TrimEnd(','); var spaceID = this.GetQueryString("SpaceID"); if (!string.IsNullOrEmpty(Reorganize.SelectNodeIDs)) { return(GetSelectedTreeList(Reorganize.SelectNodeIDs, spaceID)); } else { return(Json("")); } }
public JsonResult Reorganize(string ProjectInfoID, bool IsAll, string Files) { S_I_ProjectInfo projectInfo = this.GetEntityByID <S_I_ProjectInfo>(ProjectInfoID); if (projectInfo == null) { throw new Formula.Exceptions.BusinessException("未能找到项目信息,无法归档"); } var docList = this.entities.Set <S_D_Document>().Where(d => d.ProjectInfoID == ProjectInfoID && d.State != "Archive").ToList(); var _group = docList.GroupBy(a => a.RelateID).Select(a => new { a.Key, MaxVersion = a.Max(b => (string.IsNullOrEmpty(b.Version) ? 0d : Convert.ToDouble(b.Version))) } ).ToList(); var fileList = JsonHelper.ToList(Files); if (fileList.Count == 0) { throw new Formula.Exceptions.BusinessException("暂无文件清单,请先添加归档文件"); } if (!IsAll) { docList = docList.Where(a => _group.Any(g => g.Key == a.RelateID && g.MaxVersion == (string.IsNullOrEmpty(a.Version) ? 0d : Convert.ToDouble(a.Version)))).ToList(); } if (docList.Count > 0) { S_R_Reorganize entity = new S_R_Reorganize(); entity.TaskName = projectInfo.Name; entity.BusinessID = projectInfo.ID; foreach (var doc in docList) { S_R_Reorganize_DocumentList item = new S_R_Reorganize_DocumentList(); entity.S_R_Reorganize_DocumentList.Add(item); FormulaHelper.UpdateModel(item, doc); item.RelateID = doc.ID; item.RelateTable = "S_D_Document"; item.MainFile = doc.MainFiles; doc.State = "Archive"; doc.ArchiveDate = new DateTime?(DateTime.Now); } new ReorganizeFO().CreateReorganize("DesignDoc", entity); this.entities.SaveChanges(); } return(Json("")); }
public JsonResult ReorganizeFile(string ProjectInfoID, string Files) { S_I_ProjectInfo projectInfo = this.GetEntityByID <S_I_ProjectInfo>(ProjectInfoID); if (projectInfo == null) { throw new Formula.Exceptions.BusinessException("未能找到项目信息,无法归档"); } var fileList = JsonHelper.ToList(Files); if (fileList.Count == 0) { throw new Formula.Exceptions.BusinessException("暂无文件清单,请先添加归档文件"); } fileList = fileList.Where(a => !a.Keys.Contains("NewAdd") || (a.Keys.Contains("NewAdd") && a.GetValue("NewAdd") != "T")).ToList(); if (fileList.Count > 0) { S_R_Reorganize entity = new S_R_Reorganize(); entity.TaskName = projectInfo.Name; entity.BusinessID = projectInfo.ID; foreach (var filedic in fileList) { var doc = this.GetEntityByID <S_D_Document>(filedic.GetValue("DocumentID")); if (doc == null) { continue; } S_R_Reorganize_DocumentList item = new S_R_Reorganize_DocumentList(); entity.S_R_Reorganize_DocumentList.Add(item); FormulaHelper.UpdateModel(item, doc); item.RelateID = doc.ID; item.RelateTable = "S_D_Document"; item.MainFile = doc.MainFiles; doc.State = "Archive"; doc.ArchiveDate = new DateTime?(DateTime.Now); } new ReorganizeFO().CreateReorganize("DesignDoc", entity); this.entities.SaveChanges(); } return(base.Json("")); }
public void CreateReorganize(string spaceKey, S_R_Reorganize reorganizeTask) { DocConstEntities entities = FormulaHelper.GetEntities <DocConstEntities>(); var docConfigEntities = FormulaHelper.GetEntities <DocConfigEntities>(); var currentUser = FormulaHelper.GetUserInfo(); var space = docConfigEntities.Set <S_DOC_Space>().FirstOrDefault(a => a.SpaceKey == spaceKey); if (space == null) { throw new Formula.Exceptions.BusinessException("送整编错误:未能找到编号为【" + spaceKey + "】的图档空间配置"); } if (reorganizeTask.S_R_Reorganize_DocumentList == null || reorganizeTask.S_R_Reorganize_DocumentList.Count == 0) { throw new Formula.Exceptions.BusinessException("送整编错误:明细列表不能为空"); } if (string.IsNullOrEmpty(reorganizeTask.ID)) { reorganizeTask.ID = FormulaHelper.CreateGuid(); } if (string.IsNullOrEmpty(reorganizeTask.SendUser)) { reorganizeTask.SendUser = currentUser.UserID; reorganizeTask.SendUserName = currentUser.UserName; } if (reorganizeTask.SendDate == null) { reorganizeTask.SendDate = new DateTime?(DateTime.Now); } reorganizeTask.SpaceID = space.ID; reorganizeTask.ReorganizeState = ReorganizeState.Create.ToString(); reorganizeTask.DocumentList = JsonHelper.ToJson <List <S_R_Reorganize_DocumentList> >(reorganizeTask.S_R_Reorganize_DocumentList.ToList <S_R_Reorganize_DocumentList>()); foreach (var item in reorganizeTask.S_R_Reorganize_DocumentList) { if (string.IsNullOrEmpty(item.ID)) { item.ID = FormulaHelper.CreateGuid(); } item.S_R_ReorganizeID = reorganizeTask.ID; } entities.Set <S_R_Reorganize>().Add(reorganizeTask); entities.SaveChanges(); }
public JsonResult GetSelectedTreeList(string DefaultNodes, string SpaceID, bool ShowFile = false) { var space = DocConfigHelper.CreateConfigSpaceByID(SpaceID); if (space == null) { throw new BusinessException("未指定档案实体空间,无法获取数据访问对象"); } //string idStrs = "FullPathID like '" + IDs.Replace(",", "%' or FullPathID like '") + "%' or ( '" + IDs.Replace(",", "' like FullPathID+'%' or '") + "' like FullPathID+'%')";//查出所有上层节点与自身及下层节点 string idStrs = "id in {0}"; string nodeIDs = GetQueryString("nodeIDs"); if (!string.IsNullOrEmpty(nodeIDs)) { string sqlFullPathId = "select FullPathID,Name from S_NodeInfo where ID in ('{0}')"; string nodeFullPathIDs = string.Empty; sqlFullPathId = string.Format(sqlFullPathId, nodeIDs.Replace(",", "','")); SQLHelper helper = SQLHelper.CreateSqlHelper(space.SpaceKey, space.ConnectString); DataRowCollection Rows = helper.ExecuteDataTable(sqlFullPathId).Rows; string nodeNames = string.Empty; foreach (DataRow row in Rows) { nodeFullPathIDs += row["FullPathID"] + ","; } nodeFullPathIDs = nodeFullPathIDs.TrimEnd(','); idStrs = string.Format(idStrs, "('" + nodeFullPathIDs.Replace(",", ".").Replace(".", "','") + "') or FullPathID like '" + nodeFullPathIDs.Replace(",", "%' or FullPathID like '") + "%'"); } else { string ReorganizeFullID = string.Join("','", GetUniqFullPathIDs(DefaultNodes)); if (!string.IsNullOrEmpty(ReorganizeFullID)) { idStrs = string.Format(idStrs, "('" + ReorganizeFullID + "')"); } } string sql = @"select ID,ParentID,{0},FullPathID,ConfigID,'' as NodeType,'' rootRemove from S_NodeInfo where (" + idStrs + ") and SpaceID='" + SpaceID + "' {1}"; S_R_Reorganize reorganize = new S_R_Reorganize(); string ReorganizeID = GetQueryString("ReorganizeID"); if (!string.IsNullOrEmpty(ReorganizeID)) { reorganize = FormulaHelper.GetEntities <DocConstEntities>().S_R_Reorganize.FirstOrDefault(a => a.ID == ReorganizeID); } var treeConfig = space.S_DOC_TreeConfig.FirstOrDefault(); if (treeConfig != null) { sql = String.Format(sql, "Name", treeConfig.GetOrderByStr()); } else { sql = String.Format(sql, "Name", ""); } var instanceDB = SQLHelper.CreateSqlHelper(space.SpaceKey, space.ConnectString); var dt = instanceDB.ExecuteDataTable(sql); var fileSql = "select ID,Name,NodeID as ParentID,FullNodeID+'.'+ID as FullPathID,ConfigID from S_FileInfo where NodeID in (select ID from (" + (treeConfig != null ? sql.Replace(treeConfig.GetOrderByStr(), "") : sql) + ") tmp)"; var fileDt = instanceDB.ExecuteDataTable(fileSql); //节点都能关联文件 //var fileNodeIDs = space.S_DOC_Node.Where(a => a.S_DOC_FileNodeRelation.Count > 0).Select(a => a.ID).ToList(); var resultDt = dt.Clone(); foreach (DataRow row in dt.Rows) { var configID = row["ConfigID"].ToString(); var config = space.S_DOC_Node.FirstOrDefault(a => a.ID == configID); //if (fileNodeIDs.Contains(configID)) // row["HasFile"] = 1; if (DefaultNodes.Split(',').Contains(row["ID"].ToString())) { row["NodeType"] = "Root"; } else { row["NodeType"] = "Child"; } resultDt.ImportRow(row); var fileRelationList = config.S_DOC_FileNodeRelation.ToList(); foreach (var relation in fileRelationList) { var relationRow = resultDt.NewRow(); //虚拟文件类型节点 relationRow["ID"] = row["ID"].ToString() + '.' + relation.FileID; //NodeID.FileConfigID 作为虚拟节点ID; relationRow["Name"] = relation.S_DOC_File.Name; relationRow["ParentID"] = row["ID"]; relationRow["FullPathID"] = row["FullPathID"]; relationRow["ConfigID"] = relation.FileID; relationRow["NodeType"] = "FileConfig"; resultDt.Rows.Add(relationRow); //追加已有文件 if (ShowFile) { var files = fileDt.Select("ParentID='" + row["ID"].ToString() + "' and ConfigID = '" + relation.FileID + "'"); foreach (var fileRow in files) { var _filerow = resultDt.NewRow(); _filerow["ID"] = fileRow["ID"]; _filerow["Name"] = fileRow["Name"]; _filerow["ParentID"] = relationRow["ID"]; _filerow["FullPathID"] = fileRow["FullPathID"]; _filerow["ConfigID"] = fileRow["ConfigID"]; _filerow["NodeType"] = "File"; resultDt.Rows.Add(_filerow); } } } } return(Json(resultDt, JsonRequestBehavior.AllowGet)); }