aboutsummaryrefslogtreecommitdiffstats
path: root/Software/Visual_Studio/PPC/Modules
diff options
context:
space:
mode:
authorVictoria Plitt <Victoria.Plitt@twine-s.com>2022-05-29 18:00:42 +0300
committerVictoria Plitt <Victoria.Plitt@twine-s.com>2022-05-29 18:00:42 +0300
commita5750ed1aa564bf8a9071dd08df3a2ec003aa540 (patch)
tree56eff36769a0ba4129e3c47c9f2f9e3f2f89b4fc /Software/Visual_Studio/PPC/Modules
parent13dd96fc0e7cc40e6d1eb31f9e80ad5371a76b3d (diff)
downloadTango-a5750ed1aa564bf8a9071dd08df3a2ec003aa540.tar.gz
Tango-a5750ed1aa564bf8a9071dd08df3a2ec003aa540.zip
PPC. Saving job model to json string to compare changes.
Related Work Items: #6280
Diffstat (limited to 'Software/Visual_Studio/PPC/Modules')
-rw-r--r--Software/Visual_Studio/PPC/Modules/Tango.PPC.JobsV2/Models/BrushStopModel.cs92
-rw-r--r--Software/Visual_Studio/PPC/Modules/Tango.PPC.JobsV2/Models/JobModel.cs91
-rw-r--r--Software/Visual_Studio/PPC/Modules/Tango.PPC.JobsV2/Models/SegmentModel.cs41
-rw-r--r--Software/Visual_Studio/PPC/Modules/Tango.PPC.JobsV2/Models/SegmentsGroupModel.cs11
-rw-r--r--Software/Visual_Studio/PPC/Modules/Tango.PPC.JobsV2/Tango.PPC.JobsV2.csproj7
-rw-r--r--Software/Visual_Studio/PPC/Modules/Tango.PPC.JobsV2/ViewModels/JobViewVM.cs63
-rw-r--r--Software/Visual_Studio/PPC/Modules/Tango.PPC.JobsV2/packages.config1
7 files changed, 186 insertions, 120 deletions
diff --git a/Software/Visual_Studio/PPC/Modules/Tango.PPC.JobsV2/Models/BrushStopModel.cs b/Software/Visual_Studio/PPC/Modules/Tango.PPC.JobsV2/Models/BrushStopModel.cs
index e2acb9e7a..e7a282382 100644
--- a/Software/Visual_Studio/PPC/Modules/Tango.PPC.JobsV2/Models/BrushStopModel.cs
+++ b/Software/Visual_Studio/PPC/Modules/Tango.PPC.JobsV2/Models/BrushStopModel.cs
@@ -14,6 +14,7 @@ using System.Reflection;
using Tango.BL.Dispensing;
using Tango.BL;
using Tango.Core.ExtensionMethods;
+using Newtonsoft.Json;
namespace Tango.PPC.Jobs.Models
{
@@ -39,6 +40,7 @@ namespace Tango.PPC.Jobs.Models
public String Guid { get; set; }
+ [JsonIgnore]
public bool PreventPropertyUpdate { get; set; }
protected Double _cyan;
@@ -473,6 +475,7 @@ namespace Tango.PPC.Jobs.Models
}
protected ColorCatalogsItem _colorcatalogsitem;
+ [JsonIgnore]
public virtual ColorCatalogsItem ColorCatalogsItem
{
get
@@ -493,6 +496,13 @@ namespace Tango.PPC.Jobs.Models
}
}
+ public string ColorCatalogsItemGuid
+ {
+ get
+ {
+ return ColorCatalogsItem == null? "" : ColorCatalogsItem.Guid;
+ }
+ }
/// <summary>
/// Gets or sets the color catalog.
@@ -500,6 +510,7 @@ namespace Tango.PPC.Jobs.Models
/// <value>
/// The color catalog.
/// </value>
+ [JsonIgnore]
public virtual ColorCatalog ColorCatalog
{
get
@@ -512,6 +523,7 @@ namespace Tango.PPC.Jobs.Models
}
private System.Windows.Media.Color _color;
+ [JsonIgnore]
public System.Windows.Media.Color Color
{
get
@@ -530,7 +542,7 @@ namespace Tango.PPC.Jobs.Models
}
private System.Windows.Media.Color _bestMatchColor;
-
+ [JsonIgnore]
public System.Windows.Media.Color BestMatchColor
{
get { return _bestMatchColor; }
@@ -545,6 +557,7 @@ namespace Tango.PPC.Jobs.Models
}
}
+ [JsonIgnore]
public System.Windows.Media.Color ShownBestMatchColor
{
get
@@ -554,8 +567,8 @@ namespace Tango.PPC.Jobs.Models
return System.Windows.Media.Colors.Transparent;
}
}
-
-
+
+ [JsonIgnore]
public SolidColorBrush ColorBrush
{
get
@@ -569,18 +582,18 @@ namespace Tango.PPC.Jobs.Models
}
private SegmentModel _segmentmodel;
-
+ [JsonIgnore]
public SegmentModel SegmentModel
{
get { return _segmentmodel; }
set { _segmentmodel = value; }
}
-
-
+
private bool _outOfGamutChecked;
/// <summary>
/// Gets or sets a value indicating whether out of gamut has been checked.
/// </summary>
+ [JsonIgnore]
public bool OutOfGamutChecked
{
get { return _outOfGamutChecked; }
@@ -604,8 +617,41 @@ namespace Tango.PPC.Jobs.Models
}
}
+ [JsonIgnore]
protected bool RequiredMaxLiquidTest { get; set; }
+ [JsonIgnore]
+ public bool IsLiquidVolumesOutOfRange
+ {
+ get
+ {
+ if (RequiredMaxLiquidTest)
+ {
+ var sum = GetColorNLPerCm(Cyan, LiquidTypes.Cyan) + GetColorNLPerCm(Magenta, LiquidTypes.Magenta) + GetColorNLPerCm(Yellow, LiquidTypes.Yellow) + GetColorNLPerCm(Black, LiquidTypes.Black);
+ var maxLiq = GetTotalMaximumLiquidNlPerCMLimit();
+ LiquidVolumesOutOfRange = sum > GetTotalMaximumLiquidNlPerCMLimit();
+
+ return LiquidVolumesOutOfRange;
+ }
+ else return false;
+ }
+ }
+
+ private bool _liquidVolumesOutOfRange;
+ [JsonIgnore]
+ public bool LiquidVolumesOutOfRange
+ {
+ get { return _liquidVolumesOutOfRange; }
+ set
+ {
+ if (_liquidVolumesOutOfRange != value)
+ {
+ _liquidVolumesOutOfRange = value;
+ LiquidVolumesOutOfRangeChanged?.Invoke(this, new EventArgs());
+ }
+ }
+ }
+
#endregion
#region constructors
@@ -1269,39 +1315,7 @@ namespace Tango.PPC.Jobs.Models
}
return 0.0;
}
-
-
- public bool IsLiquidVolumesOutOfRange
- {
- get
- {
- if (RequiredMaxLiquidTest)
- {
- var sum = GetColorNLPerCm(Cyan, LiquidTypes.Cyan) + GetColorNLPerCm(Magenta, LiquidTypes.Magenta) + GetColorNLPerCm(Yellow, LiquidTypes.Yellow) + GetColorNLPerCm(Black, LiquidTypes.Black);
- var maxLiq = GetTotalMaximumLiquidNlPerCMLimit();
- LiquidVolumesOutOfRange = sum > GetTotalMaximumLiquidNlPerCMLimit();
-
- return LiquidVolumesOutOfRange;
- }
- else return false;
- }
- }
-
- private bool _liquidVolumesOutOfRange;
-
- public bool LiquidVolumesOutOfRange
- {
- get { return _liquidVolumesOutOfRange; }
- set
- {
- if (_liquidVolumesOutOfRange != value)
- {
- _liquidVolumesOutOfRange = value;
- LiquidVolumesOutOfRangeChanged?.Invoke(this, new EventArgs());
- }
- }
- }
-
+
public void OnBrushStopFieldValueChanged()
{
IsBusy = true;
diff --git a/Software/Visual_Studio/PPC/Modules/Tango.PPC.JobsV2/Models/JobModel.cs b/Software/Visual_Studio/PPC/Modules/Tango.PPC.JobsV2/Models/JobModel.cs
index 53c311c59..5b1907b4a 100644
--- a/Software/Visual_Studio/PPC/Modules/Tango.PPC.JobsV2/Models/JobModel.cs
+++ b/Software/Visual_Studio/PPC/Modules/Tango.PPC.JobsV2/Models/JobModel.cs
@@ -1,4 +1,5 @@
-using System;
+using Newtonsoft.Json;
+using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Linq;
@@ -40,6 +41,7 @@ namespace Tango.PPC.Jobs.Models
/// <summary>
/// Gets or sets the JobModel creation date.
/// </summary>
+ [JsonIgnore]
public DateTime CreationDate
{
get
@@ -164,10 +166,13 @@ namespace Tango.PPC.Jobs.Models
/// <summary>
/// Gets the total job segments length multiplied by number of units if it is an embroidery job.
/// </summary>
+ [JsonIgnore]
public double LengthIncludingNumberOfUnits
{
get
{
+ //JsonConvert.SerializeObject(this,Formatting.Indented);
+
_lastLength = GetLength();
var l = _lastLength * Math.Max(NumberOfUnits, 1);
@@ -185,6 +190,7 @@ namespace Tango.PPC.Jobs.Models
/// <summary>
/// Gets or sets the JobModel rml.
/// </summary>
+ [JsonIgnore]
public virtual Rml Rml
{
get
@@ -202,11 +208,19 @@ namespace Tango.PPC.Jobs.Models
}
}
+ public string RmlGuid
+ {
+ get
+ {
+ return Rml.Guid;
+ }
+ }
protected ColorSpace _colorspace;
/// <summary>
/// Gets or sets the JobModel color spaces.
/// </summary>
+ [JsonIgnore]
public virtual ColorSpace ColorSpace
{
get
@@ -222,10 +236,11 @@ namespace Tango.PPC.Jobs.Models
}
}
}
-
+
/// <summary>
/// Gets or sets the available color spaces.
/// </summary>
+ [JsonIgnore]
public List<ColorSpace> ColorSpacesList { get; set; }
protected Customer _customer;
@@ -233,7 +248,7 @@ namespace Tango.PPC.Jobs.Models
/// <summary>
/// Gets or sets the JobModel customer.
/// </summary>
-
+ [JsonIgnore]
public virtual Customer Customer
{
get
@@ -254,6 +269,7 @@ namespace Tango.PPC.Jobs.Models
/// <summary>
/// Gets or sets the JobModel machine.
/// </summary>
+ [JsonIgnore]
public virtual Machine Machine
{
get
@@ -276,7 +292,7 @@ namespace Tango.PPC.Jobs.Models
/// <summary>
/// Gets or sets the JobModel spool types.
/// </summary>
-
+ [JsonIgnore]
public virtual SpoolType SpoolType
{
get
@@ -295,11 +311,17 @@ namespace Tango.PPC.Jobs.Models
}
}
+ public string SpoolGuid
+ {
+ get { return SpoolType.Guid; }
+ }
+
protected User _user;
/// <summary>
/// Gets or sets the JobModel user.
/// </summary>
+ [JsonIgnore]
public virtual User User
{
get
@@ -317,15 +339,13 @@ namespace Tango.PPC.Jobs.Models
}
}
public JobTypes JobType { get; set; }
-
- public bool JobChanged { get; set; }
-
+
protected SynchronizedObservableCollection<SegmentModel> _segments;
/// <summary>
/// Gets or sets the JobModel segments.
/// </summary>
-
+ [JsonIgnore]
public SynchronizedObservableCollection<SegmentModel> Segments
{
get
@@ -348,7 +368,7 @@ namespace Tango.PPC.Jobs.Models
/// <summary>
/// Gets or sets the JobModel segments.
/// </summary>
-
+ [JsonIgnore]
public SynchronizedObservableCollection<SegmentsGroupModel> SegmentsGroups
{
get
@@ -386,6 +406,7 @@ namespace Tango.PPC.Jobs.Models
}
private ObservableCollection<SegmentModel> _effectiveSegments;
+ [JsonIgnore]
public ObservableCollection<SegmentModel> EffectiveSegments
{
get
@@ -398,6 +419,7 @@ namespace Tango.PPC.Jobs.Models
/// <summary>
/// Gets or sets the display segments.
/// </summary>
+ [JsonIgnore]
public SynchronizedObservableCollection<ISegmentModel> GroupingSegments
{
get
@@ -413,8 +435,9 @@ namespace Tango.PPC.Jobs.Models
}
}
}
- private bool _selectAllSegments;
+ private bool _selectAllSegments;
+ [JsonIgnore]
public bool SelectAllSegments
{
get { return _selectAllSegments; }
@@ -425,7 +448,8 @@ namespace Tango.PPC.Jobs.Models
RaisePropertyChangedAuto();
}
}
-
+
+ [JsonIgnore]
public bool HasSelectedItems
{
get {
@@ -434,6 +458,7 @@ namespace Tango.PPC.Jobs.Models
}
private List<ISegmentModel> _segmentsToCopy;
+ [JsonIgnore]
public List<ISegmentModel> SegmentsToCopy
{
get
@@ -450,8 +475,10 @@ namespace Tango.PPC.Jobs.Models
}
}
+ [JsonIgnore]
public int IndexToPasteCopySegments { get; set; }
+ [JsonIgnore]
public bool HasSegmentsToCopy
{
get
@@ -460,6 +487,7 @@ namespace Tango.PPC.Jobs.Models
}
}
+ [JsonIgnore]
public TimeSpan GetEstimatedDuration
{
get
@@ -476,6 +504,7 @@ namespace Tango.PPC.Jobs.Models
}
}
+ [JsonIgnore]
public int LastGroupID
{
get
@@ -485,6 +514,23 @@ namespace Tango.PPC.Jobs.Models
}
}
+ /// <summary>
+ /// Gets the ordered segments with groups.
+ /// </summary>
+ public List<ISegmentModel> OrderedSegmentsWithGroups
+ {
+ get
+ {
+ if (Segments == null)
+ return null;
+ List<ISegmentModel> orderedSegmentsWithGroups = new List<ISegmentModel>();
+
+ orderedSegmentsWithGroups.AddRange(Segments.Where(x => x.SegmentsGroupModel == null));
+ orderedSegmentsWithGroups.AddRange(SegmentsGroups);
+ return orderedSegmentsWithGroups.OrderBy(x => x.SegmentIndex).ToList();
+ }
+ }
+
#endregion
#region constructors
@@ -505,7 +551,6 @@ namespace Tango.PPC.Jobs.Models
GroupingSegments.CollectionChanged += SegmentsGroup_CollectionChanged;
SelectAllSegments = false;
NumberOfUnits = 1;
- JobChanged = false;
}
#endregion
@@ -516,27 +561,7 @@ namespace Tango.PPC.Jobs.Models
{
LoadGroupingSegments();
}
-
- /// <summary>
- /// Gets the ordered segments with groups.
- /// </summary>
- /// <value>
- /// The ordered segments with groups.
- /// </value>
- public List<ISegmentModel> OrderedSegmentsWithGroups
- {
- get
- {
- if (Segments == null)
- return null;
- List<ISegmentModel> orderedSegmentsWithGroups = new List<ISegmentModel>();
-
- orderedSegmentsWithGroups.AddRange(Segments.Where(x => x.SegmentsGroupModel == null));
- orderedSegmentsWithGroups.AddRange(SegmentsGroups);
- return orderedSegmentsWithGroups.OrderBy(x => x.SegmentIndex).ToList();
- }
- }
-
+
/// <summary>
/// Loads the grouping segments.
/// </summary>
diff --git a/Software/Visual_Studio/PPC/Modules/Tango.PPC.JobsV2/Models/SegmentModel.cs b/Software/Visual_Studio/PPC/Modules/Tango.PPC.JobsV2/Models/SegmentModel.cs
index 036f44675..60cc357f8 100644
--- a/Software/Visual_Studio/PPC/Modules/Tango.PPC.JobsV2/Models/SegmentModel.cs
+++ b/Software/Visual_Studio/PPC/Modules/Tango.PPC.JobsV2/Models/SegmentModel.cs
@@ -15,6 +15,7 @@ using Tango.BL.Enumerations;
using System.Diagnostics;
using Tango.Core.Commands;
using Tango.PPC.Jobs.UndoRedoCommands;
+using Newtonsoft.Json;
namespace Tango.PPC.Jobs.Models
{
@@ -76,7 +77,7 @@ namespace Tango.PPC.Jobs.Models
return SegmentsGroupModel != null;
}
}
-
+
public void LengthBeforeChange(double value)
{
_lastLength = Length;
@@ -85,7 +86,6 @@ namespace Tango.PPC.Jobs.Models
public void LengthChanged(double value)
{
UndoRedoManager.Instance.InsertAndExecuteCommand(new ChangeLengthCommand(this, _lastLength, value));
- Job.JobChanged = true;
_lastLength = Length;
}
@@ -137,6 +137,7 @@ namespace Tango.PPC.Jobs.Models
}
}
+ [JsonIgnore]
public bool ShowGap
{
get
@@ -194,7 +195,7 @@ namespace Tango.PPC.Jobs.Models
}
private JobModel _job;
-
+ [JsonIgnore]
public JobModel Job
{
get
@@ -211,6 +212,7 @@ namespace Tango.PPC.Jobs.Models
}
}
+ [JsonIgnore]
public Brush SegmentBrush
{
get
@@ -219,6 +221,7 @@ namespace Tango.PPC.Jobs.Models
}
}
+ [JsonIgnore]
public bool IsOffsetChanged { get; set; }
public double LeftOffset
@@ -239,6 +242,7 @@ namespace Tango.PPC.Jobs.Models
private double _leftOffsetChangeComleted;
+ [JsonIgnore]
public double LeftOffsetChangeComleted
{
get { return _leftOffsetChangeComleted; }
@@ -248,13 +252,14 @@ namespace Tango.PPC.Jobs.Models
_leftOffsetChangeComleted = value;
RaisePropertyChangedAuto();
UndoRedoManager.Instance.InsertAndExecuteCommand(new ChangeOffsetCommand(this, LeftOffsetStartChanging, _leftOffsetChangeComleted, OffsetType.Left));
- Job.JobChanged = true;
+
}
}
}
private double _leftOffsetStartChanging;
+ [JsonIgnore]
public double LeftOffsetStartChanging
{
get { return _leftOffsetStartChanging; }
@@ -284,6 +289,7 @@ namespace Tango.PPC.Jobs.Models
private double _middleOffsetChangeComleted;
+ [JsonIgnore]
public double MiddleOffsetChangeComleted
{
get { return _middleOffsetChangeComleted; }
@@ -294,13 +300,14 @@ namespace Tango.PPC.Jobs.Models
_middleOffsetChangeComleted = value;
RaisePropertyChangedAuto();
UndoRedoManager.Instance.InsertAndExecuteCommand(new ChangeOffsetCommand(this, MiddleOffsetStartChanging, _middleOffsetChangeComleted, OffsetType.Middle));
- Job.JobChanged = true;
+
}
}
}
private double _middleOffsetStartChanging;
+ [JsonIgnore]
public double MiddleOffsetStartChanging
{
get { return _middleOffsetStartChanging; }
@@ -310,6 +317,7 @@ namespace Tango.PPC.Jobs.Models
RaisePropertyChangedAuto();
}
}
+
public double RightOffset
{
get { return SecondBrushStop != null ? SecondBrushStop.OffsetPercent: 100; }
@@ -328,7 +336,7 @@ namespace Tango.PPC.Jobs.Models
}
private double _rightOffsetChangeComleted;
-
+ [JsonIgnore]
public double RightOffsetChangeComleted
{
get { return _rightOffsetChangeComleted; }
@@ -339,13 +347,13 @@ namespace Tango.PPC.Jobs.Models
_rightOffsetChangeComleted = value;
RaisePropertyChangedAuto();
UndoRedoManager.Instance.InsertAndExecuteCommand(new ChangeOffsetCommand(this, RightOffsetStartChanging, _rightOffsetChangeComleted, OffsetType.Right));
- Job.JobChanged = true;
+
}
}
}
private double _rightOffsetStartChanging;
-
+ [JsonIgnore]
public double RightOffsetStartChanging
{
get { return _rightOffsetStartChanging; }
@@ -356,6 +364,7 @@ namespace Tango.PPC.Jobs.Models
}
}
+ [JsonIgnore]
public String LeftOffsetLabel
{
get
@@ -365,6 +374,7 @@ namespace Tango.PPC.Jobs.Models
}
}
+ [JsonIgnore]
public String RightOffsetLabel
{
get
@@ -374,6 +384,7 @@ namespace Tango.PPC.Jobs.Models
}
}
+ [JsonIgnore]
public String MiddleOffsetLabel
{
get
@@ -385,7 +396,7 @@ namespace Tango.PPC.Jobs.Models
}
}
-
+ [JsonIgnore]
public bool HasColors
{
get
@@ -394,6 +405,7 @@ namespace Tango.PPC.Jobs.Models
}
}
+ [JsonIgnore]
public bool IsGradient
{
get
@@ -405,6 +417,7 @@ namespace Tango.PPC.Jobs.Models
/// <summary>
/// Gets the second brush stop.
/// </summary>
+ [JsonIgnore]
public BrushStopModel SecondBrushStop
{
get
@@ -419,6 +432,7 @@ namespace Tango.PPC.Jobs.Models
/// <summary>
/// Gets the first brush stop.
/// </summary>
+ [JsonIgnore]
public BrushStopModel FirstBrushStop
{
get
@@ -437,6 +451,7 @@ namespace Tango.PPC.Jobs.Models
/// <summary>
/// Gets the middle brush stop.
/// </summary>
+ [JsonIgnore]
public BrushStopModel MiddleBrushStop
{
get
@@ -448,6 +463,7 @@ namespace Tango.PPC.Jobs.Models
}
}
+ [JsonIgnore]
public bool HasOutOfGamutBrush
{
get
@@ -460,7 +476,7 @@ namespace Tango.PPC.Jobs.Models
}
private bool _isSelected;
-
+ [JsonIgnore]
public bool IsSelected
{
get { return _isSelected; }
@@ -470,7 +486,7 @@ namespace Tango.PPC.Jobs.Models
}
private bool _isLast;
-
+ [JsonIgnore]
public bool IsLast
{
get { return _isLast; }
@@ -490,8 +506,9 @@ namespace Tango.PPC.Jobs.Models
#endregion
#region command
-
+ [JsonIgnore]
public RelayCommand AddGapCommand { get; set; }
+ [JsonIgnore]
public RelayCommand DeleteGapCommand { get; set; }
#endregion
diff --git a/Software/Visual_Studio/PPC/Modules/Tango.PPC.JobsV2/Models/SegmentsGroupModel.cs b/Software/Visual_Studio/PPC/Modules/Tango.PPC.JobsV2/Models/SegmentsGroupModel.cs
index d8a3a6c64..76a9bfdd2 100644
--- a/Software/Visual_Studio/PPC/Modules/Tango.PPC.JobsV2/Models/SegmentsGroupModel.cs
+++ b/Software/Visual_Studio/PPC/Modules/Tango.PPC.JobsV2/Models/SegmentsGroupModel.cs
@@ -1,4 +1,5 @@
-using System;
+using Newtonsoft.Json;
+using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Linq;
@@ -50,6 +51,8 @@ namespace Tango.PPC.Jobs.Models
RaisePropertyChangedAuto();
}
}
+
+ [JsonIgnore]
public JobModel Job { get; set; }
protected Double _length;
@@ -87,7 +90,7 @@ namespace Tango.PPC.Jobs.Models
}
private bool _isSelected;
-
+ [JsonIgnore]
public bool IsSelected
{
get { return _isSelected; }
@@ -100,6 +103,7 @@ namespace Tango.PPC.Jobs.Models
}
private bool _isLast;
+ [JsonIgnore]
public bool IsLast
{
get { return _isLast; }
@@ -120,7 +124,7 @@ namespace Tango.PPC.Jobs.Models
return Segments.Count == 0 ? 0: Segments.ToList().Min(x => x.SegmentIndex);
}
}
-
+ [JsonIgnore]
public int LastSegmentIndex {
get
{
@@ -163,6 +167,7 @@ namespace Tango.PPC.Jobs.Models
}
}
+ [JsonIgnore]
public bool ShowGap
{
get
diff --git a/Software/Visual_Studio/PPC/Modules/Tango.PPC.JobsV2/Tango.PPC.JobsV2.csproj b/Software/Visual_Studio/PPC/Modules/Tango.PPC.JobsV2/Tango.PPC.JobsV2.csproj
index 41238fda1..9f7f981a0 100644
--- a/Software/Visual_Studio/PPC/Modules/Tango.PPC.JobsV2/Tango.PPC.JobsV2.csproj
+++ b/Software/Visual_Studio/PPC/Modules/Tango.PPC.JobsV2/Tango.PPC.JobsV2.csproj
@@ -46,6 +46,9 @@
<Reference Include="LiteDB, Version=5.0.4.0, Culture=neutral, PublicKeyToken=4ee40123013c9f27, processorArchitecture=MSIL">
<HintPath>..\..\..\packages\LiteDB.5.0.4\lib\net45\LiteDB.dll</HintPath>
</Reference>
+ <Reference Include="Newtonsoft.Json, Version=9.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed, processorArchitecture=MSIL">
+ <HintPath>..\..\..\packages\Newtonsoft.Json.9.0.1\lib\net45\Newtonsoft.Json.dll</HintPath>
+ </Reference>
<Reference Include="System" />
<Reference Include="System.ComponentModel.DataAnnotations" />
<Reference Include="System.Data" />
@@ -370,7 +373,9 @@
<LastGenOutput>Resources.Designer.cs</LastGenOutput>
</EmbeddedResource>
<None Include="app.config" />
- <None Include="packages.config" />
+ <None Include="packages.config">
+ <SubType>Designer</SubType>
+ </None>
<None Include="Properties\Settings.settings">
<Generator>SettingsSingleFileGenerator</Generator>
<LastGenOutput>Settings.Designer.cs</LastGenOutput>
diff --git a/Software/Visual_Studio/PPC/Modules/Tango.PPC.JobsV2/ViewModels/JobViewVM.cs b/Software/Visual_Studio/PPC/Modules/Tango.PPC.JobsV2/ViewModels/JobViewVM.cs
index 01b819284..f1a736180 100644
--- a/Software/Visual_Studio/PPC/Modules/Tango.PPC.JobsV2/ViewModels/JobViewVM.cs
+++ b/Software/Visual_Studio/PPC/Modules/Tango.PPC.JobsV2/ViewModels/JobViewVM.cs
@@ -42,6 +42,8 @@ using Tango.PPC.Common.Lubrication;
using Tango.PPC.Jobs.Models;
using Tango.Core;
using Tango.PPC.Jobs.UndoRedoCommands;
+using Newtonsoft.Json;
+using Newtonsoft.Json.Linq;
namespace Tango.PPC.Jobs.ViewModels
{
@@ -65,6 +67,7 @@ namespace Tango.PPC.Jobs.ViewModels
private bool startingJob = false;
private List<ColorCatalog> _catalogs;
+ private string _jsonJobModelLoaded;
#region Properties
private Job _job;
@@ -581,6 +584,12 @@ namespace Tango.PPC.Jobs.ViewModels
SegmentsCollectionView.SortDescriptions.Add(new SortDescription(nameof(SegmentModel.SegmentIndex), ListSortDirection.Ascending));
UndoRedoManager.Instance.ClearAll();
ArrangeSegmentsIndixes();
+ JsonSerializerSettings settings = new JsonSerializerSettings()
+ {
+ ReferenceLoopHandling = Newtonsoft.Json.ReferenceLoopHandling.Ignore,
+ PreserveReferencesHandling = Newtonsoft.Json.PreserveReferencesHandling.Objects
+ };
+ _jsonJobModelLoaded = JsonConvert.SerializeObject(JobModel , Formatting.Indented, settings);
}
/// <summary>
@@ -681,12 +690,7 @@ namespace Tango.PPC.Jobs.ViewModels
vm = await NotificationProvider.ShowDialog<JobCreationViewVM>(vm);
if (!vm.DialogResult) return;
-
- if(Job.Name != vm.JobName || Job.InterSegmentLength != vm.WhiteGap || Job.SpoolType != vm.SelectedSpoolType || SelectedRML != vm.SelectedRML)
- {
- JobModel.JobChanged = true;
- }
-
+
Job.Name = vm.JobName;
JobModel.Name = vm.JobName;
@@ -737,10 +741,6 @@ namespace Tango.PPC.Jobs.ViewModels
if (vm.DialogResult)
{
- if(JobModel.NumberOfUnits != vm.Repeats)
- {
- JobModel.JobChanged = true;
- }
JobModel.NumberOfUnits = vm.Repeats;
}
}
@@ -829,8 +829,7 @@ namespace Tango.PPC.Jobs.ViewModels
LogManager.Log("Adding new segment...");
UndoRedoManager.Instance.InsertAndExecuteCommand(new AddNewSegmentCommand(JobModel, segment, Settings.DefaultSegmentLength > 0 ? Settings.DefaultSegmentLength : 10));
- JobModel.JobChanged = true;
- ArrangeSegmentsIndixes();
+ ArrangeSegmentsIndixes();
DyeCommand.RaiseCanExecuteChanged();
}
catch (Exception ex)
@@ -852,8 +851,6 @@ namespace Tango.PPC.Jobs.ViewModels
if (vm.DialogResult)
{
- if(group.Repeats != vm.Repeats)
- JobModel.JobChanged = true;
group.Repeats = vm.Repeats;
}
}
@@ -870,7 +867,6 @@ namespace Tango.PPC.Jobs.ViewModels
if (await NotificationProvider.ShowQuestion("Are you sure you want to remove the selected segment?"))
{
UndoRedoManager.Instance.InsertAndExecuteCommand(new RemoveSegmentCommand(JobModel, segment));
- JobModel.JobChanged = true;
ArrangeSegmentsIndixes();
DyeCommand.RaiseCanExecuteChanged();
@@ -899,8 +895,7 @@ namespace Tango.PPC.Jobs.ViewModels
UndoRedoManager.Instance.InsertAndExecuteCommand(new DeleteSegmentsGroupCommand(JobModel, segmentsGroup));
ArrangeSegmentsIndixes();
- JobModel.JobChanged = true;
-
+
DyeCommand.RaiseCanExecuteChanged();
}
}
@@ -922,7 +917,7 @@ namespace Tango.PPC.Jobs.ViewModels
{
UndoRedoManager.Instance.InsertAndExecuteCommand(new DuplicateSegmentCommand(JobModel, segment));
ArrangeSegmentsIndixes();
- JobModel.JobChanged = true;
+
DyeCommand.RaiseCanExecuteChanged();
}
@@ -996,7 +991,7 @@ namespace Tango.PPC.Jobs.ViewModels
{
UndoRedoManager.Instance.InsertAndExecuteCommand(new EditBrushStopColorCommand(segment, brushStop, vm.SelectedBrushStop));
DyeCommand.RaiseCanExecuteChanged();
- JobModel.JobChanged = true;
+
}
}
@@ -1021,7 +1016,7 @@ namespace Tango.PPC.Jobs.ViewModels
}
UndoRedoManager.Instance.InsertAndExecuteCommand(new AddBrushStopCommand(JobModel, segment, newBrushStop));
ArrangeSegmentsIndixes();
- JobModel.JobChanged = true;
+
}
#endregion
@@ -1233,7 +1228,7 @@ namespace Tango.PPC.Jobs.ViewModels
UndoRedoManager.Instance.InsertAndExecuteCommand(new ReverseCommand(JobModel));
ArrangeSegmentsIndixes();
- JobModel.JobChanged = true;
+
}
private async void DeleteSegments()
@@ -1255,7 +1250,7 @@ namespace Tango.PPC.Jobs.ViewModels
UndoRedoManager.Instance.InsertAndExecuteCommand(new RemoveSegmentsCommand(JobModel));
ArrangeSegmentsIndixes();
- JobModel.JobChanged = true;
+
DyeCommand.RaiseCanExecuteChanged();
}
}
@@ -1277,28 +1272,24 @@ namespace Tango.PPC.Jobs.ViewModels
return;
UndoRedoManager.Instance.InsertAndExecuteCommand(new RepeatCommand(JobModel));
ArrangeSegmentsIndixes();
- JobModel.JobChanged = true;
}
private void UngroupSegments(SegmentsGroupModel segmentsGroup)
{
UndoRedoManager.Instance.InsertAndExecuteCommand(new UnGroupSegmentsCommand(JobModel, segmentsGroup));
ArrangeSegmentsIndixes();
- JobModel.JobChanged = true;
}
private void Paste()
{
UndoRedoManager.Instance.InsertAndExecuteCommand(new PasteSegmentsCommand(JobModel));
ArrangeSegmentsIndixes();
- JobModel.JobChanged = true;
}
private void Copy()
{
UndoRedoManager.Instance.InsertAndExecuteCommand(new CopySegmentCommand(JobModel));
ArrangeSegmentsIndixes();
- JobModel.JobChanged = true;
}
private void Undo()
@@ -1326,7 +1317,7 @@ namespace Tango.PPC.Jobs.ViewModels
UndoRedoManager.Instance.ClearAll();
var colorSpaces = await _db.ColorSpaces.ToListAsync();
-
+
Job.ColorSpace = colorSpaces.FirstOrDefault();
Job.Version = 2;
Job.NumberOfUnits = JobModel.NumberOfUnits;
@@ -1457,13 +1448,21 @@ namespace Tango.PPC.Jobs.ViewModels
}
Job.LastUpdated = DateTime.UtcNow;
Job.IsSynchronized = false;
- if(Job.JobStatus != JobStatuses.Draft && JobModel.JobChanged == true)
+
+ if(Job.JobStatus != JobStatuses.Draft )
{
- Job.JobStatus = BL.Enumerations.JobStatuses.Draft;
+ JsonSerializerSettings settings = new JsonSerializerSettings()
+ {
+ ReferenceLoopHandling = Newtonsoft.Json.ReferenceLoopHandling.Ignore,
+ PreserveReferencesHandling = Newtonsoft.Json.PreserveReferencesHandling.Objects
+ };
+ string jsonJobModelSaved = JsonConvert.SerializeObject(JobModel, Formatting.Indented, settings);
+ var json1 = JObject.Parse(_jsonJobModelLoaded);
+ var json2 = JObject.Parse(jsonJobModelSaved);
+ if(false == JToken.DeepEquals(json1, json2))
+ Job.JobStatus = BL.Enumerations.JobStatuses.Draft;
}
- JobModel.JobChanged = false;
- //Job.JobStatus = BL.Enumerations.JobStatuses.Draft;
- //_current_job_string = Job.ToJobFileWhenLoaded().ToString();
+
RaiseMessage(new JobSavedMessage() { Job = Job });
await _db.SaveChangesAsync();
diff --git a/Software/Visual_Studio/PPC/Modules/Tango.PPC.JobsV2/packages.config b/Software/Visual_Studio/PPC/Modules/Tango.PPC.JobsV2/packages.config
index 7631e246f..36ad58db6 100644
--- a/Software/Visual_Studio/PPC/Modules/Tango.PPC.JobsV2/packages.config
+++ b/Software/Visual_Studio/PPC/Modules/Tango.PPC.JobsV2/packages.config
@@ -5,4 +5,5 @@
<package id="FontAwesome.WPF" version="4.7.0.9" targetFramework="net46" />
<package id="Google.Protobuf" version="3.4.1" targetFramework="net46" />
<package id="LiteDB" version="5.0.4" targetFramework="net461" />
+ <package id="Newtonsoft.Json" version="9.0.1" targetFramework="net461" />
</packages> \ No newline at end of file