public virtual JsonResult Save() { var user = FormulaHelper.GetUserInfo(); string json = Request.Form["FormData"]; bool isUpVersion = string.IsNullOrEmpty(this.Request["UpVersion"]) ? false : this.Request["UpVersion"].ToLower() == "true"; bool isNew = false; var row = JsonHelper.ToObject <Dictionary <string, object> >(json); S_FileInfo file; if (!row.ContainsKey("ID") || Tool.IsNullOrEmpty(row["ID"])) { isNew = true; file = new S_FileInfo(this.SpaceID, this.ConfigID); file.SetData(row); var node = new S_NodeInfo(file.NodeID, this.Space); file.FullNodeID = node.FullPathID; file.ID = FormulaHelper.CreateGuid(); file.DataEntity.SetValue("State", DocState.Normal.ToString()); string mainFile = row.GetValue("MainFile"); string attachments = row.GetValue("Attachments"); string pdfFile = row.GetValue("PdfFile"); string plotFile = row.GetValue("PlotFile"); string xrefFile = row.GetValue("XrefFile"); string dwfFile = row.GetValue("DwfFile"); string tiffFile = row.GetValue("TiffFile"); string signPdfFile = row.GetValue("SignPdfFile"); string atlasFile = row.GetValue("AtlasFile"); if (!String.IsNullOrEmpty(mainFile) || !String.IsNullOrEmpty(attachments) || !String.IsNullOrEmpty(pdfFile) || !String.IsNullOrEmpty(plotFile) || !String.IsNullOrEmpty(plotFile) || !String.IsNullOrEmpty(xrefFile) || !String.IsNullOrEmpty(dwfFile) || !String.IsNullOrEmpty(signPdfFile) || !string.IsNullOrEmpty(atlasFile)) { S_Attachment attach = new S_Attachment(this.SpaceID); attach.DataEntity.SetValue("MainFile", mainFile); attach.DataEntity.SetValue("Attachments", attachments); attach.DataEntity.SetValue("PDFFile", pdfFile); attach.DataEntity.SetValue("PlotFile", plotFile); attach.DataEntity.SetValue("XrefFile", xrefFile); attach.DataEntity.SetValue("DwfFile", dwfFile); attach.DataEntity.SetValue("TiffFile", tiffFile); attach.DataEntity.SetValue("SignPdfFile", signPdfFile); attach.DataEntity.SetValue("AtlasFile", atlasFile); attach.DataEntity.SetValue("CreateDate", DateTime.Now.ToString()); attach.DataEntity.SetValue("CreateUser", user.UserID); attach.DataEntity.SetValue("CreateUserName", user.UserName); file.AddAttachment(attach); } } else { file = new S_FileInfo(row["ID"].ToString(), this.Space); string mainFile = row.GetValue("MainFile"); string attachments = row.GetValue("Attachments"); string pdfFile = row.GetValue("PdfFile"); string plotFile = row.GetValue("PlotFile"); string xrefFile = row.GetValue("XrefFile"); string dwfFile = row.GetValue("DwfFile"); string tiffFile = row.GetValue("TiffFile"); string signPdfFile = row.GetValue("SignPdfFile"); string atlasFile = row.GetValue("AtlasFile"); if (!String.IsNullOrEmpty(mainFile) || !String.IsNullOrEmpty(attachments) || !String.IsNullOrEmpty(pdfFile) || !String.IsNullOrEmpty(plotFile) || !String.IsNullOrEmpty(plotFile) || !String.IsNullOrEmpty(xrefFile) || !String.IsNullOrEmpty(dwfFile) || !String.IsNullOrEmpty(signPdfFile) || !string.IsNullOrEmpty(atlasFile)) { if (isUpVersion || file.CurrentAttachment == null || mainFile != file.CurrentAttachment.DataEntity.GetValue("MainFile")) { S_Attachment attach = new S_Attachment(this.SpaceID); attach.DataEntity.SetValue("MainFile", mainFile); attach.DataEntity.SetValue("Attachments", attachments); attach.DataEntity.SetValue("PDFFile", pdfFile); attach.DataEntity.SetValue("PlotFile", plotFile); attach.DataEntity.SetValue("XrefFile", xrefFile); attach.DataEntity.SetValue("DwfFile", dwfFile); attach.DataEntity.SetValue("TiffFile", tiffFile); attach.DataEntity.SetValue("SignPdfFile", signPdfFile); attach.DataEntity.SetValue("AtlasFile", atlasFile); attach.DataEntity.SetValue("CreateDate", DateTime.Now.ToString()); attach.DataEntity.SetValue("CreateUser", user.UserID); attach.DataEntity.SetValue("CreateUserName", user.UserName); file.AddAttachment(attach); } else { file.CurrentAttachment.DataEntity.SetValue("Attachments", attachments); file.CurrentAttachment.DataEntity.SetValue("PDFFile", pdfFile); file.CurrentAttachment.DataEntity.SetValue("PlotFile", plotFile); file.CurrentAttachment.DataEntity.SetValue("XrefFile", xrefFile); file.CurrentAttachment.DataEntity.SetValue("DwfFile", dwfFile); file.CurrentAttachment.DataEntity.SetValue("TiffFile", tiffFile); file.CurrentAttachment.DataEntity.SetValue("SignPdfFile", signPdfFile); file.CurrentAttachment.DataEntity.SetValue("AtlasFile", atlasFile); file.CurrentAttachment.Save(); } } file.SetData(row); } if (file.DataEntity.ContainsKey("DocIndexID")) { file.DataEntity.Remove("DocIndexID"); } BeforeSave(file, row, isNew); file.Save(false); AfterSave(file, row, isNew); return(Json(file.DataEntity)); }
private S_FileInfo archFile(Dictionary <string, object> reorganizeDetail, S_NodeInfo node, string targetConfigID = "") { var fileConfig = node.ConfigInfo.S_DOC_FileNodeRelation.FirstOrDefault(a => a.FileID == targetConfigID); if (fileConfig == null) { throw new Formula.Exceptions.BusinessException("节点【" + node.Name + "】下无法绑定该文件类型【" + targetConfigID + "】!"); } if (fileConfig != null && fileConfig.S_DOC_File != null) { var file = new DocSystem.Logic.Domain.S_FileInfo(node.Space.ID, fileConfig.S_DOC_File.ID); var fileFields = fileConfig.S_DOC_File.S_DOC_FileAttr.Select(a => a.FileAttrField).ToList(); var buttonEditFields = fileConfig.S_DOC_File.S_DOC_FileAttr.Where(a => a.InputType.IndexOf(ControlType.ButtonEdit.ToString()) > -1).ToList(); foreach (var item in buttonEditFields) { fileFields.Add(item.FileAttrField + "Name"); } foreach (var fileds in fileFields) { if (fileds.ToLower() == "id" || fileds.ToLower() == "attr" || fileds.ToLower() == "storagenum" || fileds.ToLower() == "storagetype" || fileds.ToLower() == "mainfile") { continue; } var _value = reorganizeDetail.GetValue(fileds); if (fileds.ToLower().Equals("quantity")) { file.DataEntity.SetValue("StorageNum", _value); } if (!string.IsNullOrEmpty(_value)) { file.DataEntity.SetValue(fileds, _value); } } //var file = new DocSystem.Logic.Domain.S_FileInfo(node.Space.ID, fileConfig.S_DOC_File.ID); if (!String.IsNullOrEmpty(reorganizeDetail.GetValue("Attr"))) { SetFileAttr(file, reorganizeDetail.GetValue("Attr")); } //file.DataEntity.SetValue("Name", reorganizeDetail.GetValue("Name")); file.DataEntity.SetValue("StorageType", "Electronic"); file.DataEntity.SetValue("NodeID", node.ID); //file.DataEntity.SetValue("Code", reorganizeDetail.GetValue("Code")); //file.DataEntity.SetValue("RelateID", reorganizeDetail.GetValue("RelateID")); //file.DataEntity.SetValue("State", DocState.Normal); //归档人、部门、时间存储 if (!string.IsNullOrEmpty(GetQueryString("SendUser"))) { Dictionary <string, string> depate = GetDepartment(GetQueryString("SendUser")); file.DataEntity.SetValue("ArchivePeople", GetQueryString("SendUser")); file.DataEntity.SetValue("ArchivePeopleName", depate.GetValue("SendUserName")); file.DataEntity.SetValue("ArchiveDate", GetQueryString("SendDate")); file.DataEntity.SetValue("ArchiveDepartment", depate.GetValue("DeptID")); file.DataEntity.SetValue("ArchiveDepartmentName", depate.GetValue("DeptName")); } if (!String.IsNullOrEmpty(reorganizeDetail.GetValue("MainFile"))) { var attachment = new S_Attachment(node.Space.ID); attachment.DataEntity.SetValue("MainFile", reorganizeDetail.GetValue("MainFile")); attachment.DataEntity.SetValue("PDFFile", reorganizeDetail.GetValue("PDFFile")); attachment.DataEntity.SetValue("PlotFile", reorganizeDetail.GetValue("PlotFile")); attachment.DataEntity.SetValue("XrefFile", reorganizeDetail.GetValue("XrefFile")); attachment.DataEntity.SetValue("DwfFile", reorganizeDetail.GetValue("DwfFile")); attachment.DataEntity.SetValue("TiffFile", reorganizeDetail.GetValue("TiffFile")); attachment.DataEntity.SetValue("SignPdfFile", reorganizeDetail.GetValue("SignPdfFile")); file.AddAttachment(attachment); } file.IsValidateDataAttr = false; DocSystem.FileController.FileValidateDataAttr(file); //node.AddFile(file, true); file.Save(true); return(file); } return(null); }
public JsonResult Archive(string ProjectInfoID, bool IsAll) { Action action = () => { var projectInfo = this.GetEntityByID <S_I_ProjectInfo>(ProjectInfoID); if (projectInfo == null) { throw new Formula.Exceptions.BusinessException("未能找到项目信息,无法归档"); } var rootFolder = projectInfo.ProjectMode.S_T_DBSDefine.FirstOrDefault(d => d.DBSType == DBSType.Root.ToString()); if (String.IsNullOrEmpty(rootFolder.ArchiveFolder)) { throw new Formula.Exceptions.BusinessException("没有为根节点定义归档目录,项目无法归档"); } var archiveFolders = projectInfo.S_D_DBS.Where(d => !String.IsNullOrEmpty(d.ArchiveFolder)).ToList(); var sqlHelper = SQLHelper.CreateSqlHelper(ConnEnum.InfrasBaseConfig); var dt = sqlHelper.ExecuteDataTable("select * from S_DOC_Node where ID='" + rootFolder.ArchiveFolder + "'"); if (dt.Rows.Count == 0) { throw new Formula.Exceptions.BusinessException("根节点定义的归档目录不存在,归档失败"); } var folderDef = FormulaHelper.DataRowToDic(dt.Rows[0]); var docSpace = DocSystem.Logic.DocConfigHelper.CreateConfigSpaceByID(folderDef.GetValue("SpaceID")); if (docSpace == null) { throw new Formula.Exceptions.BusinessException("所选择的档案空间定义不存在,请联系管理员确认档案空间配置是否正确"); } S_NodeInfo rootNode = S_NodeInfo.GetNode(docSpace.ID, rootFolder.ArchiveFolder, " where RelateID='" + projectInfo.DBSRoot.ID + "'"); if (rootNode == null) { rootNode = new DocSystem.Logic.Domain.S_NodeInfo(docSpace.ID, rootFolder.ArchiveFolder); rootNode.Name = projectInfo.Name; rootNode.DataEntity.SetValue("Code", projectInfo.Code); rootNode.DataEntity.SetValue("State", DocState.Normal.ToString()); rootNode.DataEntity.SetValue("RelateID", projectInfo.DBSRoot.ID); } this.SetAttr <S_I_ProjectInfo>(rootNode, projectInfo); rootNode.Save(true); var fileConfig = rootNode.ConfigInfo.S_DOC_FileNodeRelation.FirstOrDefault(); if (fileConfig != null && fileConfig.S_DOC_File != null) { Convert.ToDouble(""); var docList = projectInfo.DBSRoot.S_D_Document.Where(d => 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(); 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(); } foreach (var doc in docList) { var file = new DocSystem.Logic.Domain.S_FileInfo(docSpace.ID, fileConfig.S_DOC_File.ID); if (!String.IsNullOrEmpty(doc.Attr)) { this.SetFileAttr(file, doc.Attr); } file.DataEntity.SetValue("Name", doc.Name); file.DataEntity.SetValue("Code", doc.Code); rootNode.AddFile(file, true); if (!String.IsNullOrEmpty(doc.MainFiles) || !String.IsNullOrEmpty(doc.PDFFile) || !String.IsNullOrEmpty(doc.PlotFile) || !String.IsNullOrEmpty(doc.XrefFile) || !String.IsNullOrEmpty(doc.DwfFile) || !String.IsNullOrEmpty(doc.TiffFile) || !String.IsNullOrEmpty(doc.SignPdfFile)) { var attachment = new S_Attachment(docSpace.ID); attachment.DataEntity.SetValue("MainFile", doc.MainFiles); attachment.DataEntity.SetValue("PDFFile", doc.PDFFile); attachment.DataEntity.SetValue("PlotFile", doc.PlotFile); attachment.DataEntity.SetValue("XrefFile", doc.XrefFile); attachment.DataEntity.SetValue("DwfFile", doc.DwfFile); attachment.DataEntity.SetValue("TiffFile", doc.TiffFile); attachment.DataEntity.SetValue("SignPdfFile", doc.SignPdfFile); attachment.DataEntity.SetValue("TiffFile", doc.TiffFile); attachment.DataEntity.SetValue("CreateUser", this.CurrentUserInfo.UserID); attachment.DataEntity.SetValue("CreateUserName", this.CurrentUserInfo.UserName); file.AddAttachment(attachment); } doc.State = "Archive"; doc.ArchiveDate = DateTime.Now; if (doc.RelateTable == "S_E_Product") { //string update = "Update S_E_Product Set ArchiveState='True', ArchiveDate='" + DateTime.Now.ToString() + "' where ID='" + doc.RelateID + "'"; string update = string.Format(@"update S_E_Product set ArchiveState='True', ArchiveDate='{2}' where ID='{0}' update S_E_ProductVersion set ArchiveState='True', ArchiveDate='{2}' where ProductID='{0}' and Version='{1}'", doc.RelateID, doc.Version, DateTime.Now.ToString()); this.entities.Database.ExecuteSqlCommand(update); } } } this._archiveDBS(projectInfo.DBSRoot, archiveFolders, rootNode, docSpace, true, IsAll); this.entities.SaveChanges(); }; if (System.Configuration.ConfigurationManager.AppSettings["UseMsdtc"].ToLower() == "true") { using (TransactionScope ts = new TransactionScope()) { action(); ts.Complete(); } } else { action(); } return(Json("")); }
void _archiveDBS(S_D_DBS parentDBS, List <S_D_DBS> archiveDbsList, S_NodeInfo parentNode, S_DOC_Space docSpace, bool archiveFiles = true, bool isAll = true) { var folders = archiveDbsList.Where(d => d.ParentID == parentDBS.ID).ToList(); foreach (var folder in folders) { if (String.IsNullOrEmpty(folder.ArchiveFolder)) { continue; } S_NodeInfo node = S_NodeInfo.GetNode(docSpace.ID, folder.ArchiveFolder, " where Name='" + folder.Name + "' and ParentID='" + parentNode.ID + "' "); if (node == null) { node = new DocSystem.Logic.Domain.S_NodeInfo(docSpace.ID, folder.ArchiveFolder); this.SetAttr <S_D_DBS>(node, folder); node.Name = folder.Name; node.DataEntity.SetValue("State", DocState.Normal.ToString()); node.DataEntity.SetValue("RelateID", folder.ID); parentNode.AddChild(node, true); } else { this.SetAttr <S_D_DBS>(node, folder); node.Name = folder.Name; node.DataEntity.SetValue("State", DocState.Normal.ToString()); node.DataEntity.SetValue("RelateID", folder.ID); node.Save(); } if (archiveFiles && node.ConfigInfo.S_DOC_FileNodeRelation.Count > 0 && node.ConfigInfo.S_DOC_FileNodeRelation.FirstOrDefault().S_DOC_File != null) { #region 归档文件 var fileConfig = node.ConfigInfo.S_DOC_FileNodeRelation.FirstOrDefault().S_DOC_File; var docList = folder.S_D_Document.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(); 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(); } foreach (var doc in docList) { var file = S_FileInfo.GetFile(docSpace.ID, fileConfig.ID, " NodeID='" + node.ID + "' and RelateID='" + doc.ID + "' "); if (file == null) { file = new DocSystem.Logic.Domain.S_FileInfo(docSpace.ID, fileConfig.ID); if (!String.IsNullOrEmpty(doc.Attr)) { this.SetFileAttr(file, doc.Attr); } file.DataEntity.SetValue("Name", doc.Name); file.DataEntity.SetValue("Code", doc.Code); file.DataEntity.SetValue("RelateID", doc.ID); file.DataEntity.SetValue("State", DocState.Normal); if (!String.IsNullOrEmpty(doc.MainFiles) || !String.IsNullOrEmpty(doc.PDFFile) || !String.IsNullOrEmpty(doc.PlotFile) || !String.IsNullOrEmpty(doc.XrefFile) || !String.IsNullOrEmpty(doc.DwfFile) || !String.IsNullOrEmpty(doc.TiffFile) || !String.IsNullOrEmpty(doc.SignPdfFile)) { var attachment = new S_Attachment(docSpace.ID); attachment.DataEntity.SetValue("MainFile", doc.MainFiles); attachment.DataEntity.SetValue("PDFFile", doc.PDFFile); attachment.DataEntity.SetValue("PlotFile", doc.PlotFile); attachment.DataEntity.SetValue("XrefFile", doc.XrefFile); attachment.DataEntity.SetValue("DwfFile", doc.DwfFile); attachment.DataEntity.SetValue("TiffFile", doc.TiffFile); attachment.DataEntity.SetValue("SignPdfFile", doc.SignPdfFile); attachment.DataEntity.SetValue("CreateUser", this.CurrentUserInfo.UserID); attachment.DataEntity.SetValue("CreateUserName", this.CurrentUserInfo.UserName); file.AddAttachment(attachment); } node.AddFile(file, true); } else { if (!String.IsNullOrEmpty(doc.Attr)) { this.SetFileAttr(file, doc.Attr); } file.Save(); var attachment = new S_Attachment(docSpace.ID); attachment.DataEntity.SetValue("MainFile", doc.MainFiles); attachment.DataEntity.SetValue("PDFFile", doc.PDFFile); attachment.DataEntity.SetValue("PlotFile", doc.PlotFile); attachment.DataEntity.SetValue("XrefFile", doc.XrefFile); attachment.DataEntity.SetValue("DwfFile", doc.DwfFile); attachment.DataEntity.SetValue("TiffFile", doc.TiffFile); attachment.DataEntity.SetValue("SignPdfFile", doc.SignPdfFile); attachment.DataEntity.SetValue("CreateUser", this.CurrentUserInfo.UserID); attachment.DataEntity.SetValue("CreateUserName", this.CurrentUserInfo.UserName); file.AddAttachment(attachment); } doc.State = "Archive"; doc.ArchiveDate = DateTime.Now; if (doc.RelateTable == "S_E_Product") { //string update = "Update S_E_Product Set ArchiveState='True', ArchiveDate='" + DateTime.Now.ToString() + "' where ID='" + doc.RelateID + "'"; string update = string.Format(@"update S_E_Product set ArchiveState='True', ArchiveDate='{2}' where ID='{0}' update S_E_ProductVersion set ArchiveState='True', ArchiveDate='{2}' where ProductID='{0}' and Version='{1}'", doc.RelateID, doc.Version, DateTime.Now.ToString()); this.entities.Database.ExecuteSqlCommand(update); } } #endregion } _archiveDBS(folder, archiveDbsList, node, docSpace, archiveFiles, isAll); } }
public JsonResult ArchiveFile(string ProjectInfoID, string Files) { Action action = () => { var projectInfo = this.GetEntityByID <S_I_ProjectInfo>(ProjectInfoID); if (projectInfo == null) { throw new Formula.Exceptions.BusinessException("未能找到项目信息,无法归档"); } var rootFolder = projectInfo.ProjectMode.S_T_DBSDefine.FirstOrDefault(d => d.DBSType == DBSType.Root.ToString()); if (String.IsNullOrEmpty(rootFolder.ArchiveFolder)) { throw new Formula.Exceptions.BusinessException("没有为根节点定义归档目录,项目无法归档"); } var sqlHelper = SQLHelper.CreateSqlHelper(ConnEnum.InfrasBaseConfig); var dt = sqlHelper.ExecuteDataTable("select * from S_DOC_Node where ID='" + rootFolder.ArchiveFolder + "'"); if (dt.Rows.Count == 0) { throw new Formula.Exceptions.BusinessException("根节点定义的归档目录不存在,归档失败"); } var folderDef = FormulaHelper.DataRowToDic(dt.Rows[0]); var docSpace = DocSystem.Logic.DocConfigHelper.CreateConfigSpaceByID(folderDef.GetValue("SpaceID")); if (docSpace == null) { throw new Formula.Exceptions.BusinessException("所选择的档案空间定义不存在,请联系管理员确认档案空间配置是否正确"); } #region 创建项目根节点 S_NodeInfo rootNode = S_NodeInfo.GetNode(docSpace.ID, rootFolder.ArchiveFolder, " where RelateID='" + projectInfo.DBSRoot.ID + "'"); if (rootNode == null) { rootNode = new DocSystem.Logic.Domain.S_NodeInfo(docSpace.ID, rootFolder.ArchiveFolder); rootNode.Name = projectInfo.Name; rootNode.DataEntity.SetValue("Code", projectInfo.Code); rootNode.DataEntity.SetValue("State", DocState.Normal.ToString()); } #endregion this.SetAttr <S_I_ProjectInfo>(rootNode, projectInfo); rootNode.DataEntity.SetValue("RelateID", projectInfo.DBSRoot.ID); rootNode.Save(true); var fileList = JsonHelper.ToList(Files); foreach (var item in fileList) { if (item.Keys.Contains("NewAdd") && item.GetValue("NewAdd") == "T") { continue; } var doc = this.GetEntityByID <S_D_Document>(item.GetValue("DocumentID")); if (doc == null) { continue; } var folder = doc.S_D_DBS; if (String.IsNullOrEmpty(folder.ArchiveFolder)) { throw new Formula.Exceptions.BusinessException("没有为【" + folder.Name + "】配置指定归档信息,无法归档"); } var node = rootNode.AllChildren.FirstOrDefault(d => d.RelateID == folder.ID); if (node == null) { this._archiveDBS(projectInfo.DBSRoot, folder.Ansestors, rootNode, docSpace, false); node = rootNode.AllChildren.FirstOrDefault(d => d.RelateID == folder.ID); } if (node == null) { throw new Formula.Exceptions.BusinessException("目录创建失败,文件【" + doc.Name + "】归档失败"); } #region 归档文件 var fileConfig = node.ConfigInfo.S_DOC_FileNodeRelation.FirstOrDefault(); if (fileConfig != null && fileConfig.S_DOC_File != null) { var file = S_FileInfo.GetFile(docSpace.ID, fileConfig.S_DOC_File.ID, " NodeID='" + node.ID + "' and RelateID='" + doc.ID + "' "); if (file == null) { file = new DocSystem.Logic.Domain.S_FileInfo(docSpace.ID, fileConfig.S_DOC_File.ID); if (!String.IsNullOrEmpty(doc.Attr)) { this.SetFileAttr(file, doc.Attr); } file.DataEntity.SetValue("Name", doc.Name); file.DataEntity.SetValue("Code", doc.Code); file.DataEntity.SetValue("RelateID", doc.ID); file.DataEntity.SetValue("State", DocState.Normal); if (!String.IsNullOrEmpty(doc.MainFiles) || !String.IsNullOrEmpty(doc.PDFFile) || !String.IsNullOrEmpty(doc.PlotFile) || !String.IsNullOrEmpty(doc.XrefFile) || !String.IsNullOrEmpty(doc.DwfFile) || !String.IsNullOrEmpty(doc.TiffFile) || !String.IsNullOrEmpty(doc.SignPdfFile)) { var attachment = new S_Attachment(docSpace.ID); attachment.DataEntity.SetValue("MainFile", doc.MainFiles); attachment.DataEntity.SetValue("PDFFile", doc.PDFFile); attachment.DataEntity.SetValue("PlotFile", doc.PlotFile); attachment.DataEntity.SetValue("XrefFile", doc.XrefFile); attachment.DataEntity.SetValue("DwfFile", doc.DwfFile); attachment.DataEntity.SetValue("TiffFile", doc.TiffFile); attachment.DataEntity.SetValue("SignPdfFile", doc.SignPdfFile); file.AddAttachment(attachment); } node.AddFile(file, true); } else { if (!String.IsNullOrEmpty(doc.Attr)) { this.SetFileAttr(file, doc.Attr); } file.DataEntity.SetValue("RelateID", doc.ID); file.Save(); var attachment = new S_Attachment(docSpace.ID); attachment.DataEntity.SetValue("MainFile", doc.MainFiles); attachment.DataEntity.SetValue("PDFFile", doc.PDFFile); attachment.DataEntity.SetValue("PlotFile", doc.PlotFile); attachment.DataEntity.SetValue("XrefFile", doc.XrefFile); attachment.DataEntity.SetValue("DwfFile", doc.DwfFile); attachment.DataEntity.SetValue("TiffFile", doc.TiffFile); attachment.DataEntity.SetValue("SignPdfFile", doc.SignPdfFile); file.AddAttachment(attachment); } doc.State = "Archive"; doc.ArchiveDate = DateTime.Now; if (doc.RelateTable == "S_E_Product") { //string update = "Update S_E_Product Set ArchiveState='True', ArchiveDate='" + DateTime.Now.ToString() + "' where ID='" + doc.RelateID + "'"; string update = string.Format(@"update S_E_Product set ArchiveState='True', ArchiveDate='{2}' where ID='{0}' update S_E_ProductVersion set ArchiveState='True', ArchiveDate='{2}' where ProductID='{0}' and Version='{1}'", doc.RelateID, doc.Version, DateTime.Now.ToString()); this.entities.Database.ExecuteSqlCommand(update); } } #endregion } this.entities.SaveChanges(); }; if (System.Configuration.ConfigurationManager.AppSettings["UseMsdtc"].ToLower() == "true") { using (TransactionScope ts = new TransactionScope()) { action(); ts.Complete(); } } else { action(); } return(Json("")); }