/// <summary> /// <para> /// Audits the this HermesScheduleItemStatus against another HermesScheduleItemStatus. /// It makes a field-by-field comparison testing what has changed. For each property /// that has a value different from other, one HermesAuditRecord is added to the returned list. /// </para> /// <para> /// If a property is a text type then the TextValue1 and TextValue2 proeprties /// of the HermesAuditRecord are populated with the property value of the old and current instance. /// If a property is a numeric type then the NumericValue1 and NumericValue2 proeprties /// of the HermesAuditRecord are populated with the property value of the old and current instance. /// </para> /// </summary> /// <exception cref="IllegalAuditItemException"> /// If old HermesScheduleItemStatus is the same object as this instance. /// </exception> /// <param name="old">HermesScheduleItemStatus to compary this to</param> /// <returns>IList of HermesAuditRecords detailing any changes</returns> public IList <HermesAuditRecord> Audit(HermesScheduleItemStatus old) { if (object.ReferenceEquals(old, this)) { IllegalAuditItemException e = new IllegalAuditItemException("Cannot audit an item against itself."); throw Helper.GetSelfDocumentingException(e, e.Message, GetType().FullName + "Audit(HermesScheduleItemStatus old)", new string[] { "values" }, new object[] { values }, new string[] { "old" }, new object[] { old }, new string[0], new object[0]); } return(Helper.GetAuditRecords <HermesScheduleItemStatus>(this, old, Id)); }
/// <summary> /// <p>Audits the this HermesScheduleItemStatus against another HermesScheduleItemStatus. It makes a /// field-by-field comparison testing what has changed.</p> <p>This method will fill the TextValue# or /// NumericValue#, and ID fields of each HermesAuditRecord it generates. It will be up to the service using this /// entity to fill the other fields.</p> <p><strong>Implementation Notes</strong></p> <ol type="disc"> <li>If /// the passed entity is null, jus create one HermesAuditRecord</li> <li>Iterate over the Values field. For each /// changed property: <ol type="disc"> <li>Create new HermesAuditRecord.</li> <li>If it is numeric, set /// hermesAuditRecord's NumericValue2 field to this entity's property value, and the NumericValue1 field to the /// passed entity's property value</li> <li>If it is text, set hermesAuditRecord's TextValue2 field to this /// entity's property value, and the TextValue1 field to the passed entity's property value</li> </ol> </li> /// <li>Return the HermesAuditRecords as an IList of HermesAuditRecord</li> </ol> /// </summary> /// <exception cref="IllegalAuditItemException"> /// IllegalAuditItemException If old HermesScheduleItemStatus is the same object as this /// </exception> /// <param name="old">HermesScheduleItemStatus to compary this to</param> /// <returns>IList of HermesAuditRecords detailing any changes</returns> public IList <HermesAuditRecord> Audit(HermesScheduleItemStatus old) { IList <HermesAuditRecord> ret = new List <HermesAuditRecord>(); if (old == null) { ret.Add(new HermesAuditRecord()); return(ret); } if (object.ReferenceEquals(old, this)) { throw new IllegalAuditItemException("Cannot audit an item against itself."); } foreach (string key in old.Values.Keys) { object newVal = Values[key].Value; object oldVal = old.Values[key].Value; if (!oldVal.Equals(newVal)) { HermesAuditRecord auditRec = new HermesAuditRecord(); if (Helper.IsNumeric(oldVal.GetType())) { //TODO set NumericValue } else if (oldVal.GetType().Equals(typeof(string))) { //TODO set TextValue } //TODO other type of fields ret.Add(auditRec); } } return(ret); }