cityworks 0.0.52 → 0.0.53
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/README.md +1 -1
- package/dist/activity_link.js +219 -0
- package/dist/attachments.d.ts +59 -0
- package/dist/briefcase.d.ts +22 -1
- package/dist/briefcase.js +327 -0
- package/dist/case_admin.d.ts +0 -22
- package/dist/case_admin.js +821 -0
- package/dist/case_assets.js +129 -0
- package/dist/case_data.js +416 -0
- package/dist/case_financial.js +848 -0
- package/dist/case_workflow.js +455 -0
- package/dist/comments.js +126 -0
- package/dist/error.js +30 -0
- package/dist/event_layer.d.ts +97 -0
- package/dist/event_layer.js +207 -0
- package/dist/general.d.ts +23 -0
- package/dist/general.js +212 -0
- package/dist/gis.js +250 -0
- package/dist/index.d.ts +10 -8
- 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/dist/inspection.d.ts +17 -1
- package/dist/inspection.js +933 -0
- package/dist/inspection_admin.js +43 -0
- package/dist/inspection_costs.js +200 -0
- package/dist/message_queue.js +248 -0
- package/dist/query.d.ts +108 -0
- package/dist/query.js +242 -0
- package/dist/request.d.ts +5 -1
- package/dist/request.js +899 -0
- package/dist/request_admin.js +32 -0
- package/dist/request_costs.js +113 -0
- package/dist/search.d.ts +12 -1
- package/dist/search.js +371 -0
- package/dist/workorder.d.ts +4 -0
- package/dist/workorder.js +951 -0
- package/dist/workorder_admin.js +248 -0
- package/dist/workorder_costs.js +274 -0
- package/package.json +7 -2
|
@@ -0,0 +1,951 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.WorkOrder = void 0;
|
|
4
|
+
var error_1 = require("./error");
|
|
5
|
+
var _ = require('lodash');
|
|
6
|
+
var WorkOrder = /** @class */ (function () {
|
|
7
|
+
/**
|
|
8
|
+
* @hidden
|
|
9
|
+
*/
|
|
10
|
+
function WorkOrder(cw) {
|
|
11
|
+
this.cw = cw;
|
|
12
|
+
this.admin;
|
|
13
|
+
this.comment;
|
|
14
|
+
}
|
|
15
|
+
/**
|
|
16
|
+
* Create new workorders, including linkin to Requests & Inspections (optionally)
|
|
17
|
+
*
|
|
18
|
+
* @category WorkOrders
|
|
19
|
+
* @param {Object} wo_data - See /{subdirectory}/apidocs/#/data-type-infodataType=WorkOrder on the Cityworks instance
|
|
20
|
+
* @param {Array<number>} [inspectionIds] - The inspection IDs which the workorder should be linked to.
|
|
21
|
+
* @param {Array<number>} [requestIds] - The inspection IDs which the workorder should be linked to.
|
|
22
|
+
* @return {Object} Returns Promise that represents an object describing the newly-created workorder
|
|
23
|
+
*/
|
|
24
|
+
WorkOrder.prototype.create = function (wo_data, inspectionIds, requestIds) {
|
|
25
|
+
var _this = this;
|
|
26
|
+
return new Promise(function (resolve, reject) {
|
|
27
|
+
if (!_.has(wo_data, 'WOTemplateId') || !_.has(wo_data, 'EntityType')) {
|
|
28
|
+
reject(new error_1.CWError(2, 'WOTemplateId & EntityType must be provided.', { 'provided': wo_data }));
|
|
29
|
+
}
|
|
30
|
+
else {
|
|
31
|
+
var data = wo_data;
|
|
32
|
+
if (typeof inspectionIds != 'undefined' && inspectionIds != null && !_.has(data, 'InspectionIds')) {
|
|
33
|
+
_.set(data, 'InspectionIds', inspectionIds);
|
|
34
|
+
}
|
|
35
|
+
if (typeof requestIds != 'undefined' && requestIds != null && !_.has(data, 'RequestIds')) {
|
|
36
|
+
_.set(data, 'RequestIds', requestIds);
|
|
37
|
+
}
|
|
38
|
+
_this.cw.runRequest('Ams/WorkOrder/Create', data).then(function (r) {
|
|
39
|
+
resolve(r.Value);
|
|
40
|
+
}).catch(function (e) {
|
|
41
|
+
reject(e);
|
|
42
|
+
});
|
|
43
|
+
}
|
|
44
|
+
});
|
|
45
|
+
};
|
|
46
|
+
/**
|
|
47
|
+
* Create new workorder linked to parent workorder
|
|
48
|
+
*
|
|
49
|
+
* @category WorkOrders
|
|
50
|
+
* @param {Object} wo_data - See /{subdirectory}/apidocs/#/data-type-infodataType=WorkOrder on the Cityworks instance
|
|
51
|
+
* @param {string|number} workOrderSId - The workorder S/ID which the entities should be added to. # for SID, string for ID.
|
|
52
|
+
* @return {Object} Returns Promise that represents an object describing the newly-created workorder
|
|
53
|
+
*/
|
|
54
|
+
WorkOrder.prototype.createFromParent = function (wo_data, workOrderSId, s) {
|
|
55
|
+
var _this = this;
|
|
56
|
+
if (s === void 0) { s = true; }
|
|
57
|
+
return new Promise(function (resolve, reject) {
|
|
58
|
+
if (!_.has(wo_data, 'WOTemplateId') || !_.has(wo_data, 'EntityType')) {
|
|
59
|
+
reject(new error_1.CWError(2, 'WOTemplateId & EntityType must be provided.', { 'provided': wo_data }));
|
|
60
|
+
}
|
|
61
|
+
else {
|
|
62
|
+
var data = wo_data;
|
|
63
|
+
if (_.isString(workOrderSId)) {
|
|
64
|
+
_.set(data, 'WorkOrderId', workOrderSId);
|
|
65
|
+
}
|
|
66
|
+
else {
|
|
67
|
+
_.set(data, 'WorkOrderSid', workOrderSId);
|
|
68
|
+
}
|
|
69
|
+
_this.cw.runRequest('Ams/WorkOrder/Create', data).then(function (r) {
|
|
70
|
+
resolve(r.Value);
|
|
71
|
+
}).catch(function (e) {
|
|
72
|
+
reject(e);
|
|
73
|
+
});
|
|
74
|
+
}
|
|
75
|
+
});
|
|
76
|
+
};
|
|
77
|
+
/**
|
|
78
|
+
* Update a WorkOrder
|
|
79
|
+
*
|
|
80
|
+
* @category WorkOrders
|
|
81
|
+
* @param {object} wo_data - See /{subdirectory}/apidocs/#/data-type-infodataType=WorkOrder on the Cityworks instance
|
|
82
|
+
* @return {Object} Returns Promise that represents an object describing the updated workorder
|
|
83
|
+
*/
|
|
84
|
+
WorkOrder.prototype.update = function (wo_data) {
|
|
85
|
+
var _this = this;
|
|
86
|
+
return new Promise(function (resolve, reject) {
|
|
87
|
+
if (!_.has(wo_data, 'WorkOrderSid') && !_.has(wo_data, 'WorkOrderId')) {
|
|
88
|
+
reject(new error_1.CWError(3, 'WorkOrderId or WorkOrderSid must be provided.', { 'provided': wo_data }));
|
|
89
|
+
}
|
|
90
|
+
else {
|
|
91
|
+
_this.cw.runRequest('Ams/WorkOrder/Update', wo_data).then(function (r) {
|
|
92
|
+
resolve(r.Value);
|
|
93
|
+
}).catch(function (e) {
|
|
94
|
+
reject(e);
|
|
95
|
+
});
|
|
96
|
+
}
|
|
97
|
+
});
|
|
98
|
+
};
|
|
99
|
+
/**
|
|
100
|
+
* Combine WorkOrders
|
|
101
|
+
*
|
|
102
|
+
* @category WorkOrders
|
|
103
|
+
* @param {Array<string>} fromWorkOrderIds - The workorder IDs which should be combined.
|
|
104
|
+
* @param {string} toWorkOrderId - The WorkOrder ID for the single WorkOrder that should contain the info/entities from the other WorkOrders
|
|
105
|
+
* @param {boolean} cancelCombinedWorkOrders - If the WorkOrders combined into the single should then be canceled, default is true.
|
|
106
|
+
* @return {Object} Returns object that represents a collection of WorkOrders
|
|
107
|
+
*/
|
|
108
|
+
WorkOrder.prototype.combine = function (fromWorkOrderIds, toWorkOrderId, cancelCombinedWorkOrders) {
|
|
109
|
+
var _this = this;
|
|
110
|
+
if (cancelCombinedWorkOrders === void 0) { cancelCombinedWorkOrders = true; }
|
|
111
|
+
return new Promise(function (resolve, reject) {
|
|
112
|
+
var data = {
|
|
113
|
+
CancelCombinedWorkOrders: cancelCombinedWorkOrders,
|
|
114
|
+
ToWorkOrderId: toWorkOrderId,
|
|
115
|
+
FromWorkOrderIds: fromWorkOrderIds
|
|
116
|
+
};
|
|
117
|
+
_this.cw.runRequest('Ams/WorkOrder/Combine', data).then(function (r) {
|
|
118
|
+
if (r.Status > 0) {
|
|
119
|
+
reject(new error_1.CWError(4, r.Message, { 'response': r }));
|
|
120
|
+
}
|
|
121
|
+
else {
|
|
122
|
+
resolve(r.Value);
|
|
123
|
+
}
|
|
124
|
+
}).catch(function (e) {
|
|
125
|
+
reject(e);
|
|
126
|
+
});
|
|
127
|
+
});
|
|
128
|
+
};
|
|
129
|
+
/**
|
|
130
|
+
* Move a workorder's point
|
|
131
|
+
*
|
|
132
|
+
* @category WorkOrders
|
|
133
|
+
* @param {string} workOrderId
|
|
134
|
+
* @param {number} x
|
|
135
|
+
* @param {number} y
|
|
136
|
+
* @param {Object} projection - Should include WKT or WKID attribute. Can also include VcsWKID attribute.
|
|
137
|
+
* @param {number} [z] - Optional Z coordinate
|
|
138
|
+
* @return {Object} Returns Promise that represents an object describing the updated workorder
|
|
139
|
+
*/
|
|
140
|
+
WorkOrder.prototype.move = function (workOrderId, x, y, projection, z) {
|
|
141
|
+
var _this = this;
|
|
142
|
+
return new Promise(function (resolve, reject) {
|
|
143
|
+
if (!_.has(projection, 'WKID') && !_.has(projection, 'WKT')) {
|
|
144
|
+
// Throw error
|
|
145
|
+
reject(new error_1.CWError(6, 'You must provide either the WKID or WKT for the x/y coordinates.', { 'projection': projection }));
|
|
146
|
+
}
|
|
147
|
+
var base_data = {
|
|
148
|
+
WorkOrderId: workOrderId,
|
|
149
|
+
X: x,
|
|
150
|
+
Y: y
|
|
151
|
+
};
|
|
152
|
+
if (typeof (z) != 'undefined') {
|
|
153
|
+
_.set(base_data, 'z', z);
|
|
154
|
+
}
|
|
155
|
+
var data = _.merge(base_data, projection);
|
|
156
|
+
_this.cw.runRequest('Ams/WorkOrder/Move', data).then(function (r) {
|
|
157
|
+
resolve(r.Value);
|
|
158
|
+
}).catch(function (e) {
|
|
159
|
+
reject(e);
|
|
160
|
+
});
|
|
161
|
+
});
|
|
162
|
+
};
|
|
163
|
+
/**
|
|
164
|
+
* Get a workorder by S/ID
|
|
165
|
+
*
|
|
166
|
+
* @category WorkOrders
|
|
167
|
+
* @param {string|number} workOrderSId - The S/ID of the workorder to retrieve. # for SID, string for ID.
|
|
168
|
+
* @param {boolean} s - Whether first argument is an SID (true) or an ID (false). Defaults to true.
|
|
169
|
+
* @return {Object} Returns Promise that represents an object describing the workorder
|
|
170
|
+
*/
|
|
171
|
+
WorkOrder.prototype.getById = function (workOrderSId, s) {
|
|
172
|
+
var _this = this;
|
|
173
|
+
if (s === void 0) { s = true; }
|
|
174
|
+
return new Promise(function (resolve, reject) {
|
|
175
|
+
var data = {};
|
|
176
|
+
if (_.isString(workOrderSId)) {
|
|
177
|
+
_.set(data, 'WorkOrderId', workOrderSId);
|
|
178
|
+
var path = 'Ams/WorkOrder/ById';
|
|
179
|
+
}
|
|
180
|
+
else {
|
|
181
|
+
_.set(data, 'WorkOrderSid', workOrderSId);
|
|
182
|
+
var path = 'Ams/WorkOrder/BySid';
|
|
183
|
+
}
|
|
184
|
+
_this.cw.runRequest(path, data).then(function (r) {
|
|
185
|
+
resolve(r.Value);
|
|
186
|
+
}).catch(function (e) {
|
|
187
|
+
reject(e);
|
|
188
|
+
});
|
|
189
|
+
});
|
|
190
|
+
};
|
|
191
|
+
/**
|
|
192
|
+
* Get workorders by an array of S/IDs
|
|
193
|
+
*
|
|
194
|
+
* @category WorkOrders
|
|
195
|
+
* @param {Array<string|number>} workOrderSIds - The workorder S/IDs to retrieve. If providing WorkOrderID, should be all strings, else provide all numbers for WorkOrderSID
|
|
196
|
+
* @return {Object} Returns Promise that represents a collection of Objects describing the workorders
|
|
197
|
+
*/
|
|
198
|
+
WorkOrder.prototype.getByIds = function (workOrderSIds) {
|
|
199
|
+
var _this = this;
|
|
200
|
+
return new Promise(function (resolve, reject) {
|
|
201
|
+
var data = {};
|
|
202
|
+
if (workOrderSIds.length == 0) {
|
|
203
|
+
// throw error
|
|
204
|
+
reject(new error_1.CWError(101, 'No workorder S/IDs were provided.', { 'workorderSId': workOrderSIds }));
|
|
205
|
+
}
|
|
206
|
+
else {
|
|
207
|
+
var path = 'Ams/WorkOrder/ByIds';
|
|
208
|
+
if (_.isString(workOrderSIds[0])) {
|
|
209
|
+
_.set(data, 'WorkOrderIds', workOrderSIds);
|
|
210
|
+
path = 'Ams/WorkOrder/ByIds';
|
|
211
|
+
}
|
|
212
|
+
else if (_.isNumber(workOrderSIds[0])) {
|
|
213
|
+
_.set(data, 'WorkOrderSids', workOrderSIds);
|
|
214
|
+
path = 'Ams/WorkOrder/BySids';
|
|
215
|
+
}
|
|
216
|
+
else {
|
|
217
|
+
// throw error - was not number or string
|
|
218
|
+
reject(new error_1.CWError(9, 'No workorder S/IDs were provided.', { 'workorderSId': workOrderSIds }));
|
|
219
|
+
}
|
|
220
|
+
_this.cw.runRequest(path, data).then(function (r) {
|
|
221
|
+
resolve(r.Value);
|
|
222
|
+
}).catch(function (e) {
|
|
223
|
+
reject(e);
|
|
224
|
+
});
|
|
225
|
+
}
|
|
226
|
+
});
|
|
227
|
+
};
|
|
228
|
+
/**
|
|
229
|
+
* Get instructions by an array of workorders S/IDs
|
|
230
|
+
*
|
|
231
|
+
* @category WorkOrders
|
|
232
|
+
* @param {Array<string|number>} workOrderSIds - The workorder S/IDs to retrieve. If providing WorkOrderID, should be all strings, else provide all numbers for WorkOrderSID
|
|
233
|
+
* @return {Object} Returns Promise that represents an array of String, String describing the workorder instructions
|
|
234
|
+
*/
|
|
235
|
+
WorkOrder.prototype.getInstructions = function (workOrderSIds) {
|
|
236
|
+
var _this = this;
|
|
237
|
+
return new Promise(function (resolve, reject) {
|
|
238
|
+
var data = {};
|
|
239
|
+
if (workOrderSIds.length == 0) {
|
|
240
|
+
// throw error
|
|
241
|
+
reject(new error_1.CWError(102, 'No workorder S/IDs were provided.', { 'workorderSId': workOrderSIds }));
|
|
242
|
+
}
|
|
243
|
+
else {
|
|
244
|
+
var path = 'Ams/WorkOrder/ByIds';
|
|
245
|
+
if (_.isString(workOrderSIds[0])) {
|
|
246
|
+
_.set(data, 'WorkOrderIds', workOrderSIds);
|
|
247
|
+
path = 'Ams/WorkOrder/InstructionsByWorkOrderIds';
|
|
248
|
+
}
|
|
249
|
+
else if (_.isNumber(workOrderSIds[0])) {
|
|
250
|
+
_.set(data, 'WorkOrderSids', workOrderSIds);
|
|
251
|
+
path = 'Ams/WorkOrder/InstructionsByWorkOrderSids';
|
|
252
|
+
}
|
|
253
|
+
else {
|
|
254
|
+
// throw error - was not number or string
|
|
255
|
+
reject(new error_1.CWError(9, 'No workorder S/IDs were provided.', { 'workorderSId': workOrderSIds }));
|
|
256
|
+
}
|
|
257
|
+
_this.cw.runRequest(path, data).then(function (r) {
|
|
258
|
+
resolve(r.Value);
|
|
259
|
+
}).catch(function (e) {
|
|
260
|
+
reject(e);
|
|
261
|
+
});
|
|
262
|
+
}
|
|
263
|
+
});
|
|
264
|
+
};
|
|
265
|
+
/**
|
|
266
|
+
* Get the audit log for a specific workorder
|
|
267
|
+
*
|
|
268
|
+
* @category WorkOrder
|
|
269
|
+
* @param {number} workOrderSId - A WorkOrder S/ID to get the audit log for. SID is default.
|
|
270
|
+
* @return {Object} Returns Promise that represents a collection of Cityworks Metadata Objects
|
|
271
|
+
*/
|
|
272
|
+
WorkOrder.prototype.getAuditLog = function (workOrderSId) {
|
|
273
|
+
var _this = this;
|
|
274
|
+
return new Promise(function (resolve, reject) {
|
|
275
|
+
var data = {};
|
|
276
|
+
if (_.isString(workOrderSId)) {
|
|
277
|
+
_.set(data, 'WorkOrderId', workOrderSId);
|
|
278
|
+
}
|
|
279
|
+
else if (_.isNumber(workOrderSId)) {
|
|
280
|
+
_.set(data, 'WorkOrderSid', workOrderSId);
|
|
281
|
+
}
|
|
282
|
+
else {
|
|
283
|
+
// throw error - was not number or string
|
|
284
|
+
reject(new error_1.CWError(9, 'Workorder S/IDs was not provided.', { 'workorderSId': workOrderSId }));
|
|
285
|
+
}
|
|
286
|
+
_this.cw.runRequest('Ams/WorkOrder/AuditLog', data).then(function (r) {
|
|
287
|
+
resolve(r.Value);
|
|
288
|
+
}).catch(function (e) {
|
|
289
|
+
reject(e);
|
|
290
|
+
});
|
|
291
|
+
});
|
|
292
|
+
};
|
|
293
|
+
/**
|
|
294
|
+
* Get custom field values for the workorder S/IDs
|
|
295
|
+
*
|
|
296
|
+
* @category WorkOrders
|
|
297
|
+
* @param {Array<string|number>} workOrderSIds - The workorder S/IDs to retrieve. #s for SID, strings for ID.
|
|
298
|
+
* @return {Object} Returns Promise that represents a collection of Objects describing the workorders
|
|
299
|
+
*/
|
|
300
|
+
WorkOrder.prototype.getCustomFieldValues = function (workOrderSIds) {
|
|
301
|
+
var _this = this;
|
|
302
|
+
return new Promise(function (resolve, reject) {
|
|
303
|
+
var data = {};
|
|
304
|
+
var path = 'Ams/WorkOrder/CustomFields';
|
|
305
|
+
if (_.isString(workOrderSIds[0])) {
|
|
306
|
+
_.set(data, 'WorkOrderIds', workOrderSIds);
|
|
307
|
+
var path = 'Ams/WorkOrder/CustomFields';
|
|
308
|
+
}
|
|
309
|
+
else if (_.isNumber(workOrderSIds[0])) {
|
|
310
|
+
_.set(data, 'WorkOrderSids', workOrderSIds);
|
|
311
|
+
var path = 'Ams/WorkOrder/CustomFieldsByWorkOrderSids';
|
|
312
|
+
}
|
|
313
|
+
else {
|
|
314
|
+
// throw error - was not number or string
|
|
315
|
+
reject(new error_1.CWError(9, 'No workorder S/IDs were provided.', { 'workorderSIds': workOrderSIds }));
|
|
316
|
+
}
|
|
317
|
+
_this.cw.runRequest(path, data).then(function (r) {
|
|
318
|
+
resolve(r.Value);
|
|
319
|
+
}).catch(function (e) {
|
|
320
|
+
reject(e);
|
|
321
|
+
});
|
|
322
|
+
});
|
|
323
|
+
};
|
|
324
|
+
/**
|
|
325
|
+
* Get entities on an existing WorkOrder
|
|
326
|
+
*
|
|
327
|
+
* @category WorkOrders
|
|
328
|
+
* @param {Array<string|number>} workOrderSIds - The workorder S/IDs which the entities should be added to. # for SID, string for ID.
|
|
329
|
+
* @param {boolean} getGisData - Query gis to populate Entity.Attributes with current gis data. Defaults to true.
|
|
330
|
+
* @return {Object} Returns object that represents a list of entities removed.
|
|
331
|
+
*/
|
|
332
|
+
WorkOrder.prototype.getEntities = function (workOrderSIds, getGisData) {
|
|
333
|
+
var _this = this;
|
|
334
|
+
if (getGisData === void 0) { getGisData = true; }
|
|
335
|
+
return new Promise(function (resolve, reject) {
|
|
336
|
+
var data = {
|
|
337
|
+
GetGisData: getGisData
|
|
338
|
+
};
|
|
339
|
+
if (workOrderSIds.length == 0) {
|
|
340
|
+
// throw error
|
|
341
|
+
reject(new error_1.CWError(11, 'No workorder S/IDs were provided.', { 'workorderSId': workOrderSIds }));
|
|
342
|
+
}
|
|
343
|
+
else {
|
|
344
|
+
if (_.isString(workOrderSIds[0])) {
|
|
345
|
+
_.set(data, 'WorkOrderIds', workOrderSIds);
|
|
346
|
+
}
|
|
347
|
+
else if (_.isNumber(workOrderSIds[0])) {
|
|
348
|
+
_.set(data, 'WorkOrderSids', workOrderSIds);
|
|
349
|
+
}
|
|
350
|
+
else {
|
|
351
|
+
reject(new error_1.CWError(12, 'No workorder S/IDs were provided.', { 'workorderSId': workOrderSIds }));
|
|
352
|
+
}
|
|
353
|
+
}
|
|
354
|
+
_this.cw.runRequest('Ams/WorkOrder/Entities', data).then(function (r) {
|
|
355
|
+
if (r.Status > 0) {
|
|
356
|
+
reject(new error_1.CWError(4, r.Message, { 'response': r }));
|
|
357
|
+
}
|
|
358
|
+
else {
|
|
359
|
+
resolve(r.Value);
|
|
360
|
+
}
|
|
361
|
+
}).catch(function (e) {
|
|
362
|
+
reject(e);
|
|
363
|
+
});
|
|
364
|
+
});
|
|
365
|
+
};
|
|
366
|
+
/**
|
|
367
|
+
* Add entities to an existing WorkOrder
|
|
368
|
+
*
|
|
369
|
+
* @category WorkOrders
|
|
370
|
+
* @param {string|number} workOrderSId - The workorder S/ID which the entities should be added to. # for SID, string for ID.
|
|
371
|
+
* @param {Object} entityInfo - Entity info object including: (req) EntityType: {string}, (req) EntityUids: {Array<string>}, Facility_Id: {string}, Level_Id: {string}
|
|
372
|
+
* @param {boolean} updateXY - Update WorkOrder xy after adding entit(y|ies), default is true.
|
|
373
|
+
* @return {Object} Returns object that represents a list of entities removed.
|
|
374
|
+
*/
|
|
375
|
+
WorkOrder.prototype.addEntities = function (workOrderSId, entityInfo, updateXY) {
|
|
376
|
+
var _this = this;
|
|
377
|
+
if (updateXY === void 0) { updateXY = true; }
|
|
378
|
+
return new Promise(function (resolve, reject) {
|
|
379
|
+
var data = {
|
|
380
|
+
UpdateXY: updateXY
|
|
381
|
+
};
|
|
382
|
+
if (_.isString(workOrderSId)) {
|
|
383
|
+
_.set(data, 'WorkOrderId', workOrderSId);
|
|
384
|
+
}
|
|
385
|
+
else {
|
|
386
|
+
_.set(data, 'WorkOrderSid', workOrderSId);
|
|
387
|
+
}
|
|
388
|
+
if (_.has(entityInfo, 'Facility_Id'))
|
|
389
|
+
_.set(data, 'Facility_Id', _.get(entityInfo, 'Facility_Id'));
|
|
390
|
+
if (_.has(entityInfo, 'Level_Id'))
|
|
391
|
+
_.set(data, 'Level_Id', _.get(entityInfo, 'Level_Id'));
|
|
392
|
+
if (_.has(entityInfo, 'EntityUids') && _.has(entityInfo, 'EntityType')) {
|
|
393
|
+
_.set(data, 'EntityUids', _.get(entityInfo, 'EntityUids'));
|
|
394
|
+
_.set(data, 'EntityType', _.get(entityInfo, 'EntityType'));
|
|
395
|
+
}
|
|
396
|
+
else {
|
|
397
|
+
reject(new error_1.CWError(7, 'No entity info was provided.', { 'workorderSId': workOrderSId, 'entityInfo': entityInfo }));
|
|
398
|
+
}
|
|
399
|
+
_this.cw.runRequest('Ams/WorkOrder/AddEntities', data).then(function (r) {
|
|
400
|
+
if (r.Status > 0) {
|
|
401
|
+
reject(new error_1.CWError(4, r.Message, { 'response': r }));
|
|
402
|
+
}
|
|
403
|
+
else {
|
|
404
|
+
resolve(r.Value);
|
|
405
|
+
}
|
|
406
|
+
}).catch(function (e) {
|
|
407
|
+
reject(e);
|
|
408
|
+
});
|
|
409
|
+
});
|
|
410
|
+
};
|
|
411
|
+
/**
|
|
412
|
+
* Update a WorkOrder entity
|
|
413
|
+
*
|
|
414
|
+
* @category WorkOrders
|
|
415
|
+
* @param {string|number} workOrderSId - The workorder S/ID which the entities should be added to. # for SID, string for ID.
|
|
416
|
+
* @param {Object} entityInfo - Entity info object including: (req) EntityType: {string}, (req) EntityUid: {string}, Facility_Id: {string}, Level_Id: {string}
|
|
417
|
+
* @param {boolean} workComplete - Update WorkOrder completeness, default is true.
|
|
418
|
+
* @return {Object} Returns object that represents a list of entities removed.
|
|
419
|
+
*/
|
|
420
|
+
WorkOrder.prototype.updateEntity = function (workOrderSId, entityInfo, workComplete) {
|
|
421
|
+
var _this = this;
|
|
422
|
+
if (workComplete === void 0) { workComplete = false; }
|
|
423
|
+
return new Promise(function (resolve, reject) {
|
|
424
|
+
var data = {
|
|
425
|
+
WorkComplete: workComplete
|
|
426
|
+
};
|
|
427
|
+
if (_.isString(workOrderSId)) {
|
|
428
|
+
_.set(data, 'WorkOrderId', workOrderSId);
|
|
429
|
+
}
|
|
430
|
+
else {
|
|
431
|
+
_.set(data, 'WorkOrderSid', workOrderSId);
|
|
432
|
+
}
|
|
433
|
+
if (_.has(entityInfo, 'Facility_Id'))
|
|
434
|
+
_.set(data, 'Facility_Id', _.get(entityInfo, 'Facility_Id'));
|
|
435
|
+
if (_.has(entityInfo, 'Level_Id'))
|
|
436
|
+
_.set(data, 'Level_Id', _.get(entityInfo, 'Level_Id'));
|
|
437
|
+
if (_.has(entityInfo, 'EntityUids') && _.has(entityInfo, 'EntityType')) {
|
|
438
|
+
_.set(data, 'EntityUid', _.get(entityInfo, 'EntityUid'));
|
|
439
|
+
_.set(data, 'EntityType', _.get(entityInfo, 'EntityType'));
|
|
440
|
+
}
|
|
441
|
+
else {
|
|
442
|
+
reject(new error_1.CWError(7, 'No entity info was provided.', { 'workorderSId': workOrderSId, 'entityInfo': entityInfo }));
|
|
443
|
+
}
|
|
444
|
+
_this.cw.runRequest('Ams/WorkOrder/UpdateEntity', data).then(function (r) {
|
|
445
|
+
if (r.Status > 0) {
|
|
446
|
+
reject(new error_1.CWError(4, r.Message, { 'response': r }));
|
|
447
|
+
}
|
|
448
|
+
else {
|
|
449
|
+
resolve(r.Value);
|
|
450
|
+
}
|
|
451
|
+
}).catch(function (e) {
|
|
452
|
+
reject(e);
|
|
453
|
+
});
|
|
454
|
+
});
|
|
455
|
+
};
|
|
456
|
+
/**
|
|
457
|
+
* Remove entities from a WorkOrder. Provide WorkOrderId and either ObjectIds or EntityType and EntityUids
|
|
458
|
+
*
|
|
459
|
+
* @category WorkOrders
|
|
460
|
+
* @param {number} workOrderSId - The workorder S/ID which the entities should be removed from. # for SID, string for ID.
|
|
461
|
+
* @param {Object} entityInfo - Remove entities by WorkOrderEntity.ObjectId (not gis objectId).
|
|
462
|
+
* @param {boolean} updateXY - Update WorkOrder xy after removing entities, default is true.
|
|
463
|
+
* @return {Object} Returns object that represents a list of entities removed.
|
|
464
|
+
*/
|
|
465
|
+
WorkOrder.prototype.removeEntities = function (workOrderSId, entityInfo, updateXY) {
|
|
466
|
+
var _this = this;
|
|
467
|
+
if (updateXY === void 0) { updateXY = true; }
|
|
468
|
+
return new Promise(function (resolve, reject) {
|
|
469
|
+
var data = {
|
|
470
|
+
UpdateXY: updateXY
|
|
471
|
+
};
|
|
472
|
+
if (_.isString(workOrderSId)) {
|
|
473
|
+
_.set(data, 'WorkOrderId', workOrderSId);
|
|
474
|
+
}
|
|
475
|
+
else {
|
|
476
|
+
_.set(data, 'WorkOrderSid', workOrderSId);
|
|
477
|
+
}
|
|
478
|
+
if (_.has(entityInfo, 'ObjectIds')) {
|
|
479
|
+
_.set(data, 'ObjectIds', _.get(entityInfo, 'ObjectIds'));
|
|
480
|
+
}
|
|
481
|
+
else if (_.has(entityInfo, 'EntityUids') && _.has(entityInfo, 'EntityType')) {
|
|
482
|
+
_.set(data, 'EntityUids', _.get(entityInfo, 'EntityUids'));
|
|
483
|
+
_.set(data, 'EntityType', _.get(entityInfo, 'EntityType'));
|
|
484
|
+
}
|
|
485
|
+
else {
|
|
486
|
+
reject(new error_1.CWError(8, 'No entity info was provided.', { 'workorderSId': workOrderSId, 'entityInfo': entityInfo }));
|
|
487
|
+
}
|
|
488
|
+
_this.cw.runRequest('Ams/WorkOrder/RemoveEntities', data).then(function (r) {
|
|
489
|
+
if (r.Status > 0) {
|
|
490
|
+
reject(new error_1.CWError(4, r.Message, { 'response': r }));
|
|
491
|
+
}
|
|
492
|
+
else {
|
|
493
|
+
resolve(r.Value);
|
|
494
|
+
}
|
|
495
|
+
}).catch(function (e) {
|
|
496
|
+
reject(e);
|
|
497
|
+
});
|
|
498
|
+
});
|
|
499
|
+
};
|
|
500
|
+
/**
|
|
501
|
+
* Cancel workorders
|
|
502
|
+
*
|
|
503
|
+
* @category WorkOrders
|
|
504
|
+
* @param {Array<number>} workOrderIds - An array of the IDs to cancel the matched workorders
|
|
505
|
+
* @param {string} [cancelReason] - A reason for cancelling the workorder(s)
|
|
506
|
+
* @param {datetime} [dateCancelled] - The date/time that it should be indicated the workorder was cancelled
|
|
507
|
+
* @return {Object} Returns object that represents a collection of workorders
|
|
508
|
+
*/
|
|
509
|
+
WorkOrder.prototype.cancel = function (workOrderIds, cancelReason, dateCancelled) {
|
|
510
|
+
var _this = this;
|
|
511
|
+
return new Promise(function (resolve, reject) {
|
|
512
|
+
var m = new Date();
|
|
513
|
+
var data = { WorkOrderIds: workOrderIds };
|
|
514
|
+
if (typeof (cancelReason) !== 'undefined')
|
|
515
|
+
_.set(data, 'CancelReason', cancelReason);
|
|
516
|
+
if (typeof (dateCancelled) !== 'undefined')
|
|
517
|
+
_.set(data, 'DateCancelled', dateCancelled);
|
|
518
|
+
_this.cw.runRequest('Ams/WorkOrder/Cancel', data).then(function (r) {
|
|
519
|
+
resolve(r.Value);
|
|
520
|
+
}).catch(function (e) {
|
|
521
|
+
reject(e);
|
|
522
|
+
});
|
|
523
|
+
});
|
|
524
|
+
};
|
|
525
|
+
/**
|
|
526
|
+
* Uncancel workorders
|
|
527
|
+
*
|
|
528
|
+
* @category WorkOrders
|
|
529
|
+
* @param {Array<number>} workOrderIds - An array of the IDs to uncancel the matched workorders
|
|
530
|
+
* @return {Object} Returns object that represents a collection of workorders
|
|
531
|
+
*/
|
|
532
|
+
WorkOrder.prototype.uncancel = function (workOrderIds) {
|
|
533
|
+
var _this = this;
|
|
534
|
+
return new Promise(function (resolve, reject) {
|
|
535
|
+
var data = {
|
|
536
|
+
WorkOrderIds: workOrderIds
|
|
537
|
+
};
|
|
538
|
+
_this.cw.runRequest('Ams/WorkOrder/Uncancel', data).then(function (r) {
|
|
539
|
+
resolve(r.Value);
|
|
540
|
+
}).catch(function (e) {
|
|
541
|
+
reject(e);
|
|
542
|
+
});
|
|
543
|
+
});
|
|
544
|
+
};
|
|
545
|
+
/**
|
|
546
|
+
* Close WorkOrders
|
|
547
|
+
*
|
|
548
|
+
* @category WorkOrders
|
|
549
|
+
* @param {Array<number>} workOrderIds - An array of the IDs to close the matched WorkOrders
|
|
550
|
+
* @return {Object} Returns object that represents a collection of WorkOrders
|
|
551
|
+
*/
|
|
552
|
+
WorkOrder.prototype.close = function (workOrderIds) {
|
|
553
|
+
var _this = this;
|
|
554
|
+
return new Promise(function (resolve, reject) {
|
|
555
|
+
var data = {
|
|
556
|
+
WorkOrderIds: workOrderIds
|
|
557
|
+
};
|
|
558
|
+
_this.cw.runRequest('Ams/WorkOrder/Close', data).then(function (r) {
|
|
559
|
+
if (r.Status > 0) {
|
|
560
|
+
reject(new error_1.CWError(5, r.Message, { 'response': r }));
|
|
561
|
+
}
|
|
562
|
+
else {
|
|
563
|
+
resolve(r.Value);
|
|
564
|
+
}
|
|
565
|
+
}).catch(function (e) {
|
|
566
|
+
reject(e);
|
|
567
|
+
});
|
|
568
|
+
});
|
|
569
|
+
};
|
|
570
|
+
/**
|
|
571
|
+
* Reopen closed WorkOrders
|
|
572
|
+
*
|
|
573
|
+
* @category WorkOrders
|
|
574
|
+
* @param {Array<number>} workOrderIds - An array of the IDs to reopen the matched WorkOrders
|
|
575
|
+
* @return {Object} Returns object that represents a collection of WorkOrders
|
|
576
|
+
*/
|
|
577
|
+
WorkOrder.prototype.reopen = function (workOrderIds) {
|
|
578
|
+
var _this = this;
|
|
579
|
+
return new Promise(function (resolve, reject) {
|
|
580
|
+
var data = {
|
|
581
|
+
WorkOrderIds: workOrderIds
|
|
582
|
+
};
|
|
583
|
+
_this.cw.runRequest('Ams/WorkOrder/ReOpen', data).then(function (r) {
|
|
584
|
+
resolve(r.Value);
|
|
585
|
+
}).catch(function (e) {
|
|
586
|
+
reject(e);
|
|
587
|
+
});
|
|
588
|
+
});
|
|
589
|
+
};
|
|
590
|
+
/**
|
|
591
|
+
* Delete WorkOrders
|
|
592
|
+
*
|
|
593
|
+
* @category WorkOrders
|
|
594
|
+
* @param {Array<number>} workOrderIds - An array of the IDs to delete the matched WorkOrders
|
|
595
|
+
* @return {Object} Returns object that represents a collection of WorkOrder Ids which have been deleted
|
|
596
|
+
*/
|
|
597
|
+
WorkOrder.prototype.delete = function (workOrderIds) {
|
|
598
|
+
var _this = this;
|
|
599
|
+
return new Promise(function (resolve, reject) {
|
|
600
|
+
var data = {
|
|
601
|
+
WorkOrderIds: workOrderIds
|
|
602
|
+
};
|
|
603
|
+
_this.cw.runRequest('Ams/WorkOrder/Delete', data).then(function (r) {
|
|
604
|
+
if (r.Status > 0) {
|
|
605
|
+
reject(new error_1.CWError(4, r.Message, { 'response': r }));
|
|
606
|
+
}
|
|
607
|
+
else {
|
|
608
|
+
resolve(r.Value);
|
|
609
|
+
}
|
|
610
|
+
}).catch(function (e) {
|
|
611
|
+
reject(e);
|
|
612
|
+
});
|
|
613
|
+
});
|
|
614
|
+
};
|
|
615
|
+
/**
|
|
616
|
+
* Get WorkOrderS/IDs connected to provided entities
|
|
617
|
+
*
|
|
618
|
+
* @category WorkOrder Search
|
|
619
|
+
* @param {string} entityType - The entity type to find connected WorkOrders
|
|
620
|
+
* @param {Array<string>} entityUIDs - The list of entities to search for connected WorkOrders
|
|
621
|
+
* @param {boolean} s - Get WorkOrderSids. Defaults to true. When false, returned list is WorkOrderIds
|
|
622
|
+
* @param {Object} [search] - Any additional search properties of the WorkOrder (open/closed, etc)
|
|
623
|
+
* @return {Object} Returns Promise that represents an array of WorkOrderS/IDs
|
|
624
|
+
*/
|
|
625
|
+
WorkOrder.prototype.getWOsByEntities = function (entityType, entityUids, search, s) {
|
|
626
|
+
var _this = this;
|
|
627
|
+
if (s === void 0) { s = true; }
|
|
628
|
+
return new Promise(function (resolve, reject) {
|
|
629
|
+
var data = {};
|
|
630
|
+
if (typeof (search) != 'undefined') {
|
|
631
|
+
_.merge(data, search);
|
|
632
|
+
}
|
|
633
|
+
if (!_.has(data, 'EntityType')) {
|
|
634
|
+
_.set(data, 'EntityType', entityType);
|
|
635
|
+
}
|
|
636
|
+
if (!_.has(data, 'EntityUids')) {
|
|
637
|
+
_.set(data, 'EntityUids', entityUids);
|
|
638
|
+
}
|
|
639
|
+
var path = 'Ams/WorkOrder/SearchForSids';
|
|
640
|
+
if (!s) {
|
|
641
|
+
path = 'Ams/WorkOrder/Search';
|
|
642
|
+
}
|
|
643
|
+
_this.cw.runRequest(path, data).then(function (r) {
|
|
644
|
+
if (r.Status > 0) {
|
|
645
|
+
reject(new error_1.CWError(4, r.Message, { 'response': r }));
|
|
646
|
+
}
|
|
647
|
+
else {
|
|
648
|
+
resolve(r.Value);
|
|
649
|
+
}
|
|
650
|
+
}).catch(function (e) {
|
|
651
|
+
reject(e);
|
|
652
|
+
});
|
|
653
|
+
});
|
|
654
|
+
};
|
|
655
|
+
/**
|
|
656
|
+
* Get WorkOrderSid and description for provided WorkOrderId
|
|
657
|
+
*
|
|
658
|
+
* @category WorkOrder Search
|
|
659
|
+
* @param {string} workOrderId - The WorkOrderId for which to get the WorkOrderSid and description
|
|
660
|
+
* @return {Object} Returns Promise that represents an object with WorkOrderS/IDs & Description
|
|
661
|
+
*/
|
|
662
|
+
WorkOrder.prototype.getSearchList = function (workOrderId) {
|
|
663
|
+
var _this = this;
|
|
664
|
+
return new Promise(function (resolve, reject) {
|
|
665
|
+
var data = {};
|
|
666
|
+
_.set(data, 'WorkOrderId', workOrderId);
|
|
667
|
+
_this.cw.runRequest('Ams/WorkOrder/SearchObject', data).then(function (r) {
|
|
668
|
+
if (r.Status > 0) {
|
|
669
|
+
reject(new error_1.CWError(4, r.Message, { 'response': r }));
|
|
670
|
+
}
|
|
671
|
+
else {
|
|
672
|
+
resolve(r.Value);
|
|
673
|
+
}
|
|
674
|
+
}).catch(function (e) {
|
|
675
|
+
reject(e);
|
|
676
|
+
});
|
|
677
|
+
});
|
|
678
|
+
};
|
|
679
|
+
/**
|
|
680
|
+
* Get WorkOrder Employee lists
|
|
681
|
+
*
|
|
682
|
+
* @category WorkOrder Options
|
|
683
|
+
* @param {string} listType - Which list (endpoint) to get. Includes Supervisors & SubmitTos.
|
|
684
|
+
* @param {boolean} includeInactiveEmployees - Whether to include inactive employees in the returned list. Defaults to false.
|
|
685
|
+
* @param {Array<number>} [domainIds] - Filter to certain domains within the Cityworks instance.
|
|
686
|
+
* @return {Object} Returns Promise that represents a collection of employees. See: /{subdirectory}/apidocs/#/data-type-info;dataType=EmployeeNameId
|
|
687
|
+
*/
|
|
688
|
+
WorkOrder.prototype.getEmployeeLists = function (listType, includeInactiveEmployees, domainIds) {
|
|
689
|
+
var _this = this;
|
|
690
|
+
if (includeInactiveEmployees === void 0) { includeInactiveEmployees = false; }
|
|
691
|
+
return new Promise(function (resolve, reject) {
|
|
692
|
+
var data = {
|
|
693
|
+
IncludeInactiveEmployees: includeInactiveEmployees
|
|
694
|
+
};
|
|
695
|
+
if (typeof (domainIds) != 'undefined' && domainIds != null) {
|
|
696
|
+
_.set(data, 'DomainIds', domainIds);
|
|
697
|
+
}
|
|
698
|
+
if (!_.includes(['Supervisors', 'SubmitTos'], listType)) {
|
|
699
|
+
reject(new error_1.CWError(2, 'listType must be either SubmitTos or Supervisors.', { 'provided': listType }));
|
|
700
|
+
}
|
|
701
|
+
else {
|
|
702
|
+
_this.cw.runRequest("Ams/WorkOrder/" + listType, data).then(function (r) {
|
|
703
|
+
resolve(r.Value);
|
|
704
|
+
}).catch(function (e) {
|
|
705
|
+
reject(e);
|
|
706
|
+
});
|
|
707
|
+
}
|
|
708
|
+
});
|
|
709
|
+
};
|
|
710
|
+
/**
|
|
711
|
+
* Get SubmitTo list
|
|
712
|
+
*
|
|
713
|
+
* @category WorkOrder Options
|
|
714
|
+
* @param {boolean} includeInactiveEmployees - Whether to include inactive employees in the returned list. Defaults to false.
|
|
715
|
+
* @param {Array<number>} [domainIds] - Filter to certain domains within the Cityworks instance.
|
|
716
|
+
* @return {Object} Returns Promise that represents a collection of employees. See: /{subdirectory}/apidocs/#/data-type-info;dataType=EmployeeNameId
|
|
717
|
+
*/
|
|
718
|
+
WorkOrder.prototype.getSubmitTos = function (includeInactiveEmployees, domainIds) {
|
|
719
|
+
if (includeInactiveEmployees === void 0) { includeInactiveEmployees = false; }
|
|
720
|
+
return this.getEmployeeLists('SubmitTos', includeInactiveEmployees, domainIds);
|
|
721
|
+
};
|
|
722
|
+
/**
|
|
723
|
+
* Get Supervisors list
|
|
724
|
+
*
|
|
725
|
+
* @category WorkOrder Options
|
|
726
|
+
* @param {boolean} includeInactiveEmployees - Whether to include inactive employees in the returned list. Defaults to false.
|
|
727
|
+
* @param {Array<number>} [domainIds] - Filter to certain domains within the Cityworks instance.
|
|
728
|
+
* @return {Object} Returns Promise that represents a collection of employees. See: /{subdirectory}/apidocs/#/data-type-info;dataType=EmployeeNameId
|
|
729
|
+
*/
|
|
730
|
+
WorkOrder.prototype.getSupervisors = function (includeInactiveEmployees, domainIds) {
|
|
731
|
+
if (includeInactiveEmployees === void 0) { includeInactiveEmployees = false; }
|
|
732
|
+
return this.getEmployeeLists('Supervisors', includeInactiveEmployees, domainIds);
|
|
733
|
+
};
|
|
734
|
+
/**
|
|
735
|
+
* Get Status Options
|
|
736
|
+
*
|
|
737
|
+
* @category WorkOrder Options
|
|
738
|
+
* @return {Object} Returns Promise that represents a collection of codes. See: /{subdirectory}/apidocs/#/data-type-info;dataType=CodeDesc
|
|
739
|
+
*/
|
|
740
|
+
WorkOrder.prototype.getStatuses = function () {
|
|
741
|
+
var _this = this;
|
|
742
|
+
return new Promise(function (resolve, reject) {
|
|
743
|
+
_this.cw.runRequest('Ams/WorkOrder/Statuses', {}).then(function (r) {
|
|
744
|
+
resolve(r.Value);
|
|
745
|
+
}).catch(function (e) {
|
|
746
|
+
reject(e);
|
|
747
|
+
});
|
|
748
|
+
});
|
|
749
|
+
};
|
|
750
|
+
/**
|
|
751
|
+
* Get Categories
|
|
752
|
+
*
|
|
753
|
+
* @category WorkOrder Options
|
|
754
|
+
* @return {Object} Returns Promise that represents an array of configured workorder category code descriptions
|
|
755
|
+
*/
|
|
756
|
+
WorkOrder.prototype.getCategories = function () {
|
|
757
|
+
var _this = this;
|
|
758
|
+
return new Promise(function (resolve, reject) {
|
|
759
|
+
_this.cw.runRequest('Ams/WorkOrder/Categories', {}).then(function (r) {
|
|
760
|
+
resolve(r.Value);
|
|
761
|
+
}).catch(function (e) {
|
|
762
|
+
reject(e);
|
|
763
|
+
});
|
|
764
|
+
});
|
|
765
|
+
};
|
|
766
|
+
/**
|
|
767
|
+
* Get Priorities
|
|
768
|
+
*
|
|
769
|
+
* @category WorkOrder Options
|
|
770
|
+
* @return {Object} Returns Promise that represents an array of configured workorder priorities
|
|
771
|
+
*/
|
|
772
|
+
WorkOrder.prototype.getPriorities = function () {
|
|
773
|
+
var _this = this;
|
|
774
|
+
return new Promise(function (resolve, reject) {
|
|
775
|
+
_this.cw.runRequest('Ams/WorkOrder/Priorities', {}).then(function (r) {
|
|
776
|
+
resolve(r.Value);
|
|
777
|
+
}).catch(function (e) {
|
|
778
|
+
reject(e);
|
|
779
|
+
});
|
|
780
|
+
});
|
|
781
|
+
};
|
|
782
|
+
/**
|
|
783
|
+
* Get Cycle From
|
|
784
|
+
*
|
|
785
|
+
* @category WorkOrder Options
|
|
786
|
+
* @return {Object} Returns Promise that represents an array of string/string Cycle From options for workorders
|
|
787
|
+
*/
|
|
788
|
+
WorkOrder.prototype.getCycleFrom = function () {
|
|
789
|
+
var _this = this;
|
|
790
|
+
return new Promise(function (resolve, reject) {
|
|
791
|
+
_this.cw.runRequest('Ams/WorkOrder/CycleFrom', {}).then(function (r) {
|
|
792
|
+
resolve(r.Value);
|
|
793
|
+
}).catch(function (e) {
|
|
794
|
+
reject(e);
|
|
795
|
+
});
|
|
796
|
+
});
|
|
797
|
+
};
|
|
798
|
+
/**
|
|
799
|
+
* Get Cycle Intervals
|
|
800
|
+
*
|
|
801
|
+
* @category WorkOrder Options
|
|
802
|
+
* @return {Object} Returns Promise that represents an array of string/string Cycle Interval options for workorders
|
|
803
|
+
*/
|
|
804
|
+
WorkOrder.prototype.getCycleIntervals = function () {
|
|
805
|
+
var _this = this;
|
|
806
|
+
return new Promise(function (resolve, reject) {
|
|
807
|
+
_this.cw.runRequest('Ams/WorkOrder/CycleIntervals', {}).then(function (r) {
|
|
808
|
+
resolve(r.Value);
|
|
809
|
+
}).catch(function (e) {
|
|
810
|
+
reject(e);
|
|
811
|
+
});
|
|
812
|
+
});
|
|
813
|
+
};
|
|
814
|
+
/**
|
|
815
|
+
* Get Cycle Types
|
|
816
|
+
*
|
|
817
|
+
* @category WorkOrder Options
|
|
818
|
+
* @return {Object} Returns Promise that represents an array of string/string Cycle Type options for workorders
|
|
819
|
+
*/
|
|
820
|
+
WorkOrder.prototype.getCycleTypes = function () {
|
|
821
|
+
var _this = this;
|
|
822
|
+
return new Promise(function (resolve, reject) {
|
|
823
|
+
_this.cw.runRequest('Ams/WorkOrder/CycleTypes', {}).then(function (r) {
|
|
824
|
+
resolve(r.Value);
|
|
825
|
+
}).catch(function (e) {
|
|
826
|
+
reject(e);
|
|
827
|
+
});
|
|
828
|
+
});
|
|
829
|
+
};
|
|
830
|
+
/**
|
|
831
|
+
* Get WorkOrder Stages
|
|
832
|
+
*
|
|
833
|
+
* @category WorkOrder Options
|
|
834
|
+
* @return {Object} Returns Promise that represents an array of string/string Stage options for WorkOrders
|
|
835
|
+
*/
|
|
836
|
+
WorkOrder.prototype.getStages = function () {
|
|
837
|
+
var _this = this;
|
|
838
|
+
return new Promise(function (resolve, reject) {
|
|
839
|
+
_this.cw.runRequest('Ams/WorkOrder/Stages', {}).then(function (r) {
|
|
840
|
+
resolve(r.Value);
|
|
841
|
+
}).catch(function (e) {
|
|
842
|
+
reject(e);
|
|
843
|
+
});
|
|
844
|
+
});
|
|
845
|
+
};
|
|
846
|
+
/**
|
|
847
|
+
* Get Expense Types
|
|
848
|
+
*
|
|
849
|
+
* @category WorkOrder Options
|
|
850
|
+
* @return {Object} Returns Promise that represents an array of string/string Expense Type options for workorders
|
|
851
|
+
*/
|
|
852
|
+
WorkOrder.prototype.getExpenseTypes = function () {
|
|
853
|
+
var _this = this;
|
|
854
|
+
return new Promise(function (resolve, reject) {
|
|
855
|
+
_this.cw.runRequest('Ams/WorkOrder/ExpenseTypes', {}).then(function (r) {
|
|
856
|
+
resolve(r.Value);
|
|
857
|
+
}).catch(function (e) {
|
|
858
|
+
reject(e);
|
|
859
|
+
});
|
|
860
|
+
});
|
|
861
|
+
};
|
|
862
|
+
/**
|
|
863
|
+
* Get Map Layer Fields
|
|
864
|
+
*
|
|
865
|
+
* @category WorkOrders
|
|
866
|
+
* @param {string} workOrderSId - The workorder S/ID to get the map layer fields for.
|
|
867
|
+
* @return {Object} Returns Promise that represents a collection of Objects describing the workorders
|
|
868
|
+
*/
|
|
869
|
+
WorkOrder.prototype.getMLFs = function (workOrderSId) {
|
|
870
|
+
var _this = this;
|
|
871
|
+
return new Promise(function (resolve, reject) {
|
|
872
|
+
var data = {
|
|
873
|
+
WorkOrderId: workOrderSId
|
|
874
|
+
};
|
|
875
|
+
var path = 'Ams/TemplateMapLayer/WorkOrderInstanceMapLayersByWorkOrderId';
|
|
876
|
+
_this.cw.runRequest(path, data).then(function (r) {
|
|
877
|
+
resolve(r.Value);
|
|
878
|
+
}).catch(function (e) {
|
|
879
|
+
reject(e);
|
|
880
|
+
});
|
|
881
|
+
});
|
|
882
|
+
};
|
|
883
|
+
/**
|
|
884
|
+
* Update Map Layer Fields
|
|
885
|
+
*
|
|
886
|
+
* @category WorkOrders
|
|
887
|
+
* @param {string} workOrderSId - The workorder S/ID to get the map layer fields for.
|
|
888
|
+
* @param {number} x
|
|
889
|
+
* @param {number} y
|
|
890
|
+
* @param {number} domainId - Should include WKT or WKID attribute. Can also include VcsWKID attribute.
|
|
891
|
+
* @param {number} [z] - Optional Z coordinate
|
|
892
|
+
* @return {Object} Returns Promise that represents a ...
|
|
893
|
+
*/
|
|
894
|
+
WorkOrder.prototype.updateMLFs = function (workOrderSId, x, y, domainId, z) {
|
|
895
|
+
var _this = this;
|
|
896
|
+
return new Promise(function (resolve, reject) {
|
|
897
|
+
var data = {};
|
|
898
|
+
var path = 'Ams/TemplateMapLayer/UpdateWorkOrderInstanceMapLayers';
|
|
899
|
+
if (_.isString(workOrderSId)) {
|
|
900
|
+
_.set(data, 'WorkOrderId', workOrderSId);
|
|
901
|
+
}
|
|
902
|
+
else if (_.isNumber(workOrderSId)) {
|
|
903
|
+
_.set(data, 'WorkOrderSid', workOrderSId);
|
|
904
|
+
}
|
|
905
|
+
else {
|
|
906
|
+
// throw error - was not number or string
|
|
907
|
+
reject(new error_1.CWError(9, 'No workorder S/ID was provided.', { 'workorderSId': workOrderSId }));
|
|
908
|
+
}
|
|
909
|
+
if (_.isNumber(x)) {
|
|
910
|
+
_.set(data, 'X', x);
|
|
911
|
+
}
|
|
912
|
+
if (_.isNumber(y)) {
|
|
913
|
+
_.set(data, 'Y', y);
|
|
914
|
+
}
|
|
915
|
+
if (_.isNumber(z)) {
|
|
916
|
+
_.set(data, 'Z', z);
|
|
917
|
+
}
|
|
918
|
+
if (_.isNumber(domainId)) {
|
|
919
|
+
_.set(data, 'DomainId', domainId);
|
|
920
|
+
}
|
|
921
|
+
_this.cw.runRequest(path, data).then(function (r) {
|
|
922
|
+
resolve(r.Value);
|
|
923
|
+
}).catch(function (e) {
|
|
924
|
+
reject(e);
|
|
925
|
+
});
|
|
926
|
+
});
|
|
927
|
+
};
|
|
928
|
+
/**
|
|
929
|
+
* Delete Map Layer Fields
|
|
930
|
+
*
|
|
931
|
+
* @category WorkOrders
|
|
932
|
+
* @param {string} workOrderSId - The workorder S/ID to delete the map layer fields for.
|
|
933
|
+
* @return {Object} Returns Promise that represents a collection of Objects describing the workorders
|
|
934
|
+
*/
|
|
935
|
+
WorkOrder.prototype.deleteMLFs = function (workOrderSId) {
|
|
936
|
+
var _this = this;
|
|
937
|
+
return new Promise(function (resolve, reject) {
|
|
938
|
+
var data = {
|
|
939
|
+
WorkOrderId: workOrderSId
|
|
940
|
+
};
|
|
941
|
+
var path = 'Ams/TemplateMapLayer/DeleteWorkOrderInstancesByWorkOrderId';
|
|
942
|
+
_this.cw.runRequest(path, data).then(function (r) {
|
|
943
|
+
resolve(r.Value);
|
|
944
|
+
}).catch(function (e) {
|
|
945
|
+
reject(e);
|
|
946
|
+
});
|
|
947
|
+
});
|
|
948
|
+
};
|
|
949
|
+
return WorkOrder;
|
|
950
|
+
}());
|
|
951
|
+
exports.WorkOrder = WorkOrder;
|