function main() {
if (!autoServiceStart(3)) {
logd("自动化服务启动失败,无法执行脚本");
exit();
return;
}
logd("开始执行脚本...{} = {}", ecloud.getDeviceNo(), ecloud.getCloudUrl());
let ts = ecloud.getTaskInfo();
logd(ts);
if (ts == null) {
logd("没有任务信息");
return;
}
logd("任务信息:" + JSON.stringify(ts));
logd(ts["taskName"]);
if (ts.valueJson) {
logd("valueJson " + ts.valueJson["haoma"]);
logd("valueJson " + ts.valueJson['账号']);
logd("valueJson " + ts.valueJson);
}
clickSettingTask();
sleep(3000)
dataOptDemo()
}
function clickSettingTask() {
sleep(4000);
}
function dataOptDemo() {
let data = ecloud.getData({
"groupName": "账号组2"
});
if (data) {
logd("账号组2数据: " + JSON.stringify(data));
}
data = ecloud.getData({
"groupName": "账号组2",
"dataName": "001-1112"
});
if (data) {
logd("账号组2数据 + dataName : " + JSON.stringify(data));
}
let d = ecloud.addData({
"groupName": "账号组2",
"dataName": ecloud.getDeviceNo() + "-111",
"content": "xxx" + new Date()
});
logd("第一次创建账号组2 数据结果 - " + d)
let update2 = ecloud.updateData({
"groupName": "账号组2",
"dataName": ecloud.getDeviceNo() + "-111",
"content": "牛逼" + new Date()
});
logd("更新 数据结果 - " + d)
sleep(3000)
let remove3 = ecloud.removeData({
"groupName": "账号组2"
});
logd("组 移出 数据结果 - " + remove3)
let d2 = ecloud.addData({
"groupName": "账号组2",
"dataName": ecloud.getDeviceNo() + "-111",
"content": "星星xxx" + new Date()
});
logd("第二次创建账号组2 数据结果 - " + d2)
sleep(3000)
let append1 = ecloud.appendOneLineData({
"groupName": "账号组2",
"dataName": ecloud.getDeviceNo() + "-111",
"content": "我是要增加的数据1"
});
logd("追加数据 数据结果 - " + append1)
let append2 = ecloud.appendOneLineData({
"groupName": "账号组2",
"dataName": ecloud.getDeviceNo() + "-111",
"content": "我是要增加的数据2"
});
logd("追加数据 数据结果 - " + append2)
let removeline1 = ecloud.removeOneLineData({
"groupName": "账号组2",
"dataName": ecloud.getDeviceNo() + "-111",
"content": "我是要增加的数据1"
});
logd("删除一条 数据结果 - " + removeline1)
sleep(3000)
}
function autoServiceStart(time) {
for (var i = 0; i < time; i++) {
if (isServiceOk()) {
return true;
}
var started = startEnv();
logd("第" + (i + 1) + "次启动服务结果: " + started);
if (isServiceOk()) {
return true;
}
}
return isServiceOk();
}
main();