2020-11-11 16:06:25 +00:00
|
|
|
/**
|
|
|
|
* @author Martin Karkowski
|
|
|
|
* @email m.karkowski@zema.de
|
|
|
|
* @create date 2020-02-18 14:06:50
|
|
|
|
* @modify date 2020-11-11 13:07:08
|
|
|
|
* @desc [description]
|
|
|
|
*/
|
|
|
|
|
2021-09-04 11:45:52 +00:00
|
|
|
import { sleep } from "../../../lib/helpers/async";
|
|
|
|
import {
|
|
|
|
finishTask,
|
|
|
|
getActiveTasksFromMES,
|
|
|
|
getTasksFromMES,
|
|
|
|
startTask
|
|
|
|
} from "../src/xetics.functions";
|
2020-11-11 16:06:25 +00:00
|
|
|
|
2021-09-04 11:45:52 +00:00
|
|
|
const NAME = "Einlegen";
|
2020-11-11 16:06:25 +00:00
|
|
|
|
2021-09-04 11:45:52 +00:00
|
|
|
async function main() {
|
|
|
|
const active = await getActiveTasksFromMES(NAME);
|
2020-11-11 16:06:25 +00:00
|
|
|
|
2021-09-04 11:45:52 +00:00
|
|
|
if (active.length > 0) {
|
|
|
|
const finished = await finishTask(NAME, active[0].id, 1, [], []);
|
|
|
|
console.log(
|
|
|
|
finished
|
|
|
|
? "Finished already active Task!"
|
|
|
|
: "Could not finish active Task"
|
|
|
|
);
|
|
|
|
} else {
|
|
|
|
const res = await getTasksFromMES(NAME);
|
|
|
|
if (res.length > 0) {
|
|
|
|
// console.log(res[0])
|
|
|
|
console.log(NAME, "Found Task ->", JSON.stringify(res, undefined, 4));
|
|
|
|
// Finish the Task.
|
|
|
|
const started = await startTask(NAME, res[0].id, 1);
|
2020-11-11 16:06:25 +00:00
|
|
|
|
2021-09-04 11:45:52 +00:00
|
|
|
console.log(started ? "Started Task!" : "Could not start the Task");
|
2020-11-11 16:06:25 +00:00
|
|
|
|
2021-09-04 11:45:52 +00:00
|
|
|
if (started) {
|
|
|
|
await sleep(1000);
|
|
|
|
const finished = await finishTask(NAME, res[0].id, 1, [], []);
|
|
|
|
|
|
|
|
console.log(finished ? "Finished Task!" : "Could not finish the Task");
|
|
|
|
}
|
2020-11-11 16:06:25 +00:00
|
|
|
} else {
|
2021-09-04 11:45:52 +00:00
|
|
|
console.log("NO Task available.");
|
|
|
|
}
|
|
|
|
}
|
2020-11-11 16:06:25 +00:00
|
|
|
}
|
|
|
|
|
2021-09-04 11:45:52 +00:00
|
|
|
main().catch(console.error);
|