question

Upvotes
Accepted
68 3 7 10

Forgotten something

Hello everybody,

I selected a list, a report extraction, a report template, a schedule, and added a trigger to the schedule, before adding the schedule to the list and the report template.

On the web interface, the list appears with its instruments, but its schedules list remains empty.

So, I presume I made a big mistake, but I do not see where ...

If anybody sees better ?

    InstrumentList il = this.FindListByName(extractionsContext, "List for IntradaySummaries");

    this.AddInstrumentsToList(extractionsContext, il, listIdentif);

    ReportTemplate rt = extractionsContext.ReportTemplateOperations.Get("0x05a653822f9b3036");

    Schedule s = new Schedule() { ListId = il.ListId, Name = "IntraDaySummaries Schedule", ReportTemplate = rt };
    ReportExtraction re = new ReportExtraction();
    s.ReportTemplate = rt;
    s.ListId = il.ListId;
    re.ExtractionDateUtc = DateTime.Now;
    re.ExtractionStartUtc = re.ExtractionDateUtc.AddMinutes(2);
    int minutes = re.ExtractionDateUtc.AddMinutes(2).Minute;
    int hour = re.ExtractionDateUtc.AddMinutes(2).Hour;
    s.NextExtraction = re;
    TimeTrigger t = new TimeTrigger();
    t.At.Add(new ThomsonReuters.Dss.Api.HourMinute() 
	{ Hour = hour, Minute = minutes });
    s.Trigger = t;
    il.Schedules.Add(s);
    rt.Schedules.Add(s);
    Console.WriteLine("Number of schedules for list     : {0}", il.Schedules.Count); // returns 1
    Console.WriteLine("Number of schedules for template : {0}", rt.Schedules.Count); // returns 1

tick-history-rest-api
icon clock
10 |1500

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

Upvotes
Accepted
11.3k 25 9 14

Hi @Hubert CANEVET

To create Schedule, you need to set all properties of Schedule (i.e. Instrument Id, Report template Id and TimeTrigger) in the Schedule object, instead of the ReportExtraction object and then call ExtractionsContext.ScheduleOperations.Create() to post the request to the server. The ReportExtraction generally provides information about an extraction. It will be used only when you want to retreive information about an extraction.

Below is the example code of Schedule creation in the C# Example Application which can be downloaded from the download page.

//Define the schedule to be created
var schedule = new Schedule
{
    Name = "example-eod",
    TimeZone = "Central Standard Time",

    //Specify the date to run (tomorrow)
    Recurrence = ScheduleRecurrence.CreateSingleRecurrence(DateTime.UtcNow.AddDays(1).Date, false /* Is Immediate */),

    //Specify the time of day
    Trigger = ScheduleTrigger.CreateTimeTrigger(
        false, //Limit to todays data
        new[] { new HourMinute { Hour = 16, Minute = 0 } }),

    ListId = instrumentList.ListId, //Reference the list of instruments
    ReportTemplateId = reportTemplate.ReportTemplateId, //Reference the report template

};

//Post the request to create the new schedule.
ExtractionsContext.ScheduleOperations.Create(schedule);

cexample.png (18.0 KiB)
icon clock
10 |1500

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

Upvotes
68 3 7 10

Hello,

Thank you very much for your answer.

It appears I forgot ScheduleOperations.Create, and also I had to create a recurrence, to run a few tries to adjust whether to put a trigger or not (there is one, but the first try reported that a single recurrence must not have a trigger).

Once created, the schedule appeared on the web interface for the report template, and it took a few minutes more to appear for the list. Perhaps there is a reason for that ?

icon clock
10 |1500

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

Write an Answer

Hint: Notify or tag a user in this post by typing @username.

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.