Page 1 of 1

Setting Time using ITaskSettings interface

Posted: Sat Sep 13, 2008 5:30 pm
by petrossa
Using any method/property that takes a date/time as documented format (The format for this string is PnYnMnDTnHnMn etc) throws an exception.

At first i quessed i did it wrong, but i ran the provided Delphi Demo and tried to set a setting it gave the same exception.

see screenshot www.petrossa.com/error.jpg

Every tasksetting accepting these strings gets weird. I got it to accept PT1M for DeleteExpiredTaskAfter, but then it throws an EndBoundary exception. The task enddate has been set.

Posted: Thu Sep 18, 2008 6:03 am
by petrossa
is there anyway of knowing if this post is under evaluation?

Posted: Thu Sep 18, 2008 7:17 am
by isiticov
yes, we're trying to reproduce this now.

Posted: Thu Sep 18, 2008 11:18 am
by isiticov
In C++ Demo project there is code under:

Code: Select all

void __fastcall TMainForm::Runnotepadexeeachdayat09001Click(
      TObject *Sender)
which sets end date:

Code: Select all

  Task->Triggers->Items[0]->EndDate = Date() + 30; // will be executed during 1 month
  Task->Triggers->Items[0]->HasEndDate = true;
Does it raises this error? If not, do you set the EndDate using the same way?

Posted: Thu Sep 18, 2008 4:33 pm
by petrossa
EndDate in itself doesn't really cause any problems.
i use
FTask->Triggers->operator [](MultipleActionsIndex)->EndDate=TEndDate->AsDate();

where TEndDate is a TEdit decendant with a TDateTime as member, it returns a valid TDateTime at all times. And that works ok.

Just when i do:

FTask->TaskDefinition->Settings->Set_RestartInterval("PT10M");
or
FTask->TaskDefinition->Settings->Set_ExecutionTimeLimit("PT1H");
the exception as shown in the screenshot occurs.
I just mentioned enddate because at 1 time it accepted
FTask->TaskDefinition->Settings->Set_RestartInterval("PT1M");
but then threw a fit at enddate.
So the real prob is not enddate but all the functions which use the Formatstring just are not agreeable.

I never compiled the C++demo, i only compiled the DelphiDemo because it had Vista implemented. The screenshot is from the Delphi demo.

Addendum:

FTask->Triggers->operator [](CurAction)->GetStartVistaDateTime();
works perfect,
but
TDateTime Dt=FTask->Triggers->operator [](CurAction)->BeginDate;
throws:

class EConvertError Invalid argument to date decode, as do EndDate, StartTime.

Posted: Thu Sep 18, 2008 5:26 pm
by isiticov
Uhh, I thought you was referring any problem with our code.
You can try to pass fully encoded time string like: "P0DT0H1M".

Posted: Fri Sep 19, 2008 4:17 pm
by petrossa
well, first thing i did before posting was trying:
PT1H
PT2H0M
P0M3D
P0Y0M1DT0H0M

which didnt work. So thats why i compiled YOUR delphidemo, tried to set the expiration limit with using your Properties Interface on an already preexisting task set by the native Windows TaskScheduler interface.

Didnt change a letter to the code. That gave me exactly the same error, as shown in the screenshot www.petrossa.com/error.jpg which shows your demo as you can see.