/// <summary> /// This method will set all of the Attributes (for the target Field) within this Row to /// those in the provided one. /// </summary> /// <param name="poOriginal">The DataRow that we are copying all of the Attribute values from</param> /// <param name="poField">The subset of Attributes that we are targeting for the copy</param> /// <returns>None</returns> public void SetData(WonkaPrdGroupDataRow poOriginal, WonkaRefCadre poField) { foreach (int TmpAttrId in poField.AttrIds) { this[TmpAttrId] = poOriginal[TmpAttrId]; } }
/// <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. /// /// <param name="poThatGroup">The group being compared against (usually representing old data from persistence/storage)</param> /// <param name="poTargetField">The Field that has the Attribute list of interest</param> /// <returns>Bool that indicates whether or not the two Groups are equal</returns> /// </summary> public bool Equals(WonkaPrdGroup poThatGroup, WonkaRefCadre poTargetField) { Dictionary <int, string> ThisGroupAttrValues = new Dictionary <int, string>(); Dictionary <int, string> ThatGroupAttrValues = new Dictionary <int, string>(); return(Equals(poThatGroup, poTargetField, ThisGroupAttrValues, ThatGroupAttrValues)); }
/// <summary> /// /// This method will return the sought ProductField of this Product, if one is already present. /// If it is not present, it will create one by default and return it after inserting into /// our collection. /// /// <param name="poField">The Field representing the ProductField that we want to retrieve</param> /// <returns>The ProductField that we want to retrieve from this Product</returns> /// </summary> public WonkaProductCadre GetProductField(WonkaRefCadre poField) { WonkaProductCadre SoughtField = null; if (ProductCadreIndex.Keys.Contains(poField.CadreId)) { SoughtField = ProductCadreIndex[poField.CadreId]; } else if (WonkaRefEnvironment.GetInstance().DoesFieldExist(poField.CadreId)) { ProductCadreIndex[poField.CadreId] = new WonkaProductCadre(); SoughtField = ProductCadreIndex[poField.CadreId]; SoughtField.ProductId = this.ProductId; SoughtField.CadreId = poField.CadreId; SoughtField.LockCd = "N"; SoughtField.LastTouchedSourceId = (this.OwnerSourceIds != null) && (this.OwnerSourceIds.Count > 0) ? this.OwnerSourceIds.ElementAt(0) : 0; } else { throw new Exception("ERROR! WonkaProduct::getProductField(const WonkaRefField&) : " + "Requested field does not exist: (" + poField.CadreName + ")."); } return(SoughtField); }
/// <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 persistence/storage)</param> /// <param name="poTargetField">The Field that has the Attribute list of interest</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, Dictionary <int, string> poThisAttrValues, Dictionary <int, string> poThatAttrValues) { HashSet <int> IgnoreAttrIds = new HashSet <int>(); return(Equals(poThatGroup, poTargetField, IgnoreAttrIds, poThisAttrValues, poThatAttrValues)); }
/// <summary> /// /// This method will update the contents of a row (at index 'pnRowIndex') with the values from the supplied DataRow /// (via matching on the key), but only for the Attributes of a given Field. In addition, if any Attribute inside /// the updated Field has an associated AttrModDt, we will set that Attribute with the timestamp of CurrTimeStamp. /// /// NOTE: This code assumes that only 1 AttrModDt will be updated per call of updateField(...) /// /// <param name="poThatGroup">The Group that we are using to update this one</param> /// <param name="poTargetField">The Field that possesses the Attribute list of interest</param> /// <param name="psCurrTimeStamp">The current Timestamp that we will use to set any associated AttrModDdt</param> /// <returns>The AttrID of the AttrModDt which has been updated with the CurrTimeStamp</returns> /// </summary> public int UpdateField(WonkaPrdGroup poThatGroup, WonkaRefCadre poTargetField, string psCurrTimeStamp = null) { int nUpdatedModDtAttrId = 0; HashSet <int> FieldAttrIds = WonkaRefEnvironment.GetInstance().GetAttrIdsByFieldId(poTargetField.CadreId); string sTimeStamp = (!String.IsNullOrEmpty(psCurrTimeStamp)) ? psCurrTimeStamp : DateTime.Now.ToString("yyyyMMddHHmmss"); foreach (WonkaPrdGroupDataRow ThatRow in poThatGroup) { WonkaPrdGroupDataRow ThisRow = (this.GetRowIndex(ThatRow.GetKey()) >= 0) ? this.GetRow(ThatRow.GetKey()) : AppendRow(); foreach (int nTempAttrId in FieldAttrIds) { string sThatValue = ThatRow[nTempAttrId]; if (!String.IsNullOrEmpty(sThatValue)) { WonkaRefAttr TempAttr = WonkaRefEnvironment.GetInstance().GetAttributeByAttrId(nTempAttrId); ThisRow[nTempAttrId] = sThatValue; if (TempAttr.AttrModDtFlag) { try { WonkaRefAttr TempAttrModDt = WonkaRefEnvironment.GetInstance().GetAttributeByAttrName(TempAttr.AttrModDt); string sThatAttrModDtValue = ThatRow[TempAttrModDt.AttrId]; // NOTE: We will only use the CurrentTimestamp if there isn't already a timestamp value // in the provided DataRow of ThatGroup if (String.IsNullOrEmpty(sThatAttrModDtValue)) { ThisRow[TempAttrModDt.AttrId] = sTimeStamp; if (nUpdatedModDtAttrId == 0) { nUpdatedModDtAttrId = TempAttrModDt.AttrId; } } } catch (Exception ex) { throw new Exception("ERROR! Cannot set the ATTR_MOD_DT sibling (" + TempAttr.AttrModDt + ") for ATTRIBUTE (" + TempAttr.AttrName + ")."); } } } } } return(nUpdatedModDtAttrId); }
/// <summary> /// /// This method will compare two DataRows to see if their Fields are equal. /// /// NOTE: Currently, it doesn't compare them exactly. It just ensures that /// the contents of the Field in 'r1' are the same in 'r2', implying that /// the'r2' Field can be a superset of 'r1'. /// /// </summary> /// <param name="poThatDataRow">The data row that this one is being compared to</param> /// <returns>Bool that indicates whether or not the two DataRows are equal</returns> public bool Equals(WonkaPrdGroupDataRow poThatDataRow, WonkaRefCadre poField) { foreach (int nAttrId in poField.AttrIds) { if (this[nAttrId] != poThatDataRow[nAttrId]) { return(false); } } return(true); }
/// <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); }
/// <summary> /// /// This method will detect if this Data Row is null (i.e., empty with no values present) /// with respect to those Attributes in the indicated Field. /// /// </summary> /// <param name="poField">The Field whose Attributes are being inspected</param> /// <returns>Bool whether the row is empty (i.e., null) in terms of the Attributes for the Field</returns> public bool IsNull(WonkaRefCadre poField) { foreach (int nAttrId in poField.AttrIds) { string sValue = this[nAttrId]; if (sValue.Length > 0) { return(false); } } return(true); }
public List <WonkaRefCadre> GetCadreCache() { List <WonkaRefCadre> FieldCache = new List <WonkaRefCadre>(); XmlSerializer FieldSerializer = new XmlSerializer(typeof(WonkaRefCadre)); XmlNodeList FieldNodeList = moXmlDoc.GetElementsByTagName("Field"); foreach (XmlNode FieldNode in FieldNodeList) { WonkaRefCadre TempField = (WonkaRefCadre)FieldSerializer.Deserialize(new StringReader(FieldNode.OuterXml)); FieldCache.Add(TempField); } return(FieldCache); }
/// <summary> /// /// This method will detect if all DataRows contained in this Group are considered 'null' (i.e., empty of values), /// but only for those Attributes mentioned within the target Field. /// /// <param name="poField">The target Field with the list of Attributes on which we are focused</param> /// <param name="pbIgnoreDeletedRows">Indicates whether or not Marked-as-Delete rows should be ignored</param> /// <returns>Bool that indicates if there are any rows present inside the Group that are not null</returns> /// /// </summary> public bool IsNull(WonkaRefCadre poField, bool pbIgnoreDeletedRows = true) { bool bResult = true; if (GetRowCount() == 0) { return(bResult); } int nGrpSeqAttrId = -1; HashSet <int> FieldAttrIds = WonkaRefEnvironment.GetInstance().GetAttrIdsByFieldId(poField.CadreId); if (this.MasterGroup.IsSequenced) { nGrpSeqAttrId = WonkaRefEnvironment.GetInstance().GetGroupSeqAttrId(MasterGroup.GroupId); } foreach (WonkaPrdGroupDataRow TempDataRow in DataRowVector) { if (pbIgnoreDeletedRows) { if ((nGrpSeqAttrId >= 0) && (TempDataRow[nGrpSeqAttrId] == "0")) { continue; } } foreach (int nAttrId in FieldAttrIds) { string sTempValue = TempDataRow[nAttrId]; if (!String.IsNullOrEmpty(sTempValue)) { return(false); } } } return(bResult); }
public void AddField(WonkaRefCadre poNewField) { CadreCollection.Add(poNewField); }
/// <summary> /// /// This method will detect whether or not this Product already has an instance of the identified /// ProductField /// /// <param name="poField">The Field indicating the ProductField that we are interested in</param> /// <returns>Indicator of whether or not an instance of that ProductField has been created within this Product</returns> /// </summary> public bool HasProductField(WonkaRefCadre poField) { return(this.ProductCadreIndex.Keys.Contains(poField.CadreId)); }