Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
K
KGOrders
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Cam Hayes
KGOrders
Commits
7c0f2fe8
Commit
7c0f2fe8
authored
Jan 07, 2025
by
Mac Stephens
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fixed memory issues
parent
03dea1fa
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
188 additions
and
86 deletions
+188
-86
Lookup.ServiceImpl.pas
kgOrdersServer/Source/Lookup.ServiceImpl.pas
+183
-52
rOrders.pas
kgOrdersServer/Source/rOrders.pas
+2
-2
uLibrary.pas
kgOrdersServer/Source/uLibrary.pas
+0
-29
kgOrdersServer.ini
kgOrdersServer/kgOrdersServer.ini
+3
-3
No files found.
kgOrdersServer/Source/Lookup.ServiceImpl.pas
View file @
7c0f2fe8
...
@@ -173,16 +173,11 @@ var
...
@@ -173,16 +173,11 @@ var
SQL
:
string
;
SQL
:
string
;
rptOrders
:
TrptOrders
;
// Local instance of rptOrders
rptOrders
:
TrptOrders
;
// Local instance of rptOrders
begin
begin
// Create instance of rptOrders
rptOrders
:=
TrptOrders
.
Create
(
nil
);
rptOrders
:=
TrptOrders
.
Create
(
nil
);
try
try
// Generate SQL dynamically using the existing GetOrders logic
SQL
:=
GenerateOrdersSQL
(
searchOptions
).
SQL
;
SQL
:=
GenerateOrdersSQL
(
searchOptions
).
SQL
;
// Prepare the report dataset
result
:=
rptOrders
.
PrepareReport
(
SQL
);
result
:=
rptOrders
.
PrepareReport
(
SQL
);
// Generate the PDF report
//rptOrders.GeneratePDF;
//rptOrders.GeneratePDF;
// Optionally, log success
// Optionally, log success
...
@@ -389,24 +384,34 @@ begin
...
@@ -389,24 +384,34 @@ begin
result
.
whereSQL
:=
whereSQL
;
result
.
whereSQL
:=
whereSQL
;
end
;
end
;
function
TLookupService
.
g
etColorCount
(
colors
:
string
):
string
;
function
TLookupService
.
G
etColorCount
(
colors
:
string
):
string
;
var
var
colorObject
:
TJSONObject
;
colorObject
:
TJSONObject
;
colorList
:
TJSONArray
;
colorList
:
TJSONArray
;
temp
:
string
;
temp2
:
string
;
begin
begin
if
colors
=
''
then
if
colors
=
''
then
r
esult
:=
'0'
R
esult
:=
'0'
else
else
begin
begin
colorObject
:=
TJSONObject
.
ParseJSONValue
(
colors
)
as
TJSONObject
;
colorObject
:=
TJSONObject
.
ParseJSONValue
(
colors
)
as
TJSONObject
;
colorList
:=
TJSONArray
(
colorObject
.
GetValue
(
'items'
));
try
//temp := colorList.toString;
if
Assigned
(
colorObject
)
then
result
:=
IntToStr
(
colorList
.
Count
);
begin
colorList
:=
colorObject
.
GetValue
<
TJSONArray
>(
'items'
);
if
Assigned
(
colorList
)
then
Result
:=
IntToStr
(
colorList
.
Count
)
else
Result
:=
'0'
;
end
else
Result
:=
'0'
;
finally
colorObject
.
Free
;
end
;
end
;
end
;
end
;
end
;
function
TLookupService
.
GetOrders
(
searchOptions
:
string
):
TOrderList
;
function
TLookupService
.
GetOrders
(
searchOptions
:
string
):
TOrderList
;
var
var
SQL
:
string
;
SQL
:
string
;
...
@@ -414,69 +419,76 @@ var
...
@@ -414,69 +419,76 @@ var
Order
:
TOrderItem
;
Order
:
TOrderItem
;
colors
:
string
;
colors
:
string
;
ColorType
:
string
;
ColorType
:
string
;
SQLArray
:
TArray
<
string
>;
SQLQuery
:
TSQLQuery
;
SQLQuery
:
TSQLQuery
;
begin
begin
SQLQuery
:=
generateOrdersSQL
(
searchOptions
);
SQLQuery
:=
generateOrdersSQL
(
searchOptions
);
TXDataOperationContext
.
Current
.
Handler
.
ManagedObjects
.
Add
(
SQLQuery
);
// Added SQLQuery to ManagedObjects
Result
:=
TOrderList
.
Create
;
try
Result
.
data
:=
TList
<
TOrderItem
>.
Create
;
TXDataOperationContext
.
Current
.
Handler
.
ManagedObjects
.
Add
(
Result
.
data
);
SQL
:=
SQLQuery
.
SQL
;
SQL
:=
SQLQuery
.
SQL
;
whereSQL
:=
SQLQuery
.
whereSQL
;
whereSQL
:=
SQLQuery
.
whereSQL
;
doQuery
(
ordersDB
.
UniQuery1
,
SQL
);
doQuery
(
ordersDB
.
UniQuery1
,
SQL
);
Result
:=
TOrderList
.
Create
;
Result
.
data
:=
TList
<
TOrderItem
>.
Create
;
TXDataOperationContext
.
Current
.
Handler
.
ManagedObjects
.
Add
(
Result
.
data
);
while
not
ordersDB
.
UniQuery1
.
Eof
do
while
not
ordersDB
.
UniQuery1
.
Eof
do
begin
begin
Order
:=
TOrderItem
.
Create
;
Order
:=
TOrderItem
.
Create
;
TXDataOperationContext
.
Current
.
Handler
.
ManagedObjects
.
Add
(
Order
);
TXDataOperationContext
.
Current
.
Handler
.
ManagedObjects
.
Add
(
Order
);
Result
.
data
.
Add
(
Order
);
Result
.
data
.
Add
(
Order
);
order
.
ID
:=
ordersDB
.
UniQuery1
.
FieldByName
(
'ORDER_ID'
).
AsString
;
order
.
companyName
:=
ordersDB
.
UniQuery1
.
FieldByName
(
'COMPANY_NAME'
).
AsString
;
Order
.
ID
:=
ordersDB
.
UniQuery1
.
FieldByName
(
'ORDER_ID'
).
AsString
;
order
.
jobName
:=
ordersDB
.
UniQuery1
.
FieldByName
(
'JOB_NAME'
).
AsString
;
Order
.
companyName
:=
ordersDB
.
UniQuery1
.
FieldByName
(
'COMPANY_NAME'
).
AsString
;
order
.
orderDate
:=
ordersDB
.
UniQuery1
.
FieldByName
(
'ORDER_DATE'
).
AsString
;
Order
.
jobName
:=
ordersDB
.
UniQuery1
.
FieldByName
(
'JOB_NAME'
).
AsString
;
order
.
proofDue
:=
ordersDB
.
UniQuery1
.
FieldByName
(
'PROOF_DUE'
).
AsString
;
Order
.
orderDate
:=
ordersDB
.
UniQuery1
.
FieldByName
(
'ORDER_DATE'
).
AsString
;
order
.
proofDone
:=
ordersDB
.
UniQuery1
.
FieldByName
(
'PROOF_DONE'
).
AsString
;
Order
.
proofDue
:=
ordersDB
.
UniQuery1
.
FieldByName
(
'PROOF_DUE'
).
AsString
;
order
.
artDue
:=
ordersDB
.
UniQuery1
.
FieldByName
(
'ART_DUE'
).
AsString
;
Order
.
proofDone
:=
ordersDB
.
UniQuery1
.
FieldByName
(
'PROOF_DONE'
).
AsString
;
order
.
artDone
:=
ordersDB
.
UniQuery1
.
FieldByName
(
'ART_DONE'
).
AsString
;
Order
.
artDue
:=
ordersDB
.
UniQuery1
.
FieldByName
(
'ART_DUE'
).
AsString
;
order
.
plateDue
:=
ordersDB
.
UniQuery1
.
FieldByName
(
'PLATE_DUE'
).
AsString
;
Order
.
artDone
:=
ordersDB
.
UniQuery1
.
FieldByName
(
'ART_DONE'
).
AsString
;
order
.
plateDone
:=
ordersDB
.
UniQuery1
.
FieldByName
(
'PLATE_DONE'
).
AsString
;
Order
.
plateDue
:=
ordersDB
.
UniQuery1
.
FieldByName
(
'PLATE_DUE'
).
AsString
;
order
.
mountDue
:=
ordersDB
.
UniQuery1
.
FieldByName
(
'MOUNT_DUE'
).
AsString
;
Order
.
plateDone
:=
ordersDB
.
UniQuery1
.
FieldByName
(
'PLATE_DONE'
).
AsString
;
order
.
mountDone
:=
ordersDB
.
UniQuery1
.
FieldByName
(
'MOUNT_DONE'
).
AsString
;
Order
.
mountDue
:=
ordersDB
.
UniQuery1
.
FieldByName
(
'MOUNT_DUE'
).
AsString
;
order
.
shipDue
:=
ordersDB
.
UniQuery1
.
FieldByName
(
'SHIP_DUE'
).
AsString
;
Order
.
mountDone
:=
ordersDB
.
UniQuery1
.
FieldByName
(
'MOUNT_DONE'
).
AsString
;
order
.
shipDone
:=
ordersDB
.
UniQuery1
.
FieldByName
(
'SHIP_DONE'
).
AsString
;
Order
.
shipDue
:=
ordersDB
.
UniQuery1
.
FieldByName
(
'SHIP_DUE'
).
AsString
;
order
.
price
:=
ordersDB
.
UniQuery1
.
FieldByName
(
'PRICE'
).
AsString
;
Order
.
shipDone
:=
ordersDB
.
UniQuery1
.
FieldByName
(
'SHIP_DONE'
).
AsString
;
order
.
qbRefNum
:=
ordersDB
.
UniQuery1
.
FieldByName
(
'QB_REF_NUM'
).
AsString
;
Order
.
price
:=
ordersDB
.
UniQuery1
.
FieldByName
(
'PRICE'
).
AsString
;
order
.
orderType
:=
ordersDB
.
UniQuery1
.
FieldByName
(
'ORDER_TYPE'
).
AsString
.
Replace
(
'_'
,
' '
);
Order
.
qbRefNum
:=
ordersDB
.
UniQuery1
.
FieldByName
(
'QB_REF_NUM'
).
AsString
;
Order
.
orderType
:=
ordersDB
.
UniQuery1
.
FieldByName
(
'ORDER_TYPE'
).
AsString
.
Replace
(
'_'
,
' '
);
if
ordersDB
.
UniQuery1
.
FieldByName
(
'ORDER_TYPE'
).
AsString
=
'web_plate'
then
if
ordersDB
.
UniQuery1
.
FieldByName
(
'ORDER_TYPE'
).
AsString
=
'web_plate'
then
begin
begin
c
olorType
:=
'quantity_and_colors_qty_colors'
;
C
olorType
:=
'quantity_and_colors_qty_colors'
;
SQL
:=
'Select quantity_and_colors_qty_colors from web_plate_orders where order_id = '
+
o
rder
.
ID
;
SQL
:=
'Select quantity_and_colors_qty_colors from web_plate_orders where order_id = '
+
O
rder
.
ID
;
end
end
else
else
begin
begin
c
olorType
:=
'colors_colors'
;
C
olorType
:=
'colors_colors'
;
SQL
:=
'Select colors_colors from corrugated_plate_orders where order_id = '
+
o
rder
.
ID
;
SQL
:=
'Select colors_colors from corrugated_plate_orders where order_id = '
+
O
rder
.
ID
;
end
;
end
;
doQuery
(
ordersDB
.
UniQuery2
,
SQL
);
doQuery
(
ordersDB
.
UniQuery2
,
SQL
);
colors
:=
ordersDB
.
UniQuery2
.
FieldByName
(
ColorType
).
AsString
;
colors
:=
ordersDB
.
UniQuery2
.
FieldByName
(
ColorType
).
AsString
;
order
.
colors
:=
g
etColorCount
(
colors
);
Order
.
colors
:=
G
etColorCount
(
colors
);
ordersDB
.
UniQuery1
.
Next
;
ordersDB
.
UniQuery1
.
Next
;
end
;
end
;
ordersDB
.
UniQuery1
.
Close
;
ordersDB
.
UniQuery1
.
Close
;
SQL
:=
'SELECT COUNT(*) AS total_count '
+
whereSQL
;
SQL
:=
'SELECT COUNT(*) AS total_count '
+
whereSQL
;
doQuery
(
ordersDB
.
UniQuery1
,
SQL
);
doQuery
(
ordersDB
.
UniQuery1
,
SQL
);
Result
.
count
:=
ordersDB
.
UniQuery1
.
FieldByName
(
'total_count'
).
AsInteger
;
Result
.
count
:=
ordersDB
.
UniQuery1
.
FieldByName
(
'total_count'
).
AsInteger
;
ordersDB
.
UniQuery1
.
Close
;
ordersDB
.
UniQuery1
.
Close
;
except
Result
.
Free
;
// Cleaned up memory in case of exceptions
end
;
end
;
end
;
function
TLookupService
.
GetOrder
(
orderInfo
:
string
):
TFullOrder
;
function
TLookupService
.
GetOrder
(
orderInfo
:
string
):
TFullOrder
;
var
var
orderType
:
string
;
orderType
:
string
;
...
@@ -832,23 +844,140 @@ begin
...
@@ -832,23 +844,140 @@ begin
ordersDB
.
UniQuery1
.
Close
;
ordersDB
.
UniQuery1
.
Close
;
end
;
end
;
// -- Keeping this here in case you need to revert to it for some reason.
// -- The new version handles the memory issue on the exception.
//function TLookupService.AddCorrugatedOrder(orderInfo: string): TJSONObject;
//var
// JSONData, ResponseData: TJSONObject;
// SQL: string;
// Pair: TJSONPair;
// Field: TField;
// DateFormat: TFormatSettings;
// ORDER_ID: integer;
// mode: string;
//begin
// DateFormat := TFormatSettings.Create;
// DateFormat.ShortDateFormat := 'yyyy-mm-dd';
// DateFormat.DateSeparator := '-';
// JSONData := TJSONObject.ParseJSONValue(orderInfo) as TJSONObject;
// if JSONData = nil then
// raise Exception.Create('Invalid JSON format'); // If parsing fails, raise an exception
// mode := JSONData.GetValue<string>('mode');
// if mode = 'ADD' then
// SQL := 'select * from corrugated_plate_orders where ORDER_ID = 0 and ORDER_ID <> 0'
// else
// begin
// ORDER_ID := JSONData.GetValue<integer>('ORDER_ID');
// SQL := 'select * from corrugated_plate_orders where ORDER_ID = ' + IntToStr(ORDER_ID);
// end;
// doQuery(ordersDB.UniQuery1, SQL);
// try
// if mode = 'ADD' then
// ordersDB.UniQuery1.Insert
// else
// ordersDB.UniQuery1.Edit;
//
// for Pair in JSONData do
// begin
// Field := ordersDB.UniQuery1.FindField(Pair.JsonString.Value); // Checks if the field exists in the dataset
// if Assigned(Field) then
// begin
// // handles any dates or datetimes
// if (Field is TDateTimeField) and (Pair.JsonValue.Value <> '') then
// TDateTimeField(Field).AsDateTime := StrToDate(Pair.JsonValue.Value)
// else if Pair.JsonValue.Value <> '' then
// Field.AsString := Pair.JsonValue.Value;
// end;
// end;
//
// // Post the record to the database
// ordersDB.UniQuery1.Post;
//
// if mode = 'ADD' then
// begin
// SQL := 'select * from orders where ORDER_ID = 0 and ORDER_ID <> 0';
// doQuery(ordersDB.UniQuery1, SQL);
// ordersDB.UniQuery1.Insert;
// end
// else
// begin
// SQL := 'select * from orders where ORDER_ID = ' + IntToStr(ORDER_ID);
// doQuery(ordersDB.UniQuery1, SQL);
// end;
//
// ordersDB.UniQuery1.FieldByName('COMPANY_ID').AsString := JSONData.GetValue<string>('COMPANY_ID');
// ordersDB.UniQuery1.FieldByName('ORDER_TYPE').AsString := 'corrugated_plate';
//
// if mode = 'ADD' then
// ordersDB.UniQuery1.FieldByName('ORDER_DATE').AsDateTime := Now;
//
// if JSONData.GetValue<string>('staff_fields_price') = '' then
// ordersDB.UniQuery1.FieldByName('PRICE').AsString := '0'
// else
// ordersDB.UniQuery1.FieldByName('PRICE').AsString := JSONData.GetValue<string>('staff_fields_price');
//
// ordersDB.UniQuery1.FieldByName('JOB_NAME').AsString := JSONData.GetValue<string>('staff_fields_job_name');
// ordersDB.UniQuery1.FieldByName('USER_ID').AsString := JSONData.GetValue<string>('USER_ID');
// ordersDB.UniQuery1.FieldByName('LOCATION').AsString := JSONData.GetValue<string>('staff_fields_art_location');
//
// ordersDB.UniQuery1.Post;
//
// ordersDB.UniQuery1.Close;
// if mode = 'ADD' then
// begin
// ordersDB.UniQuery1.SQL.Text := 'SELECT LAST_INSERT_ID() AS OrderID'; // Use database's method to get the last inserted ID
// ordersDB.UniQuery1.Open;
// ORDER_ID := ordersDB.UniQuery1.FieldByName('OrderID').AsInteger;
// end;
//
// if JSONData.GetValue<string>('staff_fields_proof_date') <> '' then
// AddStatusSchedule('PROOF', JSONData, ORDER_ID);
// if JSONData.GetValue<string>('staff_fields_ship_date') <> '' then
// AddStatusSchedule('SHIP', JSONData, ORDER_ID);
// if JSONData.GetValue<string>('staff_fields_art_due') <> '' then
// AddStatusSchedule('ART', JSONData, ORDER_ID);
// if JSONData.GetValue<string>('staff_fields_plate_due') <> '' then
// AddStatusSchedule('PLATE', JSONData, ORDER_ID);
// if JSONData.GetValue<string>('staff_fields_mount_due') <> '' then
// AddStatusSchedule('MOUNT', JSONData, ORDER_ID);
//
// Result := TJSONObject.Create.AddPair('status', 'success');
// TXDataOperationContext.Current.Handler.ManagedObjects.Add(Result);
// except
// on E: Exception do
// begin
// Result := TJSONObject.Create.AddPair('error', E.Message);
// end;
// end;
//end;
function
TLookupService
.
AddCorrugatedOrder
(
orderInfo
:
string
):
TJSONObject
;
function
TLookupService
.
AddCorrugatedOrder
(
orderInfo
:
string
):
TJSONObject
;
var
var
JSONData
,
ResponseData
:
TJSONObject
;
JSONData
:
TJSONObject
;
SQL
:
string
;
SQL
:
string
;
Pair
:
TJSONPair
;
Pair
:
TJSONPair
;
Field
:
TField
;
Field
:
TField
;
DateFormat
:
TFormatSettings
;
DateFormat
:
TFormatSettings
;
CurrDate
:
TDateTime
;
ORDER_ID
:
integer
;
ORDER_ID
:
integer
;
mode
:
string
;
mode
:
string
;
begin
begin
DateFormat
:=
TFormatSettings
.
Create
;
DateFormat
:=
TFormatSettings
.
Create
;
DateFormat
.
ShortDateFormat
:=
'yyyy-mm-dd'
;
DateFormat
.
ShortDateFormat
:=
'yyyy-mm-dd'
;
DateFormat
.
DateSeparator
:=
'-'
;
DateFormat
.
DateSeparator
:=
'-'
;
// Initialize Result object and add it to ManagedObjects upfront
Result
:=
TJSONObject
.
Create
;
TXDataOperationContext
.
Current
.
Handler
.
ManagedObjects
.
Add
(
Result
);
JSONData
:=
TJSONObject
.
ParseJSONValue
(
orderInfo
)
as
TJSONObject
;
JSONData
:=
TJSONObject
.
ParseJSONValue
(
orderInfo
)
as
TJSONObject
;
if
JSONData
=
nil
then
if
JSONData
=
nil
then
raise
Exception
.
Create
(
'Invalid JSON format'
);
// If parsing fails, raise an exception
begin
Result
.
AddPair
(
'error'
,
'Invalid JSON format'
);
// Populate error in Result
Exit
;
end
;
mode
:=
JSONData
.
GetValue
<
string
>(
'mode'
);
mode
:=
JSONData
.
GetValue
<
string
>(
'mode'
);
if
mode
=
'ADD'
then
if
mode
=
'ADD'
then
SQL
:=
'select * from corrugated_plate_orders where ORDER_ID = 0 and ORDER_ID <> 0'
SQL
:=
'select * from corrugated_plate_orders where ORDER_ID = 0 and ORDER_ID <> 0'
...
@@ -857,8 +986,10 @@ begin
...
@@ -857,8 +986,10 @@ begin
ORDER_ID
:=
JSONData
.
GetValue
<
integer
>(
'ORDER_ID'
);
ORDER_ID
:=
JSONData
.
GetValue
<
integer
>(
'ORDER_ID'
);
SQL
:=
'select * from corrugated_plate_orders where ORDER_ID = '
+
IntToStr
(
ORDER_ID
);
SQL
:=
'select * from corrugated_plate_orders where ORDER_ID = '
+
IntToStr
(
ORDER_ID
);
end
;
end
;
doQuery
(
ordersDB
.
UniQuery1
,
SQL
);
try
try
doQuery
(
ordersDB
.
UniQuery1
,
SQL
);
if
mode
=
'ADD'
then
if
mode
=
'ADD'
then
ordersDB
.
UniQuery1
.
Insert
ordersDB
.
UniQuery1
.
Insert
else
else
...
@@ -866,18 +997,16 @@ begin
...
@@ -866,18 +997,16 @@ begin
for
Pair
in
JSONData
do
for
Pair
in
JSONData
do
begin
begin
Field
:=
ordersDB
.
UniQuery1
.
FindField
(
Pair
.
JsonString
.
Value
);
// Checks if the field exists in the dataset
Field
:=
ordersDB
.
UniQuery1
.
FindField
(
Pair
.
JsonString
.
Value
);
if
Assigned
(
Field
)
then
if
Assigned
(
Field
)
then
begin
begin
// handles any dates or datetimes
if
(
Field
is
TDateTimeField
)
and
(
Pair
.
JsonValue
.
Value
<>
''
)
then
if
(
Field
is
TDateTimeField
)
and
(
Pair
.
JsonValue
.
Value
<>
''
)
then
TDateTimeField
(
Field
).
AsDateTime
:=
StrToDate
(
Pair
.
JsonValue
.
Value
)
TDateTimeField
(
Field
).
AsDateTime
:=
StrToDate
(
Pair
.
JsonValue
.
Value
,
DateFormat
)
else
if
Pair
.
JsonValue
.
Value
<>
''
then
else
if
Pair
.
JsonValue
.
Value
<>
''
then
Field
.
AsString
:=
Pair
.
JsonValue
.
Value
;
Field
.
AsString
:=
Pair
.
JsonValue
.
Value
;
end
;
end
;
end
;
end
;
// Post the record to the database
ordersDB
.
UniQuery1
.
Post
;
ordersDB
.
UniQuery1
.
Post
;
if
mode
=
'ADD'
then
if
mode
=
'ADD'
then
...
@@ -910,6 +1039,7 @@ begin
...
@@ -910,6 +1039,7 @@ begin
ordersDB
.
UniQuery1
.
Post
;
ordersDB
.
UniQuery1
.
Post
;
ordersDB
.
UniQuery1
.
Close
;
ordersDB
.
UniQuery1
.
Close
;
if
mode
=
'ADD'
then
if
mode
=
'ADD'
then
begin
begin
ordersDB
.
UniQuery1
.
SQL
.
Text
:=
'SELECT LAST_INSERT_ID() AS OrderID'
;
// Use database's method to get the last inserted ID
ordersDB
.
UniQuery1
.
SQL
.
Text
:=
'SELECT LAST_INSERT_ID() AS OrderID'
;
// Use database's method to get the last inserted ID
...
@@ -928,16 +1058,17 @@ begin
...
@@ -928,16 +1058,17 @@ begin
if
JSONData
.
GetValue
<
string
>(
'staff_fields_mount_due'
)
<>
''
then
if
JSONData
.
GetValue
<
string
>(
'staff_fields_mount_due'
)
<>
''
then
AddStatusSchedule
(
'MOUNT'
,
JSONData
,
ORDER_ID
);
AddStatusSchedule
(
'MOUNT'
,
JSONData
,
ORDER_ID
);
Result
:=
TJSONObject
.
Create
.
AddPair
(
'status'
,
'success'
);
// Updated so an object isn't being created in the exception for memory control
TXDataOperationContext
.
Current
.
Handler
.
ManagedObjects
.
Add
(
Result
);
Result
.
AddPair
(
'status'
,
'success'
);
except
except
on
E
:
Exception
do
on
E
:
Exception
do
begin
begin
Result
:=
TJSONObject
.
Create
.
AddPair
(
'error'
,
E
.
Message
);
Result
.
AddPair
(
'error'
,
E
.
Message
);
end
;
end
;
end
;
end
;
end
;
end
;
function
TLookupService
.
AddStatusSchedule
(
StatusType
:
string
;
order
:
TJSONObject
;
ORDER_ID
:
integer
):
string
;
function
TLookupService
.
AddStatusSchedule
(
StatusType
:
string
;
order
:
TJSONObject
;
ORDER_ID
:
integer
):
string
;
var
var
SQL
:
string
;
SQL
:
string
;
...
...
kgOrdersServer/Source/rOrders.pas
View file @
7c0f2fe8
...
@@ -133,7 +133,7 @@ begin
...
@@ -133,7 +133,7 @@ begin
colorList
:=
TJSONArray
(
colorObject
.
GetValue
(
'items'
));
colorList
:=
TJSONArray
(
colorObject
.
GetValue
(
'items'
));
result
:=
IntToStr
(
colorList
.
Count
);
result
:=
IntToStr
(
colorList
.
Count
);
finally
finally
colorObject
.
Free
;
// Free TJSONObject to avoid leaks
colorObject
.
Free
;
end
;
end
;
end
;
end
;
end
;
end
;
...
@@ -161,7 +161,7 @@ begin
...
@@ -161,7 +161,7 @@ begin
frxOrders
.
Export
(
frxPDFExport1
);
frxOrders
.
Export
(
frxPDFExport1
);
//frxOrders.ShowPreparedReport;
//frxOrders.ShowPreparedReport;
finally
finally
frxOrders
.
Clear
;
// Clear
the report to avoid memory bloat
frxOrders
.
Clear
;
// Clears
the report to avoid memory bloat
end
;
end
;
Logger
.
Log
(
5
,
'PDF saved to: '
+
ReportFileName
);
Logger
.
Log
(
5
,
'PDF saved to: '
+
ReportFileName
);
...
...
kgOrdersServer/Source/uLibrary.pas
View file @
7c0f2fe8
...
@@ -7,7 +7,6 @@ uses
...
@@ -7,7 +7,6 @@ uses
procedure
LoadDatabaseSettings
(
uc
:
TUniConnection
;
iniFilename
:
string
);
procedure
LoadDatabaseSettings
(
uc
:
TUniConnection
;
iniFilename
:
string
);
procedure
DoQuery
(
uq
:
TUniQuery
;
sql
:
string
);
procedure
DoQuery
(
uq
:
TUniQuery
;
sql
:
string
);
function
CalculateAge
(
const
dob
,
dt
:
TDateTime
):
Integer
;
implementation
implementation
...
@@ -39,33 +38,5 @@ begin
...
@@ -39,33 +38,5 @@ begin
uq
.
Open
;
uq
.
Open
;
end
;
end
;
function
CalculateAge
(
const
dob
,
dt
:
TDateTime
):
Integer
;
var
age
:
Integer
;
y1
,
m1
,
d1
,
y2
,
m2
,
d2
:
Word
;
begin
Result
:=
0
;
if
dt
<
dob
then
Exit
;
DecodeDate
(
dob
,
y1
,
m1
,
d1
);
DecodeDate
(
dt
,
y2
,
m2
,
d2
);
age
:=
y2
-
y1
;
// Feb 29
//if ( (m1=2) and (d1=29) ) and ( not IsLeapYear(y2) ) then
// d1 := 28;
if
(
m1
=
2
)
and
(
d1
=
29
)
and
(
not
(
IsLeapYear
(
y2
)))
then
begin
m1
:=
3
;
d1
:=
1
;
end
;
if
(
m2
<
m1
)
or
((
m2
=
m1
)
and
(
d2
<
d1
))
then
Dec
(
age
);
Result
:=
age
end
;
end
.
end
.
kgOrdersServer/kgOrdersServer.ini
View file @
7c0f2fe8
[Settings]
[Settings]
MemoLogLevel
=
4
MemoLogLevel
=
4
FileLogLevel
=
5
FileLogLevel
=
5
LogFileNum
=
71
LogFileNum
=
90
webClientVersion
=
1.0.0
webClientVersion
=
1.0.0
[Database]
[Database]
Server
=
192.168.159.132
--
Server
=
192.168.159.132
--
Server
=
192.168.102.130
Server
=
192.168.102.130
--Server
=
192.168.75.133
--Server
=
192.168.75.133
--Database
=
--Database
=
--Username
=
--Username
=
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment