private void SetDefualtValue(string attrAttrField, string attrDefaultValue) { if (attrDefaultValue.IndexOf("{") < 0) { this.DataEntity[attrAttrField] = attrDefaultValue; } else { if (attrDefaultValue.IndexOf("{") >= 0) { var CurrentUserInfo = FormulaHelper.GetUserInfo(); // var user = UserState.CreateUserState(HttpContext.Current.User.Identity.Name); var defaultStr = attrDefaultValue.Replace("{", "").Replace("}", ""); if (defaultStr == "Now") { this.DataEntity[attrAttrField] = DateTime.Now; } else if (defaultStr == "UserID") { this.DataEntity[attrAttrField] = CurrentUserInfo.UserID; } else if (defaultStr == "UserName") { this.DataEntity[attrAttrField] = CurrentUserInfo.UserName; } if (!String.IsNullOrEmpty(this.DataEntity.GetValue("ParentID"))) { var defaultValue = attrDefaultValue.Replace("{", "").Replace("}", "").Split(':'); if (defaultValue.Length > 1) { var nodePositon = defaultValue[0]; var defaultField = defaultValue[1]; if (nodePositon == "Root") { if (this.RootNode.DataEntity.ContainsKey(defaultField)) { this.DataEntity[attrAttrField] = this.RootNode.DataEntity[defaultField]; } } else { S_NodeInfo node = _getParentNode(this.Parent, nodePositon.Split('.').Length); if (node.DataEntity.ContainsKey(defaultField)) { this.DataEntity[attrAttrField] = node.DataEntity[defaultField]; } } } else { var defaultField = defaultValue[0]; if (this.DataEntity.ContainsKey(defaultField)) { this.DataEntity[attrAttrField] = this.DataEntity[defaultField]; } } } } } }
//进到下载借阅车时,根据配置生成名称 public string CreateCarName() { var resultName = this.Name; if (this.ConfigInfo == null) { return(resultName); } if (this.ConfigInfo.ExtentionObject.GetValue("Ext_Car_UseFullName").ToLower() == "true") { var fullName = string.Empty; var splitStr = this.ConfigInfo.ExtentionObject.GetValue("Ext_Car_FullNameSplit"); if (string.IsNullOrEmpty(splitStr)) { splitStr = " > "; } var nameFormatStr = this.ConfigInfo.ExtentionObject.GetValue("Ext_Car_NameFormat"); if (string.IsNullOrEmpty(nameFormatStr)) { nameFormatStr = "{FullName} > {Name}"; } var node = S_NodeInfo.GetNode(this.NodeID, this.Space.ID); if (node != null) { fullName = string.Join(splitStr, node.Seniorities.Select(a => a.Name).ToList()); } resultName = nameFormatStr.Replace("{FullName}", fullName).Replace("{Name}", this.Name); } return(resultName); }
public void AddChild(S_NodeInfo node, bool withDefaultAttr = false) { if (String.IsNullOrEmpty(node.ID)) { node.ID = FormulaHelper.CreateGuid(); } if (!this.ConfigInfo.StructNode.Children.Exists(d => d.NodeID == node.ConfigInfo.ID) && this.ConfigInfo.IsFreeNode != TrueOrFalse.True.ToString()) { throw new Formula.Exceptions.BusinessException("【" + this.ConfigInfo.Name + "】下不能增加【" + node.ConfigInfo.Name + "】节点"); } node.DataEntity["ParentID"] = this.ID; node.DataEntity["FullPathID"] = this.FullPathID + "." + node.ID; node.DataEntity["FullPathName"] = this.FullPathName + "$.$" + node.Name; node.DataEntity["SpaceID"] = this.Space.ID; node.DataEntity["State"] = DocState.Normal; if (node.DataEntity.ContainsKey("SortIndex") && Tool.IsNullOrEmpty(node.DataEntity["SortIndex"])) { var maxIndex = 0; if (this.Children.Count > 0) { this.Children.Max(a => a.SortIndex); } node.SortIndex = ++maxIndex; } if (withDefaultAttr) { node.FillConfigDefaultAttr(); } node.ValidateDataAttr(true); node.DataEntity.InsertDB(this.InstanceDB, this.TableName, node.ID); this.Children.Add(node); this.AllChildren.Add(node); }
public virtual void MoveTo(string nodeID) { var node = S_NodeInfo.GetNode(nodeID, this.Space.ID); if (node == null) { throw new Formula.Exceptions.BusinessException("未能找到ID为【" + nodeID + "】的编目信息,移动文件信息失败"); } if (this.IsNewModel) { throw new Formula.Exceptions.BusinessException("新创建的文件对象,不能使用Move方法进行文件移动"); } this.FullNodeID = node.FullPathID; this.NodeID = nodeID; this.Save(true); }
public virtual void MoveTo(string nodeID) { var node = S_NodeInfo.GetNode(nodeID, this.Space.ID); if (node == null) { throw new Formula.Exceptions.BusinessException("未能找到ID为【" + nodeID + "】的编目信息,移动卷册失败"); } if (this.IsNewModel) { throw new Formula.Exceptions.BusinessException("新创建的卷册对象,不能使用Move方法进行卷册移动"); } this.FullPathID = node.FullPathID + "." + this.ID; this.FullPathName = node.FullPathName + "$.$" + this.Name; this.ParentID = nodeID; this.Save(true); }
public virtual void MoveTo(string nodeID, string targetConfigID = "") { var node = S_NodeInfo.GetNode(nodeID, this.Space.ID); if (node == null) { throw new Formula.Exceptions.BusinessException("未能找到ID为【" + nodeID + "】的编目信息,移动文件信息失败"); } if (this.IsNewModel) { throw new Formula.Exceptions.BusinessException("新创建的文件对象,不能使用Move方法进行文件移动"); } var targetNodeFiles = node.ConfigInfo.S_DOC_FileNodeRelation.ToList(); if (!string.IsNullOrEmpty(targetConfigID)) { targetNodeFiles = targetNodeFiles.Where(a => a.FileID == targetConfigID).ToList(); if (targetNodeFiles.Count == 0) { throw new Formula.Exceptions.BusinessException("编目信息【" + node.Name + "】下,移动文件信息失败"); } this.DataEntity["ConfigID"] = targetConfigID; } else { if (targetNodeFiles.Count == 0) { throw new Formula.Exceptions.BusinessException("编目信息【" + node.Name + "】下,移动文件信息失败"); } if (!targetNodeFiles.Any(a => a.FileID == this.DataEntity["ConfigID"].ToString())) { this.DataEntity["ConfigID"] = targetNodeFiles.FirstOrDefault().FileID; } } this.FullNodeID = node.FullPathID; this.FullNodeName = node.FullPathName; this.NodeID = nodeID; var sql = "update S_R_PhysicalReorganize_FileDetail set ReorganizePath='{1}',ReorganizeFullID='{2}' where ArchiveFileID='{0}' "; sql = string.Format(sql, this.ID, node.Name, node.FullPathID); var configDB = SQLHelper.CreateSqlHelper(ConnEnum.DocConst); configDB.ExecuteNonQuery(sql); this.Save(true); }
public void SyncInstanceDataState() { var details = this.T_Borrow_FileInfo.ToList(); var spaceList = new List <S_DOC_Space>(); foreach (var item in details) { var space = spaceList.FirstOrDefault(a => a.ID == item.SpaceID); if (space == null) { space = DocConfigHelper.CreateConfigSpaceByID(item.SpaceID); if (space == null) { continue; } spaceList.Add(space); } if (!String.IsNullOrEmpty(item.FileID)) { var file = new S_FileInfo(item.FileID, space); if (file == null) { continue; } file.DataEntity.SetValue("BorrowState", BorrowReturnState.Borrow.ToString()); file.DataEntity.SetValue("BorrowUserID", this.CreateUserID); file.DataEntity.SetValue("BorrowUserName", this.CreateUserName); file.Save(false); } else { var node = new S_NodeInfo(item.NodeID, space); if (node == null) { continue; } node.DataEntity.SetValue("BorrowState", BorrowReturnState.Borrow.ToString()); node.DataEntity.SetValue("BorrowUserID", this.CreateUserID); node.DataEntity.SetValue("BorrowUserName", this.CreateUserName); node.Save(false); } } }
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); }
public void FillConfigDefaultAttr() { if (this.ConfigInfo == null) { throw new Formula.Exceptions.BusinessException("无法获取配置信息,保存失败"); } var node = S_NodeInfo.GetNode(this.DataEntity.GetValue("NodeID"), this.Space.ID); var attrs = this.ConfigInfo.S_DOC_FileAttr.Where(d => !String.IsNullOrEmpty(d.DefaultValue)).ToList(); foreach (var attr in attrs) { if (attr.DefaultValue.Split(',').Length > 0 && attr.InputType.IndexOf(ControlType.ButtonEdit.ToString()) >= 0 && this.DataEntity.ContainsKey(attr.FileAttrField + "Name")) { SetDefualtValue(attr.FileAttrField, attr.DefaultValue.Split(',')[0], node); SetDefualtValue(attr.FileAttrField + "Name", attr.DefaultValue.Split(',')[1], node); } else { SetDefualtValue(attr.FileAttrField, attr.DefaultValue, node); } } }
private void SetDefualtValue(string attrAttrField, string attrDefaultValue, S_NodeInfo node) { if (attrDefaultValue.IndexOf("{") < 0) { this.DataEntity[attrAttrField] = attrDefaultValue; } else { if (attrDefaultValue.IndexOf("{") >= 0) { var CurrentUserInfo = FormulaHelper.GetUserInfo(); var defaultStr = attrDefaultValue.Replace("{", "").Replace("}", ""); if (defaultStr == "Now") { this.DataEntity[attrAttrField] = DateTime.Now; } else if (defaultStr == "UserID") { this.DataEntity[attrAttrField] = CurrentUserInfo.UserID; //user.UserID; } else if (defaultStr == "UserName") { this.DataEntity[attrAttrField] = CurrentUserInfo.UserName; } if (!String.IsNullOrEmpty(this.DataEntity.GetValue("NodeID"))) { var defaultValue = attrDefaultValue.Replace("{", "").Replace("}", "").Split(':'); if (defaultValue.Length > 1) { var nodePositon = defaultValue[0]; var defaultField = defaultValue[1]; if (nodePositon == "Root") { if (node.RootNode.DataEntity.ContainsKey(defaultField)) { if (!this.DataEntity.ContainsKey(attrAttrField) || string.IsNullOrEmpty(Convert.ToString(this.DataEntity[attrAttrField]))) { this.DataEntity[attrAttrField] = node.RootNode.DataEntity[defaultField]; } } } else if (nodePositon == "Node") { if (node.DataEntity.ContainsKey(defaultField)) { if (!this.DataEntity.ContainsKey(attrAttrField) || string.IsNullOrEmpty(Convert.ToString(this.DataEntity[attrAttrField]))) { this.DataEntity[attrAttrField] = node.RootNode.DataEntity[defaultField]; } } } else if (nodePositon.Split('.').Length > 0) { var pnode = _getParentNode(node, nodePositon.Split('.').Length); if (pnode.DataEntity.ContainsKey(defaultField)) { if (!this.DataEntity.ContainsKey(attrAttrField) || string.IsNullOrEmpty(Convert.ToString(this.DataEntity[attrAttrField]))) { this.DataEntity[attrAttrField] = node.RootNode.DataEntity[defaultField]; } } } } } } } }
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 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("")); }
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("")); }
public void FillConfigDefaultAttr() { if (this.ConfigInfo == null) { throw new Formula.Exceptions.BusinessException("无法获取配置信息,保存失败"); } var attrs = this.ConfigInfo.S_DOC_NodeAttr.Where(d => !String.IsNullOrEmpty(d.DefaultValue)).ToList(); foreach (var attr in attrs) { if (attr.DefaultValue.IndexOf("{") < 0) { this.DataEntity[attr.AttrField] = attr.DefaultValue; } else { if (attr.DefaultValue.IndexOf("{") >= 0) { var CurrentUserInfo = FormulaHelper.GetUserInfo(); // var user = UserState.CreateUserState(HttpContext.Current.User.Identity.Name); var defaultStr = attr.DefaultValue.Replace("{", "").Replace("}", ""); if (defaultStr == "Now") { this.DataEntity[attr.AttrField] = DateTime.Now; } else if (defaultStr == "UserID") { this.DataEntity[attr.AttrField] = CurrentUserInfo.UserID; } else if (defaultStr == "UserName") { this.DataEntity[attr.AttrField] = CurrentUserInfo.UserName; } if (!String.IsNullOrEmpty(this.DataEntity.GetValue("ParentID"))) { var defaultValue = attr.DefaultValue.Replace("{", "").Replace("}", "").Split(':'); if (defaultValue.Length > 1) { var nodePositon = defaultValue[0]; var defaultField = defaultValue[1]; if (nodePositon == "Root") { if (this.RootNode.DataEntity.ContainsKey(defaultField)) { this.DataEntity[attr.AttrField] = this.RootNode.DataEntity[defaultField]; } } else { S_NodeInfo node = _getParentNode(this.Parent, nodePositon.Split('.').Length); if (node.DataEntity.ContainsKey(defaultField)) { this.DataEntity[attr.AttrField] = node.DataEntity[defaultField]; } } } else { var defaultField = defaultValue[0]; if (this.DataEntity.ContainsKey(defaultField)) { this.DataEntity[attr.AttrField] = this.DataEntity[defaultField]; } } } } } } }