protected override bool beforeUpdateInsertAction() { FrmAttachment workCheckAth = new FrmAttachment(); bool isHave = workCheckAth.RetrieveByAttr(FrmAttachmentAttr.MyPK, this.NodeID + "_FrmWorkCheck"); //不包含审核组件 if (isHave == false) { workCheckAth = new FrmAttachment(); /*如果没有查询到它,就有可能是没有创建.*/ workCheckAth.MyPK = this.NodeID + "_FrmWorkCheck"; workCheckAth.FK_MapData = this.NodeID.ToString(); workCheckAth.NoOfObj = this.NodeID + "_FrmWorkCheck"; workCheckAth.Exts = "*.*"; //存储路径. workCheckAth.SaveTo = "/DataUser/UploadFile/"; workCheckAth.IsNote = false; //不显示note字段. workCheckAth.IsVisable = false; // 让其在form 上不可见. //位置. workCheckAth.X = (float)94.09; workCheckAth.Y = (float)333.18; workCheckAth.W = (float)626.36; workCheckAth.H = (float)150; //多附件. workCheckAth.UploadType = AttachmentUploadType.Multi; workCheckAth.Name = "审核组件"; workCheckAth.SetValByKey("AtPara", "@IsWoEnablePageset=1@IsWoEnablePrint=1@IsWoEnableViewModel=1@IsWoEnableReadonly=0@IsWoEnableSave=1@IsWoEnableWF=1@IsWoEnableProperty=1@IsWoEnableRevise=1@IsWoEnableIntoKeepMarkModel=1@FastKeyIsEnable=0@IsWoEnableViewKeepMark=1@FastKeyGenerRole=@IsWoEnableTemplete=1"); workCheckAth.Insert(); } return(base.beforeUpdateInsertAction()); }
protected void Page_Load(object sender, EventArgs e) { MapData md = new MapData(this.FK_MapData); FrmAttachment athDesc = new FrmAttachment(); int i = athDesc.Retrieve(FrmAttachmentAttr.FK_MapData, this.FK_MapData, FrmAttachmentAttr.NoOfObj, "DocMainAth"); if (i == 0) { /*如果没有数据.*/ /*如果没有查询到它,就有可能是公文多附件被删除了.*/ athDesc.NoOfObj = "DocMainAth"; athDesc.Exts = "doc,docx,xls,xlsx"; athDesc.MyPK = athDesc.FK_MapData + "_" + athDesc.NoOfObj; athDesc.FK_MapData = this.FK_MapData; //存储路径. string path = Server.MapPath("/DataUser/UploadFile/"); path += "\\F" + this.FK_Flow + "MainAth"; athDesc.SaveTo = path; //位置. athDesc.X = (float)94.09; athDesc.Y = (float)140.18; athDesc.W = (float)626.36; athDesc.H = (float)150; //多附件. athDesc.UploadType = AttachmentUploadType.Single; athDesc.Name = "公文正文(系统自动增加)"; athDesc.SetValByKey("AtPara", "@IsWoEnablePageset=1@IsWoEnablePrint=1@IsWoEnableViewModel=1@IsWoEnableReadonly=0@IsWoEnableSave=1@IsWoEnableWF=1@IsWoEnableProperty=1@IsWoEnableRevise=1@IsWoEnableIntoKeepMarkModel=1@FastKeyIsEnable=0@IsWoEnableViewKeepMark=1@FastKeyGenerRole=@IsWoEnableTemplete=1"); athDesc.Insert(); //有可能在其其它的节点上没有这个附件,所以也要循环增加上它. BP.WF.Nodes nds = new Nodes(this.FK_Flow); foreach (Node nd in nds) { athDesc.FK_MapData = "ND" + nd.NodeID; athDesc.MyPK = athDesc.FK_MapData + "_" + athDesc.NoOfObj; if (athDesc.IsExits == true) { continue; } athDesc.Insert(); } //重新查询一次,把默认值加上. athDesc.RetrieveFromDBSources(); } FrmAttachmentDBs athDBs = null; athDBs = new FrmAttachmentDBs(this.FK_MapData, this.WorkID.ToString()); FrmAttachmentDB athDB = null; if (athDBs.Count == 0 && this.IsCC == "1") { /*如果是抄送过来的, 有可能是抄送到的节点不是发送到的节点,导致附件数据没有copy。 * 也就是说,发给b节点,但是抄送到c节点上去了,导致c节点上的人看不到附件数据。*/ CCList cc = new CCList(); int nnn = cc.Retrieve(CCListAttr.FK_Node, this.FK_Node, CCListAttr.WorkID, this.WorkID, CCListAttr.CCTo, WebUser.No); this._fk_node = cc.NDFrom; if (cc.NDFrom != 0) { athDBs.Retrieve(FrmAttachmentDBAttr.FK_MapData, "ND" + cc.NDFrom, FrmAttachmentDBAttr.RefPKVal, this.WorkID.ToString()); string ndFromMapdata = athDesc.MyPK.Replace(athDesc.FK_MapData, "ND" + cc.NDFrom); athDB = athDBs.GetEntityByKey(FrmAttachmentDBAttr.FK_FrmAttachment, ndFromMapdata) as FrmAttachmentDB; //重新设置文件描述。 athDesc.Retrieve(FrmAttachmentAttr.FK_MapData, this.FK_MapData, FrmAttachmentAttr.NoOfObj, "DocMainAth"); } } else { /* 单个文件 */ athDB = athDBs.GetEntityByKey(FrmAttachmentDBAttr.FK_FrmAttachment, athDesc.MyPK) as FrmAttachmentDB; } Label lab = new Label(); lab.ID = "Lab" + athDesc.MyPK; this.Pub1.Add(lab); if (athDB != null) { if (athDB.FileExts == "ceb") { athDB.FileExts = "pdf"; } if (athDesc.IsWoEnableWF) { lab.Text = "<a href=\"javascript:OpenOfiice('" + athDB.FK_FrmAttachment + "','" + this.WorkID + "','" + athDB.MyPK + "','" + this.FK_MapData + "','" + athDesc.NoOfObj + "','" + this.FK_Node + "')\"><img src='" + BP.WF.Glo.CCFlowAppPath + "WF/Img/FileType/" + athDB.FileExts + ".gif' border=0/>" + athDB.FileName + "</a>"; } else { lab.Text = "<img src='" + BP.WF.Glo.CCFlowAppPath + "WF/Img/FileType/" + athDB.FileExts + ".gif' border=0/>" + athDB.FileName; } } #region 处理权限问题. // 处理权限问题, 有可能当前节点是可以上传或者删除,但是当前节点上不能让此人执行工作。 bool isDel = athDesc.IsDeleteInt == 0 ? false : true; bool isUpdate = athDesc.IsUpload; if (isDel == true || isUpdate == true) { if (this.WorkID != 0 && string.IsNullOrEmpty(this.FK_Flow) == false) { isDel = BP.WF.Dev2Interface.Flow_IsCanDoCurrentWork(this.FK_Flow, this.FK_Node, this.WorkID, WebUser.No); if (isDel == false) { isUpdate = false; } } } #endregion 处理权限问题. Button mybtn = new Button(); mybtn.CssClass = "Btn"; if (athDesc.IsUpload && isUpdate == true) { FileUpload fu = new FileUpload(); fu.ID = athDesc.MyPK; Btn_Upload.ID = "Btn_Upload_" + athDesc.MyPK + "_" + this.WorkID; fu.Attributes["Width"] = athDesc.W.ToString(); fu.Attributes["onchange"] = "UploadChange('" + mybtn.ID + "');"; this.Pub1.Add(fu); } if (athDesc.IsDownload) { mybtn = new Button(); mybtn.Text = "下载"; mybtn.CssClass = "Btn"; mybtn.ID = "Btn_Download_" + athDesc.MyPK + "_" + this.WorkID; mybtn.Click += new EventHandler(btnUpload_Click); mybtn.CssClass = "bg"; if (athDB == null) { mybtn.Visible = false; } else { mybtn.Visible = true; } this.Pub1.Add(mybtn); } if (this.IsReadonly == false) { if (athDesc.IsDeleteInt != 0 && isDel == true) { bool isDeleteBtn = true; if (athDesc.IsDeleteInt == 2) { if (!athDB.Rec.Equals(WebUser.No)) { isDeleteBtn = false; } } if (isDeleteBtn) { mybtn = new Button(); mybtn.CssClass = "Btn"; mybtn.Text = "删除"; mybtn.Attributes["onclick"] = " return confirm('您确定要执行删除吗?');"; mybtn.ID = "Btn_Delete_" + athDesc.MyPK + "_" + this.WorkID; mybtn.Click += new EventHandler(btnUpload_Click); mybtn.CssClass = "bg"; if (athDB == null) { mybtn.Visible = false; } else { mybtn.Visible = true; } this.Pub1.Add(mybtn); } } if (athDesc.IsWoEnableWF) { mybtn = new Button(); mybtn.CssClass = "Btn"; mybtn.Text = "打开"; mybtn.ID = "Btn_Open_" + athDesc.MyPK + "_" + this.WorkID; mybtn.Click += new EventHandler(btnUpload_Click); mybtn.CssClass = "bg"; if (athDB == null) { mybtn.Visible = false; } else { mybtn.Visible = true; } this.Pub1.Add(mybtn); } } }