1 | unit ModuleIS;
|
---|
2 |
|
---|
3 | interface
|
---|
4 |
|
---|
5 | uses
|
---|
6 | Classes, SysUtils, ModularSystem, SqlDatabase, ModuleBase, Generics;
|
---|
7 |
|
---|
8 | type
|
---|
9 |
|
---|
10 | { TModuleIS }
|
---|
11 |
|
---|
12 | TModuleIS = class(TModule)
|
---|
13 | private
|
---|
14 | public
|
---|
15 | ModuleBase: TModuleBase;
|
---|
16 | constructor Create(Owner: TComponent); override;
|
---|
17 | destructor Destroy; override;
|
---|
18 | procedure Start; override;
|
---|
19 | procedure Stop; override;
|
---|
20 | procedure Install; override;
|
---|
21 | procedure Uninstall; override;
|
---|
22 | procedure Upgrade; override;
|
---|
23 | end;
|
---|
24 |
|
---|
25 |
|
---|
26 | implementation
|
---|
27 |
|
---|
28 | uses
|
---|
29 | Core, PagePortal;
|
---|
30 |
|
---|
31 | { TModuleIS }
|
---|
32 |
|
---|
33 | constructor TModuleIS.Create(Owner: TComponent);
|
---|
34 | begin
|
---|
35 | inherited;
|
---|
36 | Identification := 'IS';
|
---|
37 | Title := 'Data management';
|
---|
38 | Version := '1.0';
|
---|
39 | License := 'GNU/LGPL v3';
|
---|
40 | Author := 'Chronosoft';
|
---|
41 | Dependencies.Add('Base');
|
---|
42 | end;
|
---|
43 |
|
---|
44 | destructor TModuleIS.Destroy;
|
---|
45 | begin
|
---|
46 | inherited;
|
---|
47 | end;
|
---|
48 |
|
---|
49 | procedure TModuleIS.Start;
|
---|
50 | begin
|
---|
51 | BeforeStart;
|
---|
52 | ModuleBase := TModuleBase(Manager.FindModuleByName('Base'));
|
---|
53 | //ModuleBase.Pages.RegisterPage(TWebPagePortal, WebPagePortal, 'portal');
|
---|
54 | AfterStart;
|
---|
55 | end;
|
---|
56 |
|
---|
57 | procedure TModuleIS.Stop;
|
---|
58 | begin
|
---|
59 | BeforeStop;
|
---|
60 | //ModuleBase.Pages.UnregisterPage('portal');
|
---|
61 | ModuleBase := nil;
|
---|
62 | AfterStop;
|
---|
63 | end;
|
---|
64 |
|
---|
65 | procedure TModuleIS.Install;
|
---|
66 | var
|
---|
67 | DbRows: TDbRows;
|
---|
68 | Data: TDictionaryStringString;
|
---|
69 | begin
|
---|
70 | try
|
---|
71 | DbRows := TDbRows.Create;
|
---|
72 | Data := TDictionaryStringString.Create;
|
---|
73 |
|
---|
74 | Core.Core.CommonDatabase.Query(DbRows,
|
---|
75 | 'CREATE TABLE IF NOT EXISTS `User` (' +
|
---|
76 | ' `Id` int(11) NOT NULL AUTO_INCREMENT,' +
|
---|
77 | ' `Name` varchar(255) NOT NULL,' +
|
---|
78 | ' `FullName` varchar(255) NOT NULL,' +
|
---|
79 | ' `Password` varchar(255) NOT NULL,' +
|
---|
80 | ' `Salt` varchar(255) NOT NULL,' +
|
---|
81 | ' `Email` varchar(255) NOT NULL,' +
|
---|
82 | ' `RegistrationTime` datetime NOT NULL,' +
|
---|
83 | ' PRIMARY KEY (`Id`)' +
|
---|
84 | ') ENGINE=InnoDB DEFAULT CHARSET=utf8 AUTO_INCREMENT=1 ;');
|
---|
85 |
|
---|
86 | Data.Add('Id', '1');
|
---|
87 | Data.Add('Name', 'anonymous');
|
---|
88 | Data.Add('FullName', 'Anonymous');
|
---|
89 | Data.Add('RegistrationTime', 'NOW()');
|
---|
90 | Data.Add('Password', '');
|
---|
91 | Data.Add('Salt', '');
|
---|
92 | Data.Add('Email', '');
|
---|
93 | Core.Core.CommonDatabase.Insert('User', Data);
|
---|
94 |
|
---|
95 | Core.Core.CommonDatabase.Query(DbRows,
|
---|
96 | 'CREATE TABLE IF NOT EXISTS `UserOnline` (' +
|
---|
97 | ' `Id` int(11) NOT NULL AUTO_INCREMENT,' +
|
---|
98 | ' `User` int(11) NOT NULL DEFAULT ''0'',' +
|
---|
99 | ' `ActivityTime` datetime NOT NULL DEFAULT ''0000-00-00 00:00:00'',' +
|
---|
100 | ' `LoginTime` datetime NOT NULL DEFAULT ''0000-00-00 00:00:00'',' +
|
---|
101 | ' `SessionId` varchar(255) COLLATE utf8_czech_ci NOT NULL DEFAULT '''',' +
|
---|
102 | ' `IpAddress` varchar(16) COLLATE utf8_czech_ci NOT NULL DEFAULT '''',' +
|
---|
103 | ' `HostName` varchar(255) COLLATE utf8_czech_ci NOT NULL DEFAULT '''',' +
|
---|
104 | ' `ScriptName` varchar(255) COLLATE utf8_czech_ci NOT NULL,' +
|
---|
105 | ' PRIMARY KEY (`Id`),' +
|
---|
106 | ' KEY `User` (`User`)' +
|
---|
107 | ') ENGINE=MEMORY DEFAULT CHARSET=utf8 COLLATE=utf8_czech_ci AUTO_INCREMENT=1 ;');
|
---|
108 | finally
|
---|
109 | Data.Free;
|
---|
110 | DbRows.Free;
|
---|
111 | end;
|
---|
112 | inherited Install;
|
---|
113 | end;
|
---|
114 |
|
---|
115 | procedure TModuleIS.Uninstall;
|
---|
116 | var
|
---|
117 | DbRows: TDbRows;
|
---|
118 | begin
|
---|
119 | inherited Uninstall;
|
---|
120 | try
|
---|
121 | DbRows := TDbRows.Create;
|
---|
122 | Core.Core.CommonDatabase.Query(DbRows, 'DROP TABLE IF EXISTS `User`');
|
---|
123 | Core.Core.CommonDatabase.Query(DbRows, 'DROP TABLE IF EXISTS `UserOnline`');
|
---|
124 | finally
|
---|
125 | DbRows.Free;
|
---|
126 | end;
|
---|
127 | end;
|
---|
128 |
|
---|
129 | procedure TModuleIS.Upgrade;
|
---|
130 | begin
|
---|
131 | inherited;
|
---|
132 | end;
|
---|
133 |
|
---|
134 | end.
|
---|
135 |
|
---|