source: branches/test1/Client/Application/UChronisModule.pas

Last change on this file was 54, checked in by chronos, 12 years ago
  • Added: ChronisAppServer base project.
  • Modified: Changes in client virtual database layer handling.
File size: 2.7 KB
Line 
1unit UChronisModule;
2
3{$mode delphi}
4
5interface
6
7uses
8 Classes, SysUtils, SpecializedList, UPDClient;
9
10type
11
12 { TChronisModule }
13
14 TChronisModule = class
15 System: TObject; // TChronisBase;
16 SysName: string;
17 Name: string;
18 Version: string;
19 Creator: string;
20 License: string;
21 Website: string;
22 Description: TStringList;
23 Dependencies: TStringList;
24 function IsInstalled: Boolean;
25 procedure Install; virtual;
26 procedure Uninstall; virtual;
27 constructor Create; virtual;
28 destructor Destroy; override;
29 end;
30
31 TChronisModuleClass = class of TChronisModule;
32
33
34implementation
35
36uses
37 USystem;
38
39
40{ TChronisModule }
41
42function TChronisModule.IsInstalled: Boolean;
43var
44 List: TListProxy;
45begin
46 List := TListProxy.Create;
47 List.Client := TChronisBase(System).Client;
48 List.Path := TChronisBase(System).Client.Schema;
49 List.ObjectName := SystemModuleObject;
50 List.Condition := '(SysName="' + SysName + '") AND (Installed=1)';
51 List.Load;
52 Result := List.Objects.Count > 0;
53 List.Free;
54end;
55
56procedure TChronisModule.Install;
57var
58 NewObject: TObjectProxy;
59 List: TListProxy;
60begin
61 List := TListProxy.Create;
62 List.Client := TChronisBase(System).Client;
63 List.Path := TChronisBase(System).Client.Schema;
64 List.ObjectName := SystemModuleObject;
65 List.Condition := 'SysName="' + SysName + '"';
66 List.Load;
67 if List.Objects.Count > 0 then begin
68 NewObject := TObjectProxy.Create;
69 NewObject.Id := StrToInt(TObjectProxy(List.Objects[0]).Properties.Values['Id']);
70 NewObject.Client := TChronisBase(System).Client;
71 NewObject.Path := TChronisBase(System).Client.Schema;
72 NewObject.ObjectName := SystemModuleObject;
73 NewObject.Properties.Add('Installed', '1');
74 NewObject.Save;
75 NewObject.Free;
76 end;
77 List.Free;
78end;
79
80procedure TChronisModule.Uninstall;
81var
82 NewObject: TObjectProxy;
83 List: TListProxy;
84begin
85 List := TListProxy.Create;
86 List.Client := TChronisBase(System).Client;
87 List.Path := TChronisBase(System).Client.Schema;
88 List.ObjectName := SystemModuleObject;
89 List.Condition := 'SysName="' + SysName + '"';
90 List.Load;
91 if List.Objects.Count > 0 then begin
92 NewObject := TObjectProxy.Create;
93 NewObject.Id := StrToInt(TObjectProxy(List.Objects[0]).Properties.Values['Id']);
94 NewObject.Client := TChronisBase(System).Client;
95 NewObject.Path := TChronisBase(System).Client.Schema;
96 NewObject.ObjectName := SystemModuleObject;
97 NewObject.Properties.Add('Installed', '0');
98 NewObject.Save;
99 NewObject.Free;
100 end;
101 List.Free;
102end;
103
104constructor TChronisModule.Create;
105begin
106 Dependencies := TStringList.Create;
107 Description := TStringList.Create;
108end;
109
110destructor TChronisModule.Destroy;
111begin
112 Description.Free;
113 Dependencies.Free;
114 inherited Destroy;
115end;
116
117end.
118
Note: See TracBrowser for help on using the repository browser.