protected override void AfterAdd(DataRow dr) { atriumDB.FileXRefRow row = (atriumDB.FileXRefRow)dr; //use odd row.Id = myA.AtMng.PKIDGet("FileXRef", 10); row.Rollup = false; row.LinkType = (int)FXLinkType.ParentChild; row.secBreakInherit = false; }
protected override void AfterUpdate(DataRow dr) { atriumDB.FileXRefRow fxr = (atriumDB.FileXRefRow)dr; //System.Xml.XmlDocument xd = new System.Xml.XmlDocument(); //if (fxr.LinkType != (int)FXLinkType.ParentChild) //{ // //TODO: fix for moves of shortcuts // //if (fxr.EFileRowByEFile_FileXRefChild == null) // // myA.EFile.Load(fxr.OtherFileId, false); // //xd.InnerXml = fxr.EFileRowByEFile_FileXRefChild.FileStructXml; // //MyXml(fxr, xd, false); // //fxr.EFileRowByEFile_FileXRefChild.FileStructXml = xd.InnerXml; // ////////if (fxr.LinkType == (int)FXLinkType.XRef) // ////////{ // //////// MyXml(fxr, xd, true); // //////// fxr.EFileRowByEFile_FileXRefChild.FileStructXml = xd.InnerXml; // ////////} //} }
private atriumDB.EFileRow CreateFile(FileManager parentFile) { try { ParentFile = parentFile; atriumDB.EFileRow drFile = (atriumDB.EFileRow)EFile.Add(parentFile.CurrentFile); atriumDB.FileXRefRow fxr = (atriumDB.FileXRefRow)GetFileXRef().Add(parentFile.CurrentFile); fxr.LinkType = 0; fxr.FileId = parentFile.CurrentFile.FileId; fxr.OtherFileId = drFile.FileId; if (!drFile.IsNull("FileNumber")) { fxr.Name = drFile.FileNumber; fxr.FullFileNumber = drFile.FullFileNumber; } return(drFile); } catch (Exception exc) { throw exc; } }
protected override void BeforeChange(DataColumn dc, DataRow dr) { atriumDB.FileXRefRow row = (atriumDB.FileXRefRow)dr; switch (dc.ColumnName) { case "FileId": case "OtherFileId": if (!row.IsNull("FileId") && !row.IsNull("OtherFileId") && !row.IsNull("LinkType")) { if (myA.DB.FileXRef.Select("Fileid=" + row.FileId.ToString() + " and linktype=" + row.LinkType.ToString() + " and OTherFileid=" + row.OtherFileId.ToString()).Length > 1) { if (row.LinkType == (int)FXLinkType.ParentChild) { throw new AtriumException("A problem has occurred.\n\nYou cannot create a duplicate child file."); } else if (row.LinkType == (int)FXLinkType.Shortcut) { string DuplicateShortcut = ""; foreach (atriumDB.FileXRefRow fxref in myA.DB.FileXRef.Select("Fileid=" + row.FileId.ToString() + " and linktype=" + row.LinkType.ToString() + " and OTherFileid=" + row.OtherFileId.ToString())) { if (fxref.Id != row.Id) { DuplicateShortcut = fxref.Name; } } throw new AtriumException("There is already a shortcut to this file called " + DuplicateShortcut + ".\n\nYou can not create a duplicate shortcut to the same file in the same folder."); } else if (row.LinkType == (int)FXLinkType.XRef) { throw new AtriumException("A cross-reference already exists between the selected files.\n\nYou can not create duplicate cross-references between the same files."); } } } break; } }
protected override void BeforeUpdate(DataRow row) { SST.SSTCaseMatterRow dr = (SST.SSTCaseMatterRow)row; BeforeChange(mySSTCaseMatterDT.IssueIdColumn, dr); //TFS#56157 BY 2013-9-20 BeforeChange(mySSTCaseMatterDT.OutcomeIdColumn, dr); BeforeChange(mySSTCaseMatterDT.AcceptIssueColumn, dr); //add or update filexref for issue if (!dr.IsIssueIdNull()) { appDB.IssueRow ir = myA.AtMng.DB.Issue.FindByIssueId(dr.IssueId); if (dr.RowState == DataRowState.Added && !ir.IsFileIdNull()) { if (!XrefExists(ir.FileId)) { atriumDB.FileXRefRow fxr = (atriumDB.FileXRefRow)myA.FM.GetFileXRef().Add(myA.FM.CurrentFile); fxr.LinkType = 1; fxr.OtherFileId = ir.FileId; fxr.Rollup = false; fxr.FullFileNumber = myA.FM.EFile.Load(ir.FileId, false).FullFileNumber; } } else if (myA.IsFieldChanged(mySSTCaseMatterDT.IssueIdColumn, dr)) { int origIssueId = (int)dr[mySSTCaseMatterDT.IssueIdColumn, DataRowVersion.Original]; appDB.IssueRow origIr = myA.AtMng.DB.Issue.FindByIssueId(origIssueId); var fxrq = from f in myA.FM.DB.FileXRef where f.OtherFileId == origIr.FileId & f.LinkType == 1 select f; if (fxrq.Count() > 0) // if false, no issue found. { atriumDB.FileXRefRow fxr = fxrq.Single(); if (ir.IsFileIdNull()) { fxr.Delete(); } else { if (XrefExists(ir.FileId)) { fxr.Delete(); } else { //check List <int> files = new List <int>(); foreach (SST.SSTCaseMatterRow scmr in mySSTCaseMatterDT) { if (!scmr.IsIssueIdNull() && scmr.SSTCaseMatterId != dr.SSTCaseMatterId) { appDB.IssueRow ir1 = myA.AtMng.DB.Issue.FindByIssueId(scmr.IssueId); if (!ir1.IsFileIdNull()) { files.Add(ir1.FileId); } } } if (files.Contains(fxr.OtherFileId)) { //another issue uses that xref so add a new xref and don't change the current one atriumDB.FileXRefRow fxr1 = (atriumDB.FileXRefRow)myA.FM.GetFileXRef().Add(myA.FM.CurrentFile); fxr1.LinkType = 1; fxr1.OtherFileId = ir.FileId; fxr1.Rollup = false; fxr1.FullFileNumber = myA.FM.EFile.Load(ir.FileId, false).FullFileNumber; } else { fxr.OtherFileId = ir.FileId; } } } } else // no issue found, so no xref to update; add a new xref. { atriumDB.FileXRefRow fxr1 = (atriumDB.FileXRefRow)myA.FM.GetFileXRef().Add(myA.FM.CurrentFile); fxr1.LinkType = 1; fxr1.OtherFileId = ir.FileId; fxr1.Rollup = false; fxr1.FullFileNumber = myA.FM.EFile.Load(ir.FileId, false).FullFileNumber; } } } }