source: trunk/Modules/Network/ModuleNetwork.pas

Last change on this file was 151, checked in by chronos, 9 months ago
File size: 5.7 KB
Line 
1unit ModuleNetwork;
2
3interface
4
5uses
6 Classes, SysUtils, ModularSystem, ModuleBase, WebPage;
7
8type
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
27implementation
28
29uses
30 Core, PageNetwork, SqlDatabase;
31
32{ TModuleNetwork }
33
34constructor TModuleNetwork.Create(Owner: TComponent);
35begin
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');
43end;
44
45destructor TModuleNetwork.Destroy;
46begin
47 inherited;
48end;
49
50procedure TModuleNetwork.Start;
51begin
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;
58end;
59
60procedure TModuleNetwork.Stop;
61begin
62 BeforeStop;
63 ModuleBase.Pages.UnregisterPage(WebPageNetwork);
64 FreeAndNil(WebPageNetwork);
65 ModuleBase := nil;
66 AfterStop;
67end;
68
69procedure TModuleNetwork.Install;
70var
71 DbRows: TDbRows;
72begin
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;
151end;
152
153procedure TModuleNetwork.Uninstall;
154var
155 DbRows: TDbRows;
156begin
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;
168end;
169
170procedure TModuleNetwork.Upgrade;
171begin
172 inherited;
173end;
174
175end.
176
Note: See TracBrowser for help on using the repository browser.