Esempio n. 1
0
        /// <summary>
        /// 增加DBS子目录
        /// </summary>
        /// <param name="child">子目录对象</param>
        public S_D_DBS AddChild(S_D_DBS child)
        {
            var user     = FormulaHelper.GetUserInfo();
            var entities = this.GetDbContext <ProjectEntities>();

            if (entities.Entry <S_D_DBS>(child).State != System.Data.EntityState.Added && entities.Entry <S_D_DBS>(child).State != System.Data.EntityState.Detached)
            {
                throw new Formula.Exceptions.BusinessException("非新增状态的DBS对象,无法调用AddChild方法");
            }
            if (String.IsNullOrEmpty(child.ID))
            {
                child.ID = FormulaHelper.CreateGuid();
            }
            if (String.IsNullOrEmpty(child.DBSType))
            {
                child.DBSType = Project.Logic.DBSType.Folder.ToString();
            }
            child.ParentID        = this.ID;
            child.FullID          = this.FullID + "." + child.ID;
            child.ProjectInfoID   = this.ProjectInfoID;
            child.S_I_ProjectInfo = this.S_I_ProjectInfo;
            child.CreateDate      = DateTime.Now;
            child.CreateUserID    = user.UserID;
            child.CreateUser      = user.UserName;
            child.IsPublic        = true;
            this.S_I_ProjectInfo.S_D_DBS.Add(child);
            child.InheritParentAuth();
            this.Children.Add(child);
            this.AllChildren.Add(child);
            return(child);
        }
Esempio n. 2
0
        /// <summary>
        /// 增加DBS节点
        /// </summary>
        /// <param name="define">DBS节点定义</param>
        public S_D_DBS AddChild(S_T_DBSDefine define)
        {
            var user  = FormulaHelper.GetUserInfo();
            var child = new S_D_DBS();

            child.ID                = FormulaHelper.CreateGuid();
            child.DBSCode           = define.DBSCode;
            child.Name              = define.Name;
            child.DBSType           = define.DBSType;
            child.MappingNodeUrl    = define.MappingNodeUrl;
            child.MappingType       = define.MappingType;
            child.CreateDate        = DateTime.Now;
            child.CreateUserID      = user.UserID;
            child.CreateUser        = user.UserName;
            child.InheritAuth       = define.InheritAuth;
            child.ParentID          = this.ID;
            child.FullID            = this.FullID + "." + child.ID;
            child.ProjectInfoID     = this.ProjectInfoID;
            child.S_I_ProjectInfo   = this.S_I_ProjectInfo;
            child.ConfigDBSID       = define.ID;
            child.ArchiveFolder     = define.ArchiveFolder;
            child.ArchiveFolderName = define.ArchiveFolderName;
            this.S_I_ProjectInfo.S_D_DBS.Add(child);
            foreach (var item in define.S_T_DBSSecurity.ToList())
            {
                var sec = new S_D_DBSSecurity();
                sec.ID          = FormulaHelper.CreateGuid();
                sec.RoleCode    = item.RoleCode;
                sec.RoleName    = item.RoleName;
                sec.AuthType    = item.AuthType;
                sec.RelateValue = "";
                child.S_D_DBSSecurity.Add(sec);
            }
            return(child);
        }
Esempio n. 3
0
        /// <summary>
        /// 增加DBS子节点
        /// </summary>
        /// <param name="name">节点名称</param>
        /// <param name="code">节点编号</param>
        public S_D_DBS AddChild(string name, string code = "")
        {
            var child = new S_D_DBS();

            child.DBSCode = code;
            child.Name    = name;
            child.DBSType = Project.Logic.DBSType.Folder.ToString();
            return(this.AddChild(child));
        }
Esempio n. 4
0
        void _createISOMappingFolder(S_D_DBS parent, string parentDefineCode, List <Dictionary <string, object> > folderDefines, List <S_D_DBS> existFolderList,
                                     S_T_ISODefine objMode, S_T_DBSDefine defineInfo, IFormExport export)
        {
            var folderDefine = folderDefines.FirstOrDefault(d => d["ParentID"].ToString() == parentDefineCode);

            if (folderDefine == null)
            {
                return;
            }
            var value = objMode.GetPropertyString(folderDefine.GetValue("FieldName"));

            if (String.IsNullOrEmpty(value))
            {
                return;
            }
            if (!String.IsNullOrEmpty(folderDefine.GetValue("EnumKey")))
            {
                var enumService = FormulaHelper.GetService <IEnumService>();
                value = enumService.GetEnumText(folderDefine.GetValue("EnumKey"), value);
            }
            var folder = existFolderList.FirstOrDefault(d => d.Name == value && d.ParentID == parent.ID);

            if (folder == null)
            {
                folder                   = new S_D_DBS();
                folder.ID                = FormulaHelper.CreateGuid();
                folder.Name              = value;
                folder.DBSCode           = objMode.ID;
                folder.DBSType           = Project.Logic.DBSType.Mapping.ToString();
                folder.ConfigDBSID       = defineInfo.ID + "." + folderDefine.GetValue("FieldName");
                folder.ArchiveFolder     = folderDefine.GetValue("ArchiveFolder");
                folder.MappingType       = parent.MappingType;
                folder.ArchiveFolderName = folderDefine.GetValue("ArchiveFolderName");
                folder.SortIndex         = objMode.SortIndex;
                parent.AddChild(folder);
                existFolderList.Add(folder);
            }
            bool addOnDocument = Convert.ToBoolean(folderDefine.GetValue("AddProduct"));

            if (addOnDocument)
            {
                if (folder.DBSCode == objMode.ID)
                {
                    _createISOForm(objMode, folder, export);
                }
            }
        }
Esempio n. 5
0
        /// <summary>
        /// 集成指定目录的权限
        /// </summary>
        /// <param name="dbs">指定的DBS目录</param>
        public void InheritNodeAuth(S_D_DBS dbs)
        {
            var entities = FormulaHelper.GetEntities <ProjectEntities>();

            entities.S_D_DBSSecurity.Delete(d => d.DBSID == this.ID);
            foreach (var security in dbs.S_D_DBSSecurity.ToList())
            {
                var sec = new S_D_DBSSecurity();
                sec.ID          = FormulaHelper.CreateGuid();
                sec.RoleCode    = security.RoleCode;
                sec.RoleName    = security.RoleName;
                sec.AuthType    = security.AuthType;
                sec.RelateValue = security.RelateValue;
                sec.RoleType    = security.RoleType;
                sec.DBSID       = this.ID;
                this.S_D_DBSSecurity.Add(sec);
                sec.S_D_DBS = this;
            }
            this.InheritAuth = true.ToString();
        }
Esempio n. 6
0
        void _createISOForm(S_T_ISODefine isoDefine, S_D_DBS fileFolder, IFormExport export)
        {
            var    entities = this.GetDbContext <ProjectEntities>();
            var    db       = SQLHelper.CreateSqlHelper(isoDefine.ConnName);
            string sql      = "select * from {0} where ProjectInfoID like '%{1}%' and FlowPhase='End'";
            var    table    = db.ExecuteDataTable(String.Format(sql, isoDefine.TableName, this.ProjectInfoID));

            foreach (DataRow isoRow in table.Rows)
            {
                #region 创建ISO表单
                var enumDefList = new List <Dictionary <string, object> >();
                if (!String.IsNullOrEmpty(isoDefine.EnumFieldInfo))
                {
                    enumDefList = JsonHelper.ToList(isoDefine.EnumFieldInfo);
                }
                string name                = Function.ReplaceRegString(isoDefine.NameFieldInfo, FormulaHelper.DataRowToDic(isoRow), enumDefList);
                var    doc                 = fileFolder.S_D_Document.FirstOrDefault(d => d.RelateID == isoRow["ID"].ToString());
                var    archiveFields       = String.IsNullOrEmpty(isoDefine.ArchiveFields) ? "" : isoDefine.ArchiveFields;
                var    isoDic              = FormulaHelper.DataRowToDic(isoRow);
                var    archiveAttachFields = archiveFields.Split(',');
                if (doc == null)
                {
                    doc            = entities.S_D_Document.Create();
                    doc.ID         = FormulaHelper.CreateGuid();
                    doc.Name       = name;
                    doc.Attr       = JsonHelper.ToJson(isoDic);
                    doc.Catagory   = isoDefine.Name;
                    doc.MajorValue = isoDic.GetValue("MajorValue");
                    var pdfFiles = export.ExportPDF(isoDefine.Name, isoRow["ID"].ToString(), isoDefine.FormCode);
                    doc.Code         = isoDic.GetValue("SerialNumber");
                    doc.Version      = isoDic.GetValue("VersionNumber");
                    doc.MainFiles    = pdfFiles;
                    doc.PDFFile      = pdfFiles;
                    doc.RelateID     = isoRow["ID"].ToString();
                    doc.RelateTable  = isoDefine.TableName;
                    doc.CreateUser   = isoDic.GetValue("CreateUser");
                    doc.CreateUserID = isoDic.GetValue("CreateUserID");
                    doc.State        = "Normal";

                    foreach (var field in archiveAttachFields)
                    {
                        if (string.IsNullOrEmpty(isoDic.GetValue(field)))
                        {
                            continue;
                        }
                        doc.Attachments += isoDic.GetValue(field) + ",";
                    }
                    if (!string.IsNullOrEmpty(doc.Attachments))
                    {
                        doc.Attachments = doc.Attachments.TrimEnd(',');
                    }
                    fileFolder.AddDocument(doc);
                    //doc.AddDocumentVersion();
                }
                else if (string.IsNullOrEmpty(doc.MainFiles))
                {
                    var pdfFiles = export.ExportPDF(isoDefine.Name, isoRow["ID"].ToString(), isoDefine.FormCode);
                    doc.MainFiles = pdfFiles;
                    doc.PDFFile   = pdfFiles;
                    foreach (var field in archiveAttachFields)
                    {
                        if (string.IsNullOrEmpty(isoDic.GetValue(field)))
                        {
                            continue;
                        }
                        doc.Attachments += isoDic.GetValue(field) + ",";
                    }
                    if (!string.IsNullOrEmpty(doc.Attachments))
                    {
                        doc.Attachments = doc.Attachments.TrimEnd(',');
                    }
                }
                #endregion
            }
        }
Esempio n. 7
0
        void _archiveProduct(S_D_DBS dbs, S_E_Product product)
        {
            #region 增加成果至归档目录
            //20190508 一个成果本版一个document记录,不用version表记录,为了多个版本独立档案记录
            var productVersion = product.Version.HasValue ? product.Version.Value.ToString() : "";
            var doc            = dbs.S_D_Document.FirstOrDefault(d => d.RelateID == product.ID && d.Version == productVersion);
            if (doc == null)
            {
                doc              = new S_D_Document();
                doc.ID           = FormulaHelper.CreateGuid();
                doc.Name         = product.Name;
                doc.Code         = product.Code;
                doc.MajorValue   = product.MajorValue;
                doc.Attr         = JsonHelper.ToJson(product);
                doc.Catagory     = product.MonomerInfo;
                doc.RelateID     = product.ID;
                doc.RelateTable  = "S_E_Product";
                doc.CreateUser   = product.CreateUser;
                doc.CreateUserID = product.CreateUserID;
                doc.State        = "Normal";
                doc.MainFiles    = product.MainFile;
                doc.PDFFile      = product.PdfFile;
                doc.PlotFile     = product.PlotFile;
                doc.XrefFile     = product.XrefFile;
                doc.DwfFile      = product.DwfFile;
                doc.TiffFile     = product.TiffFile;
                doc.SignPdfFile  = product.SignPdfFile;
                doc.Version      = productVersion;
                doc.ArchiveDate  = null;
                dbs.AddDocument(doc);
                //doc.AddDocumentVersion();
            }
            //else if (doc.Version != productVersion)
            //{
            //    doc.Name = product.Name;
            //    doc.Code = product.Code;
            //    doc.Attr = JsonHelper.ToJson(product);
            //    doc.Catagory = product.MonomerInfo;

            //    doc.MajorValue = product.MajorValue;
            //    doc.MainFiles = product.MainFile;
            //    doc.PDFFile = product.PdfFile;
            //    doc.PlotFile = product.PlotFile;
            //    doc.XrefFile = product.XrefFile;
            //    doc.DwfFile = product.DwfFile;
            //    doc.TiffFile = product.TiffFile;
            //    doc.SignPdfFile = product.SignPdfFile;
            //    doc.Version = product.Version.HasValue ? product.Version.Value.ToString() : "";
            //    doc.ArchiveDate = null;
            //    doc.State = "Normal";
            //    doc.AddDocumentVersion();
            //}
            else if (doc.State != "Archive")
            {
                doc.PDFFile     = product.PdfFile;
                doc.PlotFile    = product.PlotFile;
                doc.XrefFile    = product.XrefFile;
                doc.DwfFile     = product.DwfFile;
                doc.TiffFile    = product.TiffFile;
                doc.SignPdfFile = product.SignPdfFile;

                var docVer = doc.S_D_DocumentVersion.FirstOrDefault(a => a.Version == doc.Version);
                if (docVer != null)
                {
                    docVer.PDFFile     = doc.PDFFile;
                    docVer.PlotFile    = doc.PlotFile;
                    docVer.XrefFile    = doc.XrefFile;
                    docVer.DwfFile     = doc.DwfFile;
                    docVer.TiffFile    = doc.TiffFile;
                    docVer.SignPdfFile = doc.SignPdfFile;
                }
            }
            #endregion
        }
Esempio n. 8
0
        void _createProductMappingFolder(S_D_DBS parent, string parentDefineCode, List <Dictionary <string, object> > folderDefines, List <S_D_DBS> existFolderList,
                                         S_E_Product product, S_T_DBSDefine defineInfo)
        {
            var folderDefine = folderDefines.FirstOrDefault(d => d["ParentID"].ToString() == parentDefineCode);

            if (folderDefine == null)
            {
                return;
            }
            var value = product.GetPropertyString(folderDefine.GetValue("FieldName"));

            if (String.IsNullOrEmpty(value))
            {
                _createProductMappingFolder(parent, folderDefine.GetValue("FieldName"), folderDefines, existFolderList, product, defineInfo);
            }
            else
            {
                if (!String.IsNullOrEmpty(folderDefine.GetValue("EnumKey")))
                {
                    var enumService = FormulaHelper.GetService <IEnumService>();
                    value = enumService.GetEnumText(folderDefine.GetValue("EnumKey"), value);
                }
                var folder = existFolderList.FirstOrDefault(d => d.Name == value && d.ParentID == parent.ID);
                if (folder == null)
                {
                    folder                   = new S_D_DBS();
                    folder.ID                = FormulaHelper.CreateGuid();
                    folder.Name              = value;
                    folder.DBSCode           = folderDefine.GetValue("FieldName");
                    folder.DBSType           = Project.Logic.DBSType.Mapping.ToString();
                    folder.MappingType       = parent.MappingType;
                    folder.ConfigDBSID       = defineInfo.ID + "." + folderDefine.GetValue("FieldName");
                    folder.ArchiveFolder     = folderDefine.GetValue("ArchiveFolder");
                    folder.ArchiveFolderName = folderDefine.GetValue("ArchiveFolderName");
                    parent.AddChild(folder);
                    existFolderList.Add(folder);
                }

                bool addOnDocument = true;// Convert.ToBoolean(folderDefine.GetValue("AddProduct"));
                //根据归档结构决定是否添加成果
                var ansestorFolders = existFolderList.Where(d => folder.FullID.StartsWith(d.FullID)).OrderBy(d => d.FullID).ToList();
                var preFlag         = true;
                for (int i = 0; i < folderDefines.Count; i++)
                {
                    var fd      = folderDefines[i];
                    var pdValue = product.GetPropertyString(fd.GetValue("FieldName"));//成果的结构所属字段对应值(阶段、子项、专业、工作包)
                    if (!String.IsNullOrEmpty(fd.GetValue("EnumKey")))
                    {
                        var enumService = FormulaHelper.GetService <IEnumService>();
                        pdValue = enumService.GetEnumText(fd.GetValue("EnumKey"), pdValue);
                    }
                    if (preFlag)
                    {
                        if (!string.IsNullOrEmpty(pdValue) && !ansestorFolders.Any(a => a.Name == pdValue)) //非空校验处理,成果只有阶段、专业属性情况
                        {
                            addOnDocument = false;                                                          //成果不属于当前分支,继续创建分支
                            break;
                        }
                    }
                    else
                    {
                        if (!string.IsNullOrEmpty(pdValue)) //专业下有成果、工作包下也有成果,只有成果的工作包属性是空时,才归档在专业下
                        {
                            addOnDocument = false;
                            break;
                        }
                    }
                    if (fd == folderDefine)
                    {
                        preFlag = false;
                    }
                }
                if (addOnDocument)
                {
                    #region 增加成果至归档目录
                    _archiveProduct(folder, product);
                    #endregion
                }
                else
                {
                    _createProductMappingFolder(folder, folderDefine.GetValue("FieldName"), folderDefines, existFolderList, product, defineInfo);
                }
            }
        }