日期:2014-05-18 浏览次数:20885 次
using (TaskService ts = new TaskService())//这是本机的,你可以找下TaskService的另一个构造函数的用法 { TaskDefinition td = ts.NewTask(); //找一列用不到的,加个标示 //TaskFolder tf = ts.GetFolder(taskModel.FolderName); td.RegistrationInfo.Description = taskModel.Describe;//任务描述 td.RegistrationInfo.Author = taskModel.CreateTer;//任务的创作者 td.RegistrationInfo.Date = taskModel.CreateTime; #region 触发器设置 //trigger.Id = taskModel.Mark;//看看那个字段用不到,添加个查询标识 Trigger tg = trigger; td.Triggers.Add(tg);//添加触发器 #endregion FileInfo fileinfo=new FileInfo(@"..\..\..\Weibo.Tasks\bin\Debug\Weibo.Tasks.exe"); string path=fileinfo.FullName; var exe = new ExecAction(path, taskArgs, null); td.Actions.Add(exe); ts.GetFolder(taskModel.FolderName).RegisterTaskDefinition(taskModel.Name, td);//在客户的任务目录下注册任务 //ts.RootFolder.RegisterTaskDefinition(taskModel.Name, td); }