public static UOMConflictInfo TestConflict(string packageName, TblUOM_Row t1, KnownUOM t2) { if (!t1.Name.Equals(t2.Name)) { return(null); } if (!t1.Dimensions.Equals(t2.Dimensions)) { return(new UOMConflictInfo(packageName, t1, ConflictType.InConsistent, UOMConflictReason.Dimensions, "Dimensions", "Inconsistent dimensions")); } // TODO: Tolerance: if ((t1.Factor_A != t2.AFactor) || (t1.Factor_B != t2.BFactor) || (t1.Factor_C != t2.CFactor) || (t1.Factor_D != t2.DFactor)) { return(new UOMConflictInfo(packageName, t1, ConflictType.InConsistent, UOMConflictReason.Factors, "Factors", "Inconsistent factors")); } if (!t1.Description.Equals(t2.Description)) { return(new UOMConflictInfo(packageName, t1, ConflictType.Consistent, UOMConflictReason.Description, "Description", "Different description")); } return(new UOMConflictInfo(packageName, t1, ConflictType.Duplicate, UOMConflictReason.Duplicate, "Duplicate", "Duplicate")); }
/// <summary> /// Create a new content item from the database row /// </summary> /// <param name="knownSoFar">Used to find the baseUOM, not to check for consistency (which is done outside this routine)</param> public static KnownUOM NewContentItem(string packageName, TblUOM_Row t1, Dictionary <string, KnownUOM> knownSoFar) { bool isBase = t1.IsBase; KnownUOM baseUOM = null; if (!isBase) { foreach (var item in knownSoFar) { if (Dimensions.AreEqual(item.Value.Dimensions, t1.Dimensions)) { baseUOM = item.Value; break; } } if (baseUOM == null) { int iDbg = 0; throw new UnspecifiedException(); } } KnownUOM knownUOM = new KnownUOM(packageName, t1.Dimensions, t1.Name, t1.Description, t1.Symbol, isBase, baseUOM, t1.Factor_A, t1.Factor_B, t1.Factor_C, t1.Factor_D); return(knownUOM); }