aboutsummaryrefslogtreecommitdiffstats
path: root/Software/Visual_Studio/Tango.BL/Entities/Job.cs
diff options
context:
space:
mode:
Diffstat (limited to 'Software/Visual_Studio/Tango.BL/Entities/Job.cs')
-rw-r--r--Software/Visual_Studio/Tango.BL/Entities/Job.cs96
1 files changed, 32 insertions, 64 deletions
diff --git a/Software/Visual_Studio/Tango.BL/Entities/Job.cs b/Software/Visual_Studio/Tango.BL/Entities/Job.cs
index 5cd756f27..52101c1b5 100644
--- a/Software/Visual_Studio/Tango.BL/Entities/Job.cs
+++ b/Software/Visual_Studio/Tango.BL/Entities/Job.cs
@@ -10,10 +10,8 @@ using System.Reflection;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Media.Imaging;
-using Tango.BL.ActionLogs;
using Tango.BL.Builders;
using Tango.BL.Enumerations;
-using Tango.BL.ValueObjects;
using Tango.Core;
using Tango.Core.ExtensionMethods;
using Tango.Logging;
@@ -80,7 +78,7 @@ namespace Tango.BL.Entities
get
{
_lastLength = GetLength();
- var l = _lastLength * Math.Max(NumberOfUnits, 1);
+ var l = _lastLength * NumberOfUnits;
if (EnableInterSegment && NumberOfUnits > 1)
{
@@ -103,17 +101,6 @@ namespace Tango.BL.Entities
}
/// <summary>
- /// Gets or sets the origin of the job.
- /// </summary>
- [NotMapped]
- [JsonIgnore]
- public JobSource JobSource
- {
- get { return (JobSource)Source; }
- set { Source = value.ToInt32(); RaisePropertyChangedAuto(); }
- }
-
- /// <summary>
/// Gets or sets the job <see cref="Type"/> property as <see cref="JobType"/> enum instead of int.
/// </summary>
[NotMapped]
@@ -348,7 +335,6 @@ namespace Tango.BL.Entities
cloned.Name = Name + " - Copy";
cloned.CreationDate = DateTime.UtcNow;
- cloned.IsSynchronized = false;
cloned.LastRun = null;
cloned.ColorSpace = ColorSpace;
cloned.Customer = Customer;
@@ -389,42 +375,34 @@ namespace Tango.BL.Entities
public BitmapSource CreateSegmentsPie(double width, double height)
{
- try
- {
- Bitmap bmp = new Bitmap((int)width, (int)height);
+ Bitmap bmp = new Bitmap((int)width, (int)height);
- using (Graphics g = Graphics.FromImage(bmp))
- {
- g.Clear(Color.Transparent);
- g.CompositingQuality = System.Drawing.Drawing2D.CompositingQuality.HighQuality;
- g.InterpolationMode = System.Drawing.Drawing2D.InterpolationMode.High;
- g.SmoothingMode = System.Drawing.Drawing2D.SmoothingMode.HighQuality;
+ using (Graphics g = Graphics.FromImage(bmp))
+ {
+ g.Clear(Color.Transparent);
+ g.CompositingQuality = System.Drawing.Drawing2D.CompositingQuality.HighQuality;
+ g.InterpolationMode = System.Drawing.Drawing2D.InterpolationMode.High;
+ g.SmoothingMode = System.Drawing.Drawing2D.SmoothingMode.HighQuality;
- int fromAngle = -90;
- double totalLength = Segments.Sum(x => x.Length); //Excluding inter segment.
+ int fromAngle = -90;
+ double totalLength = Segments.Sum(x => x.Length); //Excluding inter segment.
- foreach (var segment in OrderedSegments)
- {
- int toAngle = (int)((segment.Length / totalLength) * 360d);
- Rectangle rect = new Rectangle(0, 0, bmp.Width - 2, bmp.Height - 2);
- g.FillPie(segment.CreateGdiBrush(bmp.Width - 2, bmp.Height - 2), rect, fromAngle, toAngle);
+ foreach (var segment in OrderedSegments)
+ {
+ int toAngle = (int)((segment.Length / totalLength) * 360d);
+ Rectangle rect = new Rectangle(0, 0, bmp.Width - 2, bmp.Height - 2);
+ g.FillPie(segment.CreateGdiBrush(bmp.Width - 2, bmp.Height - 2), rect, fromAngle, toAngle);
- Pen pen = new Pen(Color.Gainsboro);
- g.DrawEllipse(pen, rect);
- pen.Dispose();
- fromAngle += toAngle;
- }
+ Pen pen = new Pen(Color.Gainsboro);
+ g.DrawEllipse(pen, rect);
+ pen.Dispose();
+ fromAngle += toAngle;
}
-
- var source = bmp.ToBitmapSource();
- bmp.Dispose();
- return source;
- }
- catch (Exception ex)
- {
- LogManager.Log(ex, $"Error occurred while trying to create job pie image for job '{Name}'.");
- return null;
}
+
+ var source = bmp.ToBitmapSource();
+ bmp.Dispose();
+ return source;
}
/// <summary>
@@ -432,13 +410,13 @@ namespace Tango.BL.Entities
/// </summary>
public Segment AddSolidSegment()
{
- return AddSolidSegment(null);
+ return AddSolidSegment(System.Windows.Media.Colors.Black);
}
/// <summary>
/// Adds a new solid segment.
/// </summary>
- public Segment AddSolidSegment(System.Windows.Media.Color? color)
+ public Segment AddSolidSegment(System.Windows.Media.Color color)
{
return AddSolidSegment(color, 10);
}
@@ -448,13 +426,13 @@ namespace Tango.BL.Entities
/// </summary>
public Segment AddSolidSegment(double length)
{
- return AddSolidSegment(null, length);
+ return AddSolidSegment(System.Windows.Media.Colors.White, length);
}
/// <summary>
/// Adds a new solid segment.
/// </summary>
- public Segment AddSolidSegment(System.Windows.Media.Color? color, double length)
+ public Segment AddSolidSegment(System.Windows.Media.Color color, double length)
{
Segment segment = new Segment();
segment.Name = "Standard Segment";
@@ -473,12 +451,7 @@ namespace Tango.BL.Entities
segment.Job = this;
var stop = segment.AddBrushStop();
-
- if (color != null)
- {
- stop.Color = color.Value;
- }
-
+ stop.Color = color;
Segments.Add(segment);
return segment;
@@ -498,9 +471,9 @@ namespace Tango.BL.Entities
public Segment AddGradientSegment(double length)
{
var segment = AddSolidSegment(length);
- //segment.BrushStops.Last().Color = System.Windows.Media.Colors.White;
+ segment.BrushStops.Last().Color = System.Windows.Media.Colors.White;
segment.AddBrushStop();
- //segment.BrushStops.Last().Color = System.Windows.Media.Colors.White;
+ segment.BrushStops.Last().Color = System.Windows.Media.Colors.White;
return segment;
}
@@ -655,7 +628,7 @@ namespace Tango.BL.Entities
foreach (var stop in segment.BrushStops.OrderBy(x => x.StopIndex))
{
JobFileBrushStop st = new JobFileBrushStop();
- stop.MapPropertiesTo(st, MappingFlags.NoReferenceTypes | MappingFlags.NoNullStrings);
+ stop.MapPrimitivesWithStringsNoNullsTo(st);
st.ColorCatalogItemGuid = stop.ColorCatalogsItemGuid.ToStringOrEmpty();
foreach (var idsPack in machine.Configuration.NoneEmptyIdsPacks)
@@ -782,7 +755,7 @@ namespace Tango.BL.Entities
BrushStop st = new BrushStop();
st.StopIndex = j + 1;
st.SegmentGuid = s.Guid;
- stop.MapPropertiesTo(st, MappingFlags.NoReferenceTypes | MappingFlags.NoNullStrings);
+ stop.MapPrimitivesWithStringsNoNullsTo(st);
foreach (var volume in stop.LiquidVolumes)
{
@@ -847,11 +820,6 @@ namespace Tango.BL.Entities
{
InsertError(nameof(Name), "Job name is required");
}
-
- if (Name != null && Name.Length > 100)
- {
- InsertError(nameof(Name), "The job name exceeds the maximum allowed characters.");
- }
}
#endregion