TvPlanIt: Fix leaving orphan events, tasks and contacts in an ini datastore when a resource is deleted.
git-svn-id: https://svn.code.sf.net/p/lazarus-ccr/svn@8952 8e941d3f-bd1b-0410-a28a-d453659cc2b4
This commit is contained in:
parent
6c31a7877f
commit
c38f231c1b
@ -33,6 +33,10 @@ type
|
|||||||
procedure StrToResource(AString: String; AResource: TVpResource);
|
procedure StrToResource(AString: String; AResource: TVpResource);
|
||||||
procedure StrToTask(AString: String; ATask: TVpTask);
|
procedure StrToTask(AString: String; ATask: TVpTask);
|
||||||
|
|
||||||
|
procedure InternalPurgeContacts(Res: TVpResource); override;
|
||||||
|
procedure InternalPurgeEvents(Res: TVpResource); override;
|
||||||
|
procedure InternalPurgeTasks(Res: TVpResource); override;
|
||||||
|
|
||||||
procedure SetConnected(const AValue: Boolean); override;
|
procedure SetConnected(const AValue: Boolean); override;
|
||||||
function UniqueID(AValue: Integer): Boolean;
|
function UniqueID(AValue: Integer): Boolean;
|
||||||
|
|
||||||
@ -52,6 +56,7 @@ type
|
|||||||
procedure PostEvents; override;
|
procedure PostEvents; override;
|
||||||
procedure PostResources; override;
|
procedure PostResources; override;
|
||||||
procedure PostTasks; override;
|
procedure PostTasks; override;
|
||||||
|
procedure PurgeResource(Res: TVpResource); override;
|
||||||
procedure SetResourceByName(Value: String); override;
|
procedure SetResourceByName(Value: String); override;
|
||||||
|
|
||||||
published
|
published
|
||||||
@ -362,6 +367,21 @@ begin
|
|||||||
until UniqueID(Result) and (Result <> -1);
|
until UniqueID(Result) and (Result <> -1);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
procedure TVpIniDataStore.InternalPurgeContacts(Res: TVpResource);
|
||||||
|
begin
|
||||||
|
Res.Contacts.ClearContacts;
|
||||||
|
end;
|
||||||
|
|
||||||
|
procedure TVpIniDataStore.InternalPurgeEvents(Res: TVpResource);
|
||||||
|
begin
|
||||||
|
Res.Schedule.ClearEvents;
|
||||||
|
end;
|
||||||
|
|
||||||
|
procedure TVpIniDataStore.InternalPurgeTasks(Res: TVpResource);
|
||||||
|
begin
|
||||||
|
Res.Tasks.ClearTasks;
|
||||||
|
end;
|
||||||
|
|
||||||
function TVpIniDatastore.UniqueID(AValue: Integer): Boolean;
|
function TVpIniDatastore.UniqueID(AValue: Integer): Boolean;
|
||||||
var
|
var
|
||||||
i, j: Integer;
|
i, j: Integer;
|
||||||
@ -568,6 +588,15 @@ begin
|
|||||||
RefreshTasks;
|
RefreshTasks;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
procedure TVpIniDataStore.PurgeResource(Res: TVpResource);
|
||||||
|
begin
|
||||||
|
PurgeEvents(Res);
|
||||||
|
PurgeContacts(Res);
|
||||||
|
PurgeTasks(Res);
|
||||||
|
Res.Deleted := true;
|
||||||
|
inherited PurgeResource(Res);
|
||||||
|
end;
|
||||||
|
|
||||||
procedure TVpIniDatastore.StrToContact(AString: String; AContact: TVpContact);
|
procedure TVpIniDatastore.StrToContact(AString: String; AContact: TVpContact);
|
||||||
var
|
var
|
||||||
L: TVpIniStrings;
|
L: TVpIniStrings;
|
||||||
@ -1262,31 +1291,40 @@ begin
|
|||||||
|
|
||||||
for i:=0 to Resources.Count-1 do begin
|
for i:=0 to Resources.Count-1 do begin
|
||||||
res := Resources.Items[i];
|
res := Resources.Items[i];
|
||||||
key := Format('Contacts of resource %d', [res.ResourceID]);
|
if not res.Deleted then
|
||||||
for j:=0 to res.Contacts.Count-1 do begin
|
begin
|
||||||
contact := res.Contacts.GetContact(j);
|
key := Format('Contacts of resource %d', [res.ResourceID]);
|
||||||
if not contact.Deleted then
|
for j:=0 to res.Contacts.Count-1 do begin
|
||||||
ini.WriteString(key, IntToStr(contact.RecordID), ContactToStr(contact));
|
contact := res.Contacts.GetContact(j);
|
||||||
|
if not contact.Deleted then
|
||||||
|
ini.WriteString(key, IntToStr(contact.RecordID), ContactToStr(contact));
|
||||||
|
end;
|
||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
for i:=0 to Resources.Count-1 do begin
|
for i:=0 to Resources.Count-1 do begin
|
||||||
res := Resources.Items[i];
|
res := Resources.Items[i];
|
||||||
key := Format('Tasks of resource %d', [res.ResourceID]);
|
if not res.Deleted then
|
||||||
for j:=0 to res.Tasks.Count-1 do begin
|
begin
|
||||||
task := res.Tasks.GetTask(j);
|
key := Format('Tasks of resource %d', [res.ResourceID]);
|
||||||
if not task.Deleted then
|
for j:=0 to res.Tasks.Count-1 do begin
|
||||||
ini.WriteString(key, IntToStr(task.RecordID), TaskToStr(task));
|
task := res.Tasks.GetTask(j);
|
||||||
|
if not task.Deleted then
|
||||||
|
ini.WriteString(key, IntToStr(task.RecordID), TaskToStr(task));
|
||||||
|
end;
|
||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
for i:=0 to Resources.Count-1 do begin
|
for i:=0 to Resources.Count-1 do begin
|
||||||
res := Resources.Items[i];
|
res := Resources.Items[i];
|
||||||
key := Format('Events of resource %d', [res.ResourceID]);
|
if not res.Deleted then
|
||||||
for j:=0 to res.Schedule.EventCount-1 do begin
|
begin
|
||||||
event := res.Schedule.GetEvent(j);
|
key := Format('Events of resource %d', [res.ResourceID]);
|
||||||
if not event.Deleted then
|
for j:=0 to res.Schedule.EventCount-1 do begin
|
||||||
ini.WriteString(key, IntToStr(event.RecordID), EventToStr(event));
|
event := res.Schedule.GetEvent(j);
|
||||||
|
if not event.Deleted then
|
||||||
|
ini.WriteString(key, IntToStr(event.RecordID), EventToStr(event));
|
||||||
|
end;
|
||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user