Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
T
TwilioMsgs
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
Mac Stephens
TwilioMsgs
Commits
6af57824
Commit
6af57824
authored
Feb 14, 2025
by
Mac Stephens
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
updated search, changed dbgrid size
parent
8fba3662
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
430 additions
and
450 deletions
+430
-450
fMain.cpp
fMain.cpp
+227
-235
fMain.dfm
fMain.dfm
+158
-192
fMain.h
fMain.h
+45
-23
No files found.
fMain.cpp
View file @
6af57824
...
...
@@ -42,13 +42,6 @@ __fastcall TfrmMain::TfrmMain(TComponent* Owner)
for
(
int
i
=
0
;
i
<
12
;
i
++
)
dbcbYear
->
Items
->
Add
(
y
-
i
);
static
String
sMonths
[
12
]
=
{
"January"
,
"February"
,
"March"
,
"April"
,
"May"
,
"June"
,
"July"
,
"August"
,
"September"
,
"October"
,
"November"
,
"December"
};
for
(
int
i
=
0
;
i
<
12
;
i
++
)
dbcbMonth
->
Items
->
Add
(
sMonths
[
i
]);
}
//---------------------------------------------------------------------------
void
__fastcall
TfrmMain
::
btnExitClick
(
TObject
*
Sender
)
...
...
@@ -58,101 +51,90 @@ void __fastcall TfrmMain::btnExitClick(TObject *Sender)
//---------------------------------------------------------------------------
void
__fastcall
TfrmMain
::
btnMessagesClick
(
TObject
*
Sender
)
{
String
res
=
BuildMessageRequestURL
();
TJSONValue
*
jValue
;
TJSONObject
*
jObj
;
TJSONArray
*
jaMessages
;
String
jsonPair
;
bool
saveToDB
=
cbSaveToDB
->
Checked
;
String
nextPageUri
=
BuildMessageRequestURL
();
Memo1
->
Lines
->
Add
(
"---------------------------------------------------------------"
);
Memo1
->
Lines
->
Add
(
"/Messages.json end point..."
);
Memo2
->
Clear
();
Memo3
->
Clear
();
// Reset grid, pagination, and total message count
grdData
->
ClearAll
();
grdData
->
RowCount
=
1
;
pagesLoaded
=
0
;
int
totalMessages
=
0
;
// Reset total message count
// Create REST client
TRESTClient
*
pRESTClient
=
new
TRESTClient
(
NULL
);
pRESTClient
->
BaseURL
=
"https://api.twilio.com"
;
if
(
saveToDB
)
Memo2
->
Lines
->
Add
(
"Fetching messages to be saved in the database..."
);
else
Memo2
->
Lines
->
Add
(
"Fetching messages from Twilio for AdvGrid..."
);
TRESTRequest
*
pRESTRequest
=
new
TRESTRequest
(
NULL
);
pRESTRequest
->
Client
=
pRESTClient
;
do
{
TRESTClient
*
pRESTClient
=
new
TRESTClient
(
NULL
);
pRESTClient
->
BaseURL
=
"https://api.twilio.com"
;
TRESTResponse
*
pRESTResponse
=
new
TRESTResponse
(
NULL
);
pRESTRequest
->
Response
=
pRESTResponse
;
TRESTRequest
*
pRESTRequest
=
new
TRESTRequest
(
NULL
);
pRESTRequest
->
Client
=
pRESTClient
;
pRESTRequest
->
Method
=
rmGET
;
pRESTRequest
->
Resource
=
res
;
TRESTResponse
*
pRESTResponse
=
new
TRESTResponse
(
NULL
)
;
pRESTRequest
->
Response
=
pRESTResponse
;
// Set authorization header
TRESTRequestParameter
*
param
=
pRESTRequest
->
Params
->
AddItem
();
param
->
Name
=
"Authorization"
;
param
->
Kind
=
pkHTTPHEADER
;
param
->
Options
=
TRESTRequestParameterOptions
()
<<
poDoNotEncode
;
param
->
Value
=
authHeader
;
pRESTRequest
->
Method
=
rmGET
;
pRESTRequest
->
Resource
=
nextPageUri
;
Memo1
->
Lines
->
Add
(
"Messages: "
+
pRESTRequest
->
GetFullRequestURL
());
pRESTRequest
->
Execute
();
TRESTRequestParameter
*
param
=
pRESTRequest
->
Params
->
AddItem
();
param
->
Name
=
"Authorization"
;
param
->
Kind
=
pkHTTPHEADER
;
param
->
Options
=
TRESTRequestParameterOptions
()
<<
poDoNotEncode
;
param
->
Value
=
authHeader
;
jValue
=
pRESTResponse
->
JSONValue
;
Memo3
->
Lines
->
Add
(
""
);
Memo3
->
Lines
->
Add
(
"jValue = pRESTResponse->JSONValue;"
);
Memo3
->
Lines
->
Add
(
"---------------------------------------------------------------------"
);
Memo3
->
Lines
->
Add
(
jValue
->
Format
(
2
));
Memo1
->
Lines
->
Add
(
"Fetching Messages from URI: "
+
pRESTRequest
->
GetFullRequestURL
());
pRESTRequest
->
Execute
();
jObj
=
dynamic_cast
<
TJSONObject
*>
(
jValue
);
TJSONObject
*
jObj
=
dynamic_cast
<
TJSONObject
*>
(
pRESTResponse
->
JSONValue
);
if
(
!
jObj
)
{
Memo1
->
Lines
->
Add
(
"No JSON object returned."
);
break
;
}
if
(
jObj
)
{
for
(
int
e
=
0
;
e
<
jObj
->
Count
;
e
++
)
{
if
(
jObj
->
Pairs
[
e
]
->
JsonString
->
Value
()
!=
"messages"
)
{
jsonPair
=
jObj
->
Pairs
[
e
]
->
JsonString
->
Value
();
jsonPair
+=
" : "
+
jObj
->
Pairs
[
e
]
->
JsonValue
->
Value
();
Memo1
->
Lines
->
Add
(
jsonPair
);
TJSONArray
*
jaMessages
=
dynamic_cast
<
TJSONArray
*>
(
jObj
->
GetValue
(
"messages"
));
if
(
jaMessages
&&
jaMessages
->
Count
>
0
)
{
if
(
pagesLoaded
==
0
)
{
GetFieldsFromJsonArray
(
jaMessages
);
LoadJsonArray
(
jaMessages
,
""
);
}
else
{
AppendJsonArray
(
jaMessages
);
}
}
if
(
jObj
->
Get
(
"next_page_uri"
))
txtNextPageUri
->
Text
=
jObj
->
Get
(
"next_page_uri"
)
->
JsonValue
->
Value
();
else
txtNextPageUri
->
Text
=
""
;
if
(
saveToDB
)
SaveMessagesToDB
(
jaMessages
);
jaMessages
=
dynamic_cast
<
TJSONArray
*>
(
jObj
->
GetValue
(
"messages"
));
if
(
jaMessages
&&
jaMessages
->
Count
>
0
)
{
Memo2
->
Lines
->
Add
(
"jaMessages->Count: "
+
IntToStr
(
jaMessages
->
Count
));
pagesLoaded
++
;
totalMessages
+=
jaMessages
->
Count
;
GetFieldsFromJsonArray
(
jaMessages
);
for
(
int
i
=
0
;
i
<
fieldsList
->
Count
;
i
++
)
{
Memo2
->
Lines
->
Add
(
fieldsList
->
Strings
[
i
]);
}
LoadJsonArray
(
jaMessages
,
""
);
Memo2
->
Lines
->
Add
(
"grdMessages->Count: "
+
IntToStr
(
grdData
->
RowCount
-
1
));
Memo2
->
Lines
->
Add
(
"Loaded page #"
+
IntToStr
(
pagesLoaded
));
Memo2
->
Lines
->
Add
(
"Messages on this page: "
+
IntToStr
(
jaMessages
->
Count
));
pagesLoaded
=
1
;
if
(
saveToDB
)
Memo2
->
Lines
->
Add
(
"Total messages saved to database: "
+
IntToStr
(
totalMessages
));
else
Memo2
->
Lines
->
Add
(
"Total messages loaded: "
+
IntToStr
(
totalMessages
));
}
else
{
Memo2
->
Lines
->
Add
(
"No messages found on this page."
);
break
;
}
if
(
jObj
->
Get
(
"next_page_uri"
))
nextPageUri
=
jObj
->
Get
(
"next_page_uri"
)
->
JsonValue
->
Value
();
else
{
Memo2
->
Lines
->
Add
(
"No messages returned."
);
grdData
->
ClearAll
();
grdData
->
RowCount
=
1
;
}
}
else
{
Memo1
->
Lines
->
Add
(
"No JSON object returned."
);
}
nextPageUri
=
""
;
// No more pages
if
(
cbSaveToDB
->
Checked
)
{
SaveMessagesToDB
(
jaMessages
);
}
delete
pRESTClient
;
delete
pRESTRequest
;
delete
pRESTResponse
;
}
while
(
!
nextPageUri
.
IsEmpty
()
&&
nextPageUri
!=
"null"
);
delete
pRESTClient
;
delete
pRESTRequest
;
delete
pRESTResponse
;
Memo2
->
Lines
->
Add
(
"Get messages complete."
);
}
//---------------------------------------------------------------------------
void
TfrmMain
::
SaveMessagesToDB
(
TJSONArray
*
jaMessages
)
{
...
...
@@ -174,48 +156,47 @@ void TfrmMain::SaveMessagesToDB(TJSONArray* jaMessages)
String
sid
=
jso
->
GetValue
(
"sid"
)
->
Value
();
// Check if the message already exists
uqMessages
->
Close
();
uqMessages
->
SQL
->
Text
=
"SELECT * FROM public.messages WHERE sid = :sid"
;
uqMessages
->
ParamByName
(
"sid"
)
->
AsString
=
sid
;
Memo1
->
Lines
->
Add
(
"Checking available fields in uqMessages:"
);
uqMessages
->
Open
();
if
(
uqMessages
->
IsEmpty
())
{
uqMessages
->
Append
();
// Insert new record
}
else
{
uqMessages
->
Edit
();
// Update existing record
}
uqMessages
->
FieldByName
(
"sid"
)
->
AsString
=
sid
;
uqMessages
->
FieldByName
(
"account_sid"
)
->
AsString
=
jso
->
GetValue
(
"account_sid"
)
->
Value
();
uqMessages
->
FieldByName
(
"api_version"
)
->
AsString
=
jso
->
GetValue
(
"api_version"
)
->
Value
();
uqMessages
->
FieldByName
(
"body"
)
->
AsString
=
jso
->
GetValue
(
"body"
)
->
Value
();
uqMessages
->
FieldByName
(
"date_created"
)
->
AsDateTime
=
ParseTwilioDateTime
(
jso
->
GetValue
(
"date_created"
)
->
Value
());
uqMessages
->
FieldByName
(
"date_sent"
)
->
AsDateTime
=
ParseTwilioDateTime
(
jso
->
GetValue
(
"date_sent"
)
->
Value
());
uqMessages
->
FieldByName
(
"date_updated"
)
->
AsDateTime
=
ParseTwilioDateTime
(
jso
->
GetValue
(
"date_updated"
)
->
Value
());
uqMessages
->
FieldByName
(
"direction"
)
->
AsString
=
jso
->
GetValue
(
"direction"
)
->
Value
();
uqMessages
->
FieldByName
(
"error_code"
)
->
AsInteger
=
jso
->
GetValue
(
"error_code"
)
->
Value
().
ToIntDef
(
0
);
uqMessages
->
FieldByName
(
"error_message"
)
->
AsString
=
jso
->
GetValue
(
"error_message"
)
->
Value
();
uqMessages
->
FieldByName
(
"from_number"
)
->
AsString
=
jso
->
GetValue
(
"from"
)
->
Value
();
uqMessages
->
FieldByName
(
"messaging_service_sid"
)
->
AsString
=
jso
->
GetValue
(
"messaging_service_sid"
)
->
Value
();
uqMessages
->
FieldByName
(
"num_media"
)
->
AsInteger
=
jso
->
GetValue
(
"num_media"
)
->
Value
().
ToIntDef
(
0
);
uqMessages
->
FieldByName
(
"num_segments"
)
->
AsInteger
=
jso
->
GetValue
(
"num_segments"
)
->
Value
().
ToIntDef
(
0
);
uqMessages
->
FieldByName
(
"price"
)
->
AsFloat
=
jso
->
GetValue
(
"price"
)
->
Value
().
ToDouble
();
uqMessages
->
FieldByName
(
"price_unit"
)
->
AsString
=
jso
->
GetValue
(
"price_unit"
)
->
Value
();
uqMessages
->
FieldByName
(
"status"
)
->
AsString
=
jso
->
GetValue
(
"status"
)
->
Value
();
uqMessages
->
FieldByName
(
"to_number"
)
->
AsString
=
jso
->
GetValue
(
"to"
)
->
Value
();
uqMessages
->
FieldByName
(
"uri"
)
->
AsString
=
jso
->
GetValue
(
"uri"
)
->
Value
();
uqMessages
->
Post
();
uqMessages
->
Close
();
uqMessages
->
SQL
->
Text
=
"SELECT * FROM public.messages WHERE sid = :sid"
;
uqMessages
->
ParamByName
(
"sid"
)
->
AsString
=
sid
;
uqMessages
->
Open
();
if
(
uqMessages
->
IsEmpty
())
{
uqMessages
->
Append
();
}
else
{
uqMessages
->
Edit
();
}
uqMessages
->
FieldByName
(
"sid"
)
->
AsString
=
sid
;
uqMessages
->
FieldByName
(
"account_sid"
)
->
AsString
=
jso
->
GetValue
(
"account_sid"
)
->
Value
();
uqMessages
->
FieldByName
(
"api_version"
)
->
AsString
=
jso
->
GetValue
(
"api_version"
)
->
Value
();
uqMessages
->
FieldByName
(
"body"
)
->
AsString
=
jso
->
GetValue
(
"body"
)
->
Value
();
uqMessages
->
FieldByName
(
"date_created"
)
->
AsDateTime
=
ParseTwilioDateTime
(
jso
->
GetValue
(
"date_created"
)
->
Value
());
uqMessages
->
FieldByName
(
"date_sent"
)
->
AsDateTime
=
ParseTwilioDateTime
(
jso
->
GetValue
(
"date_sent"
)
->
Value
());
uqMessages
->
FieldByName
(
"date_updated"
)
->
AsDateTime
=
ParseTwilioDateTime
(
jso
->
GetValue
(
"date_updated"
)
->
Value
());
uqMessages
->
FieldByName
(
"direction"
)
->
AsString
=
jso
->
GetValue
(
"direction"
)
->
Value
();
uqMessages
->
FieldByName
(
"error_code"
)
->
AsInteger
=
jso
->
GetValue
(
"error_code"
)
->
Value
().
ToIntDef
(
0
);
uqMessages
->
FieldByName
(
"error_message"
)
->
AsString
=
jso
->
GetValue
(
"error_message"
)
->
Value
();
uqMessages
->
FieldByName
(
"from_number"
)
->
AsString
=
jso
->
GetValue
(
"from"
)
->
Value
();
uqMessages
->
FieldByName
(
"messaging_service_sid"
)
->
AsString
=
jso
->
GetValue
(
"messaging_service_sid"
)
->
Value
();
uqMessages
->
FieldByName
(
"num_media"
)
->
AsInteger
=
jso
->
GetValue
(
"num_media"
)
->
Value
().
ToIntDef
(
0
);
uqMessages
->
FieldByName
(
"num_segments"
)
->
AsInteger
=
jso
->
GetValue
(
"num_segments"
)
->
Value
().
ToIntDef
(
0
);
uqMessages
->
FieldByName
(
"price"
)
->
AsFloat
=
jso
->
GetValue
(
"price"
)
->
Value
().
ToDouble
();
uqMessages
->
FieldByName
(
"price_unit"
)
->
AsString
=
jso
->
GetValue
(
"price_unit"
)
->
Value
();
uqMessages
->
FieldByName
(
"status"
)
->
AsString
=
jso
->
GetValue
(
"status"
)
->
Value
();
uqMessages
->
FieldByName
(
"to_number"
)
->
AsString
=
jso
->
GetValue
(
"to"
)
->
Value
();
uqMessages
->
FieldByName
(
"uri"
)
->
AsString
=
jso
->
GetValue
(
"uri"
)
->
Value
();
uqMessages
->
Post
();
}
}
//---------------------------------------------------------------------------
TDateTime
TfrmMain
::
ParseTwilioDateTime
(
String
dateStr
)
{
// Twilio format: "Wed, 12 Feb 2025 18:21:17 +0000"
std
::
map
<
UnicodeString
,
int
>
monthMap
;
monthMap
[
"Jan"
]
=
1
;
monthMap
[
"Feb"
]
=
2
;
monthMap
[
"Mar"
]
=
3
;
// Twilio format: "Wed, 12 Feb 2025 18:21:17 +0000"
std
::
map
<
UnicodeString
,
int
>
monthMap
;
monthMap
[
"Jan"
]
=
1
;
monthMap
[
"Feb"
]
=
2
;
monthMap
[
"Mar"
]
=
3
;
monthMap
[
"Apr"
]
=
4
;
monthMap
[
"May"
]
=
5
;
monthMap
[
"Jun"
]
=
6
;
monthMap
[
"Jul"
]
=
7
;
monthMap
[
"Aug"
]
=
8
;
monthMap
[
"Sep"
]
=
9
;
monthMap
[
"Oct"
]
=
10
;
monthMap
[
"Nov"
]
=
11
;
monthMap
[
"Dec"
]
=
12
;
...
...
@@ -270,23 +251,38 @@ String TfrmMain::BuildMessageRequestURL()
if
(
hasStartDate
||
hasEndDate
)
{
TDateTime
now
=
Now
();
TDateTime
d1
,
d2
;
if
(
hasStartDate
)
d1
=
dtpStartDate
->
Date
;
if
(
hasEndDate
)
d2
=
dtpEndDate
->
Date
;
if
(
hasStartDate
&&
hasEndDate
&&
d1
>
d2
)
{
throw
Exception
(
"Invalid date range: The start date cannot be more recent than the end date."
);
}
if
(
hasStartDate
&&
hasEndDate
)
{
if
(
d1
>
d2
)
std
::
swap
(
d1
,
d2
);
url
+=
"?DateSent>="
+
FormatDateTime
(
"yyyy-mm-dd"
,
d1
)
+
"&DateSent<="
+
FormatDateTime
(
"yyyy-mm-dd"
,
d2
);
if
(
d1
==
d2
)
{
url
+=
"?DateSent="
+
FormatDateTime
(
"yyyy-mm-dd"
,
d1
);
}
else
{
url
+=
"?DateSent>="
+
FormatDateTime
(
"yyyy-mm-dd"
,
d1
)
+
"&DateSent<="
+
FormatDateTime
(
"yyyy-mm-dd"
,
d2
);
}
}
else
if
(
hasStartDate
)
{
url
+=
"?DateSent
>
="
+
FormatDateTime
(
"yyyy-mm-dd"
,
d1
);
url
+=
"?DateSent="
+
FormatDateTime
(
"yyyy-mm-dd"
,
d1
);
}
else
if
(
hasEndDate
)
{
url
+=
"?DateSent<="
+
FormatDateTime
(
"yyyy-mm-dd"
,
d2
);
TDateTime
oldestAvailable
=
now
-
395
;
// Twilio keeps messages for exactly 395 days
url
+=
"?DateSent>="
+
FormatDateTime
(
"yyyy-mm-dd"
,
oldestAvailable
)
+
"&DateSent<="
+
FormatDateTime
(
"yyyy-mm-dd"
,
d2
);
}
if
(
!
pageSizeStr
.
IsEmpty
())
...
...
@@ -295,26 +291,24 @@ String TfrmMain::BuildMessageRequestURL()
else
{
if
(
!
pageSizeStr
.
IsEmpty
())
url
+=
"?PageSize="
+
pageSizeStr
;
url
+=
"?PageSize="
+
pageSizeStr
;
}
return
url
;
}
//---------------------------------------------------------------------------
void
TfrmMain
::
GetFieldsFromJsonArray
(
TJSONArray
*
jaData
)
{
String
fieldname
;
String
str
;
TJSONObject
*
jobj
;
TJSONObject
*
jso
;
fieldsList
=
new
TStringList
;
if
(
!
jaData
||
jaData
->
Count
==
0
)
return
;
jso
=
dynamic_cast
<
TJSONObject
*>
(
jaData
->
Items
[
0
]);
if
(
!
jso
)
return
;
TJSONArray
*
ja
;
int
row
;
fieldsList
=
new
TStringList
;
jso
=
(
TJSONObject
*
)
jaData
->
Items
[
0
];
for
(
int
i
=
0
;
i
<
jso
->
Count
;
i
++
){
fieldname
=
jso
->
Pairs
[
i
]
->
JsonString
->
Value
();
str
=
fieldname
+
"=0"
;
...
...
@@ -324,34 +318,23 @@ void TfrmMain::GetFieldsFromJsonArray(TJSONArray* jaData)
//---------------------------------------------------------------------------
void
TfrmMain
::
LoadJsonArray
(
TJSONArray
*
jaData
,
String
detail
)
{
TJSONObject
*
jobj
;
TJSONObject
*
jso
;
TJSONArray
*
ja
;
int
row
;
grdData
->
ClearAll
();
grdData
->
RowCount
=
1
;
grdData
->
StartUpdate
();
if
(
!
jaData
||
jaData
->
Count
==
0
)
{
grdData
->
EndUpdate
();
return
;
}
jso
=
dynamic_cast
<
TJSONObject
*>
(
jaData
->
Items
[
0
]);
if
(
!
jso
)
{
grdData
->
EndUpdate
();
return
;
}
jso
=
(
TJSONObject
*
)
jaData
->
Items
[
0
];
grdData
->
ColCount
=
jso
->
Count
;
for
(
int
e
=
0
;
e
<
jso
->
Count
;
e
++
)
grdData
->
Cells
[
e
+
1
][
0
]
=
jso
->
Pairs
[
e
]
->
JsonString
->
Value
();
for
(
int
i
=
0
;
i
<
jaData
->
Count
;
i
++
){
jso
=
dynamic_cast
<
TJSONObject
*>
(
jaData
->
Items
[
i
]);
if
(
!
jso
)
continue
;
jso
=
(
TJSONObject
*
)
jaData
->
Items
[
i
];
grdData
->
RowCount
++
;
int
row
=
grdData
->
RowCount
-
1
;
row
=
grdData
->
RowCount
-
1
;
for
(
int
e
=
0
;
e
<
jso
->
Count
;
e
++
)
grdData
->
Cells
[
e
+
1
][
row
]
=
jso
->
Pairs
[
e
]
->
JsonValue
->
Value
();
}
...
...
@@ -366,7 +349,7 @@ void TfrmMain::AppendJsonArray(TJSONArray* jaData)
grdData
->
BeginUpdate
();
for
(
int
i
=
0
;
i
<
jaData
->
Count
;
i
++
)
{
TJSONObject
*
jso
=
dynamic_cast
<
TJSONObject
*>
(
jaData
->
Items
[
i
]);
TJSONObject
*
jso
=
dynamic_cast
<
TJSONObject
*>
(
jaData
->
Items
[
i
]);
if
(
!
jso
)
continue
;
...
...
@@ -375,7 +358,7 @@ void TfrmMain::AppendJsonArray(TJSONArray* jaData)
for
(
int
e
=
0
;
e
<
jso
->
Count
;
e
++
)
{
grdData
->
Cells
[
e
+
1
][
row
]
=
jso
->
Pairs
[
e
]
->
JsonValue
->
Value
();
}
}
}
grdData
->
EndUpdate
();
}
...
...
@@ -394,110 +377,119 @@ void TfrmMain::SetDatePickersFromMonthYear()
{
int
year
=
0
;
int
month
=
0
;
TDateTime
startDate
;
TDateTime
endDate
;
if
(
!
dbcbYear
->
Value
.
IsEmpty
()
)
year
=
StrToInt
(
dbcbYear
->
Value
);
if
(
!
dbcbYear
->
Value
.
IsEmpty
()
)
year
=
StrToInt
(
dbcbYear
->
Value
);
if
(
!
dbcbMonth
->
Value
.
IsEmpty
())
{
String
selMonth
=
dbcbMonth
->
Value
;
if
(
selMonth
==
"January"
)
month
=
1
;
else
if
(
selMonth
==
"February"
)
month
=
2
;
else
if
(
selMonth
==
"March"
)
month
=
3
;
else
if
(
selMonth
==
"April"
)
month
=
4
;
else
if
(
selMonth
==
"May"
)
month
=
5
;
else
if
(
selMonth
==
"June"
)
month
=
6
;
else
if
(
selMonth
==
"July"
)
month
=
7
;
else
if
(
selMonth
==
"August"
)
month
=
8
;
else
if
(
selMonth
==
"September"
)
month
=
9
;
else
if
(
selMonth
==
"October"
)
month
=
10
;
else
if
(
selMonth
==
"November"
)
month
=
11
;
else
if
(
selMonth
==
"December"
)
month
=
12
;
}
if
(
!
dbcbMonth
->
Value
.
IsEmpty
()
)
month
=
StrToInt
(
dbcbMonth
->
Value
);
if
(
month
>
0
&&
year
>
0
)
{
TDateTime
s
=
StartOfAMonth
(
year
,
month
);
TDateTime
e
=
EndOfAMonth
(
year
,
month
);
dtpStartDate
->
Date
=
s
;
dtpEndDate
->
Date
=
e
;
if
(
month
>
0
&&
year
>
0
){
startDate
=
StartOfAMonth
(
year
,
month
);
endDate
=
EndOfAMonth
(
year
,
month
);
dtpStartDate
->
Date
=
startDate
;
dtpEndDate
->
Date
=
endDate
;
}
else
if
(
year
>
0
)
{
TDateTime
s
=
StartOfAMonth
(
year
,
1
);
TDateTime
ee
=
EndOfAMonth
(
year
,
12
);
dtpStartDate
->
Date
=
s
;
dtpEndDate
->
Date
=
ee
;
else
if
(
year
>
0
){
startDate
=
StartOfAMonth
(
year
,
1
);
endDate
=
EndOfAMonth
(
year
,
12
);
dtpStartDate
->
Date
=
startDate
;
dtpEndDate
->
Date
=
endDate
;
}
}
//---------------------------------------------------------------------------
void
__fastcall
TfrmMain
::
btnNextPage
Click
(
TObject
*
Sender
)
void
__fastcall
TfrmMain
::
Button1
Click
(
TObject
*
Sender
)
{
// Stop if there's no next page URI
if
(
txtNextPageUri
->
Text
.
Trim
().
IsEmpty
()
||
txtNextPageUri
->
Text
==
"null"
)
{
Memo2
->
Lines
->
Add
(
"No more pages left to load."
);
return
;
}
TDateTime
dt
;
TRESTClient
*
pRESTClient
=
new
TRESTClient
(
NULL
);
pRESTClient
->
BaseURL
=
"https://api.twilio.com"
;
dt
=
ParseTwilioDateTime
(
"Wed, 12 Feb 2025 18:21:17 +0000"
);
Memo1
->
Lines
->
Add
(
dt
.
DateTimeString
()
);
}
//---------------------------------------------------------------------------
void
__fastcall
TfrmMain
::
btnDBMessagesClick
(
TObject
*
Sender
)
{
Memo1
->
Lines
->
Add
(
"Fetching messages from the database..."
);
TRESTRequest
*
pRESTRequest
=
new
TRESTRequest
(
NULL
);
pRESTRequest
->
Client
=
pRESTClient
;
if
(
!
ucTwilioDB
->
Connected
)
ucTwilioDB
->
Connected
=
true
;
TRESTResponse
*
pRESTResponse
=
new
TRESTResponse
(
NULL
);
pRESTRequest
->
Response
=
pRESTResponse
;
bool
hasStartDate
=
!
dtpStartDate
->
Text
.
IsEmpty
();
bool
hasEndDate
=
!
dtpEndDate
->
Text
.
IsEmpty
();
TDateTime
startDate
,
endDate
;
TDateTime
now
=
Now
();
TDateTime
oldestAvailable
=
now
-
395
;
// EXACTLY 395 days for Twilio's retention period
pRESTRequest
->
Method
=
rmGET
;
pRESTRequest
->
Resource
=
txtNextPageUri
->
Text
;
if
(
hasStartDate
)
startDate
=
dtpStartDate
->
Date
;
if
(
hasEndDate
)
endDate
=
dtpEndDate
->
Date
;
TRESTRequestParameter
*
param
=
pRESTRequest
->
Params
->
AddItem
();
param
->
Name
=
"Authorization"
;
param
->
Kind
=
pkHTTPHEADER
;
param
->
Options
=
TRESTRequestParameterOptions
()
<<
poDoNotEncode
;
param
->
Value
=
authHeader
;
// **Validation: Ensure Start Date is not more recent than End Date**
if
(
hasStartDate
&&
hasEndDate
&&
startDate
>
endDate
)
{
throw
Exception
(
"Invalid date range: The start date cannot be more recent than the end date."
)
;
}
pRESTRequest
->
Execut
e
();
uqDBMessages
->
Clos
e
();
TJSONObject
*
jObj
=
dynamic_cast
<
TJSONObject
*>
(
pRESTResponse
->
JSONValue
);
if
(
!
jObj
)
if
(
hasStartDate
&&
hasEndDate
)
{
if
(
startDate
==
endDate
)
// **Fix: Handle same start & end date**
{
uqDBMessages
->
SQL
->
Text
=
"SELECT * FROM public.messages "
"WHERE date_sent::DATE = :selectedDate "
"ORDER BY date_sent ASC"
;
uqDBMessages
->
ParamByName
(
"selectedDate"
)
->
AsDateTime
=
startDate
;
}
else
{
uqDBMessages
->
SQL
->
Text
=
"SELECT * FROM public.messages "
"WHERE date_sent::DATE >= :startDate AND date_sent::DATE <= :endDate "
"ORDER BY date_sent ASC"
;
uqDBMessages
->
ParamByName
(
"startDate"
)
->
AsDateTime
=
startDate
;
uqDBMessages
->
ParamByName
(
"endDate"
)
->
AsDateTime
=
endDate
;
}
}
else
if
(
hasStartDate
)
{
Memo2
->
Lines
->
Add
(
"No JSON object returned for next page."
);
uqDBMessages
->
SQL
->
Text
=
"SELECT * FROM public.messages "
"WHERE date_sent::DATE = :startDate "
"ORDER BY date_sent ASC"
;
uqDBMessages
->
ParamByName
(
"startDate"
)
->
AsDateTime
=
startDate
;
}
else
if
(
hasEndDate
)
{
uqDBMessages
->
SQL
->
Text
=
"SELECT * FROM public.messages "
"WHERE date_sent >= :oldestAvailable AND date_sent::DATE <= :endDate "
"ORDER BY date_sent ASC"
;
uqDBMessages
->
ParamByName
(
"oldestAvailable"
)
->
AsDateTime
=
oldestAvailable
;
uqDBMessages
->
ParamByName
(
"endDate"
)
->
AsDateTime
=
endDate
;
}
else
{
TJSONArray
*
jaMessages
=
dynamic_cast
<
TJSONArray
*>
(
jObj
->
GetValue
(
"messages"
));
if
(
jaMessages
&&
jaMessages
->
Count
>
0
)
{
AppendJsonArray
(
jaMessages
);
// Append new messages
pagesLoaded
++
;
Memo2
->
Lines
->
Add
(
"Loaded next page (#"
+
IntToStr
(
pagesLoaded
)
+
")."
);
Memo2
->
Lines
->
Add
(
"Total messages in grid: "
+
IntToStr
(
grdData
->
RowCount
-
1
));
// Update next_page_uri
if
(
jObj
->
Get
(
"next_page_uri"
))
txtNextPageUri
->
Text
=
jObj
->
Get
(
"next_page_uri"
)
->
JsonValue
->
Value
();
else
txtNextPageUri
->
Text
=
""
;
// Stop further pagination
}
else
{
Memo2
->
Lines
->
Add
(
"No messages in next page."
);
}
uqDBMessages
->
SQL
->
Text
=
"SELECT * FROM public.messages "
"ORDER BY date_sent ASC"
;
}
delete
pRESTClient
;
delete
pRESTRequest
;
delete
pRESTResponse
;
}
//---------------------------------------------------------------------------
void
__fastcall
TfrmMain
::
Button1Click
(
TObject
*
Sender
)
{
TDateTime
dt
;
Memo1
->
Lines
->
Add
(
"Executing query: "
+
uqDBMessages
->
SQL
->
Text
);
uqDBMessages
->
Open
();
dt
=
ParseTwilioDateTime
(
"Wed, 12 Feb 2025 18:21:17 +0000"
);
Memo1
->
Lines
->
Add
(
dt
.
DateTimeString
()
);
if
(
uqDBMessages
->
IsEmpty
())
{
Memo2
->
Lines
->
Add
(
"No messages found for the selected date range."
);
return
;
}
Memo2
->
Lines
->
Add
(
"Messages retrieved: "
+
IntToStr
(
uqDBMessages
->
RecordCount
));
dsMessages
->
DataSet
=
uqDBMessages
;
dbgrdDatabase
->
Refresh
();
Memo1
->
Lines
->
Add
(
"Database messages loaded into grid."
);
}
//---------------------------------------------------------------------------
fMain.dfm
View file @
6af57824
...
...
@@ -183,7 +183,7 @@ object frmMain: TfrmMain
Version = '4.0.6.0'
end
object cbSaveToDB: TCheckBox
Left = 1
38
Left = 1
64
Top = 82
Width = 171
Height = 17
...
...
@@ -191,14 +191,57 @@ object frmMain: TfrmMain
TabOrder = 6
end
object Button1: TButton
Left =
44
0
Top =
76
Left =
82
0
Top =
39
Width = 139
Height = 25
Caption = 'DateTime Conversion'
TabOrder = 7
OnClick = Button1Click
end
object btnDBMessages: TButton
Left = 387
Top = 78
Width = 129
Height = 25
Caption = 'Get Database Messages'
TabOrder = 8
OnClick = btnDBMessagesClick
end
object dbcbMonth: TwwDBComboBox
Left = 342
Top = 41
Width = 120
Height = 21
ShowButton = True
Style = csDropDown
MapList = True
AllowClearKey = False
DropDownCount = 12
Font.Charset = DEFAULT_CHARSET
Font.Color = clWindowText
Font.Height = -11
Font.Name = 'Tahoma'
Font.Style = []
ItemHeight = 0
Items.Strings = (
'January'#9'01'
'February'#9'02'
'March'#9'03'
'April'#9'04'
'May'#9'05'
'June'#9'06'
'July'#9'07'
'August'#9'08'
'September'#9'09'
'October'#9'10'
'November'#9'11'
'December'#9'12')
ParentFont = False
Sorted = False
TabOrder = 9
UnboundDataType = wwDefault
end
end
object Panel2: TPanel
Left = 0
...
...
@@ -213,7 +256,7 @@ object frmMain: TfrmMain
Width = 1182
Height = 267
Align = alClient
ActivePage = AdvOfficePage
1
ActivePage = AdvOfficePage
2
ButtonSettings.CloseButtonPicture.Data = {
424DA20400000000000036040000280000000900000009000000010008000000
00006C000000C30E0000C30E00000001000000010000427B8400DEEFEF00FFFF
...
...
@@ -704,6 +747,7 @@ object frmMain: TfrmMain
SortSettings.HeaderMirrorColor = clWhite
SortSettings.HeaderMirrorColorTo = clWhite
Version = '9.1.4.1'
ExplicitLeft = 1
ColWidths = (
16
64
...
...
@@ -788,153 +832,20 @@ object frmMain: TfrmMain
TabAppearance.BackGround.Color = clWhite
TabAppearance.BackGround.ColorTo = clWhite
TabAppearance.BackGround.Direction = gdHorizontal
object
grdFields: TAdvString
Grid
object
dbgrdDatabase: TDB
Grid
Left = 2
Top = 2
Width = 1176
Height = 235
Align = alClient
Ctl3D = True
DrawingStyle = gdsClassic
FixedColor = clWhite
Options = [goFixedVertLine, goFixedHorzLine, goVertLine, goHorzLine, goColSizing, goEditing, goFixedColClick]
ParentCtl3D = False
DataSource = dsMessages
Options = [dgEditing, dgTitles, dgIndicator, dgColLines, dgRowLines, dgTabs, dgConfirmDelete, dgCancelOnExit, dgTitleClick, dgTitleHotTrack]
TabOrder = 0
ActiveCellFont.Charset = DEFAULT_CHARSET
ActiveCellFont.Color = 4474440
ActiveCellFont.Height = -11
ActiveCellFont.Name = 'Tahoma'
ActiveCellFont.Style = [fsBold]
ActiveCellColor = 11565130
ActiveCellColorTo = 11565130
BorderColor = 11250603
ControlLook.FixedGradientFrom = clWhite
ControlLook.FixedGradientTo = clWhite
ControlLook.FixedGradientHoverFrom = clGray
ControlLook.FixedGradientHoverTo = clWhite
ControlLook.FixedGradientHoverMirrorFrom = clWhite
ControlLook.FixedGradientHoverMirrorTo = clWhite
ControlLook.FixedGradientHoverBorder = 11645361
ControlLook.FixedGradientDownFrom = clWhite
ControlLook.FixedGradientDownTo = clWhite
ControlLook.FixedGradientDownMirrorFrom = clWhite
ControlLook.FixedGradientDownMirrorTo = clWhite
ControlLook.FixedGradientDownBorder = 11250603
ControlLook.DropDownHeader.Font.Charset = DEFAULT_CHARSET
ControlLook.DropDownHeader.Font.Color = clWindowText
ControlLook.DropDownHeader.Font.Height = -11
ControlLook.DropDownHeader.Font.Name = 'Tahoma'
ControlLook.DropDownHeader.Font.Style = []
ControlLook.DropDownHeader.Visible = True
ControlLook.DropDownHeader.Buttons = <>
ControlLook.DropDownFooter.Font.Charset = DEFAULT_CHARSET
ControlLook.DropDownFooter.Font.Color = clWindowText
ControlLook.DropDownFooter.Font.Height = -11
ControlLook.DropDownFooter.Font.Name = 'Tahoma'
ControlLook.DropDownFooter.Font.Style = []
ControlLook.DropDownFooter.Visible = True
ControlLook.DropDownFooter.Buttons = <>
ControlLook.ToggleSwitch.BackgroundBorderWidth = 1.000000000000000000
ControlLook.ToggleSwitch.ButtonBorderWidth = 1.000000000000000000
ControlLook.ToggleSwitch.CaptionFont.Charset = DEFAULT_CHARSET
ControlLook.ToggleSwitch.CaptionFont.Color = clWindowText
ControlLook.ToggleSwitch.CaptionFont.Height = -12
ControlLook.ToggleSwitch.CaptionFont.Name = 'Segoe UI'
ControlLook.ToggleSwitch.CaptionFont.Style = []
ControlLook.ToggleSwitch.Shadow = False
Filter = <>
FilterDropDown.Font.Charset = DEFAULT_CHARSET
FilterDropDown.Font.Color = clWindowText
FilterDropDown.Font.Height = -11
FilterDropDown.Font.Name = 'Tahoma'
FilterDropDown.Font.Style = []
FilterDropDown.TextChecked = 'Checked'
FilterDropDown.TextUnChecked = 'Unchecked'
FilterDropDownClear = '(All)'
FilterEdit.TypeNames.Strings = (
'Starts with'
'Ends with'
'Contains'
'Not contains'
'Equal'
'Not equal'
'Larger than'
'Smaller than'
'Clear')
FixedColWidth = 16
FixedRowHeight = 22
FixedRowAlways = True
FixedFont.Charset = DEFAULT_CHARSET
FixedFont.Color = clWindowText
FixedFont.Height = -11
FixedFont.Name = 'Tahoma'
FixedFont.Style = [fsBold]
FloatFormat = '%.2f'
HoverButtons.Buttons = <>
HTMLSettings.ImageFolder = 'images'
HTMLSettings.ImageBaseName = 'img'
Look = glCustom
PrintSettings.DateFormat = 'dd/mm/yyyy'
PrintSettings.Font.Charset = DEFAULT_CHARSET
PrintSettings.Font.Color = clWindowText
PrintSettings.Font.Height = -11
PrintSettings.Font.Name = 'Tahoma'
PrintSettings.Font.Style = []
PrintSettings.FixedFont.Charset = DEFAULT_CHARSET
PrintSettings.FixedFont.Color = clWindowText
PrintSettings.FixedFont.Height = -11
PrintSettings.FixedFont.Name = 'Tahoma'
PrintSettings.FixedFont.Style = []
PrintSettings.HeaderFont.Charset = DEFAULT_CHARSET
PrintSettings.HeaderFont.Color = clWindowText
PrintSettings.HeaderFont.Height = -11
PrintSettings.HeaderFont.Name = 'Tahoma'
PrintSettings.HeaderFont.Style = []
PrintSettings.FooterFont.Charset = DEFAULT_CHARSET
PrintSettings.FooterFont.Color = clWindowText
PrintSettings.FooterFont.Height = -11
PrintSettings.FooterFont.Name = 'Tahoma'
PrintSettings.FooterFont.Style = []
PrintSettings.PageNumSep = '/'
SearchFooter.ColorTo = clNone
SearchFooter.FindNextCaption = 'Find &next'
SearchFooter.FindPrevCaption = 'Find &previous'
SearchFooter.Font.Charset = DEFAULT_CHARSET
SearchFooter.Font.Color = clWindowText
SearchFooter.Font.Height = -11
SearchFooter.Font.Name = 'Tahoma'
SearchFooter.Font.Style = []
SearchFooter.HighLightCaption = 'Highlight'
SearchFooter.HintClose = 'Close'
SearchFooter.HintFindNext = 'Find next occurrence'
SearchFooter.HintFindPrev = 'Find previous occurrence'
SearchFooter.HintHighlight = 'Highlight occurrences'
SearchFooter.MatchCaseCaption = 'Match case'
SearchFooter.ResultFormat = '(%d of %d)'
SelectionColor = 13744549
SelectionTextColor = clWindowText
SortSettings.HeaderColor = clWhite
SortSettings.HeaderColorTo = clWhite
SortSettings.HeaderMirrorColor = clWhite
SortSettings.HeaderMirrorColorTo = clWhite
Version = '9.1.4.1'
ColWidths = (
16
64
64
64
64)
RowHeights = (
22
22
22
22
22
22
22
22
22
22)
TitleFont.Charset = DEFAULT_CHARSET
TitleFont.Color = clWindowText
TitleFont.Height = -12
TitleFont.Name = 'Segoe UI'
TitleFont.Style = []
end
end
object AdvOfficePage3: TAdvOfficePage
...
...
@@ -1238,37 +1149,12 @@ object frmMain: TfrmMain
object btnMessages: TButton
Left = 32
Top = 78
Width =
83
Width =
121
Height = 25
Caption = 'Get Messages'
Caption = 'Get
Twilio
Messages'
TabOrder = 3
OnClick = btnMessagesClick
end
object dbcbMonth: TwwDBComboBox
Left = 342
Top = 40
Width = 123
Height = 23
ShowButton = True
Style = csDropDown
MapList = False
AllowClearKey = False
DropDownCount = 8
ItemHeight = 0
Sorted = False
TabOrder = 4
UnboundDataType = wwDefault
OnCloseUp = dbcbYearCloseUp
end
object btnNextPage: TButton
Left = 780
Top = 39
Width = 83
Height = 25
Caption = 'Next Page'
TabOrder = 5
OnClick = btnNextPageClick
end
object RESTClient1: TRESTClient
Accept = 'application/json, text/plain; q=0.9, text/html;q=0.8,'
AcceptCharset = 'utf-8, *;q=0.8'
...
...
@@ -1306,6 +1192,7 @@ object frmMain: TfrmMain
Database = 'twilio_db'
Username = 'postgres'
Server = '192.168.102.130'
Connected = True
LoginPrompt = False
Left = 562
Top = 169
...
...
@@ -1317,19 +1204,19 @@ object frmMain: TfrmMain
'select * from public.messages')
Left = 676
Top = 169
object uqMessagessid: T
Memo
Field
object uqMessagessid: T
String
Field
FieldName = 'sid'
Required = True
BlobType = ftMemo
Size = 35
end
object uqMessagesaccount_sid: T
Memo
Field
object uqMessagesaccount_sid: T
String
Field
FieldName = 'account_sid'
Required = True
BlobType = ftMemo
Size = 35
end
object uqMessagesapi_version: T
Memo
Field
object uqMessagesapi_version: T
String
Field
FieldName = 'api_version'
BlobType = ftMemo
Size = 15
end
object uqMessagesbody: TMemoField
FieldName = 'body'
...
...
@@ -1344,9 +1231,8 @@ object frmMain: TfrmMain
object uqMessagesdate_updated: TDateTimeField
FieldName = 'date_updated'
end
object uqMessagesdirection: T
Memo
Field
object uqMessagesdirection: T
String
Field
FieldName = 'direction'
BlobType = ftMemo
end
object uqMessageserror_code: TIntegerField
FieldName = 'error_code'
...
...
@@ -1355,14 +1241,13 @@ object frmMain: TfrmMain
FieldName = 'error_message'
BlobType = ftMemo
end
object uqMessagesfrom_number: T
Memo
Field
object uqMessagesfrom_number: T
String
Field
FieldName = 'from_number'
Required = True
BlobType = ftMemo
end
object uqMessagesmessaging_service_sid: T
Memo
Field
object uqMessagesmessaging_service_sid: T
String
Field
FieldName = 'messaging_service_sid'
BlobType = ftMemo
Size = 35
end
object uqMessagesnum_media: TIntegerField
FieldName = 'num_media'
...
...
@@ -1373,26 +1258,107 @@ object frmMain: TfrmMain
object uqMessagesprice: TFloatField
FieldName = 'price'
end
object uqMessagesprice_unit: T
Memo
Field
object uqMessagesprice_unit: T
String
Field
FieldName = 'price_unit'
BlobType = ftMemo
Size = 5
end
object uqMessagesstatus: T
Memo
Field
object uqMessagesstatus: T
String
Field
FieldName = 'status'
BlobType = ftMemo
Size = 25
end
object uqMessagesto_number: T
Memo
Field
object uqMessagesto_number: T
String
Field
FieldName = 'to_number'
Required = True
BlobType = ftMemo
end
object uqMessagesuri: T
Memo
Field
object uqMessagesuri: T
String
Field
FieldName = 'uri'
BlobType = ftMemo
Size = 150
end
end
object PostgreSQLUniProvider1: TPostgreSQLUniProvider
Left = 631
Top = 277
end
object dsMessages: TDataSource
DataSet = uqMessages
Left = 773
Top = 171
end
object uqDBMessages: TUniQuery
Connection = ucTwilioDB
SQL.Strings = (
'select * from public.messages')
Left = 676
Top = 231
object StringField1: TStringField
FieldName = 'sid'
Required = True
Size = 35
end
object StringField2: TStringField
FieldName = 'account_sid'
Required = True
Size = 35
end
object StringField3: TStringField
FieldName = 'api_version'
Size = 15
end
object MemoField1: TMemoField
FieldName = 'body'
BlobType = ftMemo
end
object DateTimeField1: TDateTimeField
FieldName = 'date_created'
end
object DateTimeField2: TDateTimeField
FieldName = 'date_sent'
end
object DateTimeField3: TDateTimeField
FieldName = 'date_updated'
end
object StringField4: TStringField
FieldName = 'direction'
end
object IntegerField1: TIntegerField
FieldName = 'error_code'
end
object MemoField2: TMemoField
FieldName = 'error_message'
BlobType = ftMemo
end
object StringField5: TStringField
FieldName = 'from_number'
Required = True
end
object StringField6: TStringField
FieldName = 'messaging_service_sid'
Size = 35
end
object IntegerField2: TIntegerField
FieldName = 'num_media'
end
object IntegerField3: TIntegerField
FieldName = 'num_segments'
end
object FloatField1: TFloatField
FieldName = 'price'
end
object StringField7: TStringField
FieldName = 'price_unit'
Size = 5
end
object StringField8: TStringField
FieldName = 'status'
Size = 25
end
object StringField9: TStringField
FieldName = 'to_number'
Required = True
end
object StringField10: TStringField
FieldName = 'uri'
Size = 150
end
end
end
fMain.h
View file @
6af57824
...
...
@@ -44,6 +44,7 @@
#include "vcl.wwdbdatetimepicker.hpp"
#include "PostgreSQLUniProvider.hpp"
#include "UniProvider.hpp"
#include <Vcl.DBGrids.hpp>
#include <dinkumware\map>
#include <SysUtils.hpp>
#include <DateUtils.hpp>
...
...
@@ -70,7 +71,6 @@ __published: // IDE-managed Components
TAdvOfficePage
*
AdvOfficePage1
;
TAdvStringGrid
*
grdData
;
TAdvOfficePage
*
AdvOfficePage2
;
TAdvStringGrid
*
grdFields
;
TAdvOfficePage
*
AdvOfficePage3
;
TAdvStringGrid
*
asgData
;
TButton
*
btnMessages
;
...
...
@@ -85,37 +85,59 @@ __published: // IDE-managed Components
TLabel
*
Label3
;
TLabel
*
Label4
;
TLabel
*
Label5
;
TwwDBComboBox
*
dbcbMonth
;
TLabel
*
Label6
;
TButton
*
btnNextPage
;
TCheckBox
*
cbSaveToDB
;
TPostgreSQLUniProvider
*
PostgreSQLUniProvider1
;
TMemoField
*
uqMessagessid
;
TMemoField
*
uqMessagesaccount_sid
;
TMemoField
*
uqMessagesapi_version
;
TMemoField
*
uqMessagesbody
;
TDateTimeField
*
uqMessagesdate_created
;
TDateTimeField
*
uqMessagesdate_sent
;
TDateTimeField
*
uqMessagesdate_updated
;
TMemoField
*
uqMessagesdirection
;
TIntegerField
*
uqMessageserror_code
;
TMemoField
*
uqMessageserror_message
;
TMemoField
*
uqMessagesfrom_number
;
TMemoField
*
uqMessagesmessaging_service_sid
;
TIntegerField
*
uqMessagesnum_media
;
TIntegerField
*
uqMessagesnum_segments
;
TFloatField
*
uqMessagesprice
;
TMemoField
*
uqMessagesprice_unit
;
TMemoField
*
uqMessagesstatus
;
TMemoField
*
uqMessagesto_number
;
TMemoField
*
uqMessagesuri
;
TButton
*
Button1
;
TDBGrid
*
dbgrdDatabase
;
TButton
*
btnDBMessages
;
TDataSource
*
dsMessages
;
TStringField
*
uqMessagessid
;
TStringField
*
uqMessagesaccount_sid
;
TStringField
*
uqMessagesapi_version
;
TMemoField
*
uqMessagesbody
;
TDateTimeField
*
uqMessagesdate_created
;
TDateTimeField
*
uqMessagesdate_sent
;
TDateTimeField
*
uqMessagesdate_updated
;
TStringField
*
uqMessagesdirection
;
TIntegerField
*
uqMessageserror_code
;
TMemoField
*
uqMessageserror_message
;
TStringField
*
uqMessagesfrom_number
;
TStringField
*
uqMessagesmessaging_service_sid
;
TIntegerField
*
uqMessagesnum_media
;
TIntegerField
*
uqMessagesnum_segments
;
TFloatField
*
uqMessagesprice
;
TStringField
*
uqMessagesprice_unit
;
TStringField
*
uqMessagesstatus
;
TStringField
*
uqMessagesto_number
;
TStringField
*
uqMessagesuri
;
TwwDBComboBox
*
dbcbMonth
;
TUniQuery
*
uqDBMessages
;
TStringField
*
StringField1
;
TStringField
*
StringField2
;
TStringField
*
StringField3
;
TMemoField
*
MemoField1
;
TDateTimeField
*
DateTimeField1
;
TDateTimeField
*
DateTimeField2
;
TDateTimeField
*
DateTimeField3
;
TStringField
*
StringField4
;
TIntegerField
*
IntegerField1
;
TMemoField
*
MemoField2
;
TStringField
*
StringField5
;
TStringField
*
StringField6
;
TIntegerField
*
IntegerField2
;
TIntegerField
*
IntegerField3
;
TFloatField
*
FloatField1
;
TStringField
*
StringField7
;
TStringField
*
StringField8
;
TStringField
*
StringField9
;
TStringField
*
StringField10
;
void
__fastcall
btnExitClick
(
TObject
*
Sender
);
void
__fastcall
btnMessagesClick
(
TObject
*
Sender
);
void
__fastcall
dbcbMonthCloseUp
(
TwwDBComboBox
*
Sender
,
bool
Select
);
void
__fastcall
dbcbYearCloseUp
(
TwwDBComboBox
*
Sender
,
bool
Select
);
void
__fastcall
btnNextPageClick
(
TObject
*
Sender
);
void
__fastcall
Button1Click
(
TObject
*
Sender
);
void
__fastcall
btnDBMessagesClick
(
TObject
*
Sender
);
private
:
// User declarations
String
accountSid
;
String
authHeader
;
...
...
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