Commit 38b88255 by Elias Sarraf

cleanup project + merge cam & cam2 branches

parent 1589dd42
......@@ -14,10 +14,10 @@ kgOrdersServer/Win32/
kgOrdersServer/Source/__history/
kgOrdersServer/Source/__recovery/
*.local
*.exe
*.local
*.identcache
*.res
*.skincfg
*.tvsconfig
*.skincfg
......@@ -67,5 +67,5 @@ begin
Application.MainFormOnTaskbar := True;
Application.CreateForm(TDMConnection, DMConnection);
DMConnection.InitApp(@StartApplication, @UnauthorizedAccessProc);
Application.Run;
//Application.Run;
end.
......@@ -7,7 +7,7 @@ object ApiServerModule: TApiServerModule
Top = 30
end
object XDataServer: TXDataServer
BaseUrl = 'http://localhost:2004/emsys/envoy/api/'
BaseUrl = 'http://localhost:2004/emsys/kgOrders/api/'
Dispatcher = SparkleHttpSysDispatcher
ModelName = 'Api'
EntitySetPermissions = <>
......@@ -16,8 +16,8 @@ object ApiServerModule: TApiServerModule
SwaggerUIOptions.Enabled = True
SwaggerUIOptions.ShowFilter = True
SwaggerUIOptions.TryItOutEnabled = True
Left = 85
Top = 110
Left = 89
Top = 112
object XDataServerLogging: TSparkleGenericMiddleware
OnMiddlewareCreate = XDataServerLoggingMiddlewareCreate
end
......
......@@ -82,7 +82,7 @@ begin
XDataServer.ModelName := AModelName;
SparkleHttpSysDispatcher.Start;
Logger.Log(1, Format('Api server module listening at "%s"', [Url]));
Logger.Log(1, Format('Api server module listening at "%s"', [XDataServer.BaseUrl]));
end;
procedure TApiServerModule.XDataServerLoggingMiddlewareCreate(Sender: TObject;
......
......@@ -42,33 +42,58 @@ var
iniFile: TIniFile;
iniStr: string;
begin
Logger.Log( 5, 'TAuthDatabase.DataModuleCreate' );
iniFile := TIniFile.Create( ExtractFilePath(Application.ExeName) + 'kgOrdersServer.ini' );
try
Logger.Log( 5, '--iniFile entries:' );
iniStr := iniFile.ReadString('Database', 'Server', '');
if not iniStr.IsEmpty then
if iniStr.IsEmpty then
Logger.Log( 5, '----Database->Server: Entry not found' )
else
begin
Logger.Log( 5, '----Database->Server: iniStr' );
ucKG.Server := iniStr;
end;
iniStr := iniFile.ReadString('Database', 'Database', '');
if not iniStr.IsEmpty then
if iniStr.IsEmpty then
Logger.Log( 5, '----Database->Database: Entry not found' )
else
begin
Logger.Log( 5, '----Database->Database: iniStr' );
ucKG.Database := iniStr;
end;
iniStr := iniFile.ReadString('Database', 'Username', '');
if not iniStr.IsEmpty then
if iniStr.IsEmpty then
Logger.Log( 5, '----Database->Username: Entry not found' )
else
begin
Logger.Log( 5, '----Database->Username: ' + iniStr );
ucKG.Username := iniStr;
end;
iniStr := iniFile.ReadString('Database', 'Password', '');
if not iniStr.IsEmpty then
if iniStr.IsEmpty then
Logger.Log( 5, '----Database->Password: Entry not found' )
else
begin
Logger.Log( 5, '----Database->Password: xxxxxxxx' );
ucKG.Password := iniStr;
end;
try
ucKG.Connect;
except
on E: Exception do
begin
Logger.Log(5, 'Failed to connect to auth database: ' + E.Message);
Logger.Log(3, '--TAuthDatabase.DataModuleCreate -Error connecting to database: ' + E.Message);
end;
end;
Logger.Log(1, '');
finally
IniFile.Free;
iniFile.Free;
end;
end;
......
......@@ -6,7 +6,7 @@ object AuthServerModule: TAuthServerModule
Top = 16
end
object XDataServer: TXDataServer
BaseUrl = 'http://localhost:2004/emsys/envoy/auth/'
BaseUrl = 'http://localhost:2004/emsys/kgOrders/auth/'
Dispatcher = SparkleHttpSysDispatcher
ModelName = 'Auth'
EntitySetPermissions = <>
......
......@@ -67,7 +67,7 @@ begin
XDataServer.ModelName := AModelName;
SparkleHttpSysDispatcher.Start;
Logger.Log(1, Format('Auth server module listening at "%s"', [Url]));
Logger.Log(1, Format('Auth server module listening at "%s"', [XDataServer.BaseUrl]));
end;
procedure TAuthServerModule.XDataServerLoggingMiddlewareCreate(Sender: TObject;
......
......@@ -172,7 +172,7 @@ object FData: TFData
SortSettings.HeaderColorTo = clWhite
SortSettings.HeaderMirrorColor = clWhite
SortSettings.HeaderMirrorColorTo = clWhite
Version = '2.8.3.1'
Version = '2.8.3.2'
AutoCreateColumns = True
AutoRemoveColumns = True
Columns = <
......@@ -753,7 +753,7 @@ object FData: TFData
SortSettings.HeaderColorTo = clWhite
SortSettings.HeaderMirrorColor = clWhite
SortSettings.HeaderMirrorColorTo = clWhite
Version = '2.8.3.1'
Version = '2.8.3.2'
AutoCreateColumns = True
AutoRemoveColumns = True
Columns = <
......@@ -1505,7 +1505,6 @@ object FData: TFData
Top = 472
end
object uqUsers: TUniQuery
Connection = FDatabaseModule.ucKG
SQL.Strings = (
'select * from users')
Left = 669
......
......@@ -51,11 +51,11 @@ implementation
{$R *.dfm}
uses Database, uLibrary;
uses KGOrders.Database, uLibrary;
procedure TFData.FormCreate(Sender: TObject);
begin
FDatabaseModule := TFDatabaseModule.Create(Self);
KGOrdersDatabase := TKGOrdersDatabase.Create(Self);
end;
procedure TFData.btnFindClick(Sender: TObject);
......
object FDatabaseModule: TFDatabaseModule
object KGOrdersDatabase: TKGOrdersDatabase
OnCreate = DataModuleCreate
Height = 480
Width = 640
Height = 358
Width = 519
object ucKG: TUniConnection
ProviderName = 'MySQL'
Database = 'kg_order_entry'
Username = 'root'
LoginPrompt = False
Left = 75
Top = 139
Top = 65
EncryptedPassword = '9AFF92FF8CFF86FF8CFFCFFFCEFF'
end
object UniQuery1: TUniQuery
Connection = ucKG
SQL.Strings = (
'')
Left = 363
Top = 138
Left = 73
Top = 148
end
object MySQLUniProvider1: TMySQLUniProvider
Left = 220
Top = 134
Left = 162
Top = 66
end
object UniQuery2: TUniQuery
Connection = ucKG
SQL.Strings = (
'')
Left = 433
Top = 144
Left = 179
Top = 148
end
object uqOrders: TUniQuery
Connection = ucKG
SQL.Strings = (
'select * from corrugated_plate_orders')
Left = 527
Top = 120
Left = 263
Top = 156
object uqOrdersORDER_ID: TIntegerField
FieldName = 'ORDER_ID'
end
......
// Where the database is kept. Only used by Lookup.ServiceImpl to retrieve info
// from the data base and send it to the client.
// Author: ???
unit Database;
unit KGOrders.Database;
interface
......@@ -11,7 +11,7 @@ uses
Common.Logging, Vcl.Forms, MySQLUniProvider;
type
TFDatabaseModule = class(TDataModule)
TKGOrdersDatabase = class(TDataModule)
ucKG: TUniConnection;
UniQuery1: TUniQuery;
MySQLUniProvider1: TMySQLUniProvider;
......@@ -113,7 +113,7 @@ type
end;
var
FDatabaseModule: TFDatabaseModule;
KGOrdersDatabase: TKGOrdersDatabase;
implementation
......@@ -121,35 +121,71 @@ implementation
{$R *.dfm}
procedure TFDatabaseModule.DataModuleCreate(Sender: TObject);
// Sets the database connection to the ini file IP
// TODO: clean up unnecessary reads from the ini file
procedure TKGOrdersDatabase.DataModuleCreate(Sender: TObject);
var
IniFile: TIniFile;
iniFile: TIniFile;
iniStr: string;
begin
IniFile := TIniFile.Create( ChangeFileExt(Application.ExeName, '.ini') );
Logger.Log( 5, 'TKGOrdersDatabase.DataModuleCreate' );
iniFile := TIniFile.Create( ExtractFilePath(Application.ExeName) + 'kgOrdersServer.ini' );
try
iniStr := IniFile.ReadString( 'Database', 'Server', '' );
Logger.Log( 5, '--iniFile entries:' );
iniStr := iniFile.ReadString('Database', 'Server', '');
if iniStr.IsEmpty then
Logger.Log( 1, 'iniFile: ' + ChangeFileExt(Application.ExeName, '.ini') +
' Database->Server: Entry not found' )
Logger.Log( 5, '----Database->Server: Entry not found' )
else
begin
Logger.Log( 1, 'iniFile: ' + ChangeFileExt(Application.ExeName, '.ini') +
' Database->Server: ' + iniStr );
Logger.Log( 5, '----Database->Server: iniStr' );
ucKG.Server := iniStr;
end;
iniStr := iniFile.ReadString('Database', 'Database', '');
if iniStr.IsEmpty then
Logger.Log( 5, '----Database->Database: Entry not found' )
else
begin
Logger.Log( 5, '----Database->Database: iniStr' );
ucKG.Database := iniStr;
end;
iniStr := iniFile.ReadString('Database', 'Username', '');
if iniStr.IsEmpty then
Logger.Log( 5, '----Database->Username: Entry not found' )
else
begin
Logger.Log( 5, '----Database->Username: ' + iniStr );
ucKG.Username := iniStr;
end;
iniStr := iniFile.ReadString('Database', 'Password', '');
if iniStr.IsEmpty then
Logger.Log( 5, '----Database->Password: Entry not found' )
else
begin
Logger.Log( 5, '----Database->Password: xxxxxxxx' );
ucKG.Password := iniStr;
end;
try
ucKG.Connect;
except
on E: Exception do
begin
Logger.Log(3, '--TKGOrdersDatabase.DataModuleCreate -Error connecting to database: ' + E.Message);
end;
end;
Logger.Log(1, '');
finally
IniFile.Free;
iniFile.Free;
end;
end;
class procedure TFDatabaseModule.ExecSQL(const SQL: string);
class procedure TKGOrdersDatabase.ExecSQL(const SQL: string);
var
DB: TFDatabaseModule;
DB: TKGOrdersDatabase;
begin
DB := TFDatabaseModule.Create(nil);
DB := TKGOrdersDatabase.Create(nil);
try
DB.UniQuery1.SQL.Text := SQL;
DB.UniQuery1.ExecSQL;
......
......@@ -141,7 +141,6 @@ type
supplied_by_customer_existing_: string;
supplied_by_customer_ref_art_p: string;
supplied_by_customer_ref_art_a: string;
supplied_by_customer_order_date: string;
// Layout
layout_rsc_l: string;
......
......@@ -11,7 +11,7 @@ interface
uses
XData.Server.Module,
XData.Service.Common,
Database, Data.DB,
KGOrders.Database, Data.DB,
Lookup.Service, System.Hash, System.Classes, System.JSON;
......@@ -19,7 +19,7 @@ type
[ServiceImplementation]
TLookupService = class(TInterfacedObject, ILookupService)
strict private
ordersDB: TFDatabaseModule;
ordersDB: TKGOrdersDatabase;
private
function GetItems(searchOptions: string): TItemList;
function GetUsers(searchOptions: string): TUserList;
......@@ -51,7 +51,7 @@ uses
procedure TLookupService.AfterConstruction;
begin
inherited;
ordersDB := TFDatabaseModule.Create(nil);
ordersDB := TKGOrdersDatabase.Create(nil);
end;
......@@ -383,7 +383,6 @@ begin
result.staff_fields_mount_due := ordersDB.UniQuery1.FieldByName('staff_fields_mount_due').AsString;
result.staff_fields_art_location := ordersDB.UniQuery1.FieldByName('staff_fields_art_location').AsString;
result.staff_fields_invoice_to := ordersDB.UniQuery1.FieldByName('staff_fields_invoice_to').AsString;
result.staff_fields_order_date := ordersDB.UniQuery1.FieldByName('staff_fields_order_date').AsString;
// Supplied by Customer
if ordersDB.UniQuery1.FieldByName('supplied_by_customer_b_w_copy').AsString = 'T' then
......
......@@ -41,7 +41,8 @@ uses
Common.Logging,
Common.Config,
Sparkle.Utils,
Database, Data;
KGOrders.Database,
Data;
{$R *.dfm}
......
......@@ -9,7 +9,7 @@ uses
Api.Server.Module in 'Source\Api.Server.Module.pas' {ApiServerModule: TDataModule},
Main in 'Source\Main.pas' {FMain},
Common.Logging in 'Source\Common.Logging.pas',
Database in 'Source\Database.pas' {FDatabaseModule: TDataModule},
KGOrders.Database in 'Source\KGOrders.Database.pas' {KGOrdersDatabase: TDataModule},
Common.Middleware.Logging in 'Source\Common.Middleware.Logging.pas',
Common.Config in 'Source\Common.Config.pas',
Auth.Server.Module in 'Source\Auth.Server.Module.pas' {AuthServerModule: TDataModule},
......@@ -92,12 +92,12 @@ var
begin
FLogLevel := ALogLevel;
FCriticalSection := TCriticalSection.Create;
IniFile := TIniFile.Create( ChangeFileExt( Application.ExeName, '.ini' ) );
iniFile := TIniFile.Create( ExtractFilePath(Application.ExeName) + 'kgOrdersServer.ini' );
try
fileNum := IniFile.ReadInteger( 'Options', 'LogFileNum', 0 );
fileNum := iniFile.ReadInteger( 'Settings', 'LogFileNum', 0 );
// FFilename := AFilename + Format('%.*d',[4, fileNum]);
FFilename := AFilename + Format('%.4d',[fileNum]);
iniFile.WriteInteger( 'Options', 'LogFileNum', fileNum + 1 );
iniFile.WriteInteger( 'Settings', 'LogFileNum', fileNum + 1 );
finally
iniFile.Free;
end;
......@@ -132,14 +132,12 @@ begin
try
AssignFile( FLogFile, LogFile );
if FileExists(LogFile) then
Append( FLogFile )
else
ReWrite( FLogFile );
if logLevel <= FLogLevel then
begin
if FileExists(LogFile) then
Append( FLogFile )
else
ReWrite( FLogFile );
WriteLn( FLogFile, FormattedMessage );
end;
finally
CloseFile(FLogFile);
end;
......@@ -167,7 +165,7 @@ begin
finally
iniFile.Free;
end;
Logger.AddAppender(TMemoLogAppender.Create( 5, FMain.memoinfo ));
Logger.AddAppender(TFileLogAppender.Create( 5, 'kgOrdersServer' ));
Logger.AddAppender(TMemoLogAppender.Create( memoLogLevel, FMain.memoinfo ));
Logger.AddAppender(TFileLogAppender.Create( fileLogLevel, 'kgOrdersServer' ));
Application.Run;
end.
......@@ -133,8 +133,8 @@
<Form>FMain</Form>
</DCCReference>
<DCCReference Include="Source\Common.Logging.pas"/>
<DCCReference Include="Source\Database.pas">
<Form>FDatabaseModule</Form>
<DCCReference Include="Source\KGOrders.Database.pas">
<Form>KGOrdersDatabase</Form>
<FormType>dfm</FormType>
<DesignClass>TDataModule</DesignClass>
</DCCReference>
......
[Settings]
MemoLogLevel=3
MemoLogLevel=5
FileLogLevel=5
LogFileNum=20
LogFileNum=21
webClientVersion=1.0.0
[Database]
......@@ -9,5 +9,3 @@ webClientVersion=1.0.0
Server=192.168.198.131
--Server=192.168.75.133
Password=emsys!012
[Options]
LogFileNum=6
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment