private void AddNewNode(string Action, string txtLocalPath, string StrTitle) { TreeNodeEx theNode = (TreeNodeEx)treeView1.SelectedNode; int orderindex = (new BLL.T_CellAndEFile_BLL()).GetMaxOrderIndex(theNode.Name, Globals.ProjectNO);//treesData.GetNextIndex(theNode.Name, Globals.ProjectNO); string ParentID = theNode.Name; string Filepath = txtLocalPath; string Title = StrTitle; string ProjectNO = Globals.ProjectNO; fileModel = new ERM.MDL.T_FileList(); fileModel.gdwj = Title; fileModel.wjtm = Title; fileModel.FileID = Guid.NewGuid().ToString(); fileModel.ParentID = ParentID; fileModel.ProjectNO = ProjectNO; fileModel.OrderIndex = (new BLL.T_FileList_BLL()).GetMaxOrderIndex(ParentID, Globals.ProjectNO) + 1; fileModel.isvisible = 1; fileModel.fileStatus = "0"; fileModel.FL = 0; (new BLL.T_FileList_BLL()).Add(fileModel); MDL.T_CellAndEFile cellMode = new ERM.MDL.T_CellAndEFile(); cellMode.CellID = Guid.NewGuid().ToString(); if (!System.IO.File.Exists(Filepath)) { TXMessageBoxExtensions.Info("文件不存在!"); return; } System.IO.File.Copy(Filepath, Globals.ProjectPath + "ODOC\\" + cellMode.CellID + ".cll", true); cellMode.filepath = "ODOC\\" + cellMode.CellID + ".cll"; cellMode.orderindex = orderindex + 1; cellMode.FileID = fileModel.FileID; cellMode.isvisible = 1; cellMode.EFileType = true;//电子文件类型,0=false 系统的,-1=true 用户上传的 cellMode.ProjectNO = ProjectNO; cellMode.title = Title; cellBLL.Add(cellMode); TreeNodeEx newNode = new TreeNodeEx(); newNode.Name = cellMode.FileID; newNode.ImageIndex = 2; newNode.SelectedImageIndex = 2; newNode.Text = cellMode.title; theNode.Nodes.Add(newNode); theNode.Expand(); }
private void menuPasteFile_Click(object sender, EventArgs e) { TreeNodeEx theNode = treeView1.SelectedNode as TreeNodeEx; if (theNode == null) { return; } if (CopyFileID != "") { BLL.T_FileList_BLL fileBLL = new ERM.BLL.T_FileList_BLL(); //fileBLL.FindByFileID( MDL.T_FileList fileMDL = fileBLL.Find(CopyFileID, Globals.ProjectNO); string OldFileID = fileMDL.FileID; string NewFileID = Guid.NewGuid().ToString().ToUpper(); fileMDL.FileID = NewFileID; fileMDL.ParentID = theNode.Name; fileMDL.ArchiveID = ""; fileMDL.fileStatus = "0"; fileMDL.wjtm += "_复制"; fileMDL.gdwj += "_复制"; fileMDL.OrderIndex = fileBLL.GetMaxOrderIndex(theNode.Name, Globals.ProjectNO) + 1; fileBLL.Add(fileMDL); BLL.T_CellAndEFile_BLL cellTplBLL = new ERM.BLL.T_CellAndEFile_BLL(); IList <MDL.T_CellAndEFile> cellTplList = cellTplBLL.FindByFileID(CopyFileID, Globals.ProjectNO);//cellTplBLL.FindByFileID(CopyFileID, Globals.ProjectNO, 0); foreach (MDL.T_CellAndEFile obj in cellTplList) { string newCellID = Guid.NewGuid().ToString().ToUpper(); string fileName = Globals.ProjectPath + obj.filepath; if (System.IO.File.Exists(fileName)) { System.IO.File.Copy(fileName, fileName.ToUpper().Replace(obj.CellID.ToUpper(), newCellID), true); obj.filepath = obj.filepath.ToUpper().Replace(obj.CellID.ToUpper(), newCellID); } else { obj.filepath = ""; } string fileNamePDF = Globals.ProjectPath + obj.fileTreePath; if (System.IO.File.Exists(fileNamePDF)) { System.IO.File.Copy(fileNamePDF, fileNamePDF.ToUpper().Replace(obj.CellID.ToUpper(), newCellID), true); obj.fileTreePath = obj.fileTreePath.ToUpper().Replace(obj.CellID.ToUpper(), newCellID); } else { obj.fileTreePath = ""; } obj.CellID = newCellID; obj.FileID = NewFileID; cellTplBLL.Add(obj); } TreeNodeEx newNode = new TreeNodeEx(); newNode.Name = fileMDL.FileID; newNode.Text = fileMDL.wjtm; newNode.ImageIndex = (treeFactory.CheckEFileByFileID(newNode.Name, 1) == true) ? 7 : 2;//判断是否有电子文件; newNode.SelectedImageIndex = newNode.ImageIndex; newNode.NodeValue = fileMDL.FileID; theNode.Nodes.Add(newNode); } else { TXMessageBoxExtensions.Info("请先复制!"); } }