开发者学堂课程【低代码氚云应用开发课程:氚云丨开发课— 06 Timer 定时器的常见使用】学习笔记,与课程紧密联系,让用户快速学习知识。
课程地址:https://developer.aliyun.com/learning/course/894/detail/14283
氚云丨开发课— 06 Timer 定时器的常见使用
Timer 定时器的常见使用
Timer
特性:继承类 Timer,4小时执行一遍,时间不固定public class MyTest_Timer: H3.SmartForm.Timer
//构造方法,跟类名保持一致,里面不必书写代码,但是必须存在public MyTest_Timer(){ }
//重写窟时器引擎执行的方法,必须存在,且方法名必须为 OnWorkprotected override void OnWork(H3.IEngine engine)
public class D66159979535fac4d814ac9a4e8e6596915f458: H3.SmartForm.SmartFormController
public D9@159979535fac4d814ac9a4e8e6596915f458(H3.SmartForm.SmartFormRequest request): base(request)
protected override void OnLoad(H3.SmartForm.LoadSmartFormResponse response)
base.OnLoad(response);
protected override void OnSubmit(string actionName, H3.SmartForm.SmartFormPostValue postValue, H3.SmartForm.SubmitSmartForn
base.OnSubmit(actionName, postValue, response);
public class MyTest_Timer: H3.SmartForm.Timer
//构造方法,跟类名保持一致,里面不必书写代码,但是必须存在public MyTest_Timer(){}
//重写定时器引擎执行的方法,必须存在,且方法名必须为 OnWork
protected override void OnWork(H3.IEngine
I engine)
string SelSql ="select * from I_D881599c275fala12e94a869fdd62e5727717b8 where datee";
DataTable SelDt = engine.Query.QueryTable(SelSql, null);
if(SelDt 1= null && SelDt.Rows.Count > e)
foreach(DataRow item in SelDt.Rows)
发送消息通知
示例:List _messageList=new
List0;
string title =“欢迎词”;
/标题string welcomeWords ="hello,氚云!\n很荣幸加入你";
//发送内容string send = H3.Organization.User.SystemUserld;
//发起人string receiverid = this.Request.UserContext.Userld;
//接收人H3.Notification.UserMessage _message = new
H3.Notification.UserMessage(H3.Notification.UserMessageType.DingTalkPlainText,
send, receiverid,"", title, welcomeWords,""):
_messageList.Add(_message);
ifL_messageList.Count > 0)
this.Request.Engine.Notifier.Send(_messageList.ToArray();
://执行发送public void SendMessage(H3.IEngine engine,H3.DataModel.Bizobject biz)H3.Task.UserTask task = new H3.Task.UserTask();
string appId ="D801599c275fala12e94a869fdd62e5727717b8";
//应用编码task.ObjectId = Guid.NewGuid().ToString();
//Guid 码task.Sender = H3.Organization.User.SystemUserId;
//任务的发起人 idtask.UserId ="a98364eb-5743-4890-9ed9-2bb3fBaebc92";
//任务的接收人 idtask.AppCode ="D901599W";
//应用编码task.TaskType = H3.Task.TaskType.Reminder;
//任务类型为提醒task.SchemaCode ="De61599c275fala12e94a869fdd62e5727717b8";
//表单编码task.TargetType = H3.LinkTargetType.BizObject;
//关联类型task.TargetId = biz.ObjectId;
//关联业务对象的IDtask.TargetName =
biz.Name;
//关联业务对象的数据标题task.Name =“库存过期";
//提醒标题task.Summary ="库存过期";
//提醒的内容task.AlertTime = DateTime.Now;
// 提醒时间task.ReminderType = H3.Task.ReminderType.Once;
//提醒类型task.StartTime = DateTime.Now;
//开始时间task.EndTime = DateTime.Now;
//截止时间task.TaskState = H3.Task.TaskState.Unfinished;
//任务状态task.AlertState = H3.Task.AlentState.Waiting;
//提醒的状态ensine.TaskManaser.AddTask(ta2E):77添加任务
public class MyTest_Timer: H3.SmartForm.Timer
//构造方法,跟类名保持一致,里面不必书写代码,但是必须存在public MyTest_Timer(){ }
//重写定时器引擎执行的方法,必须存在,且方法名必须为 Onworkprotected override void OnWork(H3.IEngine engine)
DoTask(engine);
public void PoTaskH3.IEngine engine)
string SelSql ="select * from I_D6@1599c275fala12e94a869fdd62e5727717b8
where datee";
DataTable SelDt = engine.Query.QueryTable(SelSql, null);
if(SelDt != null && SelDt.Rows.Count >e)
foreach(DataRow item in SelDt.Rows)
H3.DataMode1.BizObject biz = H3.DataModel.Biz0bject.Load(H3.Organization.User.SystemUserId, engine,"D861599c275fa1a12e94a869fdd62e5727717
SendMessage(engine, biz);
using System;
using System.Collections.Generic;
using System.Text;
using H3;
using System.Data;
public class D6@159979535fac4d814ac9a4e8e6596915f458:H3.SmartForm.SmartFormController
public Dee159979535fac4d814ac9a4e8e6596915f458(H3.SmartForm.SmartFormRequest request): base(request)
protected override void OnLoad(H3.SmartForm.LoadSmartFormResponse response)
MyTest_Timer timer=new MyTest_Timer();
timer.DoTask(this.Engine);
base.OnLoad(response);
protected override void OnSubmit(string actionName, H3.SmartForm.SmartFormPostValue postValue, H3.SmartForm.SubmitSmartFormResponse response)
base.OnSubmit(actionName, postvalue, response);