npm run install-server //安装程序,初始化数据库索引和管理员账号,管理员账号名可在 config.json 配置`
补救措施:
1 2 3 4 5 6
[root@VM-4-16-centos /]# docker exec -it 2e43588c8b1f bash root@2e43588c8b1f:/# node api/vendors/server/install.js (node:65) DeprecationWarning: current Server Discovery and Monitoring engine is deprecated, and will be removed in a future version. To use the new Server Discover and Monitoring engine, pass option { useUnifiedTopology: true } to the MongoClient constructor. log: mongodb load success... 初始化管理员账号成功,账号名:"xxxxx@gmail.com",密码:"ymfe.org"
var stDate =StTime;// str2date(st,'yyyy-MM-dd') var endDate =End;// str2date(end,'yyyy-MM-dd')
if(stDate==null|| endDate==null) { //Alert("error") false; }else{ var diff = dateDiff(stDate,endDate,'d') var flag = false; if(diff>=1){ var nextDate =dateAdd(stDate,'d',1); //Alert("next:"+nextDate) var strDate=date2str(stDate,'yyyy-MM-dd'); var strNextDate = date2str(nextDate,'yyyy-MM-dd');
var str1= "Hello Pentaho!"; var str2= indexOf(str1, "Pentaho"); var str3= indexOf(str1, "o", 7); writeToLog("Input : " + str1); writeToLog("Index of 'Pentaho' : " + str2); writeToLog("index of 'o', search from position 7 : " + str3);
最终控制台输出:
1 2 3
2019/08/1910:34:16 - JavaScript代码.0 - Input : Hello Pentaho! 2019/08/1910:34:16 - JavaScript代码.0 - Index of 'Pentaho' : 6 2019/08/1910:34:16 - JavaScript代码.0 - index of 'o', search from position 7 : 12
首字母大写(initCap)
对指定字符串首字母大写处理,来看代码示例:
1 2 3 4
var str1 = "my home"; writeToLog(initCap(str1)); writeToLog(initCap('test a aaa cw')); writeToLog(initCap('myhome'));
此时,最终控制台输出如下:
1 2 3
2019/08/1910:41:27 - JavaScript代码.0 - My Home 2019/08/1910:41:27 - JavaScript代码.0 - Test A Aaa Cw 2019/08/1910:41:27 - JavaScript代码.0 - Myhome
字符串转小写(lower)
将传入字符串全部转小写
代码如下:
1 2 3 4 5
var str1= "Hello World!"; var str2= lower(str1); writeToLog("Input:" + str1); writeToLog("Converted to LowerCase:" + str2); writeToLog(lower('DDDHelloSWxss'))
var str1 = "Hello World, this is a nice function"; var str2 = replace(str1,"World", "Folk"); writeToLog(str2); var str2 = replace(str1,"World", "Folk", "nice","beautifull"); writeToLog(str2);
最终输出:
1 2
2019/08/1911:10:21 - JavaScript代码.0 - Hello Folk, this is a nice function 2019/08/1911:10:21 - JavaScript代码.0 - Hello Folk, this is a beautifull function
字符串右侧填充(rpad(string,char,length))
使用方法同lpad,只是一个是左侧,一个是右侧
去除空字符(右侧)(rtrim)
正则切分(str2RegExp)
出入一个正则表达式,对string字符串进行Split操作.代码如下:
1 2 3 4 5 6 7 8 9 10 11 12
var strToMatch = "info@proconis.de"; var strReg = "^(\\w+)@([a-zA-Z_]+?)\\.([a-zA-Z]{2,3})$"; var xArr = str2RegExp(strToMatch, strReg); if ( xArr != null ) { for(i=0;i<xArr.length;i++) { writeToLog(xArr[i]); } } else { writeToLog("no match"); }
最终控制台输出:
1 2 3
2019/08/1913:21:19 - JavaScript代码.0 - info 2019/08/1913:21:19 - JavaScript代码.0 - proconis 2019/08/1913:21:19 - JavaScript代码.0 - de
字符串截取(substr)
通过制定索引开始对字符串进行截取操作,主要有两个重构参数:
substr(string,from):指定from索引开始截取字符串
substr(string,from,to):指定开始和截止索引进行截取
代码示例:
1 2 3 4 5 6
var str1= "Hello Pentaho!"; var str2= substr(str1, 6); var str3= substr(str1, 6, 7); writeToLog("Input : " + str1); writeToLog("From position 6: " + str2); writeToLog("From position 6 for 7 long : " + str3);
控制台输出如下:
1 2 3
2019/08/1913:31:20 - JavaScript代码.0 - Input : Hello Pentaho! 2019/08/1913:31:20 - JavaScript代码.0 - From position 6: Pentaho! 2019/08/1913:31:20 - JavaScript代码.0 - From position 6for7long : Pentaho
去除左右空格(trim)
不转义HTML(unEscapeHtml(html))
针对以转义的HTML字符进行解密,代码如下:
1 2 3 4 5 6 7
var w='<h2>我是H2标题</h2>';
var esW=escapeHtml(w); var unesw=unEscapeHtml(esW);
// Returns the fiscal Date from the date value, // based on a given offset. // // Usage: // getFiscalDate(var); // 1: Date - The Variable with the Date. // 2: String - The Date/Month which represents // the fiscal Start Offset. Format allways "dd.MM.". // // 2006-11-15 // var d1 = newDate(); var str1 = "01.07."; var str2 = "10.12."; Alert(getFiscalDate(d1, str1)); Alert(getFiscalDate(d1, str2));
获取下一个工作日日期(getNextWorkingDay)
传入当前日期,获取该日期后面一个工作日日期
函数定义getNextWorkingDay(date)
代码示例如下:
1 2 3 4 5 6 7 8 9 10
var d1 = newDate();
// 周1 var d2=str2date('2019-08-19 16:36:00',fmt); //周 6 var d3=str2date('2019-08-17 16:36:00',fmt);
var dateTime = newDate(); var date0 = truncDate(dateTime, 0); // gives back today at yyyy/MM/dd HH:mm:ss.000 var date1 = truncDate(dateTime, 1); // gives back today at yyyy/MM/dd HH:mm:00.000 var date2 = truncDate(dateTime, 2); // gives back today at yyyy/MM/dd HH:00:00.000 var date3 = truncDate(dateTime, 3); // gives back today at yyyy/MM/dd 00:00:00.000 var date4 = truncDate(dateTime, 4); // gives back today at yyyy/MM/01 00:00:00.000 var date5 = truncDate(dateTime, 5); // gives back today at yyyy/01/01 00:00:00.000
获取当年的周数(week)
获取指定日期的周数,代码示例:
1 2 3
var d1 = newDate(); //2019/08/19 writeToLog(week(d1));// 返回34
获取年份(year)
获取传入日期的年份,代码示例:
1 2 3
var d1 = newDate(); //2019/08/19 writeToLog(year(d1));// 返回2019
var strVarName="getVariableTest"; var strVarValue="123456"; Alert(getVariable(strVarName, "")); setVariable(strVarName,strVarValue, "r"); Alert(getVariable(strVarName, "")); strVarValue="654321"; setVariable(strVarName,strVarValue, "r"); Alert(getVariable(strVarName, ""));
控制台打印(println)
1 2 3
var str = "Hello World!"; print(str);
移除数值(removeDigits)
移除给定字符串中的数值,代码示例:
1 2 3
var str1 = "abc123cde";
writeToLog(removeDigits(str1));//返回abccde
发送邮件
设置环境变量(setEnvironmentVar)
通过在Script脚本组件中调用函数重新设置Kettle的环境变量
1 2 3 4 5 6 7 8
var strVarName="setEnvTest"; var strVarValue="123456"; Alert(getEnvironmentVar(strVarName)); setEnvironmentVar(strVarName,strVarValue); Alert(getEnvironmentVar(strVarName)); strVarValue="654321"; setEnvironmentVar(strVarName,strVarValue); Alert(getEnvironmentVar(strVarName));
CREATETABLE DEPARTMENT( ID INTPRIMARY KEY NOTNULL, DEPT CHAR(50) NOTNULL, EMP_ID INTNOTNULL ); CREATETABLE Test( ID INTPRIMARY KEY NOTNULL, NAME TEXT NOTNULL, AGE INTNOTNULL, ADDRESS CHAR(50), SALARY REAL );
First, we are going to create a Windows Service that runs under the System account. This service will be responsible for spawning an interactive process within the currently active User’s Session. This newly created process will display a UI and run with full admin rights. When the first User logs on to the computer, this service will be started and will be running in Session0; however the process that this service spawns will be running on the desktop of the currently logged on User. We will refer to this service as the LoaderService.
Next, the winlogon.exe process is responsible for managing User login and logout procedures. We know that every User who logs on to the computer will have a unique Session ID and a corresponding winlogon.exe process associated with their Session. Now, we mentioned above, the LoaderService runs under the System account. We also confirmed that each winlogon.exe process on the computer runs under the System account. Because the System account is the owner of both the LoaderService and the winlogon.exe processes, our LoaderService can copy the access token (and Session ID) of the winlogon.exe process and then call the Win32 API function CreateProcessAsUser to launch a process into the currently active Session of the logged on User. Since the Session ID located within the access token of the copied winlogon.exe process is greater than 0, we can launch an interactive process using that token.
You can specify that a task should run even if the account under which the task is scheduled to run is not logged on when the task is triggered. To do this, select the radio button labeled Run whether user is logged on or not . If this radio button is selected, tasks will not run interactively. To make a task run interactively, select the Run only when user is logged on radio button.
Essentially, if you select ‘Run whether user is logged on or not’, the process will not start a UI.