{ Basic Visual PlanIt datastore using an flat files, such as ini, xml or json } {$IF FPC_FullVersion >= 30200} {$WARN 6058 off : Call to subroutine "$1" marked as inline is not inlined} {$IFEND} {$I vp.inc} unit VpFileDS; interface uses VpData, VpBaseDS; type TVpCustomFileDataStore = class(TVpCustomDataStore) private protected public procedure RefreshEvents; override; procedure UngroupEvents; virtual; procedure UpdateGroupEvents; override; end; implementation procedure TVpCustomFileDataStore.RefreshEvents; begin UpdateGroupEvents; inherited; end; procedure TVpCustomFileDataStore.UngroupEvents; var i, j: Integer; res: TVpResource; event, newEvent: TVpEvent; eventRes: TVpResource; begin for i := 0 to Resources.Count-1 do begin res := Resources.Items[i]; for j := res.Schedule.EventCount-1 downto 0 do begin event := res.Schedule.GetEvent(j); if event.IsOverlayed then begin eventRes := Resources.GetResource(event.ResourceID); newEvent := event.CopyToSchedule(eventres.Schedule); newEvent.ResourceID := eventRes.ResourceID; event.Free; end; end; end; end; { Iterates through all events and moves them to the resource as specified by the resource groups. } procedure TVpCustomFileDataStore.UpdateGroupEvents; var i, j, k: Integer; res, gres: TVpResource; event, newevent: TVpEvent; begin UngroupEvents; for i := 0 to Resources.Count-1 do begin res := Resources.Items[i]; if res.Group <> nil then begin for j := 0 to res.Group.Count-1 do begin gres := res.Group.Items[j]; for k := gres.Schedule.EventCount-1 downto 0 do begin event := gres.Schedule.GetEvent(k); if event.ResourceID = gres.ResourceID then begin newEvent := event.CopyToSchedule(res.Schedule); newEvent.ResourceID := event.ResourceID; event.Free; end; end; end; end; end; end; end.