Commit 6af57824 by Mac Stephens

updated search, changed dbgrid size

parent 8fba3662
...@@ -42,13 +42,6 @@ __fastcall TfrmMain::TfrmMain(TComponent* Owner) ...@@ -42,13 +42,6 @@ __fastcall TfrmMain::TfrmMain(TComponent* Owner)
for(int i = 0; i < 12; i++) for(int i = 0; i < 12; i++)
dbcbYear->Items->Add(y - 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) void __fastcall TfrmMain::btnExitClick(TObject *Sender)
...@@ -58,18 +51,21 @@ void __fastcall TfrmMain::btnExitClick(TObject *Sender) ...@@ -58,18 +51,21 @@ void __fastcall TfrmMain::btnExitClick(TObject *Sender)
//--------------------------------------------------------------------------- //---------------------------------------------------------------------------
void __fastcall TfrmMain::btnMessagesClick(TObject *Sender) void __fastcall TfrmMain::btnMessagesClick(TObject *Sender)
{ {
String res = BuildMessageRequestURL(); bool saveToDB = cbSaveToDB->Checked;
TJSONValue* jValue; String nextPageUri = BuildMessageRequestURL();
TJSONObject* jObj;
TJSONArray* jaMessages; // Reset grid, pagination, and total message count
String jsonPair; grdData->ClearAll();
grdData->RowCount = 1;
Memo1->Lines->Add("---------------------------------------------------------------"); pagesLoaded = 0;
Memo1->Lines->Add("/Messages.json end point..."); int totalMessages = 0; // Reset total message count
Memo2->Clear();
Memo3->Clear(); if (saveToDB)
Memo2->Lines->Add("Fetching messages to be saved in the database...");
// Create REST client else
Memo2->Lines->Add("Fetching messages from Twilio for AdvGrid...");
do {
TRESTClient* pRESTClient = new TRESTClient(NULL); TRESTClient* pRESTClient = new TRESTClient(NULL);
pRESTClient->BaseURL = "https://api.twilio.com"; pRESTClient->BaseURL = "https://api.twilio.com";
...@@ -80,79 +76,65 @@ void __fastcall TfrmMain::btnMessagesClick(TObject *Sender) ...@@ -80,79 +76,65 @@ void __fastcall TfrmMain::btnMessagesClick(TObject *Sender)
pRESTRequest->Response = pRESTResponse; pRESTRequest->Response = pRESTResponse;
pRESTRequest->Method = rmGET; pRESTRequest->Method = rmGET;
pRESTRequest->Resource = res; pRESTRequest->Resource = nextPageUri;
// Set authorization header
TRESTRequestParameter* param = pRESTRequest->Params->AddItem(); TRESTRequestParameter* param = pRESTRequest->Params->AddItem();
param->Name = "Authorization"; param->Name = "Authorization";
param->Kind = pkHTTPHEADER; param->Kind = pkHTTPHEADER;
param->Options = TRESTRequestParameterOptions() << poDoNotEncode; param->Options = TRESTRequestParameterOptions() << poDoNotEncode;
param->Value = authHeader; param->Value = authHeader;
Memo1->Lines->Add("Messages: " + pRESTRequest->GetFullRequestURL()); Memo1->Lines->Add("Fetching Messages from URI: " + pRESTRequest->GetFullRequestURL());
pRESTRequest->Execute(); pRESTRequest->Execute();
jValue = pRESTResponse->JSONValue; TJSONObject* jObj = dynamic_cast<TJSONObject*>(pRESTResponse->JSONValue);
Memo3->Lines->Add(""); if (!jObj) {
Memo3->Lines->Add("jValue = pRESTResponse->JSONValue;"); Memo1->Lines->Add("No JSON object returned.");
Memo3->Lines->Add("---------------------------------------------------------------------"); break;
Memo3->Lines->Add(jValue->Format(2));
jObj = dynamic_cast<TJSONObject*>(jValue);
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")) if (saveToDB)
txtNextPageUri->Text = jObj->Get("next_page_uri")->JsonValue->Value(); SaveMessagesToDB(jaMessages);
else
txtNextPageUri->Text = "";
jaMessages = dynamic_cast<TJSONArray*>(jObj->GetValue("messages")); pagesLoaded++;
if (jaMessages && jaMessages->Count > 0) totalMessages += jaMessages->Count;
{
Memo2->Lines->Add("jaMessages->Count: " + IntToStr(jaMessages->Count));
GetFieldsFromJsonArray(jaMessages); Memo2->Lines->Add("Loaded page #" + IntToStr(pagesLoaded));
for (int i = 0; i < fieldsList->Count; i++) Memo2->Lines->Add("Messages on this page: " + IntToStr(jaMessages->Count));
{
Memo2->Lines->Add(fieldsList->Strings[i]);
}
LoadJsonArray(jaMessages, "");
Memo2->Lines->Add("grdMessages->Count: " + IntToStr(grdData->RowCount - 1));
pagesLoaded = 1; if (saveToDB)
} Memo2->Lines->Add("Total messages saved to database: " + IntToStr(totalMessages));
else
{
Memo2->Lines->Add("No messages returned.");
grdData->ClearAll();
grdData->RowCount = 1;
}
}
else else
{ Memo2->Lines->Add("Total messages loaded: " + IntToStr(totalMessages));
Memo1->Lines->Add("No JSON object returned.");
}
if (cbSaveToDB->Checked) } else {
{ Memo2->Lines->Add("No messages found on this page.");
SaveMessagesToDB(jaMessages); break;
} }
if (jObj->Get("next_page_uri"))
nextPageUri = jObj->Get("next_page_uri")->JsonValue->Value();
else
nextPageUri = ""; // No more pages
delete pRESTClient; delete pRESTClient;
delete pRESTRequest; delete pRESTRequest;
delete pRESTResponse; delete pRESTResponse;
} while (!nextPageUri.IsEmpty() && nextPageUri != "null");
Memo2->Lines->Add("Get messages complete.");
} }
//--------------------------------------------------------------------------- //---------------------------------------------------------------------------
void TfrmMain::SaveMessagesToDB(TJSONArray* jaMessages) void TfrmMain::SaveMessagesToDB(TJSONArray* jaMessages)
{ {
...@@ -177,16 +159,15 @@ void TfrmMain::SaveMessagesToDB(TJSONArray* jaMessages) ...@@ -177,16 +159,15 @@ void TfrmMain::SaveMessagesToDB(TJSONArray* jaMessages)
uqMessages->Close(); uqMessages->Close();
uqMessages->SQL->Text = "SELECT * FROM public.messages WHERE sid = :sid"; uqMessages->SQL->Text = "SELECT * FROM public.messages WHERE sid = :sid";
uqMessages->ParamByName("sid")->AsString = sid; uqMessages->ParamByName("sid")->AsString = sid;
Memo1->Lines->Add("Checking available fields in uqMessages:");
uqMessages->Open(); uqMessages->Open();
if (uqMessages->IsEmpty()) if (uqMessages->IsEmpty())
{ {
uqMessages->Append(); // Insert new record uqMessages->Append();
} }
else else
{ {
uqMessages->Edit(); // Update existing record uqMessages->Edit();
} }
uqMessages->FieldByName("sid")->AsString = sid; uqMessages->FieldByName("sid")->AsString = sid;
uqMessages->FieldByName("account_sid")->AsString = jso->GetValue("account_sid")->Value(); uqMessages->FieldByName("account_sid")->AsString = jso->GetValue("account_sid")->Value();
...@@ -270,23 +251,38 @@ String TfrmMain::BuildMessageRequestURL() ...@@ -270,23 +251,38 @@ String TfrmMain::BuildMessageRequestURL()
if (hasStartDate || hasEndDate) if (hasStartDate || hasEndDate)
{ {
TDateTime now = Now();
TDateTime d1, d2; TDateTime d1, d2;
if (hasStartDate) d1 = dtpStartDate->Date; if (hasStartDate) d1 = dtpStartDate->Date;
if (hasEndDate) d2 = dtpEndDate->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 (hasStartDate && hasEndDate)
{ {
if (d1 > d2) std::swap(d1, d2); if (d1 == d2)
{
url += "?DateSent=" + FormatDateTime("yyyy-mm-dd", d1);
}
else
{
url += "?DateSent>=" + FormatDateTime("yyyy-mm-dd", d1) + url += "?DateSent>=" + FormatDateTime("yyyy-mm-dd", d1) +
"&DateSent<=" + FormatDateTime("yyyy-mm-dd", d2); "&DateSent<=" + FormatDateTime("yyyy-mm-dd", d2);
} }
}
else if (hasStartDate) else if (hasStartDate)
{ {
url += "?DateSent>=" + FormatDateTime("yyyy-mm-dd", d1); url += "?DateSent=" + FormatDateTime("yyyy-mm-dd", d1);
} }
else if (hasEndDate) 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()) if (!pageSizeStr.IsEmpty())
...@@ -300,21 +296,19 @@ String TfrmMain::BuildMessageRequestURL() ...@@ -300,21 +296,19 @@ String TfrmMain::BuildMessageRequestURL()
return url; return url;
} }
//--------------------------------------------------------------------------- //---------------------------------------------------------------------------
void TfrmMain::GetFieldsFromJsonArray(TJSONArray* jaData) void TfrmMain::GetFieldsFromJsonArray(TJSONArray* jaData)
{ {
String fieldname; String fieldname;
String str; String str;
TJSONObject* jobj;
TJSONObject* jso; TJSONObject* jso;
fieldsList = new TStringList; TJSONArray* ja;
int row;
if(!jaData || jaData->Count == 0)
return;
jso = dynamic_cast<TJSONObject*>(jaData->Items[0]);
if(!jso)
return;
fieldsList = new TStringList;
jso = (TJSONObject*)jaData->Items[0];
for( int i = 0; i < jso->Count; i++ ){ for( int i = 0; i < jso->Count; i++ ){
fieldname = jso->Pairs[i]->JsonString->Value(); fieldname = jso->Pairs[i]->JsonString->Value();
str = fieldname + "=0"; str = fieldname + "=0";
...@@ -324,34 +318,23 @@ void TfrmMain::GetFieldsFromJsonArray(TJSONArray* jaData) ...@@ -324,34 +318,23 @@ void TfrmMain::GetFieldsFromJsonArray(TJSONArray* jaData)
//--------------------------------------------------------------------------- //---------------------------------------------------------------------------
void TfrmMain::LoadJsonArray(TJSONArray* jaData, String detail) void TfrmMain::LoadJsonArray(TJSONArray* jaData, String detail)
{ {
TJSONObject* jobj;
TJSONObject* jso; TJSONObject* jso;
TJSONArray* ja;
int row;
grdData->ClearAll(); grdData->ClearAll();
grdData->RowCount = 1; grdData->RowCount = 1;
grdData->StartUpdate(); grdData->StartUpdate();
jso = (TJSONObject*)jaData->Items[0];
if(!jaData || jaData->Count == 0)
{
grdData->EndUpdate();
return;
}
jso = dynamic_cast<TJSONObject*>(jaData->Items[0]);
if(!jso)
{
grdData->EndUpdate();
return;
}
grdData->ColCount = jso->Count; grdData->ColCount = jso->Count;
for( int e = 0; e < jso->Count; e++ ) for( int e = 0; e < jso->Count; e++ )
grdData->Cells[e+1][0] = jso->Pairs[e]->JsonString->Value(); grdData->Cells[e+1][0] = jso->Pairs[e]->JsonString->Value();
for( int i = 0; i < jaData->Count; i++ ){ for( int i = 0; i < jaData->Count; i++ ){
jso = dynamic_cast<TJSONObject*>(jaData->Items[i]); jso = (TJSONObject*)jaData->Items[i];
if(!jso)
continue;
grdData->RowCount++; grdData->RowCount++;
int row = grdData->RowCount - 1; row = grdData->RowCount - 1;
for( int e = 0; e < jso->Count; e++ ) for( int e = 0; e < jso->Count; e++ )
grdData->Cells[e+1][row] = jso->Pairs[e]->JsonValue->Value(); grdData->Cells[e+1][row] = jso->Pairs[e]->JsonValue->Value();
} }
...@@ -394,110 +377,119 @@ void TfrmMain::SetDatePickersFromMonthYear() ...@@ -394,110 +377,119 @@ void TfrmMain::SetDatePickersFromMonthYear()
{ {
int year = 0; int year = 0;
int month = 0; int month = 0;
TDateTime startDate;
TDateTime endDate;
if(!dbcbYear->Value.IsEmpty()) if( !dbcbYear->Value.IsEmpty() )
year = StrToInt(dbcbYear->Value); year = StrToInt( dbcbYear->Value );
if(!dbcbMonth->Value.IsEmpty()) if( !dbcbMonth->Value.IsEmpty() )
{ month = StrToInt( dbcbMonth->Value );
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(month > 0 && year > 0) if( month > 0 && year > 0 ){
{ startDate = StartOfAMonth( year, month );
TDateTime s = StartOfAMonth(year, month); endDate = EndOfAMonth( year, month );
TDateTime e = EndOfAMonth(year, month); dtpStartDate->Date = startDate;
dtpStartDate->Date = s; dtpEndDate->Date = endDate;
dtpEndDate->Date = e;
} }
else if(year > 0) else if (year > 0){
{ startDate = StartOfAMonth( year, 1 );
TDateTime s = StartOfAMonth(year, 1); endDate = EndOfAMonth( year, 12 );
TDateTime ee = EndOfAMonth(year, 12); dtpStartDate->Date = startDate;
dtpStartDate->Date = s; dtpEndDate->Date = endDate;
dtpEndDate->Date = ee;
} }
} }
//--------------------------------------------------------------------------- //---------------------------------------------------------------------------
void __fastcall TfrmMain::btnNextPageClick(TObject *Sender) void __fastcall TfrmMain::Button1Click(TObject *Sender)
{ {
// Stop if there's no next page URI TDateTime dt;
if (txtNextPageUri->Text.Trim().IsEmpty() || txtNextPageUri->Text == "null")
{
Memo2->Lines->Add("No more pages left to load.");
return;
}
TRESTClient* pRESTClient = new TRESTClient(NULL); dt = ParseTwilioDateTime( "Wed, 12 Feb 2025 18:21:17 +0000" );
pRESTClient->BaseURL = "https://api.twilio.com"; Memo1->Lines->Add( dt.DateTimeString() );
}
//---------------------------------------------------------------------------
void __fastcall TfrmMain::btnDBMessagesClick(TObject *Sender)
{
Memo1->Lines->Add("Fetching messages from the database...");
TRESTRequest* pRESTRequest = new TRESTRequest(NULL); if (!ucTwilioDB->Connected)
pRESTRequest->Client = pRESTClient; ucTwilioDB->Connected = true;
TRESTResponse* pRESTResponse = new TRESTResponse(NULL); bool hasStartDate = !dtpStartDate->Text.IsEmpty();
pRESTRequest->Response = pRESTResponse; 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; if (hasStartDate) startDate = dtpStartDate->Date;
pRESTRequest->Resource = txtNextPageUri->Text; if (hasEndDate) endDate = dtpEndDate->Date;
TRESTRequestParameter* param = pRESTRequest->Params->AddItem(); // **Validation: Ensure Start Date is not more recent than End Date**
param->Name = "Authorization"; if (hasStartDate && hasEndDate && startDate > endDate)
param->Kind = pkHTTPHEADER; {
param->Options = TRESTRequestParameterOptions() << poDoNotEncode; throw Exception("Invalid date range: The start date cannot be more recent than the end date.");
param->Value = authHeader; }
pRESTRequest->Execute(); uqDBMessages->Close();
TJSONObject* jObj = dynamic_cast<TJSONObject*>(pRESTResponse->JSONValue); if (hasStartDate && hasEndDate)
if (!jObj) {
if (startDate == endDate) // **Fix: Handle same start & end date**
{ {
Memo2->Lines->Add("No JSON object returned for next page."); uqDBMessages->SQL->Text =
"SELECT * FROM public.messages "
"WHERE date_sent::DATE = :selectedDate "
"ORDER BY date_sent ASC";
uqDBMessages->ParamByName("selectedDate")->AsDateTime = startDate;
} }
else else
{ {
TJSONArray* jaMessages = dynamic_cast<TJSONArray*>(jObj->GetValue("messages")); uqDBMessages->SQL->Text =
if (jaMessages && jaMessages->Count > 0) "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)
{ {
AppendJsonArray(jaMessages); // Append new messages uqDBMessages->SQL->Text =
pagesLoaded++; "SELECT * FROM public.messages "
Memo2->Lines->Add("Loaded next page (#" + IntToStr(pagesLoaded) + ")."); "WHERE date_sent::DATE = :startDate "
Memo2->Lines->Add("Total messages in grid: " + IntToStr(grdData->RowCount - 1)); "ORDER BY date_sent ASC";
uqDBMessages->ParamByName("startDate")->AsDateTime = startDate;
// Update next_page_uri }
if (jObj->Get("next_page_uri")) else if (hasEndDate)
txtNextPageUri->Text = jObj->Get("next_page_uri")->JsonValue->Value(); {
else uqDBMessages->SQL->Text =
txtNextPageUri->Text = ""; // Stop further pagination "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 else
{ {
Memo2->Lines->Add("No messages in next page."); uqDBMessages->SQL->Text =
"SELECT * FROM public.messages "
"ORDER BY date_sent ASC";
} }
Memo1->Lines->Add("Executing query: " + uqDBMessages->SQL->Text);
uqDBMessages->Open();
if (uqDBMessages->IsEmpty()) {
Memo2->Lines->Add("No messages found for the selected date range.");
return;
} }
delete pRESTClient; Memo2->Lines->Add("Messages retrieved: " + IntToStr(uqDBMessages->RecordCount));
delete pRESTRequest;
delete pRESTResponse;
}
//---------------------------------------------------------------------------
void __fastcall TfrmMain::Button1Click(TObject *Sender)
{
TDateTime dt;
dt = ParseTwilioDateTime( "Wed, 12 Feb 2025 18:21:17 +0000" ); dsMessages->DataSet = uqDBMessages;
Memo1->Lines->Add( dt.DateTimeString() ); dbgrdDatabase->Refresh();
Memo1->Lines->Add("Database messages loaded into grid.");
} }
//--------------------------------------------------------------------------- //---------------------------------------------------------------------------
...@@ -183,7 +183,7 @@ object frmMain: TfrmMain ...@@ -183,7 +183,7 @@ object frmMain: TfrmMain
Version = '4.0.6.0' Version = '4.0.6.0'
end end
object cbSaveToDB: TCheckBox object cbSaveToDB: TCheckBox
Left = 138 Left = 164
Top = 82 Top = 82
Width = 171 Width = 171
Height = 17 Height = 17
...@@ -191,14 +191,57 @@ object frmMain: TfrmMain ...@@ -191,14 +191,57 @@ object frmMain: TfrmMain
TabOrder = 6 TabOrder = 6
end end
object Button1: TButton object Button1: TButton
Left = 440 Left = 820
Top = 76 Top = 39
Width = 139 Width = 139
Height = 25 Height = 25
Caption = 'DateTime Conversion' Caption = 'DateTime Conversion'
TabOrder = 7 TabOrder = 7
OnClick = Button1Click OnClick = Button1Click
end 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 end
object Panel2: TPanel object Panel2: TPanel
Left = 0 Left = 0
...@@ -213,7 +256,7 @@ object frmMain: TfrmMain ...@@ -213,7 +256,7 @@ object frmMain: TfrmMain
Width = 1182 Width = 1182
Height = 267 Height = 267
Align = alClient Align = alClient
ActivePage = AdvOfficePage1 ActivePage = AdvOfficePage2
ButtonSettings.CloseButtonPicture.Data = { ButtonSettings.CloseButtonPicture.Data = {
424DA20400000000000036040000280000000900000009000000010008000000 424DA20400000000000036040000280000000900000009000000010008000000
00006C000000C30E0000C30E00000001000000010000427B8400DEEFEF00FFFF 00006C000000C30E0000C30E00000001000000010000427B8400DEEFEF00FFFF
...@@ -704,6 +747,7 @@ object frmMain: TfrmMain ...@@ -704,6 +747,7 @@ object frmMain: TfrmMain
SortSettings.HeaderMirrorColor = clWhite SortSettings.HeaderMirrorColor = clWhite
SortSettings.HeaderMirrorColorTo = clWhite SortSettings.HeaderMirrorColorTo = clWhite
Version = '9.1.4.1' Version = '9.1.4.1'
ExplicitLeft = 1
ColWidths = ( ColWidths = (
16 16
64 64
...@@ -788,153 +832,20 @@ object frmMain: TfrmMain ...@@ -788,153 +832,20 @@ object frmMain: TfrmMain
TabAppearance.BackGround.Color = clWhite TabAppearance.BackGround.Color = clWhite
TabAppearance.BackGround.ColorTo = clWhite TabAppearance.BackGround.ColorTo = clWhite
TabAppearance.BackGround.Direction = gdHorizontal TabAppearance.BackGround.Direction = gdHorizontal
object grdFields: TAdvStringGrid object dbgrdDatabase: TDBGrid
Left = 2 Left = 2
Top = 2 Top = 2
Width = 1176 Width = 1176
Height = 235 Height = 235
Align = alClient Align = alClient
Ctl3D = True DataSource = dsMessages
DrawingStyle = gdsClassic Options = [dgEditing, dgTitles, dgIndicator, dgColLines, dgRowLines, dgTabs, dgConfirmDelete, dgCancelOnExit, dgTitleClick, dgTitleHotTrack]
FixedColor = clWhite
Options = [goFixedVertLine, goFixedHorzLine, goVertLine, goHorzLine, goColSizing, goEditing, goFixedColClick]
ParentCtl3D = False
TabOrder = 0 TabOrder = 0
ActiveCellFont.Charset = DEFAULT_CHARSET TitleFont.Charset = DEFAULT_CHARSET
ActiveCellFont.Color = 4474440 TitleFont.Color = clWindowText
ActiveCellFont.Height = -11 TitleFont.Height = -12
ActiveCellFont.Name = 'Tahoma' TitleFont.Name = 'Segoe UI'
ActiveCellFont.Style = [fsBold] TitleFont.Style = []
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)
end end
end end
object AdvOfficePage3: TAdvOfficePage object AdvOfficePage3: TAdvOfficePage
...@@ -1238,37 +1149,12 @@ object frmMain: TfrmMain ...@@ -1238,37 +1149,12 @@ object frmMain: TfrmMain
object btnMessages: TButton object btnMessages: TButton
Left = 32 Left = 32
Top = 78 Top = 78
Width = 83 Width = 121
Height = 25 Height = 25
Caption = 'Get Messages' Caption = 'Get Twilio Messages'
TabOrder = 3 TabOrder = 3
OnClick = btnMessagesClick OnClick = btnMessagesClick
end 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 object RESTClient1: TRESTClient
Accept = 'application/json, text/plain; q=0.9, text/html;q=0.8,' Accept = 'application/json, text/plain; q=0.9, text/html;q=0.8,'
AcceptCharset = 'utf-8, *;q=0.8' AcceptCharset = 'utf-8, *;q=0.8'
...@@ -1306,6 +1192,7 @@ object frmMain: TfrmMain ...@@ -1306,6 +1192,7 @@ object frmMain: TfrmMain
Database = 'twilio_db' Database = 'twilio_db'
Username = 'postgres' Username = 'postgres'
Server = '192.168.102.130' Server = '192.168.102.130'
Connected = True
LoginPrompt = False LoginPrompt = False
Left = 562 Left = 562
Top = 169 Top = 169
...@@ -1317,19 +1204,19 @@ object frmMain: TfrmMain ...@@ -1317,19 +1204,19 @@ object frmMain: TfrmMain
'select * from public.messages') 'select * from public.messages')
Left = 676 Left = 676
Top = 169 Top = 169
object uqMessagessid: TMemoField object uqMessagessid: TStringField
FieldName = 'sid' FieldName = 'sid'
Required = True Required = True
BlobType = ftMemo Size = 35
end end
object uqMessagesaccount_sid: TMemoField object uqMessagesaccount_sid: TStringField
FieldName = 'account_sid' FieldName = 'account_sid'
Required = True Required = True
BlobType = ftMemo Size = 35
end end
object uqMessagesapi_version: TMemoField object uqMessagesapi_version: TStringField
FieldName = 'api_version' FieldName = 'api_version'
BlobType = ftMemo Size = 15
end end
object uqMessagesbody: TMemoField object uqMessagesbody: TMemoField
FieldName = 'body' FieldName = 'body'
...@@ -1344,9 +1231,8 @@ object frmMain: TfrmMain ...@@ -1344,9 +1231,8 @@ object frmMain: TfrmMain
object uqMessagesdate_updated: TDateTimeField object uqMessagesdate_updated: TDateTimeField
FieldName = 'date_updated' FieldName = 'date_updated'
end end
object uqMessagesdirection: TMemoField object uqMessagesdirection: TStringField
FieldName = 'direction' FieldName = 'direction'
BlobType = ftMemo
end end
object uqMessageserror_code: TIntegerField object uqMessageserror_code: TIntegerField
FieldName = 'error_code' FieldName = 'error_code'
...@@ -1355,14 +1241,13 @@ object frmMain: TfrmMain ...@@ -1355,14 +1241,13 @@ object frmMain: TfrmMain
FieldName = 'error_message' FieldName = 'error_message'
BlobType = ftMemo BlobType = ftMemo
end end
object uqMessagesfrom_number: TMemoField object uqMessagesfrom_number: TStringField
FieldName = 'from_number' FieldName = 'from_number'
Required = True Required = True
BlobType = ftMemo
end end
object uqMessagesmessaging_service_sid: TMemoField object uqMessagesmessaging_service_sid: TStringField
FieldName = 'messaging_service_sid' FieldName = 'messaging_service_sid'
BlobType = ftMemo Size = 35
end end
object uqMessagesnum_media: TIntegerField object uqMessagesnum_media: TIntegerField
FieldName = 'num_media' FieldName = 'num_media'
...@@ -1373,26 +1258,107 @@ object frmMain: TfrmMain ...@@ -1373,26 +1258,107 @@ object frmMain: TfrmMain
object uqMessagesprice: TFloatField object uqMessagesprice: TFloatField
FieldName = 'price' FieldName = 'price'
end end
object uqMessagesprice_unit: TMemoField object uqMessagesprice_unit: TStringField
FieldName = 'price_unit' FieldName = 'price_unit'
BlobType = ftMemo Size = 5
end end
object uqMessagesstatus: TMemoField object uqMessagesstatus: TStringField
FieldName = 'status' FieldName = 'status'
BlobType = ftMemo Size = 25
end end
object uqMessagesto_number: TMemoField object uqMessagesto_number: TStringField
FieldName = 'to_number' FieldName = 'to_number'
Required = True Required = True
BlobType = ftMemo
end end
object uqMessagesuri: TMemoField object uqMessagesuri: TStringField
FieldName = 'uri' FieldName = 'uri'
BlobType = ftMemo Size = 150
end end
end end
object PostgreSQLUniProvider1: TPostgreSQLUniProvider object PostgreSQLUniProvider1: TPostgreSQLUniProvider
Left = 631 Left = 631
Top = 277 Top = 277
end 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 end
...@@ -44,6 +44,7 @@ ...@@ -44,6 +44,7 @@
#include "vcl.wwdbdatetimepicker.hpp" #include "vcl.wwdbdatetimepicker.hpp"
#include "PostgreSQLUniProvider.hpp" #include "PostgreSQLUniProvider.hpp"
#include "UniProvider.hpp" #include "UniProvider.hpp"
#include <Vcl.DBGrids.hpp>
#include <dinkumware\map> #include <dinkumware\map>
#include <SysUtils.hpp> #include <SysUtils.hpp>
#include <DateUtils.hpp> #include <DateUtils.hpp>
...@@ -70,7 +71,6 @@ __published: // IDE-managed Components ...@@ -70,7 +71,6 @@ __published: // IDE-managed Components
TAdvOfficePage *AdvOfficePage1; TAdvOfficePage *AdvOfficePage1;
TAdvStringGrid *grdData; TAdvStringGrid *grdData;
TAdvOfficePage *AdvOfficePage2; TAdvOfficePage *AdvOfficePage2;
TAdvStringGrid *grdFields;
TAdvOfficePage *AdvOfficePage3; TAdvOfficePage *AdvOfficePage3;
TAdvStringGrid *asgData; TAdvStringGrid *asgData;
TButton *btnMessages; TButton *btnMessages;
...@@ -85,37 +85,59 @@ __published: // IDE-managed Components ...@@ -85,37 +85,59 @@ __published: // IDE-managed Components
TLabel *Label3; TLabel *Label3;
TLabel *Label4; TLabel *Label4;
TLabel *Label5; TLabel *Label5;
TwwDBComboBox *dbcbMonth;
TLabel *Label6; TLabel *Label6;
TButton *btnNextPage;
TCheckBox *cbSaveToDB; TCheckBox *cbSaveToDB;
TPostgreSQLUniProvider *PostgreSQLUniProvider1; TPostgreSQLUniProvider *PostgreSQLUniProvider1;
TMemoField *uqMessagessid; TButton *Button1;
TMemoField *uqMessagesaccount_sid; TDBGrid *dbgrdDatabase;
TMemoField *uqMessagesapi_version; TButton *btnDBMessages;
TDataSource *dsMessages;
TStringField *uqMessagessid;
TStringField *uqMessagesaccount_sid;
TStringField *uqMessagesapi_version;
TMemoField *uqMessagesbody; TMemoField *uqMessagesbody;
TDateTimeField *uqMessagesdate_created; TDateTimeField *uqMessagesdate_created;
TDateTimeField *uqMessagesdate_sent; TDateTimeField *uqMessagesdate_sent;
TDateTimeField *uqMessagesdate_updated; TDateTimeField *uqMessagesdate_updated;
TMemoField *uqMessagesdirection; TStringField *uqMessagesdirection;
TIntegerField *uqMessageserror_code; TIntegerField *uqMessageserror_code;
TMemoField *uqMessageserror_message; TMemoField *uqMessageserror_message;
TMemoField *uqMessagesfrom_number; TStringField *uqMessagesfrom_number;
TMemoField *uqMessagesmessaging_service_sid; TStringField *uqMessagesmessaging_service_sid;
TIntegerField *uqMessagesnum_media; TIntegerField *uqMessagesnum_media;
TIntegerField *uqMessagesnum_segments; TIntegerField *uqMessagesnum_segments;
TFloatField *uqMessagesprice; TFloatField *uqMessagesprice;
TMemoField *uqMessagesprice_unit; TStringField *uqMessagesprice_unit;
TMemoField *uqMessagesstatus; TStringField *uqMessagesstatus;
TMemoField *uqMessagesto_number; TStringField *uqMessagesto_number;
TMemoField *uqMessagesuri; TStringField *uqMessagesuri;
TButton *Button1; 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 btnExitClick(TObject *Sender);
void __fastcall btnMessagesClick(TObject *Sender); void __fastcall btnMessagesClick(TObject *Sender);
void __fastcall dbcbMonthCloseUp(TwwDBComboBox *Sender, bool Select); void __fastcall dbcbMonthCloseUp(TwwDBComboBox *Sender, bool Select);
void __fastcall dbcbYearCloseUp(TwwDBComboBox *Sender, bool Select); void __fastcall dbcbYearCloseUp(TwwDBComboBox *Sender, bool Select);
void __fastcall btnNextPageClick(TObject *Sender);
void __fastcall Button1Click(TObject *Sender); void __fastcall Button1Click(TObject *Sender);
void __fastcall btnDBMessagesClick(TObject *Sender);
private: // User declarations private: // User declarations
String accountSid; String accountSid;
String authHeader; String authHeader;
......
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