Commit a7e54751 by Elias Sarraf

clean up code

parent c062a773
......@@ -7,9 +7,9 @@ kgOrdersClient/css/__history/
kgOrdersClient/config/__history/
kgOrdersServer/__history
kgOrdersServer/__recovery
kgOrdersServer/*.log
kgOrdersServer/*.txt
kgOrdersServer/doc/
kgOrdersServer/logs
kgOrdersServer/Win32/
kgOrdersServer/Source/__history/
kgOrdersServer/Source/__recovery/
......
......@@ -78,7 +78,7 @@ type
procedure orderEntry(orderInfo, customerInfo, mode: string);
procedure HideNotification();
procedure ShowNotification(Notification: string);
procedure ShowOrderListForm();
procedure ShowAddOrderForm();
[async] procedure Search(searchOptions: string);
[async] procedure GetOrders(searchOptions: string);
[async] procedure getUser();
......@@ -124,6 +124,10 @@ begin
ShowMessage('PDF Report Generated Successfully');
end;
<<<<<<< HEAD
=======
>>>>>>> f1a2333 (clean up code)
procedure TFViewOrders.WebFormCreate(Sender: TObject);
// Initializes important values:
// PageNumber: What page number the user is on IE 1: 1-10, 2: 11-20 etc
......@@ -142,6 +146,7 @@ begin
getOrders(GenerateSearchOptions());
end;
procedure TFViewOrders.WebFormShow(Sender: TObject);
begin
console.log(info);
......@@ -151,6 +156,7 @@ begin
HideNotification();
end;
procedure TFViewOrders.getUser();
var
xdcResponse: TXDataClientResponse;
......@@ -164,6 +170,7 @@ begin
user := TJSObject(data[0]);
end;
class function TFViewOrders.CreateForm(AElementID, Info: string): TWebForm;
var
localInfo: string;
......@@ -181,7 +188,7 @@ begin
end;
procedure TFViewOrders.ShowOrderListForm();
procedure TFViewOrders.ShowAddOrderForm();
var
newform: TFAddOrder;
begin
......@@ -205,8 +212,6 @@ begin
end;
procedure TFViewOrders.GeneratePagination(TotalPages: Integer);
// Generates pagination for the table.
// TotalPages: Total amount of pages generated by the search
......@@ -437,14 +442,16 @@ end;
procedure TFViewOrders.btnAddOrderClick(Sender: TObject);
begin
ShowOrderListForm();
ShowAddOrderForm();
end;
procedure TFViewOrders.orderEntry(orderInfo, customerInfo, mode: string);
begin
FViewMain.ViewOrderEntry(orderInfo, customerInfo, mode);
end;
procedure TFViewOrders.btnApplyClick(Sender: TObject);
// Button that effectively functions as a GetOrders() button
var
......@@ -462,16 +469,19 @@ begin
GetOrders(searchOptions);
end;
procedure TFViewOrders.btnCloseNotificationClick(Sender: TObject);
begin
HideNotification();
end;
procedure TFViewOrders.btnConfirmClick(Sender: TObject);
begin
//orderEntry('', 'ADD');
end;
procedure TFViewOrders.btnFiltersClick(Sender: TObject);
var
filterSection: TJSHTMLElement;
......@@ -492,6 +502,7 @@ begin
end;
end;
procedure TFViewOrders.Search(searchOptions: string);
// Search method that searches the database for a specific phone number
var
......@@ -522,12 +533,14 @@ begin
end;
end;
procedure TFViewOrders.btnSearchClick(Sender: TObject);
// orders Search method
begin
Search(edtSearch.Text);
end;
procedure TFViewOrders.ClearTable();
// clears the table
var
......@@ -537,6 +550,7 @@ begin
tbody.innerHTML := '';
end;
function TFViewOrders.GenerateSearchOptions(): string;
// Generates searchOptions for GetOrders.
var
......@@ -558,12 +572,14 @@ begin
Result := searchOptions;
end;
procedure TFViewOrders.HideNotification;
begin
pnlMessage.ElementHandle.hidden := True;
info := '';
end;
procedure TFViewOrders.ShowNotification(Notification: string);
begin
if Notification <> '' then
......@@ -575,4 +591,26 @@ begin
end;
<<<<<<< HEAD
=======
procedure TFViewOrders.GeneratePDF(OrderID: string);
var
XDCResponse: TXDataClientResponse;
PDFBase64: string;
PDFBlob: TJSUint8Array;
PDFLink: TJSHTMLElement;
begin
// XDCResponse := await(XDataWebClient1.RawInvokeAsync('ILookupService.GenerateOrderPDF', [OrderID]));
// PDFBase64 := string(XDCResponse.Result);
//
// // Convert Base64 to binary and create a link to download it
// PDFBlob := TJSUint8Array.new(TJSBase64.decodeBase64(PDFBase64));
// PDFLink := TJSHTMLElement(document.createElement('a'));
// PDFLink.setAttribute('href', 'data:application/pdf;base64,' + PDFBase64);
// PDFLink.setAttribute('download', 'Order_' + OrderID + '.pdf');
// PDFLink.click;
end;
>>>>>>> f1a2333 (clean up code)
end.
......@@ -67,5 +67,5 @@ begin
Application.MainFormOnTaskbar := True;
Application.CreateForm(TDMConnection, DMConnection);
DMConnection.InitApp(@StartApplication, @UnauthorizedAccessProc);
//Application.Run;
Application.Run;
end.
object KGOrdersDatabase: TKGOrdersDatabase
object ApiDatabase: TApiDatabase
OnCreate = DataModuleCreate
Height = 358
Width = 519
......
// 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 KGOrders.Database;
unit Api.Database;
interface
......@@ -11,7 +11,7 @@ uses
Common.Logging, Vcl.Forms, MySQLUniProvider;
type
TKGOrdersDatabase = class(TDataModule)
TApiDatabase = class(TDataModule)
ucKG: TUniConnection;
UniQuery1: TUniQuery;
MySQLUniProvider1: TMySQLUniProvider;
......@@ -113,79 +113,35 @@ type
end;
var
KGOrdersDatabase: TKGOrdersDatabase;
ApiDatabase: TApiDatabase;
implementation
uses
uLibrary;
{%CLASSGROUP 'Vcl.Controls.TControl'}
{$R *.dfm}
procedure TKGOrdersDatabase.DataModuleCreate(Sender: TObject);
var
iniFile: TIniFile;
iniStr: string;
procedure TApiDatabase.DataModuleCreate(Sender: TObject);
begin
Logger.Log( 5, 'TKGOrdersDatabase.DataModuleCreate' );
iniFile := TIniFile.Create( ExtractFilePath(Application.ExeName) + 'kgOrdersServer.ini' );
Logger.Log( 3, 'TApiDatabase.DataModuleCreate' );
LoadDatabaseSettings( ucKG, 'kgOrdersServer.ini' );
try
Logger.Log( 5, '--iniFile entries:' );
iniStr := iniFile.ReadString('Database', 'Server', '');
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 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
ucKG.Connect;
except
on E: Exception do
begin
Logger.Log( 5, '----Database->Username: ' + iniStr );
ucKG.Username := iniStr;
Logger.Log(3, '--TApiDatabase.DataModuleCreate -Error connecting to database: ' + E.Message);
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;
class procedure TKGOrdersDatabase.ExecSQL(const SQL: string);
class procedure TApiDatabase.ExecSQL(const SQL: string);
var
DB: TKGOrdersDatabase;
DB: TApiDatabase;
begin
DB := TKGOrdersDatabase.Create(nil);
DB := TApiDatabase.Create(nil);
try
DB.UniQuery1.SQL.Text := SQL;
DB.UniQuery1.ExecSQL;
......
......@@ -2,12 +2,10 @@ object ApiServerModule: TApiServerModule
Height = 273
Width = 230
object SparkleHttpSysDispatcher: TSparkleHttpSysDispatcher
Active = True
Left = 86
Top = 30
end
object XDataServer: TXDataServer
BaseUrl = 'http://localhost:2004/emsys/kgOrders/api/'
Dispatcher = SparkleHttpSysDispatcher
ModelName = 'Api'
EntitySetPermissions = <>
......
......@@ -38,62 +38,16 @@ uses
{$R *.dfm}
procedure TAuthDatabase.DataModuleCreate(Sender: TObject);
var
iniFile: TIniFile;
iniStr: string;
begin
Logger.Log( 5, 'TAuthDatabase.DataModuleCreate' );
iniFile := TIniFile.Create( ExtractFilePath(Application.ExeName) + 'kgOrdersServer.ini' );
Logger.Log( 3, 'TAuthDatabase.DataModuleCreate' );
LoadDatabaseSettings( ucKG, 'kgOrdersServer.ini' );
try
Logger.Log( 5, '--iniFile entries:' );
iniStr := iniFile.ReadString('Database', 'Server', '');
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 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
ucKG.Connect;
except
on E: Exception do
begin
Logger.Log( 5, '----Database->Username: ' + iniStr );
ucKG.Username := iniStr;
Logger.Log(3, '--TAuthDatabase.DataModuleCreate -Error connecting to database: ' + E.Message);
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;
......
......@@ -6,7 +6,6 @@ object AuthServerModule: TAuthServerModule
Top = 16
end
object XDataServer: TXDataServer
BaseUrl = 'http://localhost:2004/emsys/kgOrders/auth/'
Dispatcher = SparkleHttpSysDispatcher
ModelName = 'Auth'
EntitySetPermissions = <>
......
......@@ -14,7 +14,7 @@ uses
BaseGrid, AdvGrid, DBAdvGrid, MemDS, DBAccess, Uni, Vcl.StdCtrls, Vcl.Mask,
vcl.wwdbedit, vcl.wwdotdot, vcl.wwdbcomb, REST.Client, REST.Types, System.JSON,
System.Generics.Collections, AdvEdit, vcl.wwdblook, vcl.wwdbdatetimepicker,
System.Hash;
System.Hash, Api.Database;
type
TFData = class(TForm)
......@@ -39,6 +39,7 @@ type
procedure btnFindClick(Sender: TObject);
procedure btnPDFClick(Sender: TObject);
private
kgDB: TApiDatabase;
accountSID: string;
authHeader: string;
public
......@@ -52,7 +53,7 @@ implementation
{$R *.dfm}
uses KGOrders.Database, uLibrary, rOrders;
uses uLibrary, rOrders;
procedure TFData.btnPDFClick(Sender: TObject);
begin
......@@ -62,7 +63,7 @@ end;
procedure TFData.FormCreate(Sender: TObject);
begin
KGOrdersDatabase := TKGOrdersDatabase.Create(Self);
kgDB := TApiDatabase.Create(Self);
end;
procedure TFData.btnFindClick(Sender: TObject);
......@@ -108,5 +109,4 @@ begin
end;
end.
......@@ -41,7 +41,7 @@ uses
Common.Logging,
Common.Config,
Sparkle.Utils,
KGOrders.Database,
Api.Database,
Data;
{$R *.dfm}
......@@ -110,7 +110,7 @@ begin
try
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', '' );
if iniStr.IsEmpty then
Logger.Log( 1, '--Settings->memoLogLevel: Entry not found - default: 3' )
......@@ -130,11 +130,29 @@ begin
else
Logger.Log( 1, '--Settings->LogFileNum: ' + IntToStr(StrToInt(iniStr) - 1) );
Logger.Log( 1, '' );
iniStr := IniFile.ReadString( 'Database', 'Server', '' );
if iniStr.IsEmpty then
Logger.Log( 1, '--Database->Server: Entry not found' )
else
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, '' );
finally
......@@ -149,6 +167,8 @@ begin
AppServerModule := TAppServerModule.Create(Self);
AppServerModule.StartAppServer( serverConfig.url );
UpdateGUI;
end;
procedure TFMain.FormClose(Sender: TObject; var Action: TCloseAction);
......@@ -160,9 +180,6 @@ begin
end;
procedure TFMain.UpdateGUI;
const
cHttp = 'http://+';
cHttpLocalhost = 'http://localhost';
begin
if AuthServerModule.SparkleHttpSysDispatcher.Active then
memoInfo.Lines.Add( 'AuthServer started at: ' + AuthServerModule.XDataServer.BaseUrl )
......
......@@ -3,7 +3,7 @@ object rptOrders: TrptOrders
Height = 480
Width = 640
object frxOrders: TfrxReport
Version = '2024.2.1'
Version = '2025.1.3'
DotMatrixReport = False
IniFile = '\Software\Fast Reports'
PreviewOptions.Buttons = [pbPrint, pbLoad, pbSave, pbExport, pbZoom, pbFind, pbOutline, pbPageSetup, pbTools, pbEdit, pbNavigator, pbExportQuick, pbCopy, pbSelection]
......@@ -861,18 +861,52 @@ object rptOrders: TrptOrders
Database = 'kg_order_entry'
Username = 'root'
Server = '192.168.102.130'
Connected = True
LoginPrompt = False
Left = 289
Top = 99
EncryptedPassword = '9AFF92FF8CFF86FF8CFFCFFFCEFF'
end
<<<<<<< HEAD
=======
object uqOrders: TUniQuery
Connection = ucKG
SQL.Strings = (
'SELECT '
' 18947 AS ORDER_ID,'
' '#39'B'#39' AS LOCATION,'
' '#39'CHOICE CANNING'#39' AS COMPANY_NAME,'
' '#39'TYOGA CONTAINER'#39' AS JOB_NAME,'
' '#39'2024-12-16'#39' AS ORDER_DATE,'
' '#39'2024-12-03 04:35'#39' AS PROOF_DUE,'
' '#39'2024-11-27 14:17'#39' AS PROOF_DONE,'
' '#39'2024-11-29'#39' AS ART_DUE,'
' '#39'2024-11-26 15:00'#39' AS ART_DONE,'
' '#39'2024-12-02 06:12'#39' AS PLATE_DUE,'
' '#39'2024-12-03 08:58'#39' AS PLATE_DONE,'
' '#39'2024-12-23 08:00'#39' AS MOUNT_DUE,'
' '#39'2024-12-23 15:00'#39' AS MOUNT_DONE,'
' '#39'2024-12-24 08:00'#39' AS SHIP_DUE,'
' '#39'2024-12-24 15:00'#39' AS SHIP_DONE, '
' 323.0 AS PRICE,'
' 1 AS QB_REF_NUM,'
' 3 AS COLORS'
'FROM DUAL'
'')
Left = 415
Top = 136
end
object frxReportTableObject1: TfrxReportTableObject
Left = 300
Top = 312
end
>>>>>>> f1a2333 (clean up code)
object frxDBOrders: TfrxDBDataset
UserName = 'frxDBOrders'
CloseDataSource = False
BCDToCurrency = False
DataSetOptions = []
Left = 424
<<<<<<< HEAD
Top = 238
FieldDefs = <
item
......@@ -959,6 +993,9 @@ object rptOrders: TrptOrders
FieldType = fftString
Size = 4096
end>
=======
Top = 224
>>>>>>> f1a2333 (clean up code)
end
object uqOrders: TUniQuery
Connection = ucKG
......
......@@ -34,6 +34,12 @@ type
uqOrdersQB_REF_NUM: TStringField;
uqOrdersCOLORS: TStringField;
procedure DataModuleCreate(Sender: TObject);
<<<<<<< HEAD
=======
private
>>>>>>> f1a2333 (clean up code)
public
procedure PrepareReport(const SQL: string);
procedure GeneratePDF;
......@@ -44,20 +50,28 @@ var
implementation
uses
uLibrary;
{%CLASSGROUP 'Vcl.Controls.TControl'}
{$R *.dfm}
procedure TrptOrders.DataModuleCreate(Sender: TObject);
var
iniFile: TIniFile;
begin
<<<<<<< HEAD
iniFile := TIniFile.Create(ExtractFilePath(Application.ExeName) + 'kgOrdersServer.ini');
=======
Logger.Log( 3, 'TAuthDatabase.DataModuleCreate' );
LoadDatabaseSettings( ucKG, 'kgOrdersServer.ini' );
>>>>>>> f1a2333 (clean up code)
try
ucKG.Server := iniFile.ReadString('Database', 'Server', '');
ucKG.Connect;
finally
iniFile.Free;
except
on E: Exception do
begin
Logger.Log(3, '--TrptOrders.DataModuleCreate -Error connecting to database: ' + E.Message);
end;
end;
end;
......@@ -87,6 +101,10 @@ begin
Logger.log(5, 'PDF saved to: ' + ReportFileName);
end;
<<<<<<< HEAD
=======
>>>>>>> f1a2333 (clean up code)
end.
end.
......@@ -5,46 +5,43 @@ interface
uses
System.Classes, Uni;
const
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 LoadDatabaseSettings( uc: TUniConnection; iniFilename: string );
procedure DoQuery( uq: TUniQuery; sql: string );
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
uses
System.SysUtils,
System.IniFiles,
Vcl.Forms,
Data.DB;
function GetServerTimeStamp( uq: TUniQuery ): TDateTime;
procedure LoadDatabaseSettings( uc: TUniConnection; iniFilename: string );
var
sql: string;
serverDateTime: TDateTime;
iniFile: TIniFile;
iniStr: string;
begin
sql := 'select sysdate as currentdatetime from dual';
DoQuery( uq, sql );
serverDateTime := uq.FieldByName('CURRENTDATETIME').AsDateTime;
uq.Close;
Result := serverDateTime;
iniFile := TIniFile.Create( ExtractFilePath(Application.ExeName) + iniFilename );
try
iniStr := iniFile.ReadString('Database', 'Server', '');
if not iniStr.IsEmpty then
uc.Server := iniStr;
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;
procedure DoQuery(uq: TUniQuery; sql: string);
......@@ -82,204 +79,5 @@ begin
Result := age
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.
......@@ -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',
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.Config in 'Source\Common.Config.pas',
Auth.Server.Module in 'Source\Auth.Server.Module.pas' {AuthServerModule: TDataModule},
......@@ -38,7 +38,7 @@ type
TFileLogAppender = class( TInterfacedObject, ILogAppender )
private
FLogLevel: Integer;
FFilename: string;
FLogFile: string;
FCriticalSection: TCriticalSection;
public
constructor Create(ALogLevel: Integer; AFilename: string);
......@@ -90,14 +90,18 @@ constructor TFileLogAppender.Create(ALogLevel: integer; AFilename: string);
var
iniFile: TIniFile;
fileNum: integer;
logsDir: string;
begin
FLogLevel := ALogLevel;
FCriticalSection := TCriticalSection.Create;
logsDir := ExtractFilePath(Application.ExeName) + 'logs\';
if not DirectoryExists(logsDir) then
CreateDir(logsDir);
iniFile := TIniFile.Create( ExtractFilePath(Application.ExeName) + 'kgOrdersServer.ini' );
try
fileNum := iniFile.ReadInteger( 'Settings', 'LogFileNum', 0 );
// FFilename := AFilename + Format('%.*d',[4, fileNum]);
FFilename := AFilename + Format('%.4d',[fileNum]);
FLogFile := logsDir + AFilename + Format( '%.4d', [fileNum] ) + '.log';
iniFile.WriteInteger( 'Settings', 'LogFileNum', fileNum + 1 );
finally
iniFile.Free;
......@@ -112,35 +116,33 @@ end;
procedure TFileLogAppender.Send(logLevel: integer; Log: ILog);
var
FormattedMessage: string;
LogFile: string;
LogTime: TDateTime;
LogMsg: string;
FLogFile: TextFile;
formattedMessage: string;
logTime: TDateTime;
logMsg: string;
txtFile: TextFile;
begin
FCriticalSection.Acquire;
try
LogTime := Now;
LogFile := ExtractFilePath(Application.ExeName) + FFilename + '.log';
logTime := Now;
FormattedMessage := FormatDateTime('[yyyy-mm-dd HH:nn:ss.zzz]', LogTime);
LogMsg := Log.GetMessage;
if LogMsg.IsEmpty then
FormattedMessage := ''
formattedMessage := FormatDateTime('[yyyy-mm-dd HH:nn:ss.zzz]', logTime);
logMsg := Log.GetMessage;
if logMsg.IsEmpty then
formattedMessage := ''
else
FormattedMessage := FormattedMessage + '[' + IntToStr(logLevel) +'] ' + LogMsg;
formattedMessage := formattedMessage + '[' + IntToStr(logLevel) +'] ' + logMsg;
try
AssignFile( FLogFile, LogFile );
if FileExists(LogFile) then
Append( FLogFile )
AssignFile( txtFile, FLogFile );
if FileExists(FLogFile) then
Append( txtFile )
else
ReWrite( FLogFile );
ReWrite( txtFile );
if logLevel <= FLogLevel then
WriteLn( FLogFile, FormattedMessage );
WriteLn( txtFile, formattedMessage );
finally
CloseFile(FLogFile);
CloseFile(txtFile);
end;
finally
FCriticalSection.Release;
......
......@@ -133,8 +133,8 @@
<Form>FMain</Form>
</DCCReference>
<DCCReference Include="Source\Common.Logging.pas"/>
<DCCReference Include="Source\KGOrders.Database.pas">
<Form>KGOrdersDatabase</Form>
<DCCReference Include="Source\Api.Database.pas">
<Form>ApiDatabase</Form>
<FormType>dfm</FormType>
<DesignClass>TDataModule</DesignClass>
</DCCReference>
......
[Settings]
MemoLogLevel=5
FileLogLevel=5
LogFileNum=23
LogFileNum=30
webClientVersion=1.0.0
[Database]
--Server=192.168.159.132
Server=192.168.198.131
Server=192.168.60.129
--Server=192.168.75.133
--Database=
--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