blob: 2e6cbb222762250d822ab65bfed62e76fec95d92 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
|
using Newtonsoft.Json;
using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.ComponentModel.DataAnnotations.Schema;
using System.Linq;
using System.Reflection;
using System.Text;
using System.Threading.Tasks;
using Tango.BL.Enumerations;
namespace Tango.BL.Entities
{
public partial class Machine
{
#region Properties
/// <summary>
/// Gets or sets the <see cref="TargetJobTypes"/> property as a collection of <see cref="JobTypes"/>.
/// </summary>
[NotMapped]
[JsonIgnore]
public List<JobTypes> SupportedJobTypes
{
get
{
try
{
if (!String.IsNullOrWhiteSpace(TargetJobTypes))
{
return TargetJobTypes.Split(',').Select(x => (JobTypes)int.Parse(x)).ToList();
}
else
{
return new List<JobTypes>();
}
}
catch (Exception ex)
{
LogManager.Log(ex, "Could not parse machine target job types!");
return new List<JobTypes>();
}
}
set
{
TargetJobTypes = String.Join(",", value.Select(x => x.ToInt32()));
}
}
#endregion
protected override void RaisePropertyChanged(string propName)
{
base.RaisePropertyChanged(propName);
if (propName == nameof(TargetJobTypes))
{
RaisePropertyChanged(nameof(SupportedJobTypes));
}
}
/// <summary>
/// Deletes this entity from the database
/// </summary>
public override void Delete(ObservablesContext context)
{
foreach (var machine_config in MachinesConfigurations)
{
machine_config.Delete(context);
machine_config.Configuration.Delete(context);
}
base.Delete(context);
}
public override void Save(ObservablesContext context)
{
foreach (var job in Jobs)
{
job.JobIndex = Jobs.IndexOf(job);
foreach (var segment in job.Segments)
{
//segment.SegmentIndex = job.Segments.IndexOf(segment);
foreach (var stop in segment.BrushStops)
{
foreach (var prop in typeof(BrushStop).GetProperties(BindingFlags.Public | BindingFlags.Instance).Where(x => x.PropertyType == typeof(double)))
{
double value = (double)prop.GetValue(stop);
if (double.IsInfinity(value))
{
prop.SetValue(stop, 0d);
}
}
}
}
}
base.Save(context);
}
}
}
|