-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathServerDB.dpr
More file actions
63 lines (56 loc) · 1.85 KB
/
ServerDB.dpr
File metadata and controls
63 lines (56 loc) · 1.85 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
program ServerDB;
uses
Windows,
Forms,
SysUtils,
mORMot,
SynSQlite3,
mORMotSQLite3,
DB,
SynDBVCL,
SynDBSQLite3,
SynDB,
SynCommons,
Dialogs,
mORMotHttpServer,
uServerDB in 'uServerDB.pas' {frmMain},
uDBOtchetRecord in 'uDBOtchetRecord.pas';
{$R *.res}
procedure ConnectDB;
begin
frmMain.Model := CreateSampleModel;
sqlite3 := TSQLite3LibraryDynamic.Create;
frmMain.Database := TSQLRestServerDB.Create(frmMain.Model, IncludeTrailingBackslash(frmMain.DirDBName)+DBName);//,True,'report');
if not Assigned(frmMain.Database) then
raise Exception.Create('Îøèáêà ïðè ñîåäèíåíèè èëè ñîçäàíèè ÁÄ îò÷åòà');
TSQLRestServerDB(frmMain.Database).CreateMissingTables;
TSQLRestServerDB(frmMain.Database).NoAJAXJSON:=False;
TSQLRestServerDB(frmMain.Database).DB.BackupBackground(ExtractFilePath(Application.ExeName)+'report_reserv.db3',1024,10,nil);
frmMain.SQLiteHTTPServer := TCustomHttpServer.Create(IPPortServer,[TSQLRestServerDB(frmMain.Database)],'+',{useHttpSocket}useHttpApiRegisteringURI,32,secNone,'report');
frmMain.SQLiteHTTPServer.AccessControlAllowOrigin := '*'; // for AJAX requests to work
frmMain.SQLiteHTTPServer.RootRedirectToURI('report/indexdb.html'); // redirect localhost:777
end;
var
HM: THandle;
function Check: boolean;
begin
HM := OpenMutex(MUTEX_ALL_ACCESS, false, 'ServerDB');
Result := (HM <> 0);
if HM = 0 then HM := CreateMutex(nil, false, 'ServerDB');
end;
begin
if Check then exit;
if ParamCount>0 then
if ParamStr(1)='/unregserver' then
begin
UnRegServer;
Exit;
end;
Application.Initialize;
Application.Title := 'Ñåðâåð ÁÄ';
Application.CreateForm(TfrmMain, frmMain);
Application.ShowMainForm:=False;
if ParamCount>0 then if ParamStr(1)='/regserver' then RegServer;
ConnectDB;
Application.Run;
end.