示例#1
0
        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));
        }
示例#2
0
        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));
        }
示例#3
0
        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);
                }
            }
        }
示例#4
0
        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();
            }
        }
示例#5
0
        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));
        }
示例#6
0
        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));
        }
示例#7
0
        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));
        }
示例#8
0
        public virtual JsonResult GetList(QueryBuilder qb)
        {
            string fileFields = this.Config.GetQueryFields();
            string sql        = "select " + fileFields + ",S_Attachment.Attachments,S_Attachment.ThumbNail,S_Attachment.SWFFile,"
                                + " S_Attachment.PDFFile,S_Attachment.MainFile,S_Attachment.PlotFile,S_Attachment.XrefFile,S_Attachment.DwfFile,S_Attachment.TiffFile,S_Attachment.SignPdfFile"
                                + " from S_FileInfo {0} left join S_Attachment  on FileID=S_FileInfo.ID  and CurrentVersion='True' "
                                + " where S_FileInfo.ConfigID='" + this.ConfigID + "' and (1=1 {1})";

            this.FillQueryBuilderFilter(qb);
            DocInstance.Logic.DocInstanceHepler.QueryBuilderExtend(qb);
            if (!String.IsNullOrEmpty(this.Request["IncludeChildren"]) && this.Request["IncludeChildren"].ToLower() == true.ToString().ToLower())
            {
                var nodeID = this.Request["NodeID"];
                var node   = S_NodeInfo.GetNode(nodeID, this.SpaceID);
                if (node != null)
                {
                    var cnd = qb.Items.SingleOrDefault(c => c.Field == "NodeID");
                    qb.Items.Remove(cnd);
                    qb.Add("FullNodeID", QueryMethod.StartsWith, node.FullPathID);
                }
            }

            #region 高级查询
            var QueryList = string.Empty;
            var joinSql   = string.Empty;
            var whereSql  = string.Empty;
            if (this.Request["QueryItems"] != null)
            {
                QueryList = this.Request["QueryItems"].ToString();
            }
            List <Dictionary <string, object> > queryList = JsonHelper.ToList(QueryList);
            if (queryList.Count > 0)
            {
                qb.Items.Clear();
            }
            foreach (var queryItem in queryList)
            {
                var ItemName = queryItem.GetValue("ItemName");
                var Method   = queryItem.GetValue("Method");
                var Value    = queryItem.GetValue("Value");
                var Logic    = queryItem.GetValue("Logic");
                if (string.IsNullOrEmpty(ItemName) || string.IsNullOrEmpty(Method) ||
                    string.IsNullOrEmpty(Value) || string.IsNullOrEmpty(Logic))
                {
                    continue;
                }
                var configID  = System.Text.RegularExpressions.Regex.Replace(ItemName, @"(.*\()(.*)(\).*)", "$2");
                var tableName = ItemName.Equals(configID) ? "S_FileInfo" : "S_NodeInfo";
                var itemName  = ItemName.Replace("(" + configID + ")", "");
                switch (Method)
                {
                case "LK": whereSql += Logic + " " + tableName + "." + itemName + " like '%" + Value + "%' "; break;

                case "EQ": whereSql += Logic + " " + tableName + "." + itemName + " ='" + Value + "' "; break;

                case "GT": whereSql += Logic + " " + tableName + "." + itemName + " >'" + Value + "' "; break;

                case "LT": whereSql += Logic + " " + tableName + "." + itemName + " <'" + Value + "' "; break;

                case "FR": whereSql += Logic + " " + tableName + "." + itemName + " >='" + Value + "' "; break;

                case "TO": whereSql += Logic + " " + tableName + "." + itemName + " <='" + Value + "' "; break;

                case "UE": whereSql += Logic + " " + tableName + "." + itemName + " <>'" + Value + "' "; break;

                case "IN": whereSql += Logic + " " + tableName + "." + itemName + " in('" + Value.Replace(",", "','") + "') "; break;

                default: break;
                }
                if (!ItemName.Equals(configID))
                {
                    joinSql   = "left join S_NodeInfo on S_NodeInfo.ID=S_FileInfo.NodeID";
                    whereSql += " AND S_NodeInfo.ConfigID='" + configID + "'";
                }
            }
            sql = string.Format(sql, joinSql, whereSql);
            #endregion

            var data = this.InstanceDB.ExecuteGridData(sql, qb);
            return(Json(data));
        }
示例#9
0
        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);
            }
        }
示例#10
0
        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(""));
        }
示例#11
0
        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(""));
        }