cityworks 1.0.4 → 1.0.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/activity_link.d.ts +5 -0
- package/dist/attachments.d.ts +17 -1
- package/dist/case_data.d.ts +4 -2
- package/dist/index.js +1 -1
- package/dist/index.js.map +1 -1
- package/dist/index.m.js +1 -1
- package/dist/index.m.js.map +1 -1
- package/dist/index.modern.mjs +1 -1
- package/dist/index.modern.mjs.map +1 -1
- package/dist/index.umd.js +1 -1
- package/dist/index.umd.js.map +1 -1
- package/package.json +1 -1
- package/dist/activity_link.js +0 -219
- package/dist/briefcase.js +0 -327
- package/dist/case.d.ts +0 -114
- package/dist/case_admin.js +0 -821
- package/dist/case_assets.js +0 -129
- package/dist/case_data.js +0 -416
- package/dist/case_financial.js +0 -848
- package/dist/case_workflow.js +0 -455
- package/dist/cityworks.d.ts +0 -224
- package/dist/comments.js +0 -126
- package/dist/error.js +0 -30
- package/dist/event_layer.d.ts +0 -97
- package/dist/event_layer.js +0 -207
- package/dist/general.js +0 -212
- package/dist/gis.js +0 -250
- package/dist/index.cjs +0 -2
- package/dist/index.cjs.map +0 -1
- package/dist/index.modern.js +0 -2
- package/dist/index.modern.js.map +0 -1
- package/dist/inspection.js +0 -933
- package/dist/inspection_admin.js +0 -43
- package/dist/inspection_costs.js +0 -200
- package/dist/message_queue.js +0 -248
- package/dist/query.js +0 -242
- package/dist/request.js +0 -899
- package/dist/request_admin.js +0 -32
- package/dist/request_costs.js +0 -113
- package/dist/search.js +0 -371
- package/dist/workorder.js +0 -951
- package/dist/workorder_admin.js +0 -248
- package/dist/workorder_costs.js +0 -274
package/dist/inspection.js
DELETED
|
@@ -1,933 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.Inspection = void 0;
|
|
4
|
-
var error_1 = require("./error");
|
|
5
|
-
var _ = require('lodash');
|
|
6
|
-
var Inspection = /** @class */ (function () {
|
|
7
|
-
/**
|
|
8
|
-
* @hidden
|
|
9
|
-
*/
|
|
10
|
-
function Inspection(cw) {
|
|
11
|
-
this.cw = cw;
|
|
12
|
-
this.admin;
|
|
13
|
-
}
|
|
14
|
-
/**
|
|
15
|
-
* Create new inspection
|
|
16
|
-
*
|
|
17
|
-
* @category Inspections
|
|
18
|
-
* @param {Object} insp_data - See /{subdirectory}/apidocs/#/data-type-infodataType=InspectionBase on your Cityworks instance
|
|
19
|
-
* @return {Object} Returns Promise that represents an object describing the newly-created inspection
|
|
20
|
-
*/
|
|
21
|
-
Inspection.prototype.create = function (insp_data) {
|
|
22
|
-
var _this = this;
|
|
23
|
-
return new Promise(function (resolve, reject) {
|
|
24
|
-
if (!_.has(insp_data, 'EntityType') || !_.has(insp_data, 'InspTemplateId')) {
|
|
25
|
-
reject(new error_1.CWError(1, 'EntityType and InspTemplateId properties must be provided.', { 'provided': insp_data }));
|
|
26
|
-
}
|
|
27
|
-
else {
|
|
28
|
-
_this.cw.runRequest('Ams/Inspection/Create', insp_data).then(function (r) {
|
|
29
|
-
resolve(r.Value);
|
|
30
|
-
}).catch(function (e) {
|
|
31
|
-
reject(e);
|
|
32
|
-
});
|
|
33
|
-
}
|
|
34
|
-
});
|
|
35
|
-
};
|
|
36
|
-
/**
|
|
37
|
-
* Create inspections from an array of entities
|
|
38
|
-
*
|
|
39
|
-
* @category Inspections
|
|
40
|
-
* @param {Object} insp_data - See /{subdirectory}/apidocs/#/data-type-infodataType=InspectionBase on your Cityworks instance
|
|
41
|
-
* @return {Object} Returns Promise that represents a collection of objects describing the newly-created inspections
|
|
42
|
-
*/
|
|
43
|
-
Inspection.prototype.createFromEntities = function (insp_data) {
|
|
44
|
-
var _this = this;
|
|
45
|
-
return new Promise(function (resolve, reject) {
|
|
46
|
-
if (!_.has(insp_data, 'EntityType') || !_.has(insp_data, 'InspTemplateId')) {
|
|
47
|
-
reject(new error_1.CWError(1, 'EntityType and InspTemplateId properties must be provided.', { 'provided': insp_data }));
|
|
48
|
-
}
|
|
49
|
-
else {
|
|
50
|
-
_this.cw.runRequest('Ams/Inspection/CreateFromEntities', insp_data).then(function (r) {
|
|
51
|
-
resolve(r.Value);
|
|
52
|
-
}).catch(function (e) {
|
|
53
|
-
reject(e);
|
|
54
|
-
});
|
|
55
|
-
}
|
|
56
|
-
});
|
|
57
|
-
};
|
|
58
|
-
/**
|
|
59
|
-
* Create an inspection from a parent inspection (TODO: what parent!?)
|
|
60
|
-
*
|
|
61
|
-
* @category Inspections
|
|
62
|
-
* @param {object} insp_data - See /{subdirectory}/apidocs/#/data-type-infodataType=InspectionBase on your Cityworks instance
|
|
63
|
-
* @return {Object} Returns object that represents an object describing the newly-created inspection
|
|
64
|
-
*/
|
|
65
|
-
Inspection.prototype.createFromParent = function (insp_data) {
|
|
66
|
-
var _this = this;
|
|
67
|
-
return new Promise(function (resolve, reject) {
|
|
68
|
-
// see if it's just InspectionId
|
|
69
|
-
if (!_.has(insp_data, 'EntityType') || !_.has(insp_data, 'InspTemplateId') || !_.has(insp_data, 'InspectionId')) {
|
|
70
|
-
reject(new error_1.CWError(1, 'EntityType and InspTemplateId properties must be provided.', { 'provided': insp_data }));
|
|
71
|
-
}
|
|
72
|
-
else {
|
|
73
|
-
_this.cw.runRequest('Ams/Inspection/CreateFromParent', insp_data).then(function (r) {
|
|
74
|
-
resolve(r.Value);
|
|
75
|
-
}).catch(function (e) {
|
|
76
|
-
reject(e);
|
|
77
|
-
});
|
|
78
|
-
}
|
|
79
|
-
});
|
|
80
|
-
};
|
|
81
|
-
/**
|
|
82
|
-
* Create an inspection from a service request
|
|
83
|
-
*
|
|
84
|
-
* @category Inspections
|
|
85
|
-
* @param {object} insp_data - See /{subdirectory}/apidocs/#/data-type-infodataType=InspectionBase on your Cityworks instance
|
|
86
|
-
* @return {Object} Returns object that represents an object describing the newly-created inspection
|
|
87
|
-
*/
|
|
88
|
-
Inspection.prototype.createFromServiceRequest = function (insp_data) {
|
|
89
|
-
var _this = this;
|
|
90
|
-
return new Promise(function (resolve, reject) {
|
|
91
|
-
if (!_.has(insp_data, 'EntityType') || !_.has(insp_data, 'InspTemplateId') || !_.has(insp_data, 'RequestId')) {
|
|
92
|
-
reject(new error_1.CWError(1, 'EntityType and InspTemplateId properties must be provided.', { 'provided': insp_data }));
|
|
93
|
-
}
|
|
94
|
-
else {
|
|
95
|
-
_this.cw.runRequest('Ams/Inspection/CreateFromServiceRequest', insp_data).then(function (r) {
|
|
96
|
-
resolve(r.Value);
|
|
97
|
-
}).catch(function (e) {
|
|
98
|
-
reject(e);
|
|
99
|
-
});
|
|
100
|
-
}
|
|
101
|
-
});
|
|
102
|
-
};
|
|
103
|
-
/**
|
|
104
|
-
* Create an inspection from a WorkOrder
|
|
105
|
-
*
|
|
106
|
-
* @category Inspections
|
|
107
|
-
* @param {object} insp_data - See /{subdirectory}/apidocs/#/data-type-infodataType=InspectionBase on your Cityworks instance
|
|
108
|
-
* @return {Object} Returns object that represents an object describing the newly-created inspection
|
|
109
|
-
*/
|
|
110
|
-
Inspection.prototype.createFromWorkOrder = function (insp_data) {
|
|
111
|
-
var _this = this;
|
|
112
|
-
return new Promise(function (resolve, reject) {
|
|
113
|
-
// Are they both actually required?!?!
|
|
114
|
-
// WorkOrderId
|
|
115
|
-
// WorkOrderSid ...do with only SID first then check
|
|
116
|
-
if (!_.has(insp_data, 'EntityType') || !_.has(insp_data, 'InspTemplateId') || !_.has(insp_data, 'WorkOrderSid')) {
|
|
117
|
-
reject(new error_1.CWError(1, 'EntityType and InspTemplateId properties must be provided.', { 'provided': insp_data }));
|
|
118
|
-
}
|
|
119
|
-
else {
|
|
120
|
-
_this.cw.runRequest('Ams/Inspection/CreateFromWorkOrder', insp_data).then(function (r) {
|
|
121
|
-
resolve(r.Value);
|
|
122
|
-
}).catch(function (e) {
|
|
123
|
-
reject(e);
|
|
124
|
-
});
|
|
125
|
-
}
|
|
126
|
-
});
|
|
127
|
-
};
|
|
128
|
-
/**
|
|
129
|
-
* Update an inspection
|
|
130
|
-
*
|
|
131
|
-
* @category Inspections
|
|
132
|
-
* @param {object} insp_data - See /{subdirectory}/apidocs/#/data-type-infodataType=InspectionBase on the Cityworks instance
|
|
133
|
-
* @return {Object} Returns Promise that represents an object describing the updated inspection
|
|
134
|
-
*/
|
|
135
|
-
Inspection.prototype.update = function (insp_data) {
|
|
136
|
-
var _this = this;
|
|
137
|
-
return new Promise(function (resolve, reject) {
|
|
138
|
-
return new Promise(function (resolve, reject) {
|
|
139
|
-
if (!_.has(insp_data, 'InspectionId')) {
|
|
140
|
-
reject(new error_1.CWError(1, 'InspectionId must be provided.', { 'provided': insp_data }));
|
|
141
|
-
}
|
|
142
|
-
else {
|
|
143
|
-
_this.cw.runRequest('Ams/Inspection/Update', insp_data).then(function (r) {
|
|
144
|
-
resolve(r.Value);
|
|
145
|
-
}).catch(function (e) {
|
|
146
|
-
reject(e);
|
|
147
|
-
});
|
|
148
|
-
}
|
|
149
|
-
});
|
|
150
|
-
});
|
|
151
|
-
};
|
|
152
|
-
/**
|
|
153
|
-
* Get an inspection by ID
|
|
154
|
-
*
|
|
155
|
-
* @category Inspections
|
|
156
|
-
* @param {number} inspectionId - The inspection ID to retrieve
|
|
157
|
-
* @return {Object} Returns Promise that represents an object describing the inspection
|
|
158
|
-
*/
|
|
159
|
-
Inspection.prototype.getById = function (inspectionId) {
|
|
160
|
-
var _this = this;
|
|
161
|
-
return new Promise(function (resolve, reject) {
|
|
162
|
-
var data = {
|
|
163
|
-
InspectionId: inspectionId
|
|
164
|
-
};
|
|
165
|
-
_this.cw.runRequest('Ams/Inspection/ById', data).then(function (r) {
|
|
166
|
-
resolve(r.Value);
|
|
167
|
-
}).catch(function (e) {
|
|
168
|
-
reject(e);
|
|
169
|
-
});
|
|
170
|
-
});
|
|
171
|
-
};
|
|
172
|
-
/**
|
|
173
|
-
* Get inspections by array of IDs
|
|
174
|
-
*
|
|
175
|
-
* @category Inspections
|
|
176
|
-
* @param {Array<number>} inspectionIds - The inspection IDs to retrieve
|
|
177
|
-
* @return {Object} Returns Promise that represents a collection of Objects describing the inspections
|
|
178
|
-
*/
|
|
179
|
-
Inspection.prototype.getByIds = function (inspectionIds) {
|
|
180
|
-
var _this = this;
|
|
181
|
-
return new Promise(function (resolve, reject) {
|
|
182
|
-
var data = {
|
|
183
|
-
InspectionIds: inspectionIds
|
|
184
|
-
};
|
|
185
|
-
_this.cw.runRequest('Ams/Inspection/ByIds', data).then(function (r) {
|
|
186
|
-
resolve(r.Value);
|
|
187
|
-
}).catch(function (e) {
|
|
188
|
-
reject(e);
|
|
189
|
-
});
|
|
190
|
-
});
|
|
191
|
-
};
|
|
192
|
-
/**
|
|
193
|
-
* Cancel inspections
|
|
194
|
-
*
|
|
195
|
-
* @category Inspections
|
|
196
|
-
* @param {Array<number>} inspectionIds - An array of the IDs to cancel the matched inspections
|
|
197
|
-
* @param {string} [cancelReason] - A reason for cancelling the inspection(s)
|
|
198
|
-
* @param {datetime} [dateCancelled] - The date/time that it should be indicated the inspection was cancelled
|
|
199
|
-
* @return {Object} Returns object that represents a collection of inspections
|
|
200
|
-
*/
|
|
201
|
-
Inspection.prototype.cancel = function (inspectionIds, cancelReason, dateCancelled) {
|
|
202
|
-
var _this = this;
|
|
203
|
-
return new Promise(function (resolve, reject) {
|
|
204
|
-
var m = new Date();
|
|
205
|
-
var data = { InspectionIds: inspectionIds };
|
|
206
|
-
if (typeof (cancelReason) !== 'undefined') {
|
|
207
|
-
data.CancelReason = cancelReason;
|
|
208
|
-
}
|
|
209
|
-
if (typeof (dateCancelled) !== 'undefined') {
|
|
210
|
-
data.DateCancelled = dateCancelled;
|
|
211
|
-
}
|
|
212
|
-
_this.cw.runRequest('Ams/Inspection/Cancel', data).then(function (r) {
|
|
213
|
-
resolve(r.Value);
|
|
214
|
-
}).catch(function (e) {
|
|
215
|
-
reject(e);
|
|
216
|
-
});
|
|
217
|
-
});
|
|
218
|
-
};
|
|
219
|
-
/**
|
|
220
|
-
* Uncancel inspections
|
|
221
|
-
*
|
|
222
|
-
* @category Requests
|
|
223
|
-
* @param {Array<number>} inspectionIds - An array of the IDs to uncancel the matched requests
|
|
224
|
-
* @return {Object} Returns object that represents a collection of requests
|
|
225
|
-
*/
|
|
226
|
-
Inspection.prototype.uncancel = function (inspectionIds) {
|
|
227
|
-
var _this = this;
|
|
228
|
-
return new Promise(function (resolve, reject) {
|
|
229
|
-
var data = {
|
|
230
|
-
InspectionIds: inspectionIds
|
|
231
|
-
};
|
|
232
|
-
_this.cw.runRequest('Ams/Inspection/Uncancel', data).then(function (r) {
|
|
233
|
-
resolve(r.Value);
|
|
234
|
-
}).catch(function (e) {
|
|
235
|
-
reject(e);
|
|
236
|
-
});
|
|
237
|
-
});
|
|
238
|
-
};
|
|
239
|
-
/**
|
|
240
|
-
* Close inspections
|
|
241
|
-
*
|
|
242
|
-
* @category Inspections
|
|
243
|
-
* @param {Array<number>} inspectionIds - An array of the IDs to close the matched inspections
|
|
244
|
-
* @return {Object} Returns object that represents a collection of inspections
|
|
245
|
-
*/
|
|
246
|
-
Inspection.prototype.close = function (inspectionIds) {
|
|
247
|
-
var _this = this;
|
|
248
|
-
return new Promise(function (resolve, reject) {
|
|
249
|
-
var data = {
|
|
250
|
-
InspectionIds: inspectionIds
|
|
251
|
-
};
|
|
252
|
-
_this.cw.runRequest('Ams/Inspection/Close', data).then(function (r) {
|
|
253
|
-
resolve(r.Value);
|
|
254
|
-
}).catch(function (e) {
|
|
255
|
-
reject(e);
|
|
256
|
-
});
|
|
257
|
-
});
|
|
258
|
-
};
|
|
259
|
-
/**
|
|
260
|
-
* Reopen closed inspections
|
|
261
|
-
*
|
|
262
|
-
* @category Inspections
|
|
263
|
-
* @param {Array<number>} inspectionIds - An array of the IDs to reopen the matched inspections
|
|
264
|
-
* @return {Object} Returns object that represents a collection of inspections
|
|
265
|
-
*/
|
|
266
|
-
Inspection.prototype.reopen = function (inspectionIds) {
|
|
267
|
-
var _this = this;
|
|
268
|
-
return new Promise(function (resolve, reject) {
|
|
269
|
-
var data = {
|
|
270
|
-
InspectionIds: inspectionIds
|
|
271
|
-
};
|
|
272
|
-
_this.cw.runRequest('Ams/Inspection/Reopen', data).then(function (r) {
|
|
273
|
-
resolve(r.Value);
|
|
274
|
-
}).catch(function (e) {
|
|
275
|
-
reject(e);
|
|
276
|
-
});
|
|
277
|
-
});
|
|
278
|
-
};
|
|
279
|
-
/**
|
|
280
|
-
* Delete inspections
|
|
281
|
-
*
|
|
282
|
-
* @category Inspections
|
|
283
|
-
* @param {Array<number>} inspectionIds - An array of the IDs to delete the matched inspections
|
|
284
|
-
* @return {Object} Returns object that represents a collection of inspection Ids which have been deleted
|
|
285
|
-
*/
|
|
286
|
-
Inspection.prototype.delete = function (inspectionIds) {
|
|
287
|
-
var _this = this;
|
|
288
|
-
return new Promise(function (resolve, reject) {
|
|
289
|
-
var data = {
|
|
290
|
-
InspectionIds: inspectionIds
|
|
291
|
-
};
|
|
292
|
-
_this.cw.runRequest('Ams/Inspection/Delete', data).then(function (r) {
|
|
293
|
-
resolve(r.Value);
|
|
294
|
-
}).catch(function (e) {
|
|
295
|
-
reject(e);
|
|
296
|
-
});
|
|
297
|
-
});
|
|
298
|
-
};
|
|
299
|
-
/**
|
|
300
|
-
* Search for inspections
|
|
301
|
-
*
|
|
302
|
-
* @category Inspection Search
|
|
303
|
-
* @param {Object} searchData - The search information to retrieve matched inspections, see instance docs: /{subdirectory}/apidocs/#/service-info/Ams/Inspection
|
|
304
|
-
* @return {Object} Returns Promise that represents an array of the matching inspection IDs
|
|
305
|
-
*/
|
|
306
|
-
Inspection.prototype.search = function (searchData) {
|
|
307
|
-
var _this = this;
|
|
308
|
-
return new Promise(function (resolve, reject) {
|
|
309
|
-
var data = searchData;
|
|
310
|
-
_this.cw.runRequest('Ams/Inspection/Search', data).then(function (r) {
|
|
311
|
-
resolve(r.Value);
|
|
312
|
-
}).catch(function (e) {
|
|
313
|
-
reject(e);
|
|
314
|
-
});
|
|
315
|
-
});
|
|
316
|
-
};
|
|
317
|
-
/**
|
|
318
|
-
* Get the records on the basis of inspectionId, only populates InspectionId, InspTemplateName, and Location properties
|
|
319
|
-
*
|
|
320
|
-
* @category Inspection Object Search
|
|
321
|
-
* @param {string} inspectionId - ???, see instance docs: /{subdirectory}/apidocs/#/service-info/Ams/Inspection
|
|
322
|
-
* @return {Object} Returns Promise that represents a collection of the matching (limited) inspection objects
|
|
323
|
-
*/
|
|
324
|
-
Inspection.prototype.searchObject = function (inspectionId) {
|
|
325
|
-
var _this = this;
|
|
326
|
-
return new Promise(function (resolve, reject) {
|
|
327
|
-
var data = {
|
|
328
|
-
InspectionId: inspectionId
|
|
329
|
-
};
|
|
330
|
-
_this.cw.runRequest('Ams/ServiceRequest/SearchObject', data).then(function (r) {
|
|
331
|
-
resolve(r.Value);
|
|
332
|
-
}).catch(function (e) {
|
|
333
|
-
reject(e);
|
|
334
|
-
});
|
|
335
|
-
});
|
|
336
|
-
};
|
|
337
|
-
/**
|
|
338
|
-
* Get list of statuses
|
|
339
|
-
*
|
|
340
|
-
* @category Inspection Options
|
|
341
|
-
* @return {Object} Returns object that represents an array of all possible statuses for an Inspection
|
|
342
|
-
*/
|
|
343
|
-
Inspection.prototype.statuses = function () {
|
|
344
|
-
var _this = this;
|
|
345
|
-
return new Promise(function (resolve, reject) {
|
|
346
|
-
_this.cw.runRequest('Ams/Inspection/Statuses', {}).then(function (r) {
|
|
347
|
-
resolve(r.Value);
|
|
348
|
-
}).catch(function (e) {
|
|
349
|
-
reject(e);
|
|
350
|
-
});
|
|
351
|
-
});
|
|
352
|
-
};
|
|
353
|
-
/**
|
|
354
|
-
* Get inspection submit to list
|
|
355
|
-
*
|
|
356
|
-
* @category Inspection Options
|
|
357
|
-
* @param {boolean} [includeInactiveEmployees] - whether to include inactive employees in the return. Defaults to false.
|
|
358
|
-
* @param {boolean} [domainIds] - which domains to include in the return, default to All domains
|
|
359
|
-
* @return {Object} Returns object that represents a collection of all possible employees for an Inspection's SubmitTo
|
|
360
|
-
*/
|
|
361
|
-
Inspection.prototype.submitTos = function (includeInactiveEmployees, domainIds) {
|
|
362
|
-
var _this = this;
|
|
363
|
-
if (includeInactiveEmployees === void 0) { includeInactiveEmployees = false; }
|
|
364
|
-
return new Promise(function (resolve, reject) {
|
|
365
|
-
var data = {};
|
|
366
|
-
if (includeInactiveEmployees) {
|
|
367
|
-
data.IncludeInactiveEmployees = true;
|
|
368
|
-
}
|
|
369
|
-
if (typeof (domainIds) !== 'undefined') {
|
|
370
|
-
data.DomainIds = domainIds;
|
|
371
|
-
}
|
|
372
|
-
_this.cw.runRequest('Ams/Inspection/SubmitTos', data).then(function (r) {
|
|
373
|
-
resolve(r.Value);
|
|
374
|
-
}).catch(function (e) {
|
|
375
|
-
reject(e);
|
|
376
|
-
});
|
|
377
|
-
});
|
|
378
|
-
};
|
|
379
|
-
/**
|
|
380
|
-
* Add an entity to an existing inspection
|
|
381
|
-
* This method requires an Entity/Asset to be specified. You can either specify the Entity Type and its UID or a WorkOrderEntityBase Object.
|
|
382
|
-
*
|
|
383
|
-
* @category Inspections
|
|
384
|
-
* @param {Object} entity - Either of two attribute combinations are valid: entityType & entityUid OR Entity as a fully-inflated WorkOrderEntity (WorkOrderEntityBase) object.
|
|
385
|
-
* @param {number} inspectionId - An Inspection ID to attach the entity/asset to.
|
|
386
|
-
* @param {boolean} updateXY - Provide a boolean to whether the inspection's X/Y coordinates should be updated. Default is true.
|
|
387
|
-
* @param {Object} facility - Add Facility_Id for the Facility Identifier and Level_id for the Facility Level Identifier. Defaults to empty so that no facility is specified.
|
|
388
|
-
* @return {Object} Returns object that represents an object which describes an Inspection Entity
|
|
389
|
-
*/
|
|
390
|
-
Inspection.prototype.connectAsset = function (entity, inspectionId, updateXY, facility) {
|
|
391
|
-
var _this = this;
|
|
392
|
-
if (updateXY === void 0) { updateXY = true; }
|
|
393
|
-
if (facility === void 0) { facility = {}; }
|
|
394
|
-
return new Promise(function (resolve, reject) {
|
|
395
|
-
var data = {
|
|
396
|
-
InspectionId: inspectionId
|
|
397
|
-
};
|
|
398
|
-
if (_.has(entity, 'EntityType') && _.has(entity, 'EntityUid')) {
|
|
399
|
-
data.EntityType = entity.EntityType;
|
|
400
|
-
data.EntityUid = entity.EntityUid;
|
|
401
|
-
}
|
|
402
|
-
else if (_.has(entity, 'Entity')) {
|
|
403
|
-
data.Entity = entity.Entity;
|
|
404
|
-
}
|
|
405
|
-
else {
|
|
406
|
-
// Throw error, no entity/asset provided
|
|
407
|
-
}
|
|
408
|
-
if (_.has(facility, 'Facility_Id')) {
|
|
409
|
-
data.Facility_Id = facility.Facility_Id;
|
|
410
|
-
}
|
|
411
|
-
if (_.has(facility, 'Level_Id')) {
|
|
412
|
-
data.Level_Id = facility.Level_Id;
|
|
413
|
-
}
|
|
414
|
-
_this.cw.runRequest('Ams/Inspection/AddEntity', data).then(function (r) {
|
|
415
|
-
resolve(r.Value);
|
|
416
|
-
}).catch(function (e) {
|
|
417
|
-
// 4 NotAuthorizedToUpdateInspection
|
|
418
|
-
// 9 InvalidActivityMapLogicXY
|
|
419
|
-
// 21 ErrorUnknownEntityType
|
|
420
|
-
// 30 InvalidField
|
|
421
|
-
// 60 WarningItemNotFound
|
|
422
|
-
// 68 MoveInvalidCityworksWkid
|
|
423
|
-
reject(e);
|
|
424
|
-
});
|
|
425
|
-
});
|
|
426
|
-
};
|
|
427
|
-
/**
|
|
428
|
-
* Get the answers for inspections
|
|
429
|
-
*
|
|
430
|
-
* @category Inspections
|
|
431
|
-
* @param {Array<number>} inspections - An Array of one or more Inspection IDs
|
|
432
|
-
* @return {Object} Returns Promise that represents a collection of Inspection Answers
|
|
433
|
-
*/
|
|
434
|
-
Inspection.prototype.getAnswers = function (inspections) {
|
|
435
|
-
var _this = this;
|
|
436
|
-
return new Promise(function (resolve, reject) {
|
|
437
|
-
var data = {};
|
|
438
|
-
if (inspections.length == 0) {
|
|
439
|
-
data.InspectionId = inspections[0];
|
|
440
|
-
}
|
|
441
|
-
else {
|
|
442
|
-
data.InspectionIds = inspections;
|
|
443
|
-
}
|
|
444
|
-
_this.cw.runRequest('Ams/Inspection/Answers', data).then(function (r) {
|
|
445
|
-
resolve(r.Value);
|
|
446
|
-
}).catch(function (e) {
|
|
447
|
-
reject(e);
|
|
448
|
-
});
|
|
449
|
-
});
|
|
450
|
-
};
|
|
451
|
-
/**
|
|
452
|
-
* Get the audit log for a specific Inspection
|
|
453
|
-
*
|
|
454
|
-
* @category Inspections
|
|
455
|
-
* @param {number} inspectionId - An Inspection ID to get the audit log for
|
|
456
|
-
* @return {Object} Returns Promise that represents a collection of Cityworks Metadata Objects
|
|
457
|
-
*/
|
|
458
|
-
Inspection.prototype.getAuditLog = function (inspectionId) {
|
|
459
|
-
var _this = this;
|
|
460
|
-
return new Promise(function (resolve, reject) {
|
|
461
|
-
var data = { InspectionId: inspectionId };
|
|
462
|
-
_this.cw.runRequest('Ams/Inspection/AuditLog', data).then(function (r) {
|
|
463
|
-
resolve(r.Value);
|
|
464
|
-
}).catch(function (e) {
|
|
465
|
-
reject(e);
|
|
466
|
-
});
|
|
467
|
-
});
|
|
468
|
-
};
|
|
469
|
-
/**
|
|
470
|
-
* Create a search definition. Save the definition by setting SaveDefinition = true and supplying a SearchName.
|
|
471
|
-
*
|
|
472
|
-
* @category Inspections
|
|
473
|
-
* @param {Object} searchData - Search data variables. See /{subdirectory}/apidocs/#/service-info/Ams/Inspection
|
|
474
|
-
* @param {number} [searchName] - What to name your search (if it should be saved)
|
|
475
|
-
* @param {number} [sharedWithin] - What group or domain to share the search to.
|
|
476
|
-
* @param {boolean} saveDefinition - Whether or not to save the search definition. Defaults to true when a search name is specified.
|
|
477
|
-
* @param {boolean} enableEurl - Whether or not to enable EURL for the saved search. Defaults to true.
|
|
478
|
-
* @return {Object} Returns Promise that represents a collection of Cityworks Metadata Objects
|
|
479
|
-
*/
|
|
480
|
-
Inspection.prototype.createSearchDefinition = function (searchData, searchName, sharedWithin, saveDefinition, enableEurl) {
|
|
481
|
-
var _this = this;
|
|
482
|
-
if (saveDefinition === void 0) { saveDefinition = true; }
|
|
483
|
-
if (enableEurl === void 0) { enableEurl = true; }
|
|
484
|
-
return new Promise(function (resolve, reject) {
|
|
485
|
-
var data = searchData;
|
|
486
|
-
if (_.isString(searchName)) {
|
|
487
|
-
_.set(data, 'SearchName', searchName);
|
|
488
|
-
_.set(data, 'SaveDefinition', saveDefinition);
|
|
489
|
-
_.set(data, 'EnableEurl', enableEurl);
|
|
490
|
-
// not sure how to handle sharedWithin...
|
|
491
|
-
// _.set(data, 'SharedWithin', sharedWithin)
|
|
492
|
-
}
|
|
493
|
-
_this.cw.runRequest('Ams/Inspection/CreateSearchDefinition', data).then(function (r) {
|
|
494
|
-
resolve(r.Value);
|
|
495
|
-
}).catch(function (e) {
|
|
496
|
-
reject(e);
|
|
497
|
-
});
|
|
498
|
-
});
|
|
499
|
-
};
|
|
500
|
-
/**
|
|
501
|
-
* Get cycle from
|
|
502
|
-
*
|
|
503
|
-
* @category Inspection Options
|
|
504
|
-
* @return {Object} Returns Promise that represents ... I have no idea what this endpoint does
|
|
505
|
-
*/
|
|
506
|
-
Inspection.prototype.getCycleFrom = function () {
|
|
507
|
-
var _this = this;
|
|
508
|
-
return new Promise(function (resolve, reject) {
|
|
509
|
-
_this.cw.runRequest('Ams/Inspection/CycleFrom', {}).then(function (r) {
|
|
510
|
-
resolve(r.Value);
|
|
511
|
-
}).catch(function (e) {
|
|
512
|
-
reject(e);
|
|
513
|
-
});
|
|
514
|
-
});
|
|
515
|
-
};
|
|
516
|
-
/**
|
|
517
|
-
* Get cycle intervals
|
|
518
|
-
*
|
|
519
|
-
* @category Inspection Options
|
|
520
|
-
* @return {Object} Returns Promise that represents a Dictionary of the cycle intervals available
|
|
521
|
-
*/
|
|
522
|
-
Inspection.prototype.getCycleIntervals = function () {
|
|
523
|
-
var _this = this;
|
|
524
|
-
return new Promise(function (resolve, reject) {
|
|
525
|
-
_this.cw.runRequest('Ams/Inspection/CycleIntervals', {}).then(function (r) {
|
|
526
|
-
resolve(r.Value);
|
|
527
|
-
}).catch(function (e) {
|
|
528
|
-
reject(e);
|
|
529
|
-
});
|
|
530
|
-
});
|
|
531
|
-
};
|
|
532
|
-
/**
|
|
533
|
-
* Get cycle types
|
|
534
|
-
*
|
|
535
|
-
* @category Inspection Options
|
|
536
|
-
* @return {Object} Returns Promise that represents a Dictionary of the cycle types available
|
|
537
|
-
*/
|
|
538
|
-
Inspection.prototype.getCycleTypes = function () {
|
|
539
|
-
var _this = this;
|
|
540
|
-
return new Promise(function (resolve, reject) {
|
|
541
|
-
_this.cw.runRequest('Ams/Inspection/CycleTypes', {}).then(function (r) {
|
|
542
|
-
resolve(r.Value);
|
|
543
|
-
}).catch(function (e) {
|
|
544
|
-
reject(e);
|
|
545
|
-
});
|
|
546
|
-
});
|
|
547
|
-
};
|
|
548
|
-
/**
|
|
549
|
-
* Get districts
|
|
550
|
-
*
|
|
551
|
-
* @category Inspection Options
|
|
552
|
-
* @return {Object} Returns Promise that represents an Array of the districts
|
|
553
|
-
*/
|
|
554
|
-
Inspection.prototype.getDistricts = function () {
|
|
555
|
-
var _this = this;
|
|
556
|
-
return new Promise(function (resolve, reject) {
|
|
557
|
-
_this.cw.runRequest('Ams/Inspection/Districts', {}).then(function (r) {
|
|
558
|
-
resolve(r.Value);
|
|
559
|
-
}).catch(function (e) {
|
|
560
|
-
reject(e);
|
|
561
|
-
});
|
|
562
|
-
});
|
|
563
|
-
};
|
|
564
|
-
/**
|
|
565
|
-
* Get Inspection Employee lists. Abstraction done here, though only one employee list field, AFAIK.
|
|
566
|
-
*
|
|
567
|
-
* @category Inspection Options
|
|
568
|
-
* @param {string} listType - Which list (endpoint) to get. Includes only SubmitTos.
|
|
569
|
-
* @param {boolean} includeInactiveEmployees - Whether to include inactive employees in the returned list. Defaults to false.
|
|
570
|
-
* @param {Array<number>} [domainIds] - Filter to certain domains within the Cityworks instance.
|
|
571
|
-
* @return {Object} Returns Promise that represents a collection of employees. See: /{subdirectory}/apidocs/#/data-type-info;dataType=EmployeeNameId
|
|
572
|
-
*/
|
|
573
|
-
Inspection.prototype.getEmployeeLists = function (listType, includeInactiveEmployees, domainIds) {
|
|
574
|
-
var _this = this;
|
|
575
|
-
if (includeInactiveEmployees === void 0) { includeInactiveEmployees = false; }
|
|
576
|
-
return new Promise(function (resolve, reject) {
|
|
577
|
-
var data = {
|
|
578
|
-
IncludeInactiveEmployees: includeInactiveEmployees
|
|
579
|
-
};
|
|
580
|
-
if (typeof (domainIds) != 'undefined' && domainIds != null) {
|
|
581
|
-
_.set(data, 'DomainIds', domainIds);
|
|
582
|
-
}
|
|
583
|
-
if (listType != 'SubmitTos') {
|
|
584
|
-
reject(new error_1.CWError(2, 'listType must be "SubmitTos".', { 'provided': listType }));
|
|
585
|
-
}
|
|
586
|
-
else {
|
|
587
|
-
_this.cw.runRequest("Ams/Inspection/" + listType, data).then(function (r) {
|
|
588
|
-
resolve(r.Value);
|
|
589
|
-
}).catch(function (e) {
|
|
590
|
-
reject(e);
|
|
591
|
-
});
|
|
592
|
-
}
|
|
593
|
-
});
|
|
594
|
-
};
|
|
595
|
-
/**
|
|
596
|
-
* Get SubmitTo list
|
|
597
|
-
*
|
|
598
|
-
* @category WorkOrder Options
|
|
599
|
-
* @param {boolean} includeInactiveEmployees - Whether to include inactive employees in the returned list. Defaults to false.
|
|
600
|
-
* @param {Array<number>} [domainIds] - Filter to certain domains within the Cityworks instance.
|
|
601
|
-
* @return {Object} Returns Promise that represents a collection of employees. See: /{subdirectory}/apidocs/#/data-type-info;dataType=EmployeeNameId
|
|
602
|
-
*/
|
|
603
|
-
Inspection.prototype.getSubmitTos = function (includeInactiveEmployees, domainIds) {
|
|
604
|
-
if (includeInactiveEmployees === void 0) { includeInactiveEmployees = false; }
|
|
605
|
-
return this.getEmployeeLists('SubmitTos', includeInactiveEmployees, domainIds);
|
|
606
|
-
};
|
|
607
|
-
/**
|
|
608
|
-
* Move inspection by InspectionId. Must provide well known id (WKID) or well known text (WKT)
|
|
609
|
-
*
|
|
610
|
-
* @category Inspections
|
|
611
|
-
* @param {number} inspectionId - The ID of the inspection that should be moved
|
|
612
|
-
* @param {number} x - The X coordinate for the move
|
|
613
|
-
* @param {number} y - The Y coordinate for the move
|
|
614
|
-
* @param {Object} projection - Should include at least WKT _or_ WKID attribute. Can also include VcsWKID attribute.
|
|
615
|
-
* @param {number} [z] - the optional Z coordinate for the move
|
|
616
|
-
* @return {Object} Returns Promise that represents an object describing the updated GISPoint
|
|
617
|
-
*/
|
|
618
|
-
Inspection.prototype.move = function (inspectionId, x, y, projection, z) {
|
|
619
|
-
var _this = this;
|
|
620
|
-
return new Promise(function (resolve, reject) {
|
|
621
|
-
if (!_.has(projection, 'WKID') && !_.has(projection, 'WKT')) {
|
|
622
|
-
// Throw error
|
|
623
|
-
reject(new error_1.CWError(3, 'You must provide either the WKID or WKT for the x/y coordinates.', { 'projection': projection }));
|
|
624
|
-
}
|
|
625
|
-
var data_init = {
|
|
626
|
-
InspectionId: inspectionId,
|
|
627
|
-
X: x,
|
|
628
|
-
Y: y
|
|
629
|
-
};
|
|
630
|
-
if (typeof z != 'undefined') {
|
|
631
|
-
_.set(data_init, 'Z', z);
|
|
632
|
-
}
|
|
633
|
-
var data = _.merge(data_init, projection);
|
|
634
|
-
_this.cw.runRequest('Ams/Inspection/Move', data).then(function (r) {
|
|
635
|
-
resolve(r.Value);
|
|
636
|
-
}).catch(function (e) {
|
|
637
|
-
reject(e);
|
|
638
|
-
});
|
|
639
|
-
});
|
|
640
|
-
};
|
|
641
|
-
/////
|
|
642
|
-
// INSPECTION TEMPLATES
|
|
643
|
-
/////
|
|
644
|
-
/**
|
|
645
|
-
* Get inspection templates
|
|
646
|
-
*
|
|
647
|
-
* @category Inspection Templates
|
|
648
|
-
* @param {Array<string>} [entityTypes] - The Entity Type(s) to return potential inspections for
|
|
649
|
-
* @param {boolean} [canCreate] - If true, only return templates the user can create, ignored if false or null, default is true
|
|
650
|
-
* @param {Object} [options] - An object which can include: [IncludeInactive]: boolean, MaximumDateModified: Date, MinimumDateModified: Date, TemplateIds: Array<number>
|
|
651
|
-
* @return {Object} Returns Promise that represents a collection of all Inspections matching the provided parameters
|
|
652
|
-
*/
|
|
653
|
-
Inspection.prototype.getTemplates = function (entityTypes, canCreate, options) {
|
|
654
|
-
var _this = this;
|
|
655
|
-
return new Promise(function (resolve, reject) {
|
|
656
|
-
var data = {};
|
|
657
|
-
if (typeof (entityTypes) !== 'undefined') {
|
|
658
|
-
data.EntityTypes = entityTypes;
|
|
659
|
-
}
|
|
660
|
-
data.CanCreate = typeof (canCreate) !== 'undefined' ? canCreate : true;
|
|
661
|
-
if (typeof (options) === 'object') {
|
|
662
|
-
_.forIn(options, function (v, k) {
|
|
663
|
-
data[k] = v;
|
|
664
|
-
});
|
|
665
|
-
}
|
|
666
|
-
_this.cw.runRequest('Ams/InspectionTemplate/Templates', data).then(function (r) {
|
|
667
|
-
resolve(r.Value);
|
|
668
|
-
}).catch(function (e) {
|
|
669
|
-
reject(e);
|
|
670
|
-
});
|
|
671
|
-
});
|
|
672
|
-
};
|
|
673
|
-
/**
|
|
674
|
-
* Get a list of templates by IDs
|
|
675
|
-
*
|
|
676
|
-
* @category Inspection Templates
|
|
677
|
-
* @param {Array<number>} inspectionIds - An array of the IDs to retrieve the matched inspections
|
|
678
|
-
* @param {Object} [options] - An object which can include: [IncludeInactive]: boolean, MaximumDateModified: Date, MinimumDateModified: Date, TemplateIds: Array<number>
|
|
679
|
-
* @return {Object} Returns object that represents an object describing the inspection
|
|
680
|
-
*/
|
|
681
|
-
Inspection.prototype.getTemplatesByIds = function (inspTemplateIds, options) {
|
|
682
|
-
var _this = this;
|
|
683
|
-
return new Promise(function (resolve, reject) {
|
|
684
|
-
var data = {
|
|
685
|
-
InspTemplateIds: inspTemplateIds
|
|
686
|
-
};
|
|
687
|
-
if (typeof (options) === 'object') {
|
|
688
|
-
_.forIn(options, function (v, k) {
|
|
689
|
-
data[k] = v;
|
|
690
|
-
});
|
|
691
|
-
}
|
|
692
|
-
_this.cw.runRequest('Ams/InspectionTemplate/ByIds', data).then(function (r) {
|
|
693
|
-
resolve(r.Value);
|
|
694
|
-
}).catch(function (e) {
|
|
695
|
-
reject(e);
|
|
696
|
-
});
|
|
697
|
-
});
|
|
698
|
-
};
|
|
699
|
-
/**
|
|
700
|
-
* Get entity types for inspection template(s)
|
|
701
|
-
*
|
|
702
|
-
* @category Inspection Templates
|
|
703
|
-
* @param {Array<number>} inspTemplateIds - An array of the IDs to reopen the matched inspections
|
|
704
|
-
* @return {Object} Returns object that represents an array of Entity Types
|
|
705
|
-
*/
|
|
706
|
-
Inspection.prototype.getTemplateEntityTypes = function (inspTemplateIds) {
|
|
707
|
-
var _this = this;
|
|
708
|
-
return new Promise(function (resolve, reject) {
|
|
709
|
-
var data = {
|
|
710
|
-
InspTemplateIds: inspTemplateIds
|
|
711
|
-
};
|
|
712
|
-
_this.cw.runRequest('Ams/InspectionTemplate/EntityTypes', data).then(function (r) {
|
|
713
|
-
resolve(r.Value);
|
|
714
|
-
}).catch(function (e) {
|
|
715
|
-
reject(e);
|
|
716
|
-
});
|
|
717
|
-
});
|
|
718
|
-
};
|
|
719
|
-
/**
|
|
720
|
-
* Get the questions and answers for inspection template(s)
|
|
721
|
-
*
|
|
722
|
-
* @category Inspection Templates
|
|
723
|
-
* @param {Array<number>} inspTemplateIds - An array of the IDs to reopen the matched inspections
|
|
724
|
-
* @return {Object} Returns object that represents an array which contains a list of InspQuestionPanel for the template
|
|
725
|
-
*/
|
|
726
|
-
Inspection.prototype.getQA = function (inspTemplateIds) {
|
|
727
|
-
var _this = this;
|
|
728
|
-
return new Promise(function (resolve, reject) {
|
|
729
|
-
var data = {
|
|
730
|
-
InspTemplateIds: inspTemplateIds
|
|
731
|
-
};
|
|
732
|
-
_this.cw.runRequest('Ams/InspectionTemplate/QA', data).then(function (r) {
|
|
733
|
-
resolve(r.Value);
|
|
734
|
-
}).catch(function (e) {
|
|
735
|
-
reject(e);
|
|
736
|
-
});
|
|
737
|
-
});
|
|
738
|
-
};
|
|
739
|
-
/**
|
|
740
|
-
* Get inspection template question conditions
|
|
741
|
-
*
|
|
742
|
-
* @category Inspection Templates
|
|
743
|
-
* @param {Array<number>} inspTemplateIds - An array of template IDs to get the matched inspection template Question conditions for
|
|
744
|
-
* @return {Object} Returns object that represents an array which contains a dictionary of InspQuestion IDs to configs
|
|
745
|
-
*/
|
|
746
|
-
Inspection.prototype.getQConditions = function (inspTemplateIds) {
|
|
747
|
-
var _this = this;
|
|
748
|
-
return new Promise(function (resolve, reject) {
|
|
749
|
-
var data = {
|
|
750
|
-
InspTemplateIds: inspTemplateIds
|
|
751
|
-
};
|
|
752
|
-
_this.cw.runRequest('Ams/InspectionTemplate/QuestionConditions', data).then(function (r) {
|
|
753
|
-
resolve(r.Value);
|
|
754
|
-
}).catch(function (e) {
|
|
755
|
-
reject(e);
|
|
756
|
-
});
|
|
757
|
-
});
|
|
758
|
-
};
|
|
759
|
-
// Attachments
|
|
760
|
-
// AddInspectionAttachment InspAttachment
|
|
761
|
-
// Add an inspection attachment
|
|
762
|
-
// Request Parameters
|
|
763
|
-
// Int32 AttachmentType V15_4
|
|
764
|
-
// String Comments
|
|
765
|
-
// String Filename
|
|
766
|
-
// Int32 req InspectionId
|
|
767
|
-
// Ams/Attachments/AddInspectionAttachment?data={
|
|
768
|
-
// "Comments": null,
|
|
769
|
-
// "Filename": null,
|
|
770
|
-
// "InspectionId": null,
|
|
771
|
-
// "AttachmentType": null
|
|
772
|
-
// }
|
|
773
|
-
/**
|
|
774
|
-
* Delete inspection attachments
|
|
775
|
-
*
|
|
776
|
-
* @category Inspection Attachments
|
|
777
|
-
* @param {Array<number>} attachmentIds - An array of inspection attachment IDs to delete
|
|
778
|
-
* @return {Object} Returns object that represents a boolean for action resolution
|
|
779
|
-
*/
|
|
780
|
-
Inspection.prototype.deleteAttachments = function (attachmentIds) {
|
|
781
|
-
var _this = this;
|
|
782
|
-
return new Promise(function (resolve, reject) {
|
|
783
|
-
var data = {
|
|
784
|
-
AttachmentIds: attachmentIds
|
|
785
|
-
};
|
|
786
|
-
_this.cw.runRequest('Ams/Attachments/DeleteInspectionAttachments', data).then(function (r) {
|
|
787
|
-
resolve(r.Value);
|
|
788
|
-
}).catch(function (e) {
|
|
789
|
-
reject(e);
|
|
790
|
-
});
|
|
791
|
-
});
|
|
792
|
-
};
|
|
793
|
-
/**
|
|
794
|
-
* Download an inspection attachment
|
|
795
|
-
*
|
|
796
|
-
* @category Inspection Attachments
|
|
797
|
-
* @param {number} attachmentId - ID of an inspection attachment to download
|
|
798
|
-
* @return {Object} Returns object that represents a file stream
|
|
799
|
-
*/
|
|
800
|
-
Inspection.prototype.downloadAttachment = function (attachmentId) {
|
|
801
|
-
var _this = this;
|
|
802
|
-
return new Promise(function (resolve, reject) {
|
|
803
|
-
var data = {
|
|
804
|
-
AttachmentId: attachmentId
|
|
805
|
-
};
|
|
806
|
-
_this.cw.runRequest('Ams/Attachments/DownloadInspectionAttachment', data).then(function (r) {
|
|
807
|
-
// TODO, pass file through // resolve(r.Value)
|
|
808
|
-
}).catch(function (e) {
|
|
809
|
-
reject(e);
|
|
810
|
-
});
|
|
811
|
-
});
|
|
812
|
-
};
|
|
813
|
-
/**
|
|
814
|
-
* Get inspection attachment by ID
|
|
815
|
-
*
|
|
816
|
-
* @category Inspection Attachments
|
|
817
|
-
* @param {number} attachmentId - An attachment ID to get info for
|
|
818
|
-
* @return {Object} Returns object that represents an object that describes the matched inspection attachment
|
|
819
|
-
*/
|
|
820
|
-
Inspection.prototype.getAttachmentById = function (attachmentId) {
|
|
821
|
-
var _this = this;
|
|
822
|
-
return new Promise(function (resolve, reject) {
|
|
823
|
-
var data = {
|
|
824
|
-
AttachmentId: attachmentId
|
|
825
|
-
};
|
|
826
|
-
_this.cw.runRequest('Ams/Attachments/InspectionAttachmentById', data).then(function (r) {
|
|
827
|
-
resolve(r.Value);
|
|
828
|
-
}).catch(function (e) {
|
|
829
|
-
reject(e);
|
|
830
|
-
});
|
|
831
|
-
});
|
|
832
|
-
};
|
|
833
|
-
/**
|
|
834
|
-
* Get inspection attachment by ID
|
|
835
|
-
*
|
|
836
|
-
* @category Inspection Attachments
|
|
837
|
-
* @param {Array<number>} inspectionIds - An array of inspection IDs to get attachments for
|
|
838
|
-
* @return {Object} Returns object that represents a collection of attachments from the matched inspections
|
|
839
|
-
*/
|
|
840
|
-
Inspection.prototype.getAttachments = function (inspectionIds) {
|
|
841
|
-
var _this = this;
|
|
842
|
-
return new Promise(function (resolve, reject) {
|
|
843
|
-
var data = {
|
|
844
|
-
InspectionIds: inspectionIds
|
|
845
|
-
};
|
|
846
|
-
_this.cw.runRequest('Ams/Attachments/InspectionAttachments', data).then(function (r) {
|
|
847
|
-
resolve(r.Value);
|
|
848
|
-
}).catch(function (e) {
|
|
849
|
-
reject(e);
|
|
850
|
-
});
|
|
851
|
-
});
|
|
852
|
-
};
|
|
853
|
-
/**
|
|
854
|
-
* Get Map Layer Fields
|
|
855
|
-
*
|
|
856
|
-
* @category Inspections
|
|
857
|
-
* @param {number} requestId - The inspection ID to get the map layer fields for.
|
|
858
|
-
* @return {Object} Returns Promise that represents a collection of Objects describing the inspections
|
|
859
|
-
*/
|
|
860
|
-
Inspection.prototype.getMLFs = function (requestId) {
|
|
861
|
-
var _this = this;
|
|
862
|
-
return new Promise(function (resolve, reject) {
|
|
863
|
-
var data = {
|
|
864
|
-
ServiceRequestId: requestId
|
|
865
|
-
};
|
|
866
|
-
var path = 'Ams/TemplateMapLayer/ServiceRequestInstanceMapLayersByRequestId';
|
|
867
|
-
_this.cw.runRequest(path, data).then(function (r) {
|
|
868
|
-
resolve(r.Value);
|
|
869
|
-
}).catch(function (e) {
|
|
870
|
-
reject(e);
|
|
871
|
-
});
|
|
872
|
-
});
|
|
873
|
-
};
|
|
874
|
-
/**
|
|
875
|
-
* Update Map Layer Fields
|
|
876
|
-
*
|
|
877
|
-
* @category Inspections
|
|
878
|
-
* @param {number} requestId - The inspection ID to get the map layer fields for.
|
|
879
|
-
* @param {number} x
|
|
880
|
-
* @param {number} y
|
|
881
|
-
* @param {number} domainId - Domain ID
|
|
882
|
-
* @param {number} [z] - Optional Z coordinate
|
|
883
|
-
* @return {Object} Returns Promise that represents a ...
|
|
884
|
-
*/
|
|
885
|
-
Inspection.prototype.updateMLFs = function (requestId, x, y, domainId, z) {
|
|
886
|
-
var _this = this;
|
|
887
|
-
return new Promise(function (resolve, reject) {
|
|
888
|
-
var data = {};
|
|
889
|
-
var path = 'Ams/TemplateMapLayer/UpdateServiceRequestInstanceMapLayers';
|
|
890
|
-
_.set(data, 'ServiceRequestId', requestId);
|
|
891
|
-
if (_.isNumber(x)) {
|
|
892
|
-
_.set(data, 'X', x);
|
|
893
|
-
}
|
|
894
|
-
if (_.isNumber(y)) {
|
|
895
|
-
_.set(data, 'Y', y);
|
|
896
|
-
}
|
|
897
|
-
if (_.isNumber(z)) {
|
|
898
|
-
_.set(data, 'Z', z);
|
|
899
|
-
}
|
|
900
|
-
if (_.isNumber(domainId)) {
|
|
901
|
-
_.set(data, 'DomainId', domainId);
|
|
902
|
-
}
|
|
903
|
-
_this.cw.runRequest(path, data).then(function (r) {
|
|
904
|
-
resolve(r.Value);
|
|
905
|
-
}).catch(function (e) {
|
|
906
|
-
reject(e);
|
|
907
|
-
});
|
|
908
|
-
});
|
|
909
|
-
};
|
|
910
|
-
/**
|
|
911
|
-
* Delete Map Layer Fields
|
|
912
|
-
*
|
|
913
|
-
* @category Inspections
|
|
914
|
-
* @param {number} inspectionId - The inspection ID to delete the map layer fields for.
|
|
915
|
-
* @return {Object} Returns Promise that represents a collection of Objects describing the workorders
|
|
916
|
-
*/
|
|
917
|
-
Inspection.prototype.deleteMLFs = function (inspectionId) {
|
|
918
|
-
var _this = this;
|
|
919
|
-
return new Promise(function (resolve, reject) {
|
|
920
|
-
var data = {
|
|
921
|
-
InspectionId: inspectionId
|
|
922
|
-
};
|
|
923
|
-
var path = 'Ams/TemplateMapLayer/DeleteInspectionInstancesByInspectionId';
|
|
924
|
-
_this.cw.runRequest(path, data).then(function (r) {
|
|
925
|
-
resolve(r.Value);
|
|
926
|
-
}).catch(function (e) {
|
|
927
|
-
reject(e);
|
|
928
|
-
});
|
|
929
|
-
});
|
|
930
|
-
};
|
|
931
|
-
return Inspection;
|
|
932
|
-
}());
|
|
933
|
-
exports.Inspection = Inspection;
|