private void LoadAttachment() { string EnName = "ND" + this.FK_Node; BP.Sys.MapData mapdata = new BP.Sys.MapData(EnName); FrmAttachments attachments = new BP.Sys.FrmAttachments(); attachments = mapdata.FrmAttachments; bool isCompleate = false; BP.WF.Node node = new BP.WF.Node(FK_Node); try { WorkFlow workFlow = new WorkFlow(node.FK_Flow, WorkID); isCompleate = workFlow.IsComplete; } catch (Exception) { try { Flow fl = new Flow(node.FK_Flow); GERpt rpt = fl.HisGERpt; rpt.OID = WorkID; rpt.Retrieve(); if (rpt != null) { if (rpt.WFState == WFState.Complete) { isCompleate = true; } } } catch (Exception ex) { } } foreach (FrmAttachment ath in attachments) { string src = ""; if (!isCompleate) { src = CCFlowAppPath + "WF/CCForm/AttachmentUpload.aspx?PKVal=" + this.WorkID + "&Ath=" + ath.NoOfObj + "&FK_MapData=" + EnName + "&FK_FrmAttachment=" + ath.MyPK + "&FK_Node=" + this.FK_Node; } else { src = CCFlowAppPath + "WF/CCForm/AttachmentUpload.aspx?PKVal=" + this.WorkID + "&Ath=" + ath.NoOfObj + "&FK_MapData=" + EnName + "&FK_FrmAttachment=" + ath.MyPK + "&FK_Node=" + this.FK_Node + "&IsReadonly=1"; } this.Pub1.Add("<iframe ID='F" + ath.MyPK + "' src='" + src + "' frameborder=0 style='position:absolute;width:" + ath.W + "px; height:" + ath.H + "px;text-align: left;' leftMargin='0' topMargin='0' scrolling=auto /></iframe>"); } }
public void BindFJ() { BP.Sys.FrmAttachments fas = new BP.Sys.FrmAttachments(); fas.Retrieve(FrmAttachmentAttr.FK_MapData, this.FK_MapData); this.Pub2.AddTable("width='100%'"); this.Pub2.AddTR(); this.Pub2.AddTDTitle("Idx"); this.Pub2.AddTDTitle("编号"); this.Pub2.AddTDTitle("名称"); this.Pub2.AddTDTitle("附件类型"); this.Pub2.AddTDTitle("原始属性"); this.Pub2.AddTDTitle("编辑"); this.Pub2.AddTDTitle("删除"); this.Pub2.AddTREnd(); int idx = 0; foreach (BP.Sys.FrmAttachment item in fas) { if (item.FK_Node != 0) { continue; } idx++; this.Pub2.AddTR(); this.Pub2.AddTDIdx(idx); this.Pub2.AddTD(item.NoOfObj); this.Pub2.AddTD(item.Name); this.Pub2.AddTD(item.UploadTypeT); this.Pub2.AddTD("<a href=\"javascript:EditFJYuanShi('" + this.FK_MapData + "','" + item.NoOfObj + "')\">原始属性</a>"); this.Pub2.AddTD("<a href=\"javascript:EditFJ('" + this.FK_Node + "','" + this.FK_MapData + "','" + item.NoOfObj + "')\">编辑</a>"); FrmAttachment en = new FrmAttachment(); en.MyPK = this.FK_MapData + "_" + item.NoOfObj + "_" + this.FK_Node; if (en.RetrieveFromDBSources() == 0) { this.Pub2.AddTD(); } else { this.Pub2.AddTD("<a href=\"javascript:DeleteFJ('" + this.FK_Node + "','" + this.FK_MapData + "','" + item.NoOfObj + "')\">删除</a>"); } this.Pub2.AddTREnd(); } this.Pub2.AddTableEnd(); }
/// <summary> /// 把当前实体的数据copy到指定的主键数据表里. /// </summary> /// <param name="oid">指定的主键</param> public void CopyToOID(string oid) { //实例化历史数据表单entity. string oidOID = this.MyPK; this.MyPK = oid; this.Save(); //复制从表数据. MapDtls dtls = new MapDtls(this.FK_MapData); foreach (MapDtl dtl in dtls) { //删除旧的数据. BP.DA.DBAccess.RunSQL("DELETE FROM " + dtl.PTable + " WHERE RefPK=" + this.MyPK); GEDtls ensDtl = new GEDtls(dtl.No); ensDtl.Retrieve(GEDtlAttr.RefPK, oidOID); foreach (GEDtl enDtl in ensDtl) { enDtl.RefPK = this.MyPK.ToString(); enDtl.InsertAsNew(); } } //复制附件数据. FrmAttachments aths = new FrmAttachments(this.FK_MapData); foreach (FrmAttachment ath in aths) { //删除可能存在的新oid数据。 DBAccess.RunSQL("DELETE FROM Sys_FrmAttachmentDB WHERE FK_MapData='" + this.FK_MapData + "' AND RefPKVal='" + this.MyPK + "'"); //找出旧数据. FrmAttachmentDBs athDBs = new FrmAttachmentDBs(this.FK_MapData, oidOID.ToString()); foreach (FrmAttachmentDB athDB in athDBs) { FrmAttachmentDB athDB_N = new FrmAttachmentDB(); athDB_N.Copy(athDB); athDB_N.FK_MapData = this.FK_MapData; athDB_N.RefPKVal = this.MyPK.ToString(); if (athDB_N.HisAttachmentUploadType == AttachmentUploadType.Single) { /*如果是单附件.*/ athDB_N.MyPK = athDB_N.FK_FrmAttachment + "_" + this.MyPK; if (athDB_N.IsExits == true) { continue; /*说明上一个节点或者子线程已经copy过了, 但是还有子线程向合流点传递数据的可能,所以不能用break.*/ } athDB_N.Insert(); } else { athDB_N.MyPK = DBAccess.GenerGUID(); athDB_N.Insert(); } } } }
/// <summary> /// 从另外的一个实体来copy数据. /// </summary> /// <param name="en"></param> public void CopyFromFrm(GEEntityMyPK en) { //先求出来旧的OID. string oldOID = this.MyPK; //复制主表数据. this.Copy(en); this.Save(); this.MyPK = oldOID; //复制从表数据. MapDtls dtls = new MapDtls(this.FK_MapData); //被copy的明细集合. MapDtls dtlsFrom = new MapDtls(en.FK_MapData); if (dtls.Count != dtls.Count) { throw new Exception("@复制的两个表单从表不一致..."); } //序号. int i = 0; foreach (MapDtl dtl in dtls) { //删除旧的数据. BP.DA.DBAccess.RunSQL("DELETE FROM " + dtl.PTable + " WHERE RefPK=" + this.MyPK); //求对应的Idx的,从表配置. MapDtl dtlFrom = dtlsFrom[i] as MapDtl; GEDtls ensDtlFrom = new GEDtls(dtlFrom.No); ensDtlFrom.Retrieve(GEDtlAttr.RefPK, oldOID); //创建一个实体. GEDtl dtlEnBlank = new GEDtl(dtl.No); // 遍历数据,执行copy. foreach (GEDtl enDtlFrom in ensDtlFrom) { dtlEnBlank.Copy(enDtlFrom); dtlEnBlank.RefPK = this.MyPK.ToString(); dtlEnBlank.SaveAsNew(); } i++; } //复制附件数据. FrmAttachments aths = new FrmAttachments(this.FK_MapData); FrmAttachments athsFrom = new FrmAttachments(en.FK_MapData); foreach (FrmAttachment ath in aths) { //删除数据,防止copy重复 DBAccess.RunSQL("DELETE FROM Sys_FrmAttachmentDB WHERE FK_MapData='" + this.FK_MapData + "' AND RefPKVal='" + this.MyPK + "'"); foreach (FrmAttachment athFrom in athsFrom) { if (athFrom.NoOfObj != ath.NoOfObj) { continue; } FrmAttachmentDBs athDBsFrom = new FrmAttachmentDBs(); athDBsFrom.Retrieve(FrmAttachmentDBAttr.FK_FrmAttachment, athFrom.MyPK, FrmAttachmentDBAttr.RefPKVal, en.MyPK.ToString()); foreach (FrmAttachmentDB athDBFrom in athDBsFrom) { athDBFrom.MyPK = BP.DA.DBAccess.GenerGUID(); athDBFrom.FK_FrmAttachment = ath.MyPK; athDBFrom.RefPKVal = this.MyPK.ToString(); athDBFrom.Insert(); } } } }