SiComponents Home Page SiComponents Forums
Here you will be able to get help and share your experience
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Vista/Win7 MonthlyDOW Trigger

 
Post new topic   Reply to topic    SiComponents Forums Forum Index -> VCL Scheduling Agent
View previous topic :: View next topic  
Author Message
bigstar



Joined: 02 Aug 2005
Posts: 11

PostPosted: Mon Jan 09, 2012 6:48 pm    Post subject: Vista/Win7 MonthlyDOW Trigger Reply with quote

I recently upgraded to VCL Scheduling Agent v2.0.7 and while testing to insure that the component and my application still work without any unexpected defeats I noticed a possible problem, either in my code or in the component I'm not entirely sure.

I am trying to define multiple weeks for a MonthlyDOW trigger and the demo only allows a single week so I cant test this. the windows task manager does allow this. Is this some funky limitation of the component?

This appears to be flawed and non-functional to me, Can you please post an example of how this should be done? Its not explained in the help file.

I assumed I would do it similar to the other properties that accept multiple selection. i.e. days
Back to top
View user's profile Send private message
isiticov
Site Admin


Joined: 21 Nov 2002
Posts: 2103

PostPosted: Wed Jan 11, 2012 11:36 am    Post subject: Reply with quote

Hello,

Task Scheduler 1x interface doesn't allow to set-up multiple weeks for this kind of trigger and this caused to have this limitation in our port of Task Scheduler 2.x interface. We will try to find a way how this could be improved. Meantime you can use the following workaround:
Code:

// Just sample code

procedure TMainForm.SetMonthlyDOWTrigger(Task: TTaskItem);
var
  imonthdow: IMonthlyDOWTrigger;
  Details: TTriggerDetails;
const
  VISTA_TASK_FIRST_WEEK = 1;
  VISTA_TASK_SECOND_WEEK = 2;
  VISTA_TASK_THIRD_WEEK = 4;
  VISTA_TASK_FOURTH_WEEK = 8;
  VISTA_TASK_LAST_WEEK = 16;
begin
  Task.Activate;
  if (not Task.TaskScheduler.RunningVistaOrLater) then
  begin
    Details := Task.Triggers[0].Details;
    Details.MonthlyDOW.wWhichWeek := TASK_SECOND_WEEK;
    Task.Triggers[0].Details := Details;
  end
  else
  begin
      // VISTA specific!
    imonthdow := Task.Triggers[0].GetVistaTrigger as IMonthlyDOWTrigger;
    imonthdow.WeeksOfMonth := VISTA_TASK_SECOND_WEEK or VISTA_TASK_THIRD_WEEK;
  end;
  Task.Triggers.UpdateTriggers;
end;
Back to top
View user's profile Send private message
bigstar



Joined: 02 Aug 2005
Posts: 11

PostPosted: Thu Jan 12, 2012 4:08 am    Post subject: Reply with quote

This is what I came up with and so far it seems to work with every combination I've tried.

procedure TTrigger.SetMonthlyDOWTrigger;
var
imonthdow: IMonthlyDOWTrigger;
X: Word;
begin
imonthdow := FInterfaceVista as IMonthlyDOWTrigger;
imonthdow.DaysOfWeek := FTaskTrigger._Type.MonthlyDOW.rgfDaysOfTheWeek;
X := FTaskTrigger._Type.MonthlyDOW.wWhichWeek;
imonthdow.RunOnLastWeekOfMonth := (X > 15);
if imonthdow.RunOnLastWeekOfMonth then
X := X - 16;
imonthdow.WeeksOfMonth := X;
imonthdow.MonthsOfYear := FTaskTrigger._Type.MonthlyDOW.rgfMonths;
imonthdow.StartBoundary := GetStartDateTime;
if (FTaskTrigger.rgFlags and TASK_TRIGGER_FLAG_HAS_END_DATE) = 1 then
imonthdow.EndBoundary := GetEndDateTime;
end;

function TTrigger.GetMonthlyDOWTrigger: TTaskTrigger;
var
imonthdow: IMonthlyDOWTrigger;
begin
imonthdow := FInterfaceVista as IMonthlyDOWTrigger;
FTaskTrigger._Type.MonthlyDOW.rgfDaysOfTheWeek := imonthdow.DaysOfWeek;
FTaskTrigger._Type.MonthlyDOW.wWhichWeek := imonthdow.WeeksOfMonth;
if imonthdow.RunOnLastWeekOfMonth then
FTaskTrigger._Type.MonthlyDOW.wWhichWeek := FTaskTrigger._Type.MonthlyDOW.wWhichWeek + 16;
FTaskTrigger._Type.MonthlyDOW.rgfMonths := imonthdow.MonthsOfYear;
BeginDate := GetStartVistaDateTime;
Result := FTaskTrigger;
end;
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    SiComponents Forums Forum Index -> VCL Scheduling Agent All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by p h p B B  © 2001, 2005 p h p B B  Group