1 | unit ModuleNetwork;
|
---|
2 |
|
---|
3 | interface
|
---|
4 |
|
---|
5 | uses
|
---|
6 | Classes, SysUtils, ModularSystem, ModuleBase, WebPage;
|
---|
7 |
|
---|
8 | type
|
---|
9 |
|
---|
10 | { TModuleNetwork }
|
---|
11 |
|
---|
12 | TModuleNetwork = class(TModule)
|
---|
13 | private
|
---|
14 | WebPageNetwork: TWebPage;
|
---|
15 | public
|
---|
16 | ModuleBase: TModuleBase;
|
---|
17 | constructor Create(Owner: TComponent); override;
|
---|
18 | destructor Destroy; override;
|
---|
19 | procedure Start; override;
|
---|
20 | procedure Stop; override;
|
---|
21 | procedure Install; override;
|
---|
22 | procedure Uninstall; override;
|
---|
23 | procedure Upgrade; override;
|
---|
24 | end;
|
---|
25 |
|
---|
26 |
|
---|
27 | implementation
|
---|
28 |
|
---|
29 | uses
|
---|
30 | Core, PageNetwork, SqlDatabase;
|
---|
31 |
|
---|
32 | { TModuleNetwork }
|
---|
33 |
|
---|
34 | constructor TModuleNetwork.Create(Owner: TComponent);
|
---|
35 | begin
|
---|
36 | inherited;
|
---|
37 | Identification := 'Network';
|
---|
38 | Title := 'Network management';
|
---|
39 | Version := '1.0';
|
---|
40 | License := 'GNU/LGPL v3';
|
---|
41 | Author := 'Chronosoft';
|
---|
42 | Dependencies.Add('Base');
|
---|
43 | end;
|
---|
44 |
|
---|
45 | destructor TModuleNetwork.Destroy;
|
---|
46 | begin
|
---|
47 | inherited;
|
---|
48 | end;
|
---|
49 |
|
---|
50 | procedure TModuleNetwork.Start;
|
---|
51 | begin
|
---|
52 | BeforeStart;
|
---|
53 | ModuleBase := TModuleBase(Manager.FindModuleByName('Base'));
|
---|
54 | WebPageNetwork := TWebPageNetwork.Create(nil);
|
---|
55 | ModuleBase.Pages.RegisterPage(WebPageNetwork, 'sit');
|
---|
56 | //RegisterPage(TUserControlPage, UserControlPage, '');
|
---|
57 | AfterStart;
|
---|
58 | end;
|
---|
59 |
|
---|
60 | procedure TModuleNetwork.Stop;
|
---|
61 | begin
|
---|
62 | BeforeStop;
|
---|
63 | ModuleBase.Pages.UnregisterPage(WebPageNetwork);
|
---|
64 | FreeAndNil(WebPageNetwork);
|
---|
65 | ModuleBase := nil;
|
---|
66 | AfterStop;
|
---|
67 | end;
|
---|
68 |
|
---|
69 | procedure TModuleNetwork.Install;
|
---|
70 | var
|
---|
71 | DbRows: TDbRows;
|
---|
72 | begin
|
---|
73 | try
|
---|
74 | DbRows := TDbRows.Create;
|
---|
75 |
|
---|
76 | Core.Core.CommonDatabase.Query(DbRows,
|
---|
77 | 'CREATE TABLE IF NOT EXISTS `NetworkConfiguration` (' +
|
---|
78 | ' `Id` int(11) NOT NULL AUTO_INCREMENT,' +
|
---|
79 | ' `Caption` varchar(255) COLLATE utf8_czech_ci NOT NULL,' +
|
---|
80 | ' `Execute` varchar(255) COLLATE utf8_czech_ci NOT NULL,' +
|
---|
81 | ' `Changed` int(11) NOT NULL DEFAULT "0",' +
|
---|
82 | ' `LastTime` datetime NOT NULL DEFAULT "0000-00-00 00:00:00",' +
|
---|
83 | ' `ExecutionTime` int(11) NOT NULL,' +
|
---|
84 | ' `Enabled` int(11) NOT NULL DEFAULT "1",' +
|
---|
85 | ' `Period` int(11) NOT NULL DEFAULT "60",' +
|
---|
86 | ' `Log` mediumtext COLLATE utf8_czech_ci NOT NULL,' +
|
---|
87 | ' PRIMARY KEY (`Id`)' +
|
---|
88 | ') ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_czech_ci AUTO_INCREMENT=1; ');
|
---|
89 |
|
---|
90 | Core.Core.CommonDatabase.Query(DbRows,
|
---|
91 | 'CREATE TABLE IF NOT EXISTS `NetworkDevice` (' +
|
---|
92 | ' `Id` int(11) NOT NULL AUTO_INCREMENT,' +
|
---|
93 | ' `Name` varchar(255) COLLATE utf8_czech_ci NOT NULL,' +
|
---|
94 | ' `Member` int(11) NOT NULL COMMENT "Member",' +
|
---|
95 | ' `Location` int(11) NOT NULL COMMENT "Member",' +
|
---|
96 | ' `Type` int(11) NOT NULL COMMENT "NetworkDeviceType",' +
|
---|
97 | ' `PositionLatitude` double NOT NULL DEFAULT "0",' +
|
---|
98 | ' `PositionLongitude` double NOT NULL DEFAULT "0",' +
|
---|
99 | ' `Used` int(11) NOT NULL DEFAULT "1",' +
|
---|
100 | ' `Online` int(11) NOT NULL DEFAULT "0",' +
|
---|
101 | ' `LastOnline` datetime NOT NULL,' +
|
---|
102 | ' `PermanentOnline` int(11) NOT NULL DEFAULT "0",' +
|
---|
103 | ' `InboundNATPriority` int(11) NOT NULL DEFAULT "1",' +
|
---|
104 | ' PRIMARY KEY (`Id`),' +
|
---|
105 | ' UNIQUE KEY `Name` (`Name`),' +
|
---|
106 | ' KEY `Member` (`Member`),' +
|
---|
107 | ' KEY `Location` (`Location`),' +
|
---|
108 | ' KEY `Type` (`Type`)' +
|
---|
109 | ') ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_czech_ci AUTO_INCREMENT=1 ;');
|
---|
110 |
|
---|
111 | Core.Core.CommonDatabase.Query(DbRows,
|
---|
112 | 'CREATE TABLE IF NOT EXISTS `NetworkInterface` (' +
|
---|
113 | ' `Id` int(11) NOT NULL AUTO_INCREMENT,' +
|
---|
114 | ' `Name` varchar(16) COLLATE utf8_czech_ci NOT NULL,' +
|
---|
115 | ' `Type` int(11) NOT NULL,' +
|
---|
116 | ' `MAC` varchar(17) COLLATE utf8_czech_ci NOT NULL,' +
|
---|
117 | ' `LocalIP` varchar(16) COLLATE utf8_czech_ci NOT NULL,' +
|
---|
118 | ' `IPv6` varchar(255) COLLATE utf8_czech_ci NOT NULL,' +
|
---|
119 | ' `ExternalIP` varchar(16) COLLATE utf8_czech_ci NOT NULL,' +
|
---|
120 | ' `Device` int(11) NOT NULL,' +
|
---|
121 | ' `Online` int(11) NOT NULL DEFAULT "0",' +
|
---|
122 | ' `LastOnline` datetime NOT NULL,' +
|
---|
123 | ' PRIMARY KEY (`Id`),' +
|
---|
124 | ' KEY `Device` (`Device`),' +
|
---|
125 | ' KEY `Type` (`Type`)' +
|
---|
126 | ') ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_czech_ci AUTO_INCREMENT=1 ;');
|
---|
127 |
|
---|
128 | Core.Core.CommonDatabase.Query(DbRows,
|
---|
129 | 'CREATE TABLE IF NOT EXISTS `NetworkInterfaceType` (' +
|
---|
130 | ' `Id` int(11) NOT NULL AUTO_INCREMENT,' +
|
---|
131 | ' `Name` varchar(255) COLLATE utf8_czech_ci NOT NULL,' +
|
---|
132 | ' `MaxSpeed` int(11) NOT NULL,' +
|
---|
133 | ' `FullDuplex` int(11) NOT NULL DEFAULT "1",' +
|
---|
134 | ' `Color` varchar(6) COLLATE utf8_czech_ci NOT NULL DEFAULT "ffffff",' +
|
---|
135 | ' PRIMARY KEY (`Id`)' +
|
---|
136 | ') ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_czech_ci AUTO_INCREMENT=1 ;');
|
---|
137 |
|
---|
138 | Core.Core.CommonDatabase.Query(DbRows,
|
---|
139 | 'CREATE TABLE IF NOT EXISTS `NetworkDeviceType` (' +
|
---|
140 | ' `Id` int(11) NOT NULL AUTO_INCREMENT,' +
|
---|
141 | ' `Name` varchar(255) COLLATE utf8_czech_ci NOT NULL,' +
|
---|
142 | ' `ShowOnline` int(11) NOT NULL DEFAULT "0",' +
|
---|
143 | ' `IconName` varchar(255) COLLATE utf8_czech_ci NOT NULL,' +
|
---|
144 | ' PRIMARY KEY (`Id`)' +
|
---|
145 | ') ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_czech_ci AUTO_INCREMENT=1 ;');
|
---|
146 |
|
---|
147 | finally
|
---|
148 | DbRows.Free;
|
---|
149 | end;
|
---|
150 | inherited;
|
---|
151 | end;
|
---|
152 |
|
---|
153 | procedure TModuleNetwork.Uninstall;
|
---|
154 | var
|
---|
155 | DbRows: TDbRows;
|
---|
156 | begin
|
---|
157 | inherited Uninstall;
|
---|
158 | try
|
---|
159 | DbRows := TDbRows.Create;
|
---|
160 | Core.Core.CommonDatabase.Query(DbRows, 'DROP TABLE IF EXISTS `NetworkInterfaceType`');
|
---|
161 | Core.Core.CommonDatabase.Query(DbRows, 'DROP TABLE IF EXISTS `NetworkInterface`');
|
---|
162 | Core.Core.CommonDatabase.Query(DbRows, 'DROP TABLE IF EXISTS `NetworkDeviceType`');
|
---|
163 | Core.Core.CommonDatabase.Query(DbRows, 'DROP TABLE IF EXISTS `NetworkDevice`');
|
---|
164 | Core.Core.CommonDatabase.Query(DbRows, 'DROP TABLE IF EXISTS `NetworkConfiguration`');
|
---|
165 | finally
|
---|
166 | DbRows.Free;
|
---|
167 | end;
|
---|
168 | end;
|
---|
169 |
|
---|
170 | procedure TModuleNetwork.Upgrade;
|
---|
171 | begin
|
---|
172 | inherited;
|
---|
173 | end;
|
---|
174 |
|
---|
175 | end.
|
---|
176 |
|
---|