unit stgGatherControl; interface uses Classes, stgGatherCacheData, stgGatherDm, stgResultFrm, stgGather; type TstgGatherControl = class private FProjects: TList; FSumBaseFile: string; FGatherCacheData: tstgGatherCacheData; FGatherData: TstgGatherData; FResultForm: TstgResultForm; procedure LoadSumBaseFile; procedure GatherSubTenderFiles; procedure CheckErrorData; procedure SaveGatherResult; public constructor Create; destructor Destroy; override; procedure Gather; property Projects: TList read FProjects; property SumBaseFile: string read FSumBaseFile write FSumBaseFile; end; implementation { TstgGatherControl } procedure TstgGatherControl.CheckErrorData; var vChecker: TstgErrorChecker; begin vChecker := TstgErrorChecker.Create; try vChecker.Check(FGatherCacheData); finally vChecker.Free; end; end; constructor TstgGatherControl.Create; begin FProjects := TList.Create; FGatherCacheData := TstgGatherCacheData.Create; FGatherData := TstgGatherData.Create(nil); end; destructor TstgGatherControl.Destroy; begin FGatherData.Free; FGatherCacheData.Free; FProjects.Free; inherited; end; procedure TstgGatherControl.Gather; begin LoadSumBaseFile; GatherSubTenderFiles; CheckErrorData; SaveGatherResult; end; procedure TstgGatherControl.GatherSubTenderFiles; var vGather: TstgSubTenderFileGather; begin vGather := TstgSubTenderFileGather.Create; try vGather.GatherTo(FGatherCacheData, FProjects); finally vGather.Free; end; end; procedure TstgGatherControl.LoadSumBaseFile; var vLoader: TstgSumBaseFileLoader; begin vLoader := TstgSumBaseFileLoader.Create(FGatherCacheData.GatherTree, FSumBaseFile); try vLoader.LoadData; finally vLoader.Free; end; end; procedure TstgGatherControl.SaveGatherResult; var Form: TstgResultForm; begin FGatherData.LoadGatherData(FGatherCacheData); Form := TstgResultForm.Create(nil); try Form.SetGatherData(FGatherData); Form.ShowModal; finally Form.Free; end; end; end.