feat:現在時刻の取得

This commit is contained in:
takuto
2024-06-03 03:35:14 +09:00
parent b97888fca9
commit a161d8e2c8
3 changed files with 73 additions and 5 deletions

View File

@@ -0,0 +1,66 @@
import { actionAddins } from ".";
import { IAction, IActionResult, IActionNode, IActionProperty, IField ,IContext} from "../types/ActionTypes";
/**
* アクションの属性定義
*/
interface IDatetimeGetterProps {
/**変数の名前 */
verName:string;
}
/**
* 現在日時を取得するアクション
*/
export class DatetimeGetterAction implements IAction {
name: string;
actionProps: IActionProperty[];
props: IDatetimeGetterProps;
constructor() {
this.name = "現在日時";
this.actionProps = [];
this.props = {
verName:''
}
this.register();
}
/**
* アクションの実行を呼び出す
* @param actionNode
* @param event
* @returns
*/
async process(actionNode: IActionNode, event: any,context:IContext): Promise<IActionResult> {
let result = {
canNext: true,
result: false
};
try {
//属性設定を取得する
this.actionProps = actionNode.actionProps;
if (!('verName' in actionNode.ActionValue) ) {
return result
}
this.props = actionNode.ActionValue as IDatetimeGetterProps;
let today = new Date();
if(this.props.verName){
context.variables[this.props.verName]=today.toISOString();
}
return result;
} catch (error) {
event.error = error;
console.error(error);
result.canNext = false;
return result;
}
};
register(): void {
actionAddins[this.name] = this;
}
}
new DatetimeGetterAction();

View File

@@ -9,6 +9,7 @@ import '../actions/condition-action';
import '../actions/regular-check';
import '../actions/mail-check';
import '../actions/counter-check';
import '../actions/datetime-getter';
import { ActionFlow,IActionFlow, IActionResult,IContext } from "./ActionTypes";
export class ActionProcess{