diff options
| author | Roy Ben Shabat <Roy.mail.net@gmail.com> | 2019-12-18 15:52:25 +0200 |
|---|---|---|
| committer | Roy Ben Shabat <Roy.mail.net@gmail.com> | 2019-12-18 15:52:25 +0200 |
| commit | 41b950b3f3f7fa0384cccd13ed4ef38119bbcbcf (patch) | |
| tree | f6c535ae38fcf71842f0af4622c806044224974d /Software/Visual_Studio/Tango.BL | |
| parent | 615bc666c8d0618d93bc4401a74928535c2cc7f6 (diff) | |
| download | Tango-41b950b3f3f7fa0384cccd13ed4ef38119bbcbcf.tar.gz Tango-41b950b3f3f7fa0384cccd13ed4ef38119bbcbcf.zip | |
Fixed ContinueThreadLoadingResponse.
Refactored ActionLog Difference data structure to node tree.
Diffstat (limited to 'Software/Visual_Studio/Tango.BL')
18 files changed, 269 insertions, 115 deletions
diff --git a/Software/Visual_Studio/Tango.BL/ActionLogs/BasicActionLogComparer.cs b/Software/Visual_Studio/Tango.BL/ActionLogs/BasicActionLogComparer.cs index 61fc373a8..af52bf394 100644 --- a/Software/Visual_Studio/Tango.BL/ActionLogs/BasicActionLogComparer.cs +++ b/Software/Visual_Studio/Tango.BL/ActionLogs/BasicActionLogComparer.cs @@ -11,19 +11,36 @@ namespace Tango.BL.ActionLogs { public class BasicActionLogComparer { - public Task<List<ActionLogDifference>> Compare(IActionLogComparable before, IActionLogComparable after) + public Task<ActionLogDifference> Compare(IActionLogComparable before, IActionLogComparable after) { - return Task.Factory.StartNew<List<ActionLogDifference>>(() => + return Task.Factory.StartNew<ActionLogDifference>(() => { - List<ActionLogDifference> diffs = new List<ActionLogDifference>(); + ActionLogDifference diff = new ActionLogDifference(); + diff.Name = GetComponentName(before, after); - Compare(diffs, before, after, null); + Compare(diff, before, after, null); + RemoveNoDifferences(diff); - return diffs; + return diff; }); } - private void Compare(List<ActionLogDifference> diffs, Object before, Object after, HashSet<Object> scannedObjects) + private void RemoveNoDifferences(ActionLogDifference diff) + { + foreach (var child in diff.Children.ToList()) + { + if (!child.HasDifference) + { + diff.Children.Remove(child); + } + else + { + RemoveNoDifferences(child); + } + } + } + + private void Compare(ActionLogDifference diff, Object before, Object after, HashSet<Object> scannedObjects) { if (scannedObjects == null) { @@ -46,7 +63,7 @@ namespace Tango.BL.ActionLogs String component = GetComponentName(before, after); - foreach (var prop in GetProperties(before, after)) + foreach (var prop in GetProperties(before, after).OrderByDescending(x => x.PropertyType.IsPrimitive || x.PropertyType.IsValueType || x.PropertyType == typeof(String))) { if (GetShouldIgnore(prop, before, after)) continue; @@ -65,14 +82,14 @@ namespace Tango.BL.ActionLogs afterValue = prop.GetValue(after); } - if (afterValue == null && beforeValue != null) AddDiff(diffs, component, prop.Name, beforeValue, afterValue); - if (afterValue != null && beforeValue == null) AddDiff(diffs, component, prop.Name, beforeValue, afterValue); + if (afterValue == null && beforeValue != null) AddValueDiff(diff, prop.Name, beforeValue, afterValue); + if (afterValue != null && beforeValue == null) AddValueDiff(diff, prop.Name, beforeValue, afterValue); if (afterValue != null && beforeValue != null) { if (!afterValue.Equals(beforeValue)) { - AddDiff(diffs, component, prop.Name, beforeValue, afterValue); + AddValueDiff(diff, prop.Name, beforeValue, afterValue); } } } @@ -91,7 +108,7 @@ namespace Tango.BL.ActionLogs afterPropInstance = prop.GetValue(after); } - Compare(diffs, beforePropInstance, afterPropInstance, scannedObjects); + Compare(AddChildDiff(diff, prop.Name), beforePropInstance, afterPropInstance, scannedObjects); } else { @@ -108,18 +125,18 @@ namespace Tango.BL.ActionLogs afterCollection = prop.GetValue(after) as IList; } - if (beforeCollection != null && beforeCollection == null) + if (beforeCollection != null && afterCollection == null) { for (int i = 0; i < beforeCollection.Count; i++) { - Compare(diffs, beforeCollection[i], null, scannedObjects); + Compare(AddChildDiff(diff, GetActionLogName(beforeCollection[i],prop.Name)), beforeCollection[i], null, scannedObjects); } } else if (beforeCollection == null && afterCollection != null) { for (int i = 0; i < afterCollection.Count; i++) { - Compare(diffs, null, afterCollection[i], scannedObjects); + Compare(AddChildDiff(diff, GetActionLogName(afterCollection[i], prop.Name)), null, afterCollection[i], scannedObjects); } } @@ -129,27 +146,52 @@ namespace Tango.BL.ActionLogs { var beforeItem = i < beforeCollection.Count ? beforeCollection[i] : null; var afterItem = i < afterCollection.Count ? afterCollection[i] : null; - Compare(diffs, beforeItem, afterItem, scannedObjects); + Compare(AddChildDiff(diff, GetActionLogName(beforeItem, prop.Name)), beforeItem, afterItem, scannedObjects); } } } } } - private void AddDiff(List<ActionLogDifference> diffs, String component, String property, object before, object after) + private void AddValueDiff(ActionLogDifference diff, String property, object before, object after) { - diffs.Add(new ActionLogDifference() + diff.Children.Add(new ActionLogDifferenceValue() { - Component = component, - Property = property, + Name = property, Before = before, After = after }); } + private ActionLogDifference AddChildDiff(ActionLogDifference diff, String property) + { + ActionLogDifference childDiff = new ActionLogDifference(); + childDiff.Name = property; + diff.Children.Add(childDiff); + return childDiff; + } + private String GetComponentName(Object before, Object after) { - return after != null ? after.GetType().Name : before.GetType().Name; + var afterCast = after as IActionLogComparable; + var beforeCast = before as IActionLogComparable; + + var name = afterCast != null ? afterCast.GetActionName() : beforeCast.GetActionName(); + + return name; + } + + private String GetActionLogName(Object obj, String defaultName) + { + var objCast = obj as IActionLogComparable; + if (objCast != null) + { + return objCast.GetActionName(); + } + else + { + return defaultName; + } } private PropertyInfo GetProperty(String name, Object before, Object after) diff --git a/Software/Visual_Studio/Tango.BL/ActionLogs/DefaultActionLogManager.cs b/Software/Visual_Studio/Tango.BL/ActionLogs/DefaultActionLogManager.cs index 23562bee0..9d632bccc 100644 --- a/Software/Visual_Studio/Tango.BL/ActionLogs/DefaultActionLogManager.cs +++ b/Software/Visual_Studio/Tango.BL/ActionLogs/DefaultActionLogManager.cs @@ -14,109 +14,113 @@ namespace Tango.BL.ActionLogs { public class DefaultActionLogManager : ExtendedObject, IActionLogManager { - public bool ThrowExceptions { get; set; } - - public DefaultActionLogManager() + public void InsertLog(ActionLogType type, string userGuid, string relatedObjectName, string relatedObjectGuid, ActionLogDifference difference, string message = null) { - ThrowExceptions = true; - } - - public async Task InsertLog(ActionLogType type, string userGuid, string relatedObjectName, string relatedObjectGuid, List<ActionLogDifference> differences, string message = null) - { - using (ObservablesContext db = ObservablesContext.CreateDefault()) + Task.Factory.StartNew(() => { - try + using (ObservablesContext db = ObservablesContext.CreateDefault()) { - ActionLog log = new ActionLog(); - log.ActionType = type; - log.LastUpdated = DateTime.UtcNow; - log.UserGuid = userGuid; - log.RelatedObjectName = relatedObjectName; - log.RelatedObjectGuid = relatedObjectGuid; - log.Message = message; - log.Differences = differences; + try + { + ActionLog log = new ActionLog(); + log.ActionType = type; + log.LastUpdated = DateTime.UtcNow; + log.UserGuid = userGuid; + log.RelatedObjectName = relatedObjectName; + log.RelatedObjectGuid = relatedObjectGuid; + log.Message = message; + log.DifferenceObject = difference; - db.ActionLogs.Add(log); + db.ActionLogs.Add(log); - await db.SaveChangesAsync(); + db.SaveChanges(); - LogManager.Log($"Action log '{type}' inserted."); + LogManager.Log($"Action log '{type}' inserted."); - if (differences != null && differences.Count > 0) - { - Debug.WriteLine($"Action log differences:\n{differences.ToJsonString()}"); + if (difference != null && difference.Children.Count > 0) + { + Debug.WriteLine($"Action log differences:\n{difference.ToJsonString()}"); + } } - } - catch (Exception ex) - { - LogManager.Log(ex, $"Error inserting action log '{type}'."); - - if (ThrowExceptions) + catch (Exception ex) { - throw ex; + LogManager.Log(ex, $"Error inserting action log '{type}'."); } } - } + }); } - public async Task InsertLog(ActionLogType type, string userGuid, string relatedObjectName, IActionLogComparable relatedObjectBefore, IActionLogComparable relatedObjectAfter, string message = null) + public void InsertLog(ActionLogType type, string userGuid, string relatedObjectName, IActionLogComparable relatedObjectBefore, IActionLogComparable relatedObjectAfter, string message = null) { - List<ActionLogDifference> diffs = null; - - try + Task.Factory.StartNew(() => { - if (relatedObjectAfter != null) + ActionLogDifference diff = null; + + try { - diffs = await relatedObjectAfter.CompareTo(relatedObjectBefore); + diff = new BasicActionLogComparer().Compare(relatedObjectBefore, relatedObjectAfter).Result; } - else + catch (Exception ex) { - diffs = await relatedObjectBefore.CompareTo(relatedObjectAfter); + LogManager.Log(ex, $"Error while comparing for action log '{type}'."); } - } - catch (Exception ex) - { - LogManager.Log(ex, $"Error while comparing for action log '{type}'."); - if (ThrowExceptions) + if (diff.Children.Count > 0) { - throw ex; + InsertLog(type, userGuid, relatedObjectName, GetRelatedObjectGuid(relatedObjectBefore, relatedObjectAfter), diff, message); } - } + else + { + LogManager.Log($"Action log '{type}' was about to be inserted but skipped due to no differences."); + } + }); + } + + public void InsertLog(ActionLogType type, User user, string relatedObjectName, IActionLogComparable relatedObjectBefore, IActionLogComparable relatedObjectAfter, string message = null) + { + InsertLog(type, user.Guid, relatedObjectName, relatedObjectBefore, relatedObjectAfter, message); + } + + public void InsertLog(ActionLogType type, string userGuid, string relatedObjectName, string relatedObjectGuid, string message = null) + { + InsertLog(type, userGuid, relatedObjectName, relatedObjectGuid, null, message); + } - if (diffs.Count > 0) + public void InsertLog(ActionLogType type, User user, string relatedObjectName, IActionLogComparable relatedObject, string message = null, bool serializeRelatedObject = false) + { + if (serializeRelatedObject) { - await InsertLog(type, userGuid, relatedObjectName, relatedObjectAfter.Guid, diffs, message); + InsertLog(type, user.Guid, relatedObjectName, relatedObject, null, message); } else { - LogManager.Log($"Action log '{type}' was about to be inserted but skipped due to no differences."); + InsertLog(type, user.Guid, relatedObjectName, relatedObject?.Guid, message); } } - public Task InsertLog(ActionLogType type, User user, string relatedObjectName, IActionLogComparable relatedObjectBefore, IActionLogComparable relatedObjectAfter, string message = null) + public void InsertLog(ActionLogType type, string userGuid, string message = null) { - return InsertLog(type, user.Guid, relatedObjectName, relatedObjectBefore, relatedObjectAfter, message); + InsertLog(type, userGuid, null, null, message); } - public Task InsertLog(ActionLogType type, string userGuid, string relatedObjectName, string relatedObjectGuid, string message = null) + public void InsertLog(ActionLogType type, User user, string message = null) { - return InsertLog(type, userGuid, relatedObjectName, relatedObjectGuid, null, message); + InsertLog(type, user.Guid, message); } - public Task InsertLog(ActionLogType type, User user, string relatedObjectName, IObservableEntity relatedObject, string message = null) + private String GetRelatedObjectGuid(IActionLogComparable before, IActionLogComparable after) { - return InsertLog(type, user.Guid, relatedObjectName, relatedObject?.Guid, message); - } + if (before != null) + { + return before.Guid; + } - public Task InsertLog(ActionLogType type, string userGuid, string message = null) - { - return InsertLog(type, userGuid, null, null, message); - } + if (after != null) + { + return after.Guid; + } - public Task InsertLog(ActionLogType type, User user, string message = null) - { - return InsertLog(type, user.Guid, message); + return null; } } } diff --git a/Software/Visual_Studio/Tango.BL/ActionLogs/IActionLogComparable.cs b/Software/Visual_Studio/Tango.BL/ActionLogs/IActionLogComparable.cs index de534141b..d98dd9122 100644 --- a/Software/Visual_Studio/Tango.BL/ActionLogs/IActionLogComparable.cs +++ b/Software/Visual_Studio/Tango.BL/ActionLogs/IActionLogComparable.cs @@ -10,12 +10,13 @@ namespace Tango.BL.ActionLogs public interface IActionLogComparable { String Guid { get; } - Task<List<ActionLogDifference>> CompareTo(IActionLogComparable before); + Task<ActionLogDifference> CompareTo(IActionLogComparable before); bool ShouldActionLogIgnore(String propName); + String GetActionName(); } public interface IActionLogComparable<T> : IActionLogComparable where T : class { - Task<List<ActionLogDifference>> CompareTo(T before); + Task<ActionLogDifference> CompareTo(T before); } } diff --git a/Software/Visual_Studio/Tango.BL/ActionLogs/IActionLogManager.cs b/Software/Visual_Studio/Tango.BL/ActionLogs/IActionLogManager.cs index fd903bbba..36fb62ed4 100644 --- a/Software/Visual_Studio/Tango.BL/ActionLogs/IActionLogManager.cs +++ b/Software/Visual_Studio/Tango.BL/ActionLogs/IActionLogManager.cs @@ -11,13 +11,12 @@ namespace Tango.BL.ActionLogs { public interface IActionLogManager { - bool ThrowExceptions { get; set; } - Task InsertLog(ActionLogType type, String userGuid, String relatedObjectName, String relatedObjectGuid, List<ActionLogDifference> differences, String message = null); - Task InsertLog(ActionLogType type, String userGuid, String relatedObjectName, IActionLogComparable relatedObjectBefore, IActionLogComparable relatedObjectAfter, String message = null); - Task InsertLog(ActionLogType type, User user, String relatedObjectName, IActionLogComparable relatedObjectBefore, IActionLogComparable relatedObjectAfter, String message = null); - Task InsertLog(ActionLogType type, String userGuid, String relatedObjectName, String relatedObjectGuid, String message = null); - Task InsertLog(ActionLogType type, User user, String relatedObjectName, IObservableEntity relatedObject, String message = null); - Task InsertLog(ActionLogType type, String userGuid, String message = null); - Task InsertLog(ActionLogType type, User user, String message = null); + void InsertLog(ActionLogType type, String userGuid, String relatedObjectName, String relatedObjectGuid, ActionLogDifference diffference, String message = null); + void InsertLog(ActionLogType type, String userGuid, String relatedObjectName, IActionLogComparable relatedObjectBefore, IActionLogComparable relatedObjectAfter, String message = null); + void InsertLog(ActionLogType type, User user, String relatedObjectName, IActionLogComparable relatedObjectBefore, IActionLogComparable relatedObjectAfter, String message = null); + void InsertLog(ActionLogType type, String userGuid, String relatedObjectName, String relatedObjectGuid, String message = null); + void InsertLog(ActionLogType type, User user, String relatedObjectName, IActionLogComparable relatedObject, String message = null, bool serializeRelatedObject = false); + void InsertLog(ActionLogType type, String userGuid, String message = null); + void InsertLog(ActionLogType type, User user, String message = null); } } diff --git a/Software/Visual_Studio/Tango.BL/DTO/BrushStopDTO.cs b/Software/Visual_Studio/Tango.BL/DTO/BrushStopDTO.cs index 585f2f2ee..fd1d707b5 100644 --- a/Software/Visual_Studio/Tango.BL/DTO/BrushStopDTO.cs +++ b/Software/Visual_Studio/Tango.BL/DTO/BrushStopDTO.cs @@ -13,5 +13,10 @@ namespace Tango.BL.DTO { return propName == nameof(Corrected); } + + protected override string OnGetActionLogName() + { + return $"BrushStop '{StopIndex}'"; + } } } diff --git a/Software/Visual_Studio/Tango.BL/DTO/ColorCatalogDTO.cs b/Software/Visual_Studio/Tango.BL/DTO/ColorCatalogDTO.cs index 012e7aede..7daa98aca 100644 --- a/Software/Visual_Studio/Tango.BL/DTO/ColorCatalogDTO.cs +++ b/Software/Visual_Studio/Tango.BL/DTO/ColorCatalogDTO.cs @@ -9,6 +9,16 @@ namespace Tango.BL.DTO { public class ColorCatalogDTO : ColorCatalogDTOBase { + public List<ColorCatalogsGroupDTO> ColorCatalogsGroups { get; set; } + public ColorCatalogDTO() + { + ColorCatalogsGroups = new List<ColorCatalogsGroupDTO>(); + } + + protected override string OnGetActionLogName() + { + return $"'{Name}' Catalog"; + } } } diff --git a/Software/Visual_Studio/Tango.BL/DTO/ColorCatalogsGroupDTO.cs b/Software/Visual_Studio/Tango.BL/DTO/ColorCatalogsGroupDTO.cs index 8115923e5..50c5e051e 100644 --- a/Software/Visual_Studio/Tango.BL/DTO/ColorCatalogsGroupDTO.cs +++ b/Software/Visual_Studio/Tango.BL/DTO/ColorCatalogsGroupDTO.cs @@ -9,6 +9,16 @@ namespace Tango.BL.DTO { public class ColorCatalogsGroupDTO : ColorCatalogsGroupDTOBase { + public List<ColorCatalogsItemDTO> ColorCatalogsItems { get; set; } + public ColorCatalogsGroupDTO() + { + ColorCatalogsItems = new List<ColorCatalogsItemDTO>(); + } + + protected override string OnGetActionLogName() + { + return $"Color Group '{Name}'"; + } } } diff --git a/Software/Visual_Studio/Tango.BL/DTO/ColorCatalogsItemDTO.cs b/Software/Visual_Studio/Tango.BL/DTO/ColorCatalogsItemDTO.cs index 46b33b715..5e0fd3115 100644 --- a/Software/Visual_Studio/Tango.BL/DTO/ColorCatalogsItemDTO.cs +++ b/Software/Visual_Studio/Tango.BL/DTO/ColorCatalogsItemDTO.cs @@ -9,6 +9,11 @@ namespace Tango.BL.DTO { public class ColorCatalogsItemDTO : ColorCatalogsItemDTOBase { + public List<ColorCatalogsItemsRecipeDTO> ColorCatalogsItemsRecipes { get; set; } + protected override string OnGetActionLogName() + { + return $"Color Item '{Name}'"; + } } } diff --git a/Software/Visual_Studio/Tango.BL/DTO/ColorCatalogsItemsRecipeDTO.cs b/Software/Visual_Studio/Tango.BL/DTO/ColorCatalogsItemsRecipeDTO.cs index 07c7695e1..34b061df8 100644 --- a/Software/Visual_Studio/Tango.BL/DTO/ColorCatalogsItemsRecipeDTO.cs +++ b/Software/Visual_Studio/Tango.BL/DTO/ColorCatalogsItemsRecipeDTO.cs @@ -9,6 +9,9 @@ namespace Tango.BL.DTO { public class ColorCatalogsItemsRecipeDTO : ColorCatalogsItemsRecipeDTOBase { - + protected override string OnGetActionLogName() + { + return $"Color Recipe for RML '{RmlGuid}'"; + } } } diff --git a/Software/Visual_Studio/Tango.BL/DTO/JobDTO.cs b/Software/Visual_Studio/Tango.BL/DTO/JobDTO.cs index 36f7ea9be..176d97251 100644 --- a/Software/Visual_Studio/Tango.BL/DTO/JobDTO.cs +++ b/Software/Visual_Studio/Tango.BL/DTO/JobDTO.cs @@ -22,5 +22,10 @@ namespace Tango.BL.DTO propName == nameof(JobDTO.Status) || propName == nameof(JobDTO.IsSynchronized); } + + protected override string OnGetActionLogName() + { + return $"'{Name}' Job"; + } } } diff --git a/Software/Visual_Studio/Tango.BL/DTO/SegmentDTO.cs b/Software/Visual_Studio/Tango.BL/DTO/SegmentDTO.cs index 09f581db2..00d74ec30 100644 --- a/Software/Visual_Studio/Tango.BL/DTO/SegmentDTO.cs +++ b/Software/Visual_Studio/Tango.BL/DTO/SegmentDTO.cs @@ -15,5 +15,10 @@ namespace Tango.BL.DTO { BrushStops = new List<BrushStopDTO>(); } + + protected override string OnGetActionLogName() + { + return $"Segment '{SegmentIndex}'"; + } } } diff --git a/Software/Visual_Studio/Tango.BL/Entities/ActionLog.cs b/Software/Visual_Studio/Tango.BL/Entities/ActionLog.cs index af88ee7f1..bb122872f 100644 --- a/Software/Visual_Studio/Tango.BL/Entities/ActionLog.cs +++ b/Software/Visual_Studio/Tango.BL/Entities/ActionLog.cs @@ -12,7 +12,7 @@ namespace Tango.BL.Entities { public class ActionLog : ActionLogBase { - private List<ActionLogDifference> _differences; + private ActionLogDifference _differenceObject; [NotMapped] [JsonIgnore] @@ -24,35 +24,35 @@ namespace Tango.BL.Entities [NotMapped] [JsonIgnore] - public List<ActionLogDifference> Differences + public ActionLogDifference DifferenceObject { get { - if (_differences != null) + if (_differenceObject != null) { try { - _differences = JsonConvert.DeserializeObject<List<ActionLogDifference>>(Difference); + _differenceObject = JsonConvert.DeserializeObject<ActionLogDifference>(Difference); } catch { - _differences = new List<ActionLogDifference>(); + _differenceObject = new ActionLogDifference(); } } else { - _differences = new List<ActionLogDifference>(); + _differenceObject = new ActionLogDifference(); } - return _differences; + return _differenceObject; } set { - _differences = value; + _differenceObject = value; - if (_differences != null) + if (_differenceObject != null) { - Difference = JsonConvert.SerializeObject(_differences); + Difference = JsonConvert.SerializeObject(_differenceObject); } } } diff --git a/Software/Visual_Studio/Tango.BL/Enumerations/ActionLogType.cs b/Software/Visual_Studio/Tango.BL/Enumerations/ActionLogType.cs index 94eb07cda..5114538ef 100644 --- a/Software/Visual_Studio/Tango.BL/Enumerations/ActionLogType.cs +++ b/Software/Visual_Studio/Tango.BL/Enumerations/ActionLogType.cs @@ -50,6 +50,8 @@ namespace Tango.BL.Enumerations JobDeleted = 301, [Description("Job Saved")] JobSaved = 302, + [Description("Job Imported")] + JobImported = 303, //Machines [Description("Machine Created")] diff --git a/Software/Visual_Studio/Tango.BL/ObservableEntity.cs b/Software/Visual_Studio/Tango.BL/ObservableEntity.cs index 11aca0e99..36e1a4ef8 100644 --- a/Software/Visual_Studio/Tango.BL/ObservableEntity.cs +++ b/Software/Visual_Studio/Tango.BL/ObservableEntity.cs @@ -663,12 +663,12 @@ namespace Tango.BL #region Action Log - public Task<List<ActionLogDifference>> CompareTo(T before) + public Task<ActionLogDifference> CompareTo(T before) { return new BasicActionLogComparer().Compare(before as IActionLogComparable, this); } - Task<List<ActionLogDifference>> IActionLogComparable.CompareTo(IActionLogComparable before) + Task<ActionLogDifference> IActionLogComparable.CompareTo(IActionLogComparable before) { return CompareTo(before as T); } @@ -683,6 +683,16 @@ namespace Tango.BL return false; } + string IActionLogComparable.GetActionName() + { + return OnGetActionLogName(); + } + + protected virtual String OnGetActionLogName() + { + return this.GetType().Name; + } + #endregion } } diff --git a/Software/Visual_Studio/Tango.BL/ObservableEntityDTO.cs b/Software/Visual_Studio/Tango.BL/ObservableEntityDTO.cs index f587147e1..cb49f3769 100644 --- a/Software/Visual_Studio/Tango.BL/ObservableEntityDTO.cs +++ b/Software/Visual_Studio/Tango.BL/ObservableEntityDTO.cs @@ -210,12 +210,12 @@ namespace Tango.BL return EqualsToObservable(observable); } - public Task<List<ActionLogDifference>> CompareTo(DTO before) + public Task<ActionLogDifference> CompareTo(DTO before) { return new BasicActionLogComparer().Compare(before, this); } - Task<List<ActionLogDifference>> IActionLogComparable.CompareTo(IActionLogComparable before) + Task<ActionLogDifference> IActionLogComparable.CompareTo(IActionLogComparable before) { return CompareTo(before as DTO); } @@ -229,5 +229,15 @@ namespace Tango.BL { return false; } + + string IActionLogComparable.GetActionName() + { + return OnGetActionLogName(); + } + + protected virtual String OnGetActionLogName() + { + return this.GetType().Name; + } } } diff --git a/Software/Visual_Studio/Tango.BL/Tango.BL.csproj b/Software/Visual_Studio/Tango.BL/Tango.BL.csproj index 469e23165..2f9cf489e 100644 --- a/Software/Visual_Studio/Tango.BL/Tango.BL.csproj +++ b/Software/Visual_Studio/Tango.BL/Tango.BL.csproj @@ -510,6 +510,7 @@ <Compile Include="Serialization\SerializableEntityContractResolver.cs" /> <Compile Include="Utils\BrushStopUtils.cs" /> <Compile Include="ValueObjects\ActionLogDifference.cs" /> + <Compile Include="ValueObjects\ActionLogDifferenceValue.cs" /> <Compile Include="ValueObjects\HardwareConfiguration.cs" /> </ItemGroup> <ItemGroup> @@ -590,7 +591,7 @@ </Target> <ProjectExtensions> <VisualStudio> - <UserProperties BuildVersion_StartDate="2000/1/1" BuildVersion_UseGlobalSettings="False" BuildVersion_BuildVersioningStyle="None.None.Increment.TimeStamp" BuildVersion_UpdateAssemblyVersion="True" BuildVersion_AssemblyInfoFilename="Properties\AssemblyInfo.cs" /> + <UserProperties BuildVersion_AssemblyInfoFilename="Properties\AssemblyInfo.cs" BuildVersion_UpdateAssemblyVersion="True" BuildVersion_BuildVersioningStyle="None.None.Increment.TimeStamp" BuildVersion_UseGlobalSettings="False" BuildVersion_StartDate="2000/1/1" /> </VisualStudio> </ProjectExtensions> </Project>
\ No newline at end of file diff --git a/Software/Visual_Studio/Tango.BL/ValueObjects/ActionLogDifference.cs b/Software/Visual_Studio/Tango.BL/ValueObjects/ActionLogDifference.cs index a89348249..d15ddc9c7 100644 --- a/Software/Visual_Studio/Tango.BL/ValueObjects/ActionLogDifference.cs +++ b/Software/Visual_Studio/Tango.BL/ValueObjects/ActionLogDifference.cs @@ -1,4 +1,5 @@ -using System; +using Newtonsoft.Json; +using System; using System.Collections.Generic; using System.Linq; using System.Text; @@ -8,9 +9,24 @@ namespace Tango.BL.ValueObjects { public class ActionLogDifference { - public String Component { get; set; } - public String Property { get; set; } - public Object Before { get; set; } - public Object After { get; set; } + public String Name { get; set; } + + public List<ActionLogDifference> Children { get; set; } + + [JsonIgnore] + public virtual bool HasDifference + { + get { return Children.Any(x => x.HasDifference); } + } + + public ActionLogDifference() + { + Children = new List<ActionLogDifference>(); + } + + public override string ToString() + { + return $"{Name} | Children[{Children.Count}]"; + } } } diff --git a/Software/Visual_Studio/Tango.BL/ValueObjects/ActionLogDifferenceValue.cs b/Software/Visual_Studio/Tango.BL/ValueObjects/ActionLogDifferenceValue.cs new file mode 100644 index 000000000..145fcd9b7 --- /dev/null +++ b/Software/Visual_Studio/Tango.BL/ValueObjects/ActionLogDifferenceValue.cs @@ -0,0 +1,26 @@ +using Newtonsoft.Json; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace Tango.BL.ValueObjects +{ + public class ActionLogDifferenceValue : ActionLogDifference + { + public Object Before { get; set; } + public Object After { get; set; } + + [JsonIgnore] + public override bool HasDifference + { + get { return Before != After; } + } + + public override string ToString() + { + return $"{Name}: Before: {Before} != After: {After}"; + } + } +} |
