Changeset 93
- Timestamp:
- Sep 7, 2012, 10:31:31 PM (12 years ago)
- Location:
- trunk
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Modules/System/UModuleSystem.pas
r92 r93 6 6 7 7 uses 8 Classes, SysUtils, UModularSystem ;8 Classes, SysUtils, UModularSystem, SpecializedDictionary; 9 9 10 10 type … … 13 13 14 14 TModuleSystem = class(TModule) 15 private 16 procedure ModuleChange(Sender: TObject; Module: TModule); 15 17 public 16 18 constructor Create(Owner: TComponent); override; … … 21 23 procedure Uninstall; override; 22 24 procedure Upgrade; override; 25 procedure UpdateModuleList; 23 26 end; 24 27 … … 30 33 31 34 { TModuleSystem } 35 36 procedure TModuleSystem.ModuleChange(Sender: TObject; Module: TModule); 37 var 38 DbRows: TDbRows; 39 Data: TDictionaryStringString; 40 begin 41 try 42 DbRows := TDbRows.Create; 43 Data := TDictionaryStringString.Create; 44 if Module.Installed then Data.Add('Installed', '1') 45 else Data.Add('Installed', '0'); 46 Core.CommonDatabase.Update('SystemModule', Data, 'Name="' + Module.Identification + '"'); 47 finally 48 Data.Free; 49 DbRows.Free; 50 end; 51 end; 32 52 33 53 constructor TModuleSystem.Create(Owner: TComponent); … … 47 67 48 68 procedure TModuleSystem.Start; 69 var 70 DbRows: TDbRows; 71 I: Integer; 72 Module: TModule; 49 73 begin 74 try 75 DbRows := TDbRows.Create; 76 Core.CommonDatabase.Select(DbRows, 'SystemModule', 'Name, Installed'); 77 for I := 0 to DbRows.Count - 1 do 78 with DbRows[I] do begin 79 Module := Core.ModuleManager.FindModuleByName(Values['Name']); 80 if Assigned(Module) then 81 if Values['Installed'] = '1' then Module.SetInstalledState(True) 82 else Module.SetInstalledState(False); 83 end; 84 finally 85 DbRows.Free; 86 end; 87 Core.ModuleManager.OnModuleChange := ModuleChange; 50 88 inherited Start; 51 89 end; … … 54 92 begin 55 93 inherited Stop; 94 Core.ModuleManager.OnModuleChange := nil; 56 95 end; 57 96 … … 78 117 DbRows.Free; 79 118 end; 119 UpdateModuleList; 80 120 inherited Install; 81 121 end; … … 99 139 end; 100 140 141 procedure TModuleSystem.UpdateModuleList; 142 var 143 DbRows: TDbRows; 144 I: Integer; 145 Index: Integer; 146 Data: TDictionaryStringString; 147 begin 148 try 149 DbRows := TDbRows.Create; 150 Data := TDictionaryStringString.Create; 151 152 Core.CommonDatabase.Select(DbRows, 'SystemModule', 'Name'); 153 154 for I := 0 to Core.ModuleManager.Modules.Count - 1 do 155 with TModule(Core.ModuleManager.Modules[I]) do begin 156 Data.Clear; 157 Data.Add('Name', Identification); 158 Data.Add('Version', Version); 159 Data.Add('License', License); 160 Data.Add('Creator', Author); 161 Data.Add('Description', Description.Text); 162 Data.Add('Title', Title); 163 Data.Add('Dependencies', Dependencies.Text); 164 if Installed then Data.Add('Installed', '1') 165 else Data.Add('Installed', '0'); 166 167 Index := 0; 168 while (Index < DbRows.Count) and (DbRows[Index].Values['Name'] <> Identification) do Inc(Index); 169 if Index >= DbRows.Count then Core.CommonDatabase.Insert('SystemModule', Data) 170 else Core.CommonDatabase.Update('SystemModule', Data, 'Name="' + Identification + '"'); 171 end; 172 finally 173 Data.Free; 174 DbRows.Free; 175 end; 176 end; 177 101 178 end. 102 179 -
trunk/Packages/ModularSystem/UModularSystem.pas
r92 r93 58 58 end; 59 59 60 TModuleEvent = procedure (Sender: TObject; Module: TModule) of object; 61 60 62 { TModuleManager } 61 63 … … 63 65 private 64 66 FAPI: TAPI; 67 FOnModuleChange: TModuleEvent; 65 68 procedure SetAPI(AValue: TAPI); 66 69 public … … 84 87 destructor Destroy; override; 85 88 property API: TAPI read FAPI write SetAPI; 89 property OnModuleChange: TModuleEvent read FOnModuleChange write FOnModuleChange; 86 90 end; 87 91 … … 328 332 Manager.InstallDependencies(Identification, Dependencies); 329 333 FInstalled := True; 334 if Assigned(Manager.FOnModuleChange) then 335 Manager.FOnModuleChange(Manager, Self); 330 336 end; 331 337 … … 336 342 Manager.UninstallDependencies(Identification); 337 343 FInstalled := False; 344 if Assigned(Manager.FOnModuleChange) then 345 Manager.FOnModuleChange(Manager, Self); 338 346 end; 339 347 … … 370 378 begin 371 379 FInstalled := Value; 380 if Assigned(Manager.FOnModuleChange) then 381 Manager.FOnModuleChange(Manager, Self); 372 382 end; 373 383 -
trunk/Pages/UPageAdmin.pas
r92 r93 48 48 else PageName := ''; 49 49 with HtmlDocument.Body do begin 50 LoadUserInfo;51 50 if PageName = '' then PageName := 'modulelist'; 52 51 if PageName = 'modulelist' then HandleModuleList(HandlerData) -
trunk/UCore.pas
r92 r93 192 192 //SaveToRegistry; 193 193 FreeAndNil(CommonDatabase); 194 ModuleManager.StopAll; 194 195 FreeAndNil(ModuleManager); 195 196 FreeAndNil(Pages); … … 279 280 DbRows: TDbRows; 280 281 Module: TModule; 282 I: Integer; 281 283 begin 282 284 try
Note:
See TracChangeset
for help on using the changeset viewer.