Commit f1a2333b by Elias Sarraf

clean up code

parent 3ff5c8d6
...@@ -7,9 +7,9 @@ kgOrdersClient/css/__history/ ...@@ -7,9 +7,9 @@ kgOrdersClient/css/__history/
kgOrdersClient/config/__history/ kgOrdersClient/config/__history/
kgOrdersServer/__history kgOrdersServer/__history
kgOrdersServer/__recovery kgOrdersServer/__recovery
kgOrdersServer/*.log
kgOrdersServer/*.txt kgOrdersServer/*.txt
kgOrdersServer/doc/ kgOrdersServer/doc/
kgOrdersServer/logs
kgOrdersServer/Win32/ kgOrdersServer/Win32/
kgOrdersServer/Source/__history/ kgOrdersServer/Source/__history/
kgOrdersServer/Source/__recovery/ kgOrdersServer/Source/__recovery/
......
...@@ -78,7 +78,7 @@ type ...@@ -78,7 +78,7 @@ type
procedure orderEntry(orderInfo, customerInfo, mode: string); procedure orderEntry(orderInfo, customerInfo, mode: string);
procedure HideNotification(); procedure HideNotification();
procedure ShowNotification(Notification: string); procedure ShowNotification(Notification: string);
procedure ShowOrderListForm(); procedure ShowAddOrderForm();
[async] procedure Search(searchOptions: string); [async] procedure Search(searchOptions: string);
[async] procedure GetOrders(searchOptions: string); [async] procedure GetOrders(searchOptions: string);
[async] procedure getUser(); [async] procedure getUser();
...@@ -126,7 +126,6 @@ begin ...@@ -126,7 +126,6 @@ begin
end; end;
procedure TFViewOrders.WebFormCreate(Sender: TObject); procedure TFViewOrders.WebFormCreate(Sender: TObject);
// Initializes important values: // Initializes important values:
// PageNumber: What page number the user is on IE 1: 1-10, 2: 11-20 etc // PageNumber: What page number the user is on IE 1: 1-10, 2: 11-20 etc
...@@ -145,6 +144,7 @@ begin ...@@ -145,6 +144,7 @@ begin
getOrders(GenerateSearchOptions()); getOrders(GenerateSearchOptions());
end; end;
procedure TFViewOrders.WebFormShow(Sender: TObject); procedure TFViewOrders.WebFormShow(Sender: TObject);
begin begin
console.log(info); console.log(info);
...@@ -154,6 +154,7 @@ begin ...@@ -154,6 +154,7 @@ begin
HideNotification(); HideNotification();
end; end;
procedure TFViewOrders.getUser(); procedure TFViewOrders.getUser();
var var
xdcResponse: TXDataClientResponse; xdcResponse: TXDataClientResponse;
...@@ -167,6 +168,7 @@ begin ...@@ -167,6 +168,7 @@ begin
user := TJSObject(data[0]); user := TJSObject(data[0]);
end; end;
class function TFViewOrders.CreateForm(AElementID, Info: string): TWebForm; class function TFViewOrders.CreateForm(AElementID, Info: string): TWebForm;
var var
localInfo: string; localInfo: string;
...@@ -184,7 +186,7 @@ begin ...@@ -184,7 +186,7 @@ begin
end; end;
procedure TFViewOrders.ShowOrderListForm(); procedure TFViewOrders.ShowAddOrderForm();
var var
newform: TFAddOrder; newform: TFAddOrder;
begin begin
...@@ -208,8 +210,6 @@ begin ...@@ -208,8 +210,6 @@ begin
end; end;
procedure TFViewOrders.GeneratePagination(TotalPages: Integer); procedure TFViewOrders.GeneratePagination(TotalPages: Integer);
// Generates pagination for the table. // Generates pagination for the table.
// TotalPages: Total amount of pages generated by the search // TotalPages: Total amount of pages generated by the search
...@@ -440,14 +440,16 @@ end; ...@@ -440,14 +440,16 @@ end;
procedure TFViewOrders.btnAddOrderClick(Sender: TObject); procedure TFViewOrders.btnAddOrderClick(Sender: TObject);
begin begin
ShowOrderListForm(); ShowAddOrderForm();
end; end;
procedure TFViewOrders.orderEntry(orderInfo, customerInfo, mode: string); procedure TFViewOrders.orderEntry(orderInfo, customerInfo, mode: string);
begin begin
FViewMain.ViewOrderEntry(orderInfo, customerInfo, mode); FViewMain.ViewOrderEntry(orderInfo, customerInfo, mode);
end; end;
procedure TFViewOrders.btnApplyClick(Sender: TObject); procedure TFViewOrders.btnApplyClick(Sender: TObject);
// Button that effectively functions as a GetOrders() button // Button that effectively functions as a GetOrders() button
var var
...@@ -465,16 +467,19 @@ begin ...@@ -465,16 +467,19 @@ begin
GetOrders(searchOptions); GetOrders(searchOptions);
end; end;
procedure TFViewOrders.btnCloseNotificationClick(Sender: TObject); procedure TFViewOrders.btnCloseNotificationClick(Sender: TObject);
begin begin
HideNotification(); HideNotification();
end; end;
procedure TFViewOrders.btnConfirmClick(Sender: TObject); procedure TFViewOrders.btnConfirmClick(Sender: TObject);
begin begin
//orderEntry('', 'ADD'); //orderEntry('', 'ADD');
end; end;
procedure TFViewOrders.btnFiltersClick(Sender: TObject); procedure TFViewOrders.btnFiltersClick(Sender: TObject);
var var
filterSection: TJSHTMLElement; filterSection: TJSHTMLElement;
...@@ -495,6 +500,7 @@ begin ...@@ -495,6 +500,7 @@ begin
end; end;
end; end;
procedure TFViewOrders.Search(searchOptions: string); procedure TFViewOrders.Search(searchOptions: string);
// Search method that searches the database for a specific phone number // Search method that searches the database for a specific phone number
var var
...@@ -525,12 +531,14 @@ begin ...@@ -525,12 +531,14 @@ begin
end; end;
end; end;
procedure TFViewOrders.btnSearchClick(Sender: TObject); procedure TFViewOrders.btnSearchClick(Sender: TObject);
// orders Search method // orders Search method
begin begin
Search(edtSearch.Text); Search(edtSearch.Text);
end; end;
procedure TFViewOrders.ClearTable(); procedure TFViewOrders.ClearTable();
// clears the table // clears the table
var var
...@@ -540,6 +548,7 @@ begin ...@@ -540,6 +548,7 @@ begin
tbody.innerHTML := ''; tbody.innerHTML := '';
end; end;
function TFViewOrders.GenerateSearchOptions(): string; function TFViewOrders.GenerateSearchOptions(): string;
// Generates searchOptions for GetOrders. // Generates searchOptions for GetOrders.
var var
...@@ -561,12 +570,14 @@ begin ...@@ -561,12 +570,14 @@ begin
Result := searchOptions; Result := searchOptions;
end; end;
procedure TFViewOrders.HideNotification; procedure TFViewOrders.HideNotification;
begin begin
pnlMessage.ElementHandle.hidden := True; pnlMessage.ElementHandle.hidden := True;
info := ''; info := '';
end; end;
procedure TFViewOrders.ShowNotification(Notification: string); procedure TFViewOrders.ShowNotification(Notification: string);
begin begin
if Notification <> '' then if Notification <> '' then
...@@ -597,5 +608,4 @@ begin ...@@ -597,5 +608,4 @@ begin
end; end;
end. end.
...@@ -67,5 +67,5 @@ begin ...@@ -67,5 +67,5 @@ begin
Application.MainFormOnTaskbar := True; Application.MainFormOnTaskbar := True;
Application.CreateForm(TDMConnection, DMConnection); Application.CreateForm(TDMConnection, DMConnection);
DMConnection.InitApp(@StartApplication, @UnauthorizedAccessProc); DMConnection.InitApp(@StartApplication, @UnauthorizedAccessProc);
//Application.Run; Application.Run;
end. end.
object KGOrdersDatabase: TKGOrdersDatabase object ApiDatabase: TApiDatabase
OnCreate = DataModuleCreate OnCreate = DataModuleCreate
Height = 358 Height = 358
Width = 519 Width = 519
......
// Where the database is kept. Only used by Lookup.ServiceImpl to retrieve info // Where the database is kept. Only used by Lookup.ServiceImpl to retrieve info
// from the data base and send it to the client. // from the data base and send it to the client.
// Author: ??? // Author: ???
unit KGOrders.Database; unit Api.Database;
interface interface
...@@ -11,7 +11,7 @@ uses ...@@ -11,7 +11,7 @@ uses
Common.Logging, Vcl.Forms, MySQLUniProvider; Common.Logging, Vcl.Forms, MySQLUniProvider;
type type
TKGOrdersDatabase = class(TDataModule) TApiDatabase = class(TDataModule)
ucKG: TUniConnection; ucKG: TUniConnection;
UniQuery1: TUniQuery; UniQuery1: TUniQuery;
MySQLUniProvider1: TMySQLUniProvider; MySQLUniProvider1: TMySQLUniProvider;
...@@ -113,79 +113,35 @@ type ...@@ -113,79 +113,35 @@ type
end; end;
var var
KGOrdersDatabase: TKGOrdersDatabase; ApiDatabase: TApiDatabase;
implementation implementation
uses
uLibrary;
{%CLASSGROUP 'Vcl.Controls.TControl'} {%CLASSGROUP 'Vcl.Controls.TControl'}
{$R *.dfm} {$R *.dfm}
procedure TKGOrdersDatabase.DataModuleCreate(Sender: TObject); procedure TApiDatabase.DataModuleCreate(Sender: TObject);
var
iniFile: TIniFile;
iniStr: string;
begin begin
Logger.Log( 5, 'TKGOrdersDatabase.DataModuleCreate' ); Logger.Log( 3, 'TApiDatabase.DataModuleCreate' );
iniFile := TIniFile.Create( ExtractFilePath(Application.ExeName) + 'kgOrdersServer.ini' ); LoadDatabaseSettings( ucKG, 'kgOrdersServer.ini' );
try try
Logger.Log( 5, '--iniFile entries:' ); ucKG.Connect;
iniStr := iniFile.ReadString('Database', 'Server', ''); except
if iniStr.IsEmpty then on E: Exception do
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 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 begin
Logger.Log( 5, '----Database->Username: ' + iniStr ); Logger.Log(3, '--TApiDatabase.DataModuleCreate -Error connecting to database: ' + E.Message);
ucKG.Username := iniStr;
end; 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;
end; end;
end; end;
class procedure TKGOrdersDatabase.ExecSQL(const SQL: string); class procedure TApiDatabase.ExecSQL(const SQL: string);
var var
DB: TKGOrdersDatabase; DB: TApiDatabase;
begin begin
DB := TKGOrdersDatabase.Create(nil); DB := TApiDatabase.Create(nil);
try try
DB.UniQuery1.SQL.Text := SQL; DB.UniQuery1.SQL.Text := SQL;
DB.UniQuery1.ExecSQL; DB.UniQuery1.ExecSQL;
......
...@@ -2,12 +2,10 @@ object ApiServerModule: TApiServerModule ...@@ -2,12 +2,10 @@ object ApiServerModule: TApiServerModule
Height = 273 Height = 273
Width = 230 Width = 230
object SparkleHttpSysDispatcher: TSparkleHttpSysDispatcher object SparkleHttpSysDispatcher: TSparkleHttpSysDispatcher
Active = True
Left = 86 Left = 86
Top = 30 Top = 30
end end
object XDataServer: TXDataServer object XDataServer: TXDataServer
BaseUrl = 'http://localhost:2004/emsys/kgOrders/api/'
Dispatcher = SparkleHttpSysDispatcher Dispatcher = SparkleHttpSysDispatcher
ModelName = 'Api' ModelName = 'Api'
EntitySetPermissions = <> EntitySetPermissions = <>
......
...@@ -38,62 +38,16 @@ uses ...@@ -38,62 +38,16 @@ uses
{$R *.dfm} {$R *.dfm}
procedure TAuthDatabase.DataModuleCreate(Sender: TObject); procedure TAuthDatabase.DataModuleCreate(Sender: TObject);
var
iniFile: TIniFile;
iniStr: string;
begin begin
Logger.Log( 5, 'TAuthDatabase.DataModuleCreate' ); Logger.Log( 3, 'TAuthDatabase.DataModuleCreate' );
iniFile := TIniFile.Create( ExtractFilePath(Application.ExeName) + 'kgOrdersServer.ini' ); LoadDatabaseSettings( ucKG, 'kgOrdersServer.ini' );
try try
Logger.Log( 5, '--iniFile entries:' ); ucKG.Connect;
iniStr := iniFile.ReadString('Database', 'Server', ''); except
if iniStr.IsEmpty then on E: Exception do
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 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 begin
Logger.Log( 5, '----Database->Username: ' + iniStr ); Logger.Log(3, '--TAuthDatabase.DataModuleCreate -Error connecting to database: ' + E.Message);
ucKG.Username := iniStr;
end; 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, '--TAuthDatabase.DataModuleCreate -Error connecting to database: ' + E.Message);
end;
end;
Logger.Log(1, '');
finally
iniFile.Free;
end; end;
end; end;
......
...@@ -6,7 +6,6 @@ object AuthServerModule: TAuthServerModule ...@@ -6,7 +6,6 @@ object AuthServerModule: TAuthServerModule
Top = 16 Top = 16
end end
object XDataServer: TXDataServer object XDataServer: TXDataServer
BaseUrl = 'http://localhost:2004/emsys/kgOrders/auth/'
Dispatcher = SparkleHttpSysDispatcher Dispatcher = SparkleHttpSysDispatcher
ModelName = 'Auth' ModelName = 'Auth'
EntitySetPermissions = <> EntitySetPermissions = <>
......
...@@ -14,7 +14,7 @@ uses ...@@ -14,7 +14,7 @@ uses
BaseGrid, AdvGrid, DBAdvGrid, MemDS, DBAccess, Uni, Vcl.StdCtrls, Vcl.Mask, BaseGrid, AdvGrid, DBAdvGrid, MemDS, DBAccess, Uni, Vcl.StdCtrls, Vcl.Mask,
vcl.wwdbedit, vcl.wwdotdot, vcl.wwdbcomb, REST.Client, REST.Types, System.JSON, vcl.wwdbedit, vcl.wwdotdot, vcl.wwdbcomb, REST.Client, REST.Types, System.JSON,
System.Generics.Collections, AdvEdit, vcl.wwdblook, vcl.wwdbdatetimepicker, System.Generics.Collections, AdvEdit, vcl.wwdblook, vcl.wwdbdatetimepicker,
System.Hash; System.Hash, Api.Database;
type type
TFData = class(TForm) TFData = class(TForm)
...@@ -39,6 +39,7 @@ type ...@@ -39,6 +39,7 @@ type
procedure btnFindClick(Sender: TObject); procedure btnFindClick(Sender: TObject);
procedure btnPDFClick(Sender: TObject); procedure btnPDFClick(Sender: TObject);
private private
kgDB: TApiDatabase;
accountSID: string; accountSID: string;
authHeader: string; authHeader: string;
public public
...@@ -52,7 +53,7 @@ implementation ...@@ -52,7 +53,7 @@ implementation
{$R *.dfm} {$R *.dfm}
uses KGOrders.Database, uLibrary, rOrders; uses uLibrary, rOrders;
procedure TFData.btnPDFClick(Sender: TObject); procedure TFData.btnPDFClick(Sender: TObject);
begin begin
...@@ -62,7 +63,7 @@ end; ...@@ -62,7 +63,7 @@ end;
procedure TFData.FormCreate(Sender: TObject); procedure TFData.FormCreate(Sender: TObject);
begin begin
KGOrdersDatabase := TKGOrdersDatabase.Create(Self); kgDB := TApiDatabase.Create(Self);
end; end;
procedure TFData.btnFindClick(Sender: TObject); procedure TFData.btnFindClick(Sender: TObject);
...@@ -108,5 +109,4 @@ begin ...@@ -108,5 +109,4 @@ begin
end; end;
end. end.
...@@ -41,7 +41,7 @@ uses ...@@ -41,7 +41,7 @@ uses
Common.Logging, Common.Logging,
Common.Config, Common.Config,
Sparkle.Utils, Sparkle.Utils,
KGOrders.Database, Api.Database,
Data; Data;
{$R *.dfm} {$R *.dfm}
...@@ -110,7 +110,7 @@ begin ...@@ -110,7 +110,7 @@ begin
try try
Logger.Log( 1, 'iniFile: ' + ExtractFilePath(Application.ExeName) + 'kgOrdersServer.ini' ); Logger.Log( 1, 'iniFile: ' + ExtractFilePath(Application.ExeName) + 'kgOrdersServer.ini' );
Logger.Log( 1, 'LogLevels are displayed here. They were set in kgOrders.dpr, it executes first' ); Logger.Log( 1, 'LogLevels are displayed here. They were set in kgOrdersServer.dpr, it executes first' );
iniStr := iniFile.ReadString( 'Settings', 'MemoLogLevel', '' ); iniStr := iniFile.ReadString( 'Settings', 'MemoLogLevel', '' );
if iniStr.IsEmpty then if iniStr.IsEmpty then
Logger.Log( 1, '--Settings->memoLogLevel: Entry not found - default: 3' ) Logger.Log( 1, '--Settings->memoLogLevel: Entry not found - default: 3' )
...@@ -130,11 +130,29 @@ begin ...@@ -130,11 +130,29 @@ begin
else else
Logger.Log( 1, '--Settings->LogFileNum: ' + IntToStr(StrToInt(iniStr) - 1) ); Logger.Log( 1, '--Settings->LogFileNum: ' + IntToStr(StrToInt(iniStr) - 1) );
Logger.Log( 1, '' );
iniStr := IniFile.ReadString( 'Database', 'Server', '' ); iniStr := IniFile.ReadString( 'Database', 'Server', '' );
if iniStr.IsEmpty then if iniStr.IsEmpty then
Logger.Log( 1, '--Database->Server: Entry not found' ) Logger.Log( 1, '--Database->Server: Entry not found' )
else else
Logger.Log( 1, '--Database->Server: ' + iniStr ); Logger.Log( 1, '--Database->Server: ' + iniStr );
iniStr := iniFile.ReadString('Database', 'Database', '');
if iniStr.IsEmpty then
Logger.Log( 1, '----Database->Database: Entry not found' )
else
Logger.Log( 1, '----Database->Database: ' + iniStr );
iniStr := iniFile.ReadString('Database', 'Username', '');
if iniStr.IsEmpty then
Logger.Log( 1, '----Database->Username: Entry not found' )
else
Logger.Log( 1, '----Database->Username: ' + iniStr );
iniStr := iniFile.ReadString('Database', 'Password', '');
if iniStr.IsEmpty then
Logger.Log( 1, '----Database->Password: Entry not found' )
else
Logger.Log( 1, '----Database->Password: xxxxxxxx' );
Logger.Log( 1, '' ); Logger.Log( 1, '' );
finally finally
...@@ -149,6 +167,8 @@ begin ...@@ -149,6 +167,8 @@ begin
AppServerModule := TAppServerModule.Create(Self); AppServerModule := TAppServerModule.Create(Self);
AppServerModule.StartAppServer( serverConfig.url ); AppServerModule.StartAppServer( serverConfig.url );
UpdateGUI;
end; end;
procedure TFMain.FormClose(Sender: TObject; var Action: TCloseAction); procedure TFMain.FormClose(Sender: TObject; var Action: TCloseAction);
...@@ -160,9 +180,6 @@ begin ...@@ -160,9 +180,6 @@ begin
end; end;
procedure TFMain.UpdateGUI; procedure TFMain.UpdateGUI;
const
cHttp = 'http://+';
cHttpLocalhost = 'http://localhost';
begin begin
if AuthServerModule.SparkleHttpSysDispatcher.Active then if AuthServerModule.SparkleHttpSysDispatcher.Active then
memoInfo.Lines.Add( 'AuthServer started at: ' + AuthServerModule.XDataServer.BaseUrl ) memoInfo.Lines.Add( 'AuthServer started at: ' + AuthServerModule.XDataServer.BaseUrl )
......
...@@ -3,7 +3,7 @@ object rptOrders: TrptOrders ...@@ -3,7 +3,7 @@ object rptOrders: TrptOrders
Height = 480 Height = 480
Width = 640 Width = 640
object frxOrders: TfrxReport object frxOrders: TfrxReport
Version = '2024.2.1' Version = '2025.1.3'
DotMatrixReport = False DotMatrixReport = False
IniFile = '\Software\Fast Reports' IniFile = '\Software\Fast Reports'
PreviewOptions.Buttons = [pbPrint, pbLoad, pbSave, pbExport, pbZoom, pbFind, pbOutline, pbPageSetup, pbTools, pbEdit, pbNavigator, pbExportQuick, pbCopy, pbSelection] PreviewOptions.Buttons = [pbPrint, pbLoad, pbSave, pbExport, pbZoom, pbFind, pbOutline, pbPageSetup, pbTools, pbEdit, pbNavigator, pbExportQuick, pbCopy, pbSelection]
...@@ -1212,7 +1212,6 @@ object rptOrders: TrptOrders ...@@ -1212,7 +1212,6 @@ object rptOrders: TrptOrders
Database = 'kg_order_entry' Database = 'kg_order_entry'
Username = 'root' Username = 'root'
Server = '192.168.102.130' Server = '192.168.102.130'
Connected = True
LoginPrompt = False LoginPrompt = False
Left = 289 Left = 289
Top = 99 Top = 99
...@@ -1242,7 +1241,6 @@ object rptOrders: TrptOrders ...@@ -1242,7 +1241,6 @@ object rptOrders: TrptOrders
' 3 AS COLORS' ' 3 AS COLORS'
'FROM DUAL' 'FROM DUAL'
'') '')
Active = True
Left = 415 Left = 415
Top = 136 Top = 136
end end
...@@ -1258,108 +1256,5 @@ object rptOrders: TrptOrders ...@@ -1258,108 +1256,5 @@ object rptOrders: TrptOrders
DataSetOptions = [] DataSetOptions = []
Left = 424 Left = 424
Top = 224 Top = 224
FieldDefs = <
item
FieldName = 'ORDER_ID'
end
item
FieldName = 'COMPANY_ID'
end
item
FieldName = 'USER_ID'
end
item
FieldName = 'ORDER_DATE'
FieldType = fftString
end
item
FieldName = 'START_DATE'
FieldType = fftDateTime
end
item
FieldName = 'END_DATE'
FieldType = fftDateTime
end
item
FieldName = 'ORDER_STATUS'
FieldType = fftString
end
item
FieldName = 'SCHED_JSON'
FieldType = fftString
Size = 4096
end
item
FieldName = 'LOCATION'
FieldType = fftString
end
item
FieldName = 'JOB_NAME'
FieldType = fftString
Size = 15
end
item
FieldName = 'COMPANY_NAME'
FieldType = fftString
Size = 14
end
item
FieldName = 'PROOF_DUE'
FieldType = fftString
Size = 16
end
item
FieldName = 'PROOF_DONE'
FieldType = fftString
Size = 16
end
item
FieldName = 'ART_DUE'
FieldType = fftString
end
item
FieldName = 'ART_DONE'
FieldType = fftString
Size = 16
end
item
FieldName = 'PLATE_DUE'
FieldType = fftString
Size = 16
end
item
FieldName = 'PLATE_DONE'
FieldType = fftString
Size = 16
end
item
FieldName = 'PRICE'
end
item
FieldName = 'QB_REF_NUM'
end
item
FieldName = 'MOUNT_DUE'
FieldType = fftString
Size = 16
end
item
FieldName = 'MOUNT_DONE'
FieldType = fftString
Size = 16
end
item
FieldName = 'SHIP_DUE'
FieldType = fftString
Size = 16
end
item
FieldName = 'SHIP_DONE'
FieldType = fftString
Size = 16
end
item
FieldName = 'COLORS'
end>
end end
end end
...@@ -16,6 +16,7 @@ type ...@@ -16,6 +16,7 @@ type
frxReportTableObject1: TfrxReportTableObject; frxReportTableObject1: TfrxReportTableObject;
frxDBOrders: TfrxDBDataset; frxDBOrders: TfrxDBDataset;
procedure DataModuleCreate(Sender: TObject); procedure DataModuleCreate(Sender: TObject);
private private
public public
...@@ -29,21 +30,24 @@ var ...@@ -29,21 +30,24 @@ var
implementation implementation
uses
uLibrary;
{%CLASSGROUP 'Vcl.Controls.TControl'} {%CLASSGROUP 'Vcl.Controls.TControl'}
{$R *.dfm} {$R *.dfm}
procedure TrptOrders.DataModuleCreate(Sender: TObject); procedure TrptOrders.DataModuleCreate(Sender: TObject);
var
iniFile: TIniFile;
begin begin
// Load database connection settings from INI file Logger.Log( 3, 'TAuthDatabase.DataModuleCreate' );
iniFile := TIniFile.Create(ExtractFilePath(Application.ExeName) + 'kgOrdersServer.ini'); LoadDatabaseSettings( ucKG, 'kgOrdersServer.ini' );
try try
ucKG.Server := iniFile.ReadString('Database', 'Server', '');
ucKG.Connect; ucKG.Connect;
finally except
iniFile.Free; on E: Exception do
begin
Logger.Log(3, '--TrptOrders.DataModuleCreate -Error connecting to database: ' + E.Message);
end;
end; end;
end; end;
...@@ -103,9 +107,5 @@ begin ...@@ -103,9 +107,5 @@ begin
end; end;
end. end.
...@@ -5,46 +5,43 @@ interface ...@@ -5,46 +5,43 @@ interface
uses uses
System.Classes, Uni; System.Classes, Uni;
const procedure LoadDatabaseSettings( uc: TUniConnection; iniFilename: string );
ADD_REC_AUDIT_ENTRY = '0';
EDIT_REC_AUDIT_ENTRY = '1';
DEL_REC_AUDIT_ENTRY = '2';
REVIEW_REC_AUDIT_ENTRY = '3';
VIEW_REC_AUDIT_ENTRY = '4';
FIND_REC_AUDIT_ENTRY = '5';
PRINT_REC_AUDIT_ENTRY = '6';
OTHER_REC_AUDIT_ENTRY = '99';
function GetServerTimeStamp( uq: TUniQuery ): TDateTime;
procedure DoQuery( uq: TUniQuery; sql: string ); procedure DoQuery( uq: TUniQuery; sql: string );
function CalculateAge( const dob, dt: TDateTime ): Integer; function CalculateAge( const dob, dt: TDateTime ): Integer;
function GetNextSeqVal( uq: TUniQuery; sequence: string ): string;
function FormatNamePersonnel( uq: TUniQuery; format: string ): string;
function FormatBkNum( bkNum: string ): string;
function GetAssociatedNumber( uq: TUniQuery; numberType: string ): string;
function FormatBookingAddress( uq: TUniQuery; format: string ): string;
function SetMasterAuditEntry( uq: TUniQuery; const entryId, auditType, linkId, agency, personnelId, recUser, details, searchKey, execSource: string ): Boolean;
function SetDetailAuditEntry( uq: TUniQuery; const entryId, title, auditType: string; auditList: TStringList ): Boolean;
function GetOfficerName( agency, officer: string; uq: TUniQuery ): string;
function GetRiciOfficerName( agency, officer: string; uq: TUniQuery ): string;
implementation implementation
uses uses
System.SysUtils, System.SysUtils,
System.IniFiles,
Vcl.Forms,
Data.DB; Data.DB;
function GetServerTimeStamp( uq: TUniQuery ): TDateTime; procedure LoadDatabaseSettings( uc: TUniConnection; iniFilename: string );
var var
sql: string; iniFile: TIniFile;
serverDateTime: TDateTime; iniStr: string;
begin begin
sql := 'select sysdate as currentdatetime from dual'; iniFile := TIniFile.Create( ExtractFilePath(Application.ExeName) + iniFilename );
try
DoQuery( uq, sql ); iniStr := iniFile.ReadString('Database', 'Server', '');
serverDateTime := uq.FieldByName('CURRENTDATETIME').AsDateTime; if not iniStr.IsEmpty then
uq.Close; uc.Server := iniStr;
Result := serverDateTime;
iniStr := iniFile.ReadString('Database', 'Database', '');
if not iniStr.IsEmpty then
uc.Database := iniStr;
iniStr := iniFile.ReadString('Database', 'Username', '');
if not iniStr.IsEmpty then
uc.Username := iniStr;
iniStr := iniFile.ReadString('Database', 'Password', '');
if not iniStr.IsEmpty then
uc.Password := iniStr;
finally
iniFile.Free;
end;
end; end;
procedure DoQuery(uq: TUniQuery; sql: string); procedure DoQuery(uq: TUniQuery; sql: string);
...@@ -82,204 +79,5 @@ begin ...@@ -82,204 +79,5 @@ begin
Result := age Result := age
end; end;
function GetNextSeqVal(uq: TUniQuery; sequence: string ): string;
var
sql: string;
begin
sql := 'select ' + sequence + '.NEXTVAL as nextseqval from dual';
uq.Close;
uq.SQL.Text := sql;
uq.Open;
Result := uq.FieldByName('NEXTSEQVAL').AsString;
end;
function FormatNamePersonnel( uq: TUniQuery; format: string ): string;
var
leng: Integer;
i: Integer;
officerText: String;
begin
leng := Length( format );
for i := 0 to leng - 1 do
begin
case format[i+1] of
'S':
officerText := officerText + uq.FieldByName('PF_LNAME').AsString;
'F':
if not uq.FieldByName('PF_FNAME').AsString.IsEmpty then
officerText := TrimRight( officerText + uq.FieldByName('PF_FNAME').AsString ) ;
'M':
if not uq.FieldByName('PF_MI').AsString.IsEmpty then
officerText := TrimRight( officerText + uq.FieldByName('PF_MI').AsString );
',':
officerText := officerText + ',';
'.':
officerText := officerText + '.';
' ':
officerText := officerText + ' ';
end;
end;
Result := officerText;
end;
function FormatBkNum( bkNum: string ): string;
var
bkNumStr: string;
begin
bkNumStr := bkNum;
Result := bkNumStr.Insert( 4, '-' );
end;
function GetAssociatedNumber( uq: TUniQuery; numberType: string): string;
var
TLocateOptions: set of TLocateOption;
begin
if uq.Locate('OTHER_AGENCY_CODE', numberType, TLocateOptions)
then Result := uq.FieldByName('IDENTIFICATION').AsString
end;
function FormatBookingAddress( uq: TUniQuery; format: string ): string;
var
addressText: AnsiString;
leng: Integer;
i : Integer;
begin
leng := Length( format );
for i := 0 to leng - 1 do
begin
case format[i+1] of
'S':
begin
addressText := addressText + uq.FieldByName('STREET_NUM').AsString;
if uq.FieldByName('STREET_NUM_HALF').AsString = 'Y' then
addressText := addressText + ' 1/2';
if uq.FieldByName('STREET_DIRECTION').AsString <> '' then
addressText := addressText + ' ' + uq.FieldByName('STREET_DIRECTION').AsString;
if uq.FieldByName('STREET_NAME').AsString <> '' then
addressText := addressText + ' ' + TrimRight( uq.FieldByName('STREET_NAME').AsString );
if uq.FieldByName('STREET_TYPE').AsString <> '' then
addressText := addressText + ' ' + TrimRight( uq.FieldByName('STREET_TYPE').AsString );
if uq.FieldByName('APARTMENT_NUM').AsString <> '' then
addressText := addressText + ' APT: ' + TrimRight( uq.FieldByName('APARTMENT_NUM').AsString );
end;
'C':
if uq.FieldByName('CITY').AsString <> '' then
addressText := addressText + ' ' + TrimRight( uq.FieldByName('CITY').AsString );
'T':
if uq.FieldByName('STATE').AsString <> '' then
addressText := addressText + ' ' + TrimRight( uq.FieldByName('STATE').AsString );
'Z':
if uq.FieldByName('ZIP_CODE').AsString <> '' then
addressText := addressText + ' ' + TrimRight( uq.FieldByName('ZIP_CODE').AsString );
'R':
if uq.FieldByName('COUNTRY').AsString <> '' then
addressText := addressText + ' ' + TrimRight( uq.FieldByName('COUNTRY').AsString );
',':
addressText := addressText + ',';
'.':
addressText := addressText + '.';
' ':
addressText := addressText + ' ';
end;
end;
Result := addressText;
end;
function SetMasterAuditEntry(uq: TUniQuery; const entryId, auditType, linkId, agency, personnelId, recUser, details, searchKey, execSource: string) : Boolean;
var
sql: string;
begin
sql := 'insert into auditmaster ';
sql := sql + '( AUDITMASTERID, SOURCEID, AUDITTYPE, AGENCY, PERSONNELID, RECUSER, RECDATE, DETAILS, SEARCHKEY, EXECSRC) ';
sql := sql + 'values (';
sql := sql + entryID + ', ';
sql := sql + QuotedStr(linkID) + ', ';
sql := sql + QuotedStr(auditType) + ', ';
sql := sql + QuotedStr(agency) + ', ';
sql := sql + personnelid + ', ';
sql := sql + QuotedStr(recUser) + ', ';
sql := sql + 'sysdate, ';
sql := sql + QuotedStr(details) + ', ';
sql := sql + QuotedStr(searchKey) + ', ';
sql := sql + QuotedStr(execSource) + ')';
uq.Close;
uq.SQL.Text := sql;
uq.Execute;
uq.Close;
Result := True;
end;
function SetDetailAuditEntry(uq: TUniQuery; const entryId, title, auditType: string; auditList: TStringList) : Boolean;
var
i: Integer;
sql: string;
begin
for i := 0 to auditList.Count - 1 do
begin
sql := 'insert into auditdetail values (';
sql := sql + entryId + ', ';
sql := sql + QuotedStr( auditList.Names[i] ) + ', ';
sql := sql + QuotedStr( '' ) + ', ';
sql := sql + QuotedStr( auditList.ValueFromIndex[i] ) + ', ';
sql := sql + auditType + ')';
uq.Close;
uq.SQL.Text := sql;
uq.Execute;
uq.Close;
end;
Result := True;
end;
function GetOfficerName( agency, officer: string; uq: TUniQuery ): string;
var
sql: string;
begin
if agency.IsEmpty or officer.IsEmpty then
Exit;
sql := 'select a.agency_id, p.agency, p.pf_nameid, pf_lname, pf_fname, pf_mi, pf_badge ';
sql := sql + 'from personnel p ';
sql := sql + 'join agencycodes a on a.agency = p.agency ';
sql := sql + 'where a.agency_id = ' + agency + ' and p.pf_nameid = ' + officer;
uq.Close;
uq.SQL.Text := sql;
uq.Open;
if uq.IsEmpty then
Result := agency + '-' + officer + ': not found'
else
begin
Result := uq.FieldByName('pf_lname').AsString + ', ' + uq.FieldByName('pf_fname').AsString;
Result := Result + ' ' + uq.FieldByName('pf_mi').AsString + ' (' + uq.FieldByName('pf_badge').AsString + ')';
end;
end;
function GetRiciOfficerName( agency, officer: string; uq: TUniQuery ): string;
var
sql: string;
begin
if agency.IsEmpty or officer.IsEmpty then
Exit;
sql := 'select * from rici.officer@rici_link where agency = ' + agency + ' and empno = ' + QuotedStr(officer);
uq.Close;
uq.SQL.Text := sql;
uq.Open;
if uq.IsEmpty then
Result := agency + '-' + officer + ': not found'
else
Result := uq.FieldByName('surname').AsString + ', ' + uq.FieldByName('given1').AsString + ' (' + uq.FieldByName('empno').AsString + ')';
end;
end. end.
...@@ -9,7 +9,7 @@ uses ...@@ -9,7 +9,7 @@ uses
Api.Server.Module in 'Source\Api.Server.Module.pas' {ApiServerModule: TDataModule}, Api.Server.Module in 'Source\Api.Server.Module.pas' {ApiServerModule: TDataModule},
Main in 'Source\Main.pas' {FMain}, Main in 'Source\Main.pas' {FMain},
Common.Logging in 'Source\Common.Logging.pas', Common.Logging in 'Source\Common.Logging.pas',
KGOrders.Database in 'Source\KGOrders.Database.pas' {KGOrdersDatabase: TDataModule}, Api.Database in 'Source\Api.Database.pas' {ApiDatabase: TDataModule},
Common.Middleware.Logging in 'Source\Common.Middleware.Logging.pas', Common.Middleware.Logging in 'Source\Common.Middleware.Logging.pas',
Common.Config in 'Source\Common.Config.pas', Common.Config in 'Source\Common.Config.pas',
Auth.Server.Module in 'Source\Auth.Server.Module.pas' {AuthServerModule: TDataModule}, Auth.Server.Module in 'Source\Auth.Server.Module.pas' {AuthServerModule: TDataModule},
...@@ -38,7 +38,7 @@ type ...@@ -38,7 +38,7 @@ type
TFileLogAppender = class( TInterfacedObject, ILogAppender ) TFileLogAppender = class( TInterfacedObject, ILogAppender )
private private
FLogLevel: Integer; FLogLevel: Integer;
FFilename: string; FLogFile: string;
FCriticalSection: TCriticalSection; FCriticalSection: TCriticalSection;
public public
constructor Create(ALogLevel: Integer; AFilename: string); constructor Create(ALogLevel: Integer; AFilename: string);
...@@ -90,14 +90,18 @@ constructor TFileLogAppender.Create(ALogLevel: integer; AFilename: string); ...@@ -90,14 +90,18 @@ constructor TFileLogAppender.Create(ALogLevel: integer; AFilename: string);
var var
iniFile: TIniFile; iniFile: TIniFile;
fileNum: integer; fileNum: integer;
logsDir: string;
begin begin
FLogLevel := ALogLevel; FLogLevel := ALogLevel;
FCriticalSection := TCriticalSection.Create; FCriticalSection := TCriticalSection.Create;
logsDir := ExtractFilePath(Application.ExeName) + 'logs\';
if not DirectoryExists(logsDir) then
CreateDir(logsDir);
iniFile := TIniFile.Create( ExtractFilePath(Application.ExeName) + 'kgOrdersServer.ini' ); iniFile := TIniFile.Create( ExtractFilePath(Application.ExeName) + 'kgOrdersServer.ini' );
try try
fileNum := iniFile.ReadInteger( 'Settings', 'LogFileNum', 0 ); fileNum := iniFile.ReadInteger( 'Settings', 'LogFileNum', 0 );
// FFilename := AFilename + Format('%.*d',[4, fileNum]); FLogFile := logsDir + AFilename + Format( '%.4d', [fileNum] ) + '.log';
FFilename := AFilename + Format('%.4d',[fileNum]);
iniFile.WriteInteger( 'Settings', 'LogFileNum', fileNum + 1 ); iniFile.WriteInteger( 'Settings', 'LogFileNum', fileNum + 1 );
finally finally
iniFile.Free; iniFile.Free;
...@@ -112,35 +116,33 @@ end; ...@@ -112,35 +116,33 @@ end;
procedure TFileLogAppender.Send(logLevel: integer; Log: ILog); procedure TFileLogAppender.Send(logLevel: integer; Log: ILog);
var var
FormattedMessage: string; formattedMessage: string;
LogFile: string; logTime: TDateTime;
LogTime: TDateTime; logMsg: string;
LogMsg: string; txtFile: TextFile;
FLogFile: TextFile;
begin begin
FCriticalSection.Acquire; FCriticalSection.Acquire;
try try
LogTime := Now; logTime := Now;
LogFile := ExtractFilePath(Application.ExeName) + FFilename + '.log';
FormattedMessage := FormatDateTime('[yyyy-mm-dd HH:nn:ss.zzz]', LogTime); formattedMessage := FormatDateTime('[yyyy-mm-dd HH:nn:ss.zzz]', logTime);
LogMsg := Log.GetMessage; logMsg := Log.GetMessage;
if LogMsg.IsEmpty then if logMsg.IsEmpty then
FormattedMessage := '' formattedMessage := ''
else else
FormattedMessage := FormattedMessage + '[' + IntToStr(logLevel) +'] ' + LogMsg; formattedMessage := formattedMessage + '[' + IntToStr(logLevel) +'] ' + logMsg;
try try
AssignFile( FLogFile, LogFile ); AssignFile( txtFile, FLogFile );
if FileExists(LogFile) then if FileExists(FLogFile) then
Append( FLogFile ) Append( txtFile )
else else
ReWrite( FLogFile ); ReWrite( txtFile );
if logLevel <= FLogLevel then if logLevel <= FLogLevel then
WriteLn( FLogFile, FormattedMessage ); WriteLn( txtFile, formattedMessage );
finally finally
CloseFile(FLogFile); CloseFile(txtFile);
end; end;
finally finally
FCriticalSection.Release; FCriticalSection.Release;
......
...@@ -133,8 +133,8 @@ ...@@ -133,8 +133,8 @@
<Form>FMain</Form> <Form>FMain</Form>
</DCCReference> </DCCReference>
<DCCReference Include="Source\Common.Logging.pas"/> <DCCReference Include="Source\Common.Logging.pas"/>
<DCCReference Include="Source\KGOrders.Database.pas"> <DCCReference Include="Source\Api.Database.pas">
<Form>KGOrdersDatabase</Form> <Form>ApiDatabase</Form>
<FormType>dfm</FormType> <FormType>dfm</FormType>
<DesignClass>TDataModule</DesignClass> <DesignClass>TDataModule</DesignClass>
</DCCReference> </DCCReference>
......
[Settings] [Settings]
MemoLogLevel=5 MemoLogLevel=5
FileLogLevel=5 FileLogLevel=5
LogFileNum=23 LogFileNum=30
webClientVersion=1.0.0 webClientVersion=1.0.0
[Database] [Database]
--Server=192.168.159.132 --Server=192.168.159.132
Server=192.168.198.131 Server=192.168.60.129
--Server=192.168.75.133 --Server=192.168.75.133
--Database= --Database=
--Username= --Username=
--Password= Password=emsys!012
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