Commit 6af57824 by Mac Stephens

updated search, changed dbgrid size

parent 8fba3662
......@@ -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,18 +51,21 @@ void __fastcall TfrmMain::btnExitClick(TObject *Sender)
//---------------------------------------------------------------------------
void __fastcall TfrmMain::btnMessagesClick(TObject *Sender)
{
String res = BuildMessageRequestURL();
TJSONValue* jValue;
TJSONObject* jObj;
TJSONArray* jaMessages;
String jsonPair;
Memo1->Lines->Add("---------------------------------------------------------------");
Memo1->Lines->Add("/Messages.json end point...");
Memo2->Clear();
Memo3->Clear();
// Create REST client
bool saveToDB = cbSaveToDB->Checked;
String nextPageUri = BuildMessageRequestURL();
// Reset grid, pagination, and total message count
grdData->ClearAll();
grdData->RowCount = 1;
pagesLoaded = 0;
int totalMessages = 0; // Reset total message count
if (saveToDB)
Memo2->Lines->Add("Fetching messages to be saved in the database...");
else
Memo2->Lines->Add("Fetching messages from Twilio for AdvGrid...");
do {
TRESTClient* pRESTClient = new TRESTClient(NULL);
pRESTClient->BaseURL = "https://api.twilio.com";
......@@ -80,79 +76,65 @@ void __fastcall TfrmMain::btnMessagesClick(TObject *Sender)
pRESTRequest->Response = pRESTResponse;
pRESTRequest->Method = rmGET;
pRESTRequest->Resource = res;
pRESTRequest->Resource = nextPageUri;
// Set authorization header
TRESTRequestParameter* param = pRESTRequest->Params->AddItem();
param->Name = "Authorization";
param->Kind = pkHTTPHEADER;
param->Options = TRESTRequestParameterOptions() << poDoNotEncode;
param->Value = authHeader;
Memo1->Lines->Add("Messages: " + pRESTRequest->GetFullRequestURL());
Memo1->Lines->Add("Fetching Messages from URI: " + pRESTRequest->GetFullRequestURL());
pRESTRequest->Execute();
jValue = pRESTResponse->JSONValue;
Memo3->Lines->Add("");
Memo3->Lines->Add("jValue = pRESTResponse->JSONValue;");
Memo3->Lines->Add("---------------------------------------------------------------------");
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);
TJSONObject* jObj = dynamic_cast<TJSONObject*>(pRESTResponse->JSONValue);
if (!jObj) {
Memo1->Lines->Add("No JSON object returned.");
break;
}
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;
}
else
{
Memo2->Lines->Add("No messages returned.");
grdData->ClearAll();
grdData->RowCount = 1;
}
}
if (saveToDB)
Memo2->Lines->Add("Total messages saved to database: " + IntToStr(totalMessages));
else
{
Memo1->Lines->Add("No JSON object returned.");
}
Memo2->Lines->Add("Total messages loaded: " + IntToStr(totalMessages));
if (cbSaveToDB->Checked)
{
SaveMessagesToDB(jaMessages);
} 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
nextPageUri = ""; // No more pages
delete pRESTClient;
delete pRESTRequest;
delete pRESTResponse;
} while (!nextPageUri.IsEmpty() && nextPageUri != "null");
Memo2->Lines->Add("Get messages complete.");
}
//---------------------------------------------------------------------------
void TfrmMain::SaveMessagesToDB(TJSONArray* jaMessages)
{
......@@ -177,16 +159,15 @@ void TfrmMain::SaveMessagesToDB(TJSONArray* jaMessages)
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
uqMessages->Append();
}
else
{
uqMessages->Edit(); // Update existing record
uqMessages->Edit();
}
uqMessages->FieldByName("sid")->AsString = sid;
uqMessages->FieldByName("account_sid")->AsString = jso->GetValue("account_sid")->Value();
......@@ -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);
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())
......@@ -300,21 +296,19 @@ String TfrmMain::BuildMessageRequestURL()
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();
}
......@@ -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::btnNextPageClick(TObject *Sender)
void __fastcall TfrmMain::Button1Click(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->Execute();
uqDBMessages->Close();
TJSONObject* jObj = dynamic_cast<TJSONObject*>(pRESTResponse->JSONValue);
if (!jObj)
if (hasStartDate && hasEndDate)
{
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
{
TJSONArray* jaMessages = dynamic_cast<TJSONArray*>(jObj->GetValue("messages"));
if (jaMessages && jaMessages->Count > 0)
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)
{
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
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
{
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;
delete pRESTRequest;
delete pRESTResponse;
}
//---------------------------------------------------------------------------
void __fastcall TfrmMain::Button1Click(TObject *Sender)
{
TDateTime dt;
Memo2->Lines->Add("Messages retrieved: " + IntToStr(uqDBMessages->RecordCount));
dt = ParseTwilioDateTime( "Wed, 12 Feb 2025 18:21:17 +0000" );
Memo1->Lines->Add( dt.DateTimeString() );
dsMessages->DataSet = uqDBMessages;
dbgrdDatabase->Refresh();
Memo1->Lines->Add("Database messages loaded into grid.");
}
//---------------------------------------------------------------------------
......@@ -183,7 +183,7 @@ object frmMain: TfrmMain
Version = '4.0.6.0'
end
object cbSaveToDB: TCheckBox
Left = 138
Left = 164
Top = 82
Width = 171
Height = 17
......@@ -191,14 +191,57 @@ object frmMain: TfrmMain
TabOrder = 6
end
object Button1: TButton
Left = 440
Top = 76
Left = 820
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 = AdvOfficePage1
ActivePage = AdvOfficePage2
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: TAdvStringGrid
object dbgrdDatabase: TDBGrid
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: TMemoField
object uqMessagessid: TStringField
FieldName = 'sid'
Required = True
BlobType = ftMemo
Size = 35
end
object uqMessagesaccount_sid: TMemoField
object uqMessagesaccount_sid: TStringField
FieldName = 'account_sid'
Required = True
BlobType = ftMemo
Size = 35
end
object uqMessagesapi_version: TMemoField
object uqMessagesapi_version: TStringField
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: TMemoField
object uqMessagesdirection: TStringField
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: TMemoField
object uqMessagesfrom_number: TStringField
FieldName = 'from_number'
Required = True
BlobType = ftMemo
end
object uqMessagesmessaging_service_sid: TMemoField
object uqMessagesmessaging_service_sid: TStringField
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: TMemoField
object uqMessagesprice_unit: TStringField
FieldName = 'price_unit'
BlobType = ftMemo
Size = 5
end
object uqMessagesstatus: TMemoField
object uqMessagesstatus: TStringField
FieldName = 'status'
BlobType = ftMemo
Size = 25
end
object uqMessagesto_number: TMemoField
object uqMessagesto_number: TStringField
FieldName = 'to_number'
Required = True
BlobType = ftMemo
end
object uqMessagesuri: TMemoField
object uqMessagesuri: TStringField
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
......@@ -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;
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;
TMemoField *uqMessagesdirection;
TStringField *uqMessagesdirection;
TIntegerField *uqMessageserror_code;
TMemoField *uqMessageserror_message;
TMemoField *uqMessagesfrom_number;
TMemoField *uqMessagesmessaging_service_sid;
TStringField *uqMessagesfrom_number;
TStringField *uqMessagesmessaging_service_sid;
TIntegerField *uqMessagesnum_media;
TIntegerField *uqMessagesnum_segments;
TFloatField *uqMessagesprice;
TMemoField *uqMessagesprice_unit;
TMemoField *uqMessagesstatus;
TMemoField *uqMessagesto_number;
TMemoField *uqMessagesuri;
TButton *Button1;
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;
......
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