diff --git a/PROMS/VEPROMS.CSLA.Library/Extension/DocVersionExt.cs b/PROMS/VEPROMS.CSLA.Library/Extension/DocVersionExt.cs index e4509568..dec27227 100644 --- a/PROMS/VEPROMS.CSLA.Library/Extension/DocVersionExt.cs +++ b/PROMS/VEPROMS.CSLA.Library/Extension/DocVersionExt.cs @@ -649,14 +649,40 @@ namespace VEPROMS.CSLA.Library #endregion public ROFstInfo GetROFst(int rodbid) { - if (DocVersionAssociations == null) return null; + if (DocVersionAssociations == null || DocVersionAssociations.Count == 0) // No RO Association for this Data + { + if(FirstBadRODBIDProblemDetected) + _MyLog.ErrorFormat("<<>> - Missing RO Association\r\nMissing RO Association for this Folder ([{0}] - {1})",VersionID, MyFolder.Name); + return null; + } foreach (AssociationInfo dva in DocVersionAssociations) { if (dva.MyROFst.RODbID == rodbid) return dva.MyROFst; } + if (DocVersionAssociations.Count == 1) // Different Association and ROUsage values for RODBID - default to asssociation value + { + if (FirstBadRODBIDProblemDetected) + _MyLog.ErrorFormat("<<>> - ROUsage Does Not match Association\r\nROUsage (RODBID = {0}) does not match Association Information (RODBID = {1}) for this Folder ([2] - {3})", + rodbid, DocVersionAssociations[0].MyROFst.RODbID, VersionID, MyFolder.Name); + return DocVersionAssociations[0].MyROFst; + } + // More than one association record - Cannot guess which to return + if (FirstBadRODBIDProblemDetected) + _MyLog.ErrorFormat("<<>> - More than One Association Record\r\nROUsage (RODBID = {0}) does not match any of the {1} Associations for this Folder ([{2}] -{3})", + rodbid, DocVersionAssociations.Count, VersionID, MyFolder.Name); return null; } + private static List _HasBadRODBIDProblem = new List(); + private bool FirstBadRODBIDProblemDetected + { + get + { + if (_HasBadRODBIDProblem.Contains(VersionID)) return false; + _HasBadRODBIDProblem.Add(VersionID); + return true; + } + } public bool IsFolder { get