/
Job.cs
329 lines (289 loc) · 12 KB
/
Job.cs
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
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
using System;
using System.Collections.Generic;
using System.Runtime.Serialization;
using Newtonsoft.Json;
using Skyline.DataMiner.Net.IManager.Objects;
using Skyline.DataMiner.Net.ManagerStore;
using Skyline.DataMiner.Net.Messages.SLDataGateway;
using Skyline.DataMiner.Net.Sections;
using Skyline.DataMiner.Net.ToolsSpace.Collections;
#pragma warning disable 618
namespace Skyline.DataMiner.Net.Jobs
{
/// <summary>
/// Represents a job.
/// </summary>
/// <remarks>
/// <para>A job consists of a number of sections and each section in turn consists of a number of FieldValues.</para>
/// <para>A job may contain multiple sections with the same <see cref="SectionDefinition"/>.</para>
/// <para>The following diagram gives an overview of the different classes in the Jobs API:</para>
/// <img src="~/develop/images/JobMVP.png" />
/// </remarks>
/// <example>
/// <code>
/// JobManagerHelper jobManagerHelper = new JobManagerHelper(msg => protocol.SLNet.RawConnection.HandleMessages(msg));
///
/// var sectionDefinition = jobManagerHelper.SectionDefinitions.Read(SectionDefinitionExposers.Name.Equal("MyCustomSectionDefinition")).FirstOrDefault() as CustomSectionDefinition;
/// var fieldDescriptor = sectionDefinition.GetAllFieldDescriptors().FirstOrDefault(x => x.Name == "MyStringField");
///
/// var startTime = DateTime.UtcNow;
/// var endTime = startTime.AddHours(10);
///
/// Job job = new Job();
/// job.SetJobName("MyJob");
/// job.SetJobStartTime(startTime);
/// job.SetJobEndTime(endTime);
///
/// // Add a section to the Job.
/// var section = new Section(sectionDefinition);
/// section.AddOrUpdateValue(fieldDescriptor, "My field value.");
///
/// job.Sections.Add(section);
///
/// jobManagerHelper.Jobs.Create(job);
/// </code>
/// </example>
[Serializable]
//[DataContract]
[JsonObject(MemberSerialization.OptIn)]// this is required so that the JSON serialization doesn't use the ISerializable interface implementation
public class Job : IEquatable<Job>, ISerializable, ICloneable, CustomDataType, IManagerIdentifiableObject<JobID>, ITrackLastModified, ISectionContainer
{
#region Properties & Fields
/// <summary>
/// Gets or sets the job ID.
/// </summary>
/// <value>The job ID.</value>
public JobID ID
{
get
{
return null;
}
set
{
}
}
/// <summary>
/// Gets the sections of this job.
/// </summary>
/// <value>The sections of this job.</value>
//[DataMember(Name = "Sections")]
public List<Section> Sections { get; private set; }
/// <summary>
/// Gets or sets the security view ID. Available from DataMiner 10.0.5 (RN 24800) onwards.
/// </summary>
/// <value>The security view ID.</value>
/// <remarks>
/// <para>This property is considered obsolete from DataMiner 10.1.1 (RN 28311) onwards. Use the SecurityViewIDs property instead.</para>
/// <para>If, for a particular job or booking instance (i.e. ReservationInstance), this property contains a view ID, then the job or booking instance will only be accessible to users who have access to the specified view.</para>
/// <list type="bullet">
/// <item><description>Users who display a list of jobs or booking instances will only see the jobs or booking instances associated with a view to which they have read access.</description></item>
/// <item><description>Users who try to create, update or delete a job or a booking instance will only be able to do so if they have write access to the view associated with that job or booking instance.</description></item>
/// <item><description>Users who try to create, update or delete a job or a booking instance will only be able to do so if they have write access to the view associated with that job or booking instance.</description></item>
/// <item><description>When scheduling checks are performed, the booking instances to which a user does not have access will still be taken into account.</description></item>
/// </list>
/// <para>Every booking instance (i.e. ReservationInstance) within the same tree must have the same SecurityViewID.</para>
/// <para>If a view specified in the SecurityViewID property of a job or booking instance is deleted, only Administrators or users with access to all views will have access to that job or booking instance.</para>
/// </remarks>
//[DataMember(Name = "SecurityViewID")]
[Obsolete("Please use SecurityViewIDs")]
public int? SecurityViewID { get; set; }
//[DataMember(Name = "SecurityViewIDs")]
private List<int> _securityViewIDs = new List<int>();
/// <summary>
/// Gets or sets the security view IDs. Available from DataMiner 10.1.1 (RN 28311) onwards.
/// </summary>
/// <value>The security view IDs.</value>
/// <remarks>
/// <list type="bullet">
/// <item><description>If, for a particular job or booking instance (i.e. ReservationInstance), this property contains view IDs, then the job or booking instance will only be accessible to users who have access to at least one of the specified views. For example, if you have access to the view with ID 10, and you display a list of jobs or booking instances, it will only contain the jobs or booking instances of which the list of values in the SecurityViewIDs property includes "10" or no IDs at all.</description></item>
/// <item><description>The values in this property can be filtered using a “Contains” filter. Example: JobExposers.SecurityViewIDs.Contains(136).</description></item>
/// <item><description>This property renders the <see cref="Job.SecurityViewID"/> property obsolete.</description></item>
/// </list>
/// </remarks>
public List<int> SecurityViewIDs
{
get;
set;
}
/// <summary>
/// Gets or sets the Job domain ID.
/// </summary>
/// <value>The Job domain ID.</value>
//[DataMember(Name = "JobDomainID")]
public JobDomainID JobDomainID { get; set; }
//[DataMember(Name = "SyncLastModified")]
DateTime ITrackLastModified.LastModified { get; set; }
/// <summary>
/// Gets a value indicating whether this job was stitched.
/// </summary>
/// <value><c>true</c> if this job was stitched; otherwise <c>false</c>.</value>
public bool WasStitched => false;
#endregion Properties & Fields
#region Constructor
/// <summary>
/// Initializes a new instance of the <see cref="Job"/> class.
/// </summary>
public Job()
{
}
#endregion Constructor
#region Public Methods
/// <summary>
/// Stitches this job with the specified section definition provider.
/// </summary>
/// <param name="sectionDefinitionProvider">The section definition provider to stitch this job with.</param>
[Obsolete("Please use Stitch with a JobDomainProvider")]
public void Stitch(Func<SectionDefinitionID, SectionDefinition> sectionDefinitionProvider)
{
}
/// <summary>
/// Stitches this job with the specified section definition provider and job domain provider.
/// </summary>
/// <param name="sectionDefinitionProvider">The section definition provider to stitch this job with.</param>
/// <param name="jobDomainProvider">The job domain provider.</param>
public void Stitch(Func<SectionDefinitionID, SectionDefinition> sectionDefinitionProvider, Func<JobDomainID, JobDomain> jobDomainProvider)
{
}
/// <summary>
/// Returns the JobDomain when the Job has been stitched
/// </summary>
public JobDomain GetJobDomain()
{
return null;
}
/// <summary>
/// Converts this job to an ID-based filter of the specified type.
/// </summary>
/// <typeparam name="T">The filter element type.</typeparam>
/// <returns>The created filter element of the specified type.</returns>
public FilterElement<T> ToFilter<T>()
{
return null;
}
IReadOnlyList<Section> ISectionContainer.GetSections()
{
// Returns a copy of the list
return null;
}
void ISectionContainer.SetSections(IEnumerable<Section> sections)
{
}
/// <summary>
/// Returns this job as a JSON serializable dictionary.
/// </summary>
/// <returns>The JSON serializable dictionary representation of this job.</returns>
/// <remarks>
/// <para>Converts all the fields to a JSONSerializableDictionary. These are mapped as follows: FieldDescriptor GUID -> List of value objects. In case there are multiple FieldValues for the same FieldDescriptor, these are merged as a list value.</para>
/// </remarks>
public JSONSerializableDictionary AsJsonSerializableDictionary()
{
return null;
}
/// <summary>
/// Gets the security view IDs.
/// </summary>
/// <returns>The security view IDs.</returns>
public IReadOnlyCollection<int> GetSecurityViewIds()
{
return null;
}
#endregion Public Methods
#region JSON Serialization
/// <summary>
/// Retrieves the JSON representation of this object.
/// </summary>
/// <returns>The JSON representation of this object.</returns>
public string ToJson()
{
return null;
}
/// <summary>
/// Deserializes the specified JSON string into a new instance of this class.
/// </summary>
/// <param name="json">The JSON string.</param>
/// <returns>The deserialized object.</returns>
/// <exception cref="ArgumentNullException"><paramref name="json"/> is <see langword="null"/>.</exception>
public static Job FromJson(string json)
{
return null;
}
/// <summary>
/// Populates a SerializationInfo with the data needed to serialize the target object.
/// </summary>
/// <param name="info">The SerializationInfo to populate with data.</param>
/// <param name="context">The destination for this serialization.</param>
public void GetObjectData(SerializationInfo info, StreamingContext context)
{
}
/// <summary>
/// Initializes a new instance of the <see cref="Job"/> class using the specified serialization info and streaming context.
/// </summary>
/// <param name="info">The serialization info.</param>
/// <param name="context">The streaming context.</param>
public Job(SerializationInfo info, StreamingContext context)
{
}
#endregion JSON Serialization
#region Equals & HashCode & ToString
/// <summary>
/// Determines whether the specified object is equal to the current object.
/// </summary>
/// <param name="obj">The object to compare with the current object.</param>
/// <returns><c>true</c> if the specified object is equal to the current object; otherwise <c>false</c>.</returns>
public override bool Equals(object obj)
{
return false;
}
/// <summary>
/// Indicates whether the current object is equal to another object of the same type.
/// </summary>
/// <param name="other">An object to compare with this object.</param>
/// <returns><c>true</c> if the current object is equal to the other parameter; otherwise <c>false</c>.</returns>
public bool Equals(Job other)
{
return true;
}
/// <summary>
/// Calculates the hash code for this object.
/// </summary>
/// <returns>A hash code for the current object.</returns>
public override int GetHashCode()
{
return 0;
}
/// <summary>
/// Returns a string that represents the current object.
/// </summary>
/// <returns>A string that represents the current object.</returns>
public override string ToString()
{
return "";
}
/// <summary>
/// Creates a new object that is a copy of the current instance.
/// </summary>
/// <returns>A new object that is a copy of this instance.</returns>
public object Clone()
{
return null;
}
#endregion Equals & HashCode & ToString
#region DataType
bool DataType.FromMigration { get; set; }
string DataType.DataTypeID => ID.SafeId().ToString();
string[] DataType.ToStringArray()
{
throw new NotSupportedException();
}
object[] DataType.ToInterOp()
{
throw new NotSupportedException();
}
DataType DataType.toType(string[] data)
{
throw new NotSupportedException();
}
#endregion DataType
}
}