示例#1
0
        /// <summary>
        ///
        /// This method will compare two Groups to see if they are equal, but it will
        /// only compare those Attributes mentioned in the target Field.
        ///
        /// NOTE: The auditing containers 'poThisAttrValues' and 'poThatAttrValues' will only
        /// work correctly with a group that only has one row.
        ///
        /// <param name="poThatGroup">The group being compared against (usually representing old data from the DB)</param>
        /// <param name="poTargetField">The Field that has the Attribute list of interest</param>
        /// <param name="poIgnoreAttrIds">The list of Attributes that should be ignored when comparisons are done</param>
        /// <param name="poThisAttrValues">Storage for the values different from "this" group</param>
        /// <param name="poThatAttrValues">Storage for the values different from "that" group</param>
        /// <returns>Bool that indicates whether or not the two Groups are equal</returns>
        /// </summary>
        public bool Equals(WonkaPrdGroup poThatGroup,
                           WonkaRefCadre poTargetField,
                           HashSet <int> poIgnoreAttrIds,
                           Dictionary <int, string> poNewAttrValues,
                           Dictionary <int, string> poOldAttrValues)
        {
            bool bResult = true;

            foreach (WonkaPrdGroupDataRow ThisRow in this.DataRowVector)
            {
                int nThatRowIndex = poThatGroup.GetRowIndex(ThisRow.GetKey());

                if (nThatRowIndex != -1)
                {
                    WonkaPrdGroupDataRow ThatRow = poThatGroup[nThatRowIndex];

                    HashSet <int> FieldAttrIds =
                        WonkaRefEnvironment.GetInstance().GetAttrIdsByFieldId(poTargetField.CadreId);

                    foreach (int nAttrId in FieldAttrIds)
                    {
                        WonkaRefAttr TempAttr = WonkaRefEnvironment.GetInstance().GetAttributeByAttrId(nAttrId);

                        if (poIgnoreAttrIds.Contains(nAttrId))
                        {
                            continue;
                        }

                        if (poTargetField.MergeNullAttrFlag || !String.IsNullOrEmpty(ThisRow[nAttrId]))
                        {
                            string sThisValue = ThisRow[nAttrId];
                            string sThatValue = ThatRow[nAttrId];

                            if (sThisValue != sThatValue)
                            {
                                // NOTE: Need to record these values, maybe for auditing
                                if (TempAttr.IsAudited)
                                {
                                    poNewAttrValues[TempAttr.AttrId] = sThisValue;
                                    poOldAttrValues[TempAttr.AttrId] = sThatValue;
                                }

                                bResult = Compare(TempAttr, sThisValue, sThatValue);
                            }
                        }
                    }
                }
            }

            return(bResult);
        }
示例#2
0
        /// <summary>
        ///
        /// This method will compare two Groups to see if they are equal. It will compare
        /// them by finding a corresponding DataRow within ThisGroup and ThatGroup, based
        /// on the key.
        ///
        /// NOTE: This Group (i.e., the left-hand data row) usually represents incoming/new data
        ///
        /// NOTE: Currently, it doesn't compare them exactly.  It just ensures that
        /// the contents of 'r1' are the same in 'r2', implying that 'r2' can be a
        /// superset of 'r1'.
        ///
        /// <param name="ThatGroup">The right-hand data row (usually representing old data from persistence/storage)</param>
        /// <returns>Bool that indicates whether or not the two Groups are equal</returns>
        public bool Equals(WonkaPrdGroup poThatGroup)
        {
            foreach (WonkaPrdGroupDataRow ThisRow in this)
            {
                int nThatRowIndex = poThatGroup.GetRowIndex(ThisRow.GetKey());

                if (nThatRowIndex != -1)
                {
                    if (ThisRow != poThatGroup.GetRow(nThatRowIndex))
                    {
                        return(false);
                    }
                }
                else
                {
                    return(false);
                }
            }

            return(true);
        }