aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--Software/PMR/Messages/ThreadLoading/ContinueThreadLoadingResponse.proto5
-rw-r--r--Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Catalogs/ViewModels/MainViewVM.cs19
-rw-r--r--Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Developer/ViewModels/MainViewVM.cs23
-rw-r--r--Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/ViewModelLocator.cs2
-rw-r--r--Software/Visual_Studio/Tango.BL/ActionLogs/BasicActionLogComparer.cs82
-rw-r--r--Software/Visual_Studio/Tango.BL/ActionLogs/DefaultActionLogManager.cs132
-rw-r--r--Software/Visual_Studio/Tango.BL/ActionLogs/IActionLogComparable.cs5
-rw-r--r--Software/Visual_Studio/Tango.BL/ActionLogs/IActionLogManager.cs15
-rw-r--r--Software/Visual_Studio/Tango.BL/DTO/BrushStopDTO.cs5
-rw-r--r--Software/Visual_Studio/Tango.BL/DTO/ColorCatalogDTO.cs10
-rw-r--r--Software/Visual_Studio/Tango.BL/DTO/ColorCatalogsGroupDTO.cs10
-rw-r--r--Software/Visual_Studio/Tango.BL/DTO/ColorCatalogsItemDTO.cs5
-rw-r--r--Software/Visual_Studio/Tango.BL/DTO/ColorCatalogsItemsRecipeDTO.cs5
-rw-r--r--Software/Visual_Studio/Tango.BL/DTO/JobDTO.cs5
-rw-r--r--Software/Visual_Studio/Tango.BL/DTO/SegmentDTO.cs5
-rw-r--r--Software/Visual_Studio/Tango.BL/Entities/ActionLog.cs20
-rw-r--r--Software/Visual_Studio/Tango.BL/Enumerations/ActionLogType.cs2
-rw-r--r--Software/Visual_Studio/Tango.BL/ObservableEntity.cs14
-rw-r--r--Software/Visual_Studio/Tango.BL/ObservableEntityDTO.cs14
-rw-r--r--Software/Visual_Studio/Tango.BL/Tango.BL.csproj3
-rw-r--r--Software/Visual_Studio/Tango.BL/ValueObjects/ActionLogDifference.cs26
-rw-r--r--Software/Visual_Studio/Tango.BL/ValueObjects/ActionLogDifferenceValue.cs26
22 files changed, 311 insertions, 122 deletions
diff --git a/Software/PMR/Messages/ThreadLoading/ContinueThreadLoadingResponse.proto b/Software/PMR/Messages/ThreadLoading/ContinueThreadLoadingResponse.proto
index 5763dbb2c..b937fbb34 100644
--- a/Software/PMR/Messages/ThreadLoading/ContinueThreadLoadingResponse.proto
+++ b/Software/PMR/Messages/ThreadLoading/ContinueThreadLoadingResponse.proto
@@ -1,12 +1,9 @@
syntax = "proto3";
-import "ThreadLoadingState.proto";
-
package Tango.PMR.ThreadLoading;
option java_package = "com.twine.tango.pmr.threadloading";
message ContinueThreadLoadingResponse
{
- ThreadLoadingState State = 1;
- string ErrorReason = 2;
+
} \ No newline at end of file
diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Catalogs/ViewModels/MainViewVM.cs b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Catalogs/ViewModels/MainViewVM.cs
index 4d88a71d9..404a459d3 100644
--- a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Catalogs/ViewModels/MainViewVM.cs
+++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Catalogs/ViewModels/MainViewVM.cs
@@ -17,6 +17,10 @@ using Microsoft.Win32;
using Tango.Core.Helpers;
using System.IO;
using Tango.MachineStudio.Catalogs.Excel;
+using Tango.BL.ActionLogs;
+using Tango.MachineStudio.Common.Authentication;
+using Tango.BL.Enumerations;
+using Tango.BL.DTO;
namespace Tango.MachineStudio.Catalogs.ViewModels
{
@@ -25,6 +29,9 @@ namespace Tango.MachineStudio.Catalogs.ViewModels
private ObservablesContext _catalogsContext;
private ObservablesContext _activeCatalogContext;
private INotificationProvider _notification;
+ private IActionLogManager _actionLogManager;
+ private IAuthenticationProvider _authentication;
+ private ColorCatalogDTO _catalogBeforeSave;
#region Properties
@@ -151,9 +158,11 @@ namespace Tango.MachineStudio.Catalogs.ViewModels
/// Initializes a new instance of the <see cref="MainViewVM"/> class.
/// </summary>
/// <param name="notificationProvider">The notification provider.</param>
- public MainViewVM(INotificationProvider notificationProvider) : this()
+ public MainViewVM(INotificationProvider notificationProvider, IActionLogManager actionLogManager, IAuthenticationProvider authenticationProvider) : this()
{
+ _actionLogManager = actionLogManager;
_notification = notificationProvider;
+ _authentication = authenticationProvider;
}
#endregion
@@ -206,6 +215,8 @@ namespace Tango.MachineStudio.Catalogs.ViewModels
SelectedItem = SelectedGroup.ColorCatalogsItems.FirstOrDefault();
}
+ _catalogBeforeSave = ColorCatalogDTO.FromObservable(ActiveCatalog);
+
View.NavigateTo(CatalogsNavigationView.CatalogView);
}
catch (Exception ex)
@@ -233,6 +244,7 @@ namespace Tango.MachineStudio.Catalogs.ViewModels
{
IsFree = false;
await SelectedCatalog.DeleteCascadeAsync(_catalogsContext);
+ _actionLogManager.InsertLog(ActionLogType.CatalogDeleted, _authentication.CurrentUser, SelectedCatalog.Name, SelectedCatalog, "Catalog deleted using Machine Studio.");
SelectedCatalog = null;
}
catch (Exception ex)
@@ -265,6 +277,7 @@ namespace Tango.MachineStudio.Catalogs.ViewModels
newCatalog.Company = "Twine";
_catalogsContext.ColorCatalogs.Add(newCatalog);
await _catalogsContext.SaveChangesAsync();
+ _actionLogManager.InsertLog(ActionLogType.CatalogCreated, _authentication.CurrentUser, newCatalog.Name, newCatalog, "Catalog created using Machine Studio.");
SelectedCatalog = newCatalog;
EditSelectedCatalog();
}
@@ -308,6 +321,10 @@ namespace Tango.MachineStudio.Catalogs.ViewModels
ActiveCatalog.LastUpdated = DateTime.UtcNow;
await _activeCatalogContext.SaveChangesAsync();
await LoadCatalogs();
+
+ var activeCatalogDTO = ColorCatalogDTO.FromObservable(ActiveCatalog);
+ _actionLogManager.InsertLog(ActionLogType.CatalogSaved, _authentication.CurrentUser, ActiveCatalog.Name, _catalogBeforeSave, activeCatalogDTO, "Catalog created using Machine Studio.");
+ _catalogBeforeSave = activeCatalogDTO;
_notification.ShowInfo("Catalog updated successfully.");
}
catch (Exception ex)
diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Developer/ViewModels/MainViewVM.cs b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Developer/ViewModels/MainViewVM.cs
index d598e2458..4b276462e 100644
--- a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Developer/ViewModels/MainViewVM.cs
+++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Developer/ViewModels/MainViewVM.cs
@@ -1928,7 +1928,7 @@ namespace Tango.MachineStudio.Developer.ViewModels
_activeJobDbContext.SaveChanges();
var afterJobDTO = JobDTO.FromObservable(ActiveJob);
- _actionLogManager.InsertLog(ActionLogType.JobSaved, AuthenticationProvider.CurrentUser, _beforeSaveJobDTO.Name, _beforeSaveJobDTO, afterJobDTO, "Job saved from research module in Machine Studio.").GetAwaiter().GetResult();
+ _actionLogManager.InsertLog(ActionLogType.JobSaved, AuthenticationProvider.CurrentUser, _beforeSaveJobDTO.Name, _beforeSaveJobDTO, afterJobDTO, "Job saved from research module in Machine Studio.");
_beforeSaveJobDTO = afterJobDTO;
_machineDbContext.Entry(SelectedMachineJob).Reload();
@@ -2191,6 +2191,8 @@ namespace Tango.MachineStudio.Developer.ViewModels
{
if (_notification.ShowQuestion("Are you sure you want to delete the selected jobs?"))
{
+ var jobsToReport = SelectedJobs.Select(x => JobDTO.FromObservable(x)).ToList();
+
LogManager.Log(String.Format("Removing {0} jobs...", SelectedJobs.Count));
SelectedJobs.ToList().ForEach(x =>
{
@@ -2202,6 +2204,11 @@ namespace Tango.MachineStudio.Developer.ViewModels
LogManager.Log("Saving selected machine to database...");
await SelectedMachine.SaveAsync(_machineDbContext);
}
+
+ foreach (var job in jobsToReport)
+ {
+ _actionLogManager.InsertLog(ActionLogType.JobDeleted, AuthenticationProvider.CurrentUser, job.Name, job, "Job deleted using Machine Studio.", true);
+ }
}
}
}
@@ -2258,6 +2265,7 @@ namespace Tango.MachineStudio.Developer.ViewModels
LogManager.Log("Saving selected machine to database...");
await SelectedMachine.SaveAsync(_machineDbContext);
+ _actionLogManager.InsertLog(ActionLogType.JobCreated, AuthenticationProvider.CurrentUser, newJob.Name, newJob, "Job created using Machine Studio.");
SelectedMachineJob = newJob;
LoadSelectedJob();
}
@@ -2388,6 +2396,11 @@ namespace Tango.MachineStudio.Developer.ViewModels
LogManager.Log("Saving selected machine to database...");
await SelectedMachine.SaveAsync(_machineDbContext);
+ foreach (var job in SelectedJobs)
+ {
+ _actionLogManager.InsertLog(ActionLogType.JobCreated, AuthenticationProvider.CurrentUser, job.Name, job, "Job created using Machine Studio.");
+ }
+
CanWork = true;
}
}
@@ -2611,6 +2624,8 @@ namespace Tango.MachineStudio.Developer.ViewModels
LogManager.Log($"Importing job files...");
+ List<Job> jobsToReport = new List<Job>();
+
foreach (var file in dlg.FileNames)
{
var bytes = File.ReadAllBytes(file);
@@ -2619,10 +2634,16 @@ namespace Tango.MachineStudio.Developer.ViewModels
job.JobSource = JobSource.Remote;
_machineDbContext.Jobs.Add(job);
+ jobsToReport.Add(job);
}
await _machineDbContext.SaveChangesAsync();
+ foreach (var job in jobsToReport)
+ {
+ _actionLogManager.InsertLog(ActionLogType.JobImported, AuthenticationProvider.CurrentUser, job.Name, job, "New job imported using Machine Studio.");
+ }
+
IsFree = true;
_notification.ShowInfo($"Jobs imported successfully.");
diff --git a/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/ViewModelLocator.cs b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/ViewModelLocator.cs
index a61f14746..6c550ffda 100644
--- a/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/ViewModelLocator.cs
+++ b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/ViewModelLocator.cs
@@ -95,7 +95,7 @@ namespace Tango.MachineStudio.UI
TangoIOC.Default.Register<IEventLogger, DefaultEventLogger>();
TangoIOC.Default.Register<ISpeechProvider, DefaultSpeechProvider>();
TangoIOC.Default.Register<IFirmwareUpgrader, DefaultFirmwareUpgrader>();
- TangoIOC.Default.Register<IActionLogManager, DefaultActionLogManager>(new DefaultActionLogManager() { ThrowExceptions = false });
+ TangoIOC.Default.Register<IActionLogManager, DefaultActionLogManager>();
TangoIOC.Default.Register<TeamFoundationServiceExtendedClient>(new TeamFoundationServiceExtendedClient("https://twinetfs.visualstudio.com", String.Empty, "szzfokrceo4rhd4eqi5qpmxn3pa5iwl3q7tlqd36l2m7smz2ynoa"));
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}";
+ }
+ }
+}