예제 #1
0
 public void UpdateAttachment(S_Attachment attachment)
 {
     if (attachment.IsNewModel)
     {
         throw new Formula.Exceptions.BusinessException("附件对象新建对象,无法调用更新方法");
     }
     attachment.Save();
     var attch = this.Attachments.FirstOrDefault(d => d.ID == attachment.ID);
 }
예제 #2
0
 public void AddAttachment(S_Attachment attachment)
 {
     if (!attachment.IsNewModel)
     {
         throw new Formula.Exceptions.BusinessException("附件对象不是新建对象,无法调用添加方法");
     }
     attachment.NodeID         = this.ID;
     attachment.CurrentVersion = "True";
     attachment.Version        = this.getMaxAttachVersion();
     attachment.Save();
     this.Attachments.Add(attachment);
 }
예제 #3
0
 public void AddAttachment(S_Attachment attachment)
 {
     if (!attachment.IsNewModel)
     {
         throw new Formula.Exceptions.BusinessException("附件对象不是新建对象,无法调用添加方法");
     }
     if (this.IsNewModel)
     {
         this.Attachments.Add(attachment);
         attachment.Version = 0;
     }
     else
     {
         this.InstanceDB.ExecuteNonQuery(" update S_Attachment set CurrentVersion='False' where FileID='" + this.ID + "' ");
         attachment.FileID         = this.ID;
         attachment.NodeID         = this.NodeID;
         attachment.CurrentVersion = "True";
         attachment.Version        = this.getMaxAttachVersion();
         attachment.Save();
         this.Attachments.Add(attachment);
     }
 }
예제 #4
0
        public void Publish()
        {
            var user = FormulaHelper.GetUserInfo();

            if (this.ReorganizeState == DocSystem.Logic.ReorganizeState.Execute.ToString())
            {
                if (this.ReorganizeUser != user.UserID)
                {
                    throw new Formula.Exceptions.BusinessException("【" + this.TaskName + "】已经由【" + this.ReorganizeUserName + "】整编,请等【" + this.ReorganizeUserName + "】整编完成以后再操作");
                }
            }
            else if (this.ReorganizeState != DocSystem.Logic.ReorganizeState.Finish.ToString())
            {
                throw new Formula.Exceptions.BusinessException("【" + this.TaskName + "】未完成整编,无法归档");
            }

            var docList = this.GetDocConfigSqlHelper().ExecuteList <S_R_Reorganize_DocumentList>
                              ("select * from S_R_Reorganize_DocumentList where S_R_ReorganizeID='" + this.ID + "'");

            if (docList.Any(a => string.IsNullOrEmpty(a.ReorganizeFullID)))
            {
                throw new Formula.Exceptions.BusinessException("所有文件资料都指定整编目录后才能归档");
            }

            //归档
            var    docSpace = DocConfigHelper.CreateConfigSpaceByID(this.SpaceID);
            var    nodeIds  = docList.Select(a => a.ReorganizeFullID.Split('.').LastOrDefault()).Distinct();
            var    db       = SQLHelper.CreateSqlHelper(docSpace.SpaceKey, docSpace.ConnectString);
            string sql      = "select * from S_NodeInfo where ID in ('" + string.Join("','", nodeIds) + "') ";
            var    dt       = db.ExecuteDataTable(sql);
            var    nodeList = new List <S_NodeInfo>();

            foreach (DataRow row in dt.Rows)
            {
                nodeList.Add(new S_NodeInfo(row));
            }

            foreach (var item in docList)
            {
                var nodeID = item.ReorganizeFullID.Split('.').LastOrDefault();
                var node   = nodeList.FirstOrDefault(a => a.ID == nodeID);
                if (node == null)
                {
                    throw new Formula.Exceptions.BusinessException("【" + this.TaskName + "】未找到【" + item.Name + "】的整编目录【" + item.ReorganizePath + "】,无法归档");
                }
                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='" + item.RelateID + "' ");
                    if (file == null)
                    {
                        file = new DocSystem.Logic.Domain.S_FileInfo(docSpace.ID, fileConfig.S_DOC_File.ID);
                        if (!String.IsNullOrEmpty(item.Attr))
                        {
                            this.SetFileAttr(file, item.Attr);
                        }
                        file.DataEntity.SetValue("Name", item.Name);
                        file.DataEntity.SetValue("Code", item.Code);
                        file.DataEntity.SetValue("RelateID", item.RelateID);
                        file.DataEntity.SetValue("State", DocState.Normal);
                        if (!String.IsNullOrEmpty(item.MainFile))
                        {
                            var attachment = new S_Attachment(docSpace.ID);
                            attachment.DataEntity.SetValue("MainFile", item.MainFile);
                            attachment.DataEntity.SetValue("PDFFile", item.PDFFile);
                            attachment.DataEntity.SetValue("PlotFile", item.PlotFile);
                            attachment.DataEntity.SetValue("XrefFile", item.XrefFile);
                            attachment.DataEntity.SetValue("DwfFile", item.DwfFile);
                            attachment.DataEntity.SetValue("TiffFile", item.TiffFile);
                            attachment.DataEntity.SetValue("SignPdfFile", item.SignPdfFile);
                            file.AddAttachment(attachment);
                        }
                        node.AddFile(file, true);
                    }
                    else
                    {
                        if (!String.IsNullOrEmpty(item.Attr))
                        {
                            this.SetFileAttr(file, item.Attr);
                        }
                        file.DataEntity.SetValue("RelateID", item.RelateID);
                        file.Save();
                        var attachment = new S_Attachment(docSpace.ID);
                        attachment.DataEntity.SetValue("MainFile", item.MainFile);
                        attachment.DataEntity.SetValue("PDFFile", item.PDFFile);
                        attachment.DataEntity.SetValue("PlotFile", item.PlotFile);
                        attachment.DataEntity.SetValue("XrefFile", item.XrefFile);
                        attachment.DataEntity.SetValue("DwfFile", item.DwfFile);
                        attachment.DataEntity.SetValue("TiffFile", item.TiffFile);
                        attachment.DataEntity.SetValue("SignPdfFile", item.SignPdfFile);
                        file.AddAttachment(attachment);
                    }
                }
            }
        }