Changeset 93 for trunk/Modules/System/UModuleSystem.pas
- Timestamp:
- Sep 7, 2012, 10:31:31 PM (12 years ago)
- File:
-
- 1 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
Note:
See TracChangeset
for help on using the changeset viewer.