Skip to main content

Schedule.CreateScheduleAsync

Description

Creates a new Schedule (Time Trigger) with specified NewScheduleInfo details inside the connected Control Room.

Signature [C#]

Task<ScheduleInfo> CreateScheduleAsync(NewScheduleInfo newScheduleInfo)

Properties

Input

PropertyDescription
NewScheduleInfoSpecify the details to create new Schedule (Time Trigger).

Output

| Task<ScheduleInfo> | Returns newly created Schedule (Time Trigger) details. | |||

Remarks

Use CreateScheduleAsync API to create new Schedule (Time Trigger) with specified NewScheduleInfo details from the connected Control Room.

Example

C#
public void CreateTimeTrigger()
{
IControlRoomContext context = LoginControlRoom("RegularBuild", "BasicAuth");

int processId = 1;
int botId = 1;
string scheduleName = "TestSchedule";
DateTime? expiresOn = null;

// Creates a schedule of type Daily
List<TimeSpan> timeSpan = new List<TimeSpan>
{
DateTime.UtcNow.AddMinutes(1).TimeOfDay
};

ExecutionTimeInfo executionTimeInfo = new ExecutionTimeInfo();
executionTimeInfo.Times = timeSpan;
executionTimeInfo.TimeInterval = TimeSpan.Zero;

NewScheduleInfo newScheduleInfo = new NewScheduleInfo()
{
ProcessId = processId,
BotId = botId,
Name = scheduleName,
ScheduleType = ScheduleType.Daily,
StartDate = DateTime.UtcNow,
ExpiresOn = expiresOn,
Frequency = executionTimeInfo
};

ScheduleInfo createSchedule = Task.Run(() => context.Schedules.CreateScheduleAsync(newScheduleInfo)).Result;
System.Console.WriteLine("Schedule Id: " + schedules.ScheduleId + "ScheduleName: " + schedules.Name);
}
C#
public IControlRoomContext LoginControlRoom()
{
IControlRoomContext context;
string connectionString;

connectionString = "ServerUrl=https://demo.onnitellibuddies.com;UserName=demoadmin;Password=password";
context = new ControlRoomContext(connectionString);

context.Open();
return context;
}