Changeset 4 for trunk/UFormCalls.pas
- Timestamp:
- Aug 24, 2019, 12:56:52 PM (5 years ago)
- Location:
- trunk
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk
- Property svn:ignore
-
old new 3 3 __recovery 4 4 __history 5 OdorikApi.dproj.local
-
- Property svn:ignore
-
trunk/UFormCalls.pas
r3 r4 8 8 FMX.ListView.Types, FMX.ListView.Appearances, FMX.ListView.Adapters.Base, 9 9 FMX.ListView, FMX.TabControl, FMX.StdCtrls, FMX.Controls.Presentation, 10 System.DateUtils, System.TimeSpan, System.JSON; 10 System.DateUtils, System.TimeSpan, System.JSON, Generics.Collections, 11 UOdorikApi, FMX.Layouts, FMX.ListBox; 11 12 12 13 type … … 19 20 TabItemActive: TTabItem; 20 21 TabItemStatistics: TTabItem; 21 List View1: TListView;22 ListBox1: TListBox; 22 23 procedure SpeedButtonBackClick(Sender: TObject); 23 24 procedure TabControl1Change(Sender: TObject); … … 50 51 end; 51 52 52 function DateTimeToXMLTime(Value: TDateTime; ApplyLocalBias: Boolean = True): string;53 const54 Neg: array[Boolean] of string = ('+', '-');55 var56 Bias: Integer;57 begin58 Result := FormatDateTime('yyyy''-''mm''-''dd''T''hh'':''nn'':''ss''.''zzz', Value); { Do not localize }59 Bias := Trunc(TTimeZone.Local.GetUtcOffset(Value).TotalMinutes);60 if (Bias <> 0) and ApplyLocalBias then61 begin62 Result := Format('%s%s%.2d:%.2d', [Result, Neg[Bias > 0], { Do not localize }63 Abs(Bias) div MinsPerHour,64 Abs(Bias) mod MinsPerHour]);65 end else66 Result := Result + 'Z'; { Do not localize }67 end;68 69 53 procedure TFormCalls.TabControl1Change(Sender: TObject); 70 54 var 71 Response: string;72 55 IntervalFrom: TDateTime; 73 56 IntervalTo: TDateTime; 74 57 ListViewItem: TListViewItem; 75 Lines: TArray<string>; 76 I: Integer; 77 LJsonResponse: TJSONValue; 78 jv: TJSONValue; 79 joName: TJSONObject; 58 Call: TCall; 59 CallHistory: TList<TCall>; 80 60 begin 81 61 ListView1.Items.Clear; 82 62 IntervalTo := Now; 83 63 IntervalFrom := IntervalTo - OneHour * 24; 84 Response := FormMain.OdorikApi.SendGet('/calls.json', 'from=' + DateTimeToXMLTime(IntervalFrom) + 85 '&to=' + DateTimeToXMLTime(IntervalTo)); 86 LJsonResponse := TJSONObject.ParseJSONValue(Response); 87 for jv in LJsonResponse as TJSONArray do begin 88 joName := jv as TJSONObject; 64 CallHistory := FormMain.OdorikApi.GetCallHistory(IntervalFrom, IntervalTo); 65 for Call in CallHistory do begin 89 66 ListViewItem := ListView1.Items.Add; 90 ListViewItem.Text := joName.Get('source_number').JSONValue.Value;67 ListViewItem.Text := Call.SourceNumber; 91 68 end; 92 69 end;
Note:
See TracChangeset
for help on using the changeset viewer.