task.cs

来自「< SQL Server2005程序设计>」· CS 代码 · 共 43 行

CS
43
字号
using System;
using System.Collections.Generic;
using System.Text;
using Microsoft.SqlServer.Dts.Runtime;

namespace CustomTask
{
	[ DtsTask(
		DisplayName = "Custom Task",
		Description = "Description of custom task",
		IconResource = "CustomTask.TaskIcon.ico" ) ]
	public class CustomTask : Task
	{
		private int _sleepPeriod = 3000;

		// TODO: Implement task properties as needed. These properties will appear
		// in Properties window when you select your task in the Control Flow.
		public int SleepPeriod
		{
			get { return _sleepPeriod; }
			set { _sleepPeriod = value; }
		}

		public override DTSExecResult Validate(Connections connections, VariableDispenser variableDispenser, IDTSComponentEvents componentEvents, IDTSLogging log)
		{
			// TODO: Add your validation code here.
			return DTSExecResult.Success;
		}

		public override DTSExecResult Execute(Connections connections, VariableDispenser variableDispenser, IDTSComponentEvents componentEvents, IDTSLogging log, object transaction)
		{
			// TODO: Add your execution code here. The following is an example.

			bool fireAgain = false;
			componentEvents.FireInformation(1, "", "Sleeping for " + _sleepPeriod.ToString() + " ms", "", 0, ref fireAgain);	
			System.Threading.Thread.Sleep(_sleepPeriod);
			componentEvents.FireInformation(2, "", "Woke up", "", 0, ref fireAgain);

			return DTSExecResult.Success;
		}
	}
}

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?