From 128de8bce3e56fa13a198c55778495a898852c37 Mon Sep 17 00:00:00 2001 From: wp_xxyyzz Date: Mon, 6 Dec 2021 09:19:50 +0000 Subject: [PATCH] tvplanit: read/write Event.ResourceID to/from file git-svn-id: https://svn.code.sf.net/p/lazarus-ccr/svn@8170 8e941d3f-bd1b-0410-a28a-d453659cc2b4 --- components/tvplanit/source/vpinids.pas | 2 ++ components/tvplanit/source/vpjsonds.pas | 2 ++ components/tvplanit/source/vpxmlds.pas | 2 ++ 3 files changed, 6 insertions(+) diff --git a/components/tvplanit/source/vpinids.pas b/components/tvplanit/source/vpinids.pas index 28cf96710..d3aceed53 100644 --- a/components/tvplanit/source/vpinids.pas +++ b/components/tvplanit/source/vpinids.pas @@ -323,6 +323,7 @@ begin try L.AddDateTimeField('StartTime', AEvent.StartTime, 'c'); // short date + long time L.AddDateTimeField('EndTime', AEvent.EndTime, 'c'); // 1 + L.AddField('ResourceID', IntToStr(AEvent.ResourceID)); L.AddField('Description', AEvent.Description); L.AddField('Location', AEvent.Location); L.AddField('Notes', EncodeLineEndings(AEvent.Notes)); @@ -1201,6 +1202,7 @@ begin StrToEventTimes(s, tStart, tEnd); event := res.Schedule.AddEvent(id, tStart, tEnd); StrToEvent(s, event); + event.ResourceID := event.Owner.Owner.ResourceID; end; key := Format('Tasks of resource %d', [resID]); diff --git a/components/tvplanit/source/vpjsonds.pas b/components/tvplanit/source/vpjsonds.pas index ec02c58d8..ff7fe2236 100644 --- a/components/tvplanit/source/vpjsonds.pas +++ b/components/tvplanit/source/vpjsonds.pas @@ -188,6 +188,7 @@ function TVpJSONDatastore.EventToJSON(AEvent: TVpEvent): TJSONObject; begin Result := TJSONObject.Create; Result.Add('RecordID', AEvent.RecordID); + Result.Add('ResourceID', AEvent.ResourceID); Result.Add('Description', AEvent.Description); Result.Add('Notes', AEvent.Notes); Result.Add('Location', AEvent.Location); @@ -333,6 +334,7 @@ begin endDate := StrToDateTime(s, FFormatSettings) else endDate := 0; Result := AResource.Schedule.AddEvent(evID, startDate, endDate); + Result.ResourceID := AResource.ResourceID; Result.Description := AObj.Get('Description', ''); Result.Notes := AObj.Get('Notes', ''); Result.Location := AObj.Get('Location', ''); diff --git a/components/tvplanit/source/vpxmlds.pas b/components/tvplanit/source/vpxmlds.pas index 7b4031850..5e1b91402 100644 --- a/components/tvplanit/source/vpxmlds.pas +++ b/components/tvplanit/source/vpxmlds.pas @@ -731,6 +731,7 @@ begin t2 := GetDateTimeAttrValue(ANode, 'EndTime', FXmlSettings); ev := ASchedule.AddEvent(id, t1, t2); + ev.ResourceID := ASchedule.Owner.ResourceID; ev.AlarmAdvance := GetIntAttrValue(ANode, 'AlarmAdvance'); ev.AlarmSet := GetBoolAttrValue(ANode, 'AlarmSet'); ev.AlertDisplayed := GetBoolAttrValue(ANode, 'AlertDisplayed'); @@ -1317,6 +1318,7 @@ var begin with TDOMElement(AEventNode) do begin SetAttribute('RecordID', IntToStr(AEvent.RecordID)); + SetAttribute('ResourceID', IntToStr(AEvent.ResourceID)); SetAttribute('Category', IntToStr(AEvent.Category)); if AEvent.StartTime <> 0 then SetAttribute('StartTime', DateTimeToStr(AEvent.StartTime, FXmlSettings));