Changeset 51 for trunk/Client/Application/UChronisModule.pas
- Timestamp:
- Apr 2, 2012, 3:59:58 PM (13 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Client/Application/UChronisModule.pas
r29 r51 6 6 7 7 uses 8 Classes, SysUtils ;8 Classes, SysUtils, SpecializedList, UChronisClient; 9 9 10 10 type … … 14 14 TChronisModule = class 15 15 System: TObject; // TChronisSystem; 16 SysName: string; 16 17 Name: string; 18 Version: string; 19 Creator: string; 20 License: string; 21 HomePage: string; 22 Dependencies: TStringList; 23 function IsInstalled: Boolean; 17 24 procedure Install; virtual; 18 25 procedure Uninstall; virtual; 19 26 constructor Create; virtual; 27 destructor Destroy; override; 20 28 end; 21 29 22 30 TChronisModuleClass = class of TChronisModule; 31 23 32 24 33 implementation … … 27 36 USystem; 28 37 38 29 39 { TChronisModule } 30 40 41 function TChronisModule.IsInstalled: Boolean; 42 var 43 List: TListProxy; 44 begin 45 List := TListProxy.Create; 46 List.Client := TChronisBase(System).Client; 47 List.SchemaName := TChronisBase(System).Client.Schema; 48 List.ObjectName := SystemModuleObject; 49 List.Condition := '(SysName="' + SysName + '") AND (Installed=1)'; 50 List.Load; 51 Result := List.Objects.Count > 0; 52 List.Free; 53 end; 54 31 55 procedure TChronisModule.Install; 56 var 57 NewObject: TObjectProxy; 58 List: TListProxy; 32 59 begin 33 60 List := TListProxy.Create; 61 List.Client := TChronisBase(System).Client; 62 List.SchemaName := TChronisBase(System).Client.Schema; 63 List.ObjectName := SystemModuleObject; 64 List.Condition := 'SysName="' + SysName + '"'; 65 List.Load; 66 if List.Objects.Count > 0 then begin 67 NewObject := TObjectProxy.Create; 68 NewObject.Id := StrToInt(TObjectProxy(List.Objects[0]).Properties.Values['Id']); 69 NewObject.Client := TChronisBase(System).Client; 70 NewObject.SchemaName := TChronisBase(System).Client.Schema; 71 NewObject.ObjectName := SystemModuleObject; 72 NewObject.Properties.Add('Installed', '1'); 73 NewObject.Save; 74 NewObject.Free; 75 end; 76 List.Free; 34 77 end; 35 78 36 79 procedure TChronisModule.Uninstall; 80 var 81 NewObject: TObjectProxy; 82 List: TListProxy; 37 83 begin 38 84 List := TListProxy.Create; 85 List.Client := TChronisBase(System).Client; 86 List.SchemaName := TChronisBase(System).Client.Schema; 87 List.ObjectName := SystemModuleObject; 88 List.Condition := 'SysName="' + SysName + '"'; 89 List.Load; 90 if List.Objects.Count > 0 then begin 91 NewObject := TObjectProxy.Create; 92 NewObject.Id := StrToInt(TObjectProxy(List.Objects[0]).Properties.Values['Id']); 93 NewObject.Client := TChronisBase(System).Client; 94 NewObject.SchemaName := TChronisBase(System).Client.Schema; 95 NewObject.ObjectName := SystemModuleObject; 96 NewObject.Properties.Add('Installed', '0'); 97 NewObject.Save; 98 NewObject.Free; 99 end; 100 List.Free; 39 101 end; 40 102 41 103 constructor TChronisModule.Create; 42 104 begin 105 Dependencies := TStringList.Create; 106 end; 43 107 108 destructor TChronisModule.Destroy; 109 begin 110 Dependencies.Free; 111 inherited Destroy; 44 112 end; 45 113
Note:
See TracChangeset
for help on using the changeset viewer.