Example #1
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
            }
        }
Example #2
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
        }