- Timestamp:
- Mar 14, 2013, 9:24:41 PM (12 years ago)
- Location:
- trunk
- Files:
-
- 78 added
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/FioInfo.lpi
r3 r6 27 27 <SearchPaths> 28 28 <IncludeFiles Value="$(ProjOutDir)"/> 29 <OtherUnitFiles Value="Forms"/> 29 30 <UnitOutputDirectory Value="lib/$(TargetCPU)-$(TargetOS)"/> 30 31 </SearchPaths> 32 <Parsing> 33 <SyntaxOptions> 34 <SyntaxMode Value="Delphi"/> 35 <CStyleOperator Value="False"/> 36 <AllowLabel Value="False"/> 37 <CPPInline Value="False"/> 38 </SyntaxOptions> 39 </Parsing> 40 <CodeGeneration> 41 <Checks> 42 <IOChecks Value="True"/> 43 <RangeChecks Value="True"/> 44 <OverflowChecks Value="True"/> 45 <StackChecks Value="True"/> 46 </Checks> 47 <VerifyObjMethodCallValidity Value="True"/> 48 </CodeGeneration> 31 49 <Linking> 50 <Debugging> 51 <UseHeaptrc Value="True"/> 52 <UseExternalDbgSyms Value="True"/> 53 </Debugging> 32 54 <Options> 33 55 <Win32> … … 56 78 </local> 57 79 </RunParams> 58 <RequiredPackages Count=" 2">80 <RequiredPackages Count="4"> 59 81 <Item1> 82 <PackageName Value="TemplateGenerics"/> 83 <DefaultFilename Value="Packages/TemplateGenerics/TemplateGenerics.lpk" Prefer="True"/> 84 </Item1> 85 <Item2> 86 <PackageName Value="Common"/> 87 <DefaultFilename Value="Packages/Common/Common.lpk" Prefer="True"/> 88 </Item2> 89 <Item3> 60 90 <PackageName Value="laz_synapse"/> 61 91 <DefaultFilename Value="Packages/synapse/source/lib/laz_synapse.lpk" Prefer="True"/> 62 </Item 1>63 <Item 2>92 </Item3> 93 <Item4> 64 94 <PackageName Value="LCL"/> 65 </Item 2>95 </Item4> 66 96 </RequiredPackages> 67 <Units Count=" 3">97 <Units Count="4"> 68 98 <Unit0> 69 99 <Filename Value="FioInfo.lpr"/> … … 84 114 <UnitName Value="UFioAPI"/> 85 115 </Unit2> 116 <Unit3> 117 <Filename Value="Forms/UFormSettings.pas"/> 118 <IsPartOfProject Value="True"/> 119 <ComponentName Value="FormSettings"/> 120 <ResourceBaseClass Value="Form"/> 121 <UnitName Value="UFormSettings"/> 122 </Unit3> 86 123 </Units> 87 124 </ProjectOptions> … … 93 130 <SearchPaths> 94 131 <IncludeFiles Value="$(ProjOutDir)"/> 132 <OtherUnitFiles Value="Forms"/> 95 133 <UnitOutputDirectory Value="lib/$(TargetCPU)-$(TargetOS)"/> 96 134 </SearchPaths> 135 <Parsing> 136 <SyntaxOptions> 137 <SyntaxMode Value="Delphi"/> 138 <CStyleOperator Value="False"/> 139 <AllowLabel Value="False"/> 140 <CPPInline Value="False"/> 141 </SyntaxOptions> 142 </Parsing> 143 <CodeGeneration> 144 <SmartLinkUnit Value="True"/> 145 <Optimizations> 146 <OptimizationLevel Value="3"/> 147 </Optimizations> 148 </CodeGeneration> 97 149 <Linking> 150 <Debugging> 151 <GenerateDebugInfo Value="False"/> 152 </Debugging> 98 153 <Options> 99 154 <Win32> -
trunk/FioInfo.lpr
r3 r6 8 8 {$ENDIF}{$ENDIF} 9 9 Interfaces, // this includes the LCL widgetset 10 Forms, UFormMain, laz_synapse, UFioAPI; 10 Forms, UFormMain, laz_synapse, UFioAPI, Common, TemplateGenerics, 11 UFormSettings; 11 12 12 13 {$R *.res} … … 16 17 Application.Initialize; 17 18 Application.CreateForm(TFormMain, FormMain); 19 Application.CreateForm(TFormSettings, FormSettings); 18 20 Application.Run; 19 21 end. -
trunk/UFioAPI.pas
r5 r6 1 1 unit UFioAPI; 2 2 3 {$mode objfpc}{$H+}3 {$mode delphi}{$H+} 4 4 5 5 interface … … 10 10 type 11 11 12 TFioDataFormat = (dfXML, dfCVS, dfGPC, dfOFX, dfJSON, dfHTML, dfSTA); 13 12 14 { TFioAPI } 13 15 … … 17 19 public 18 20 Token: string; 19 Format: string;21 Format: TFioDataFormat; 20 22 function DownloadInterval(TimeFrom, TimeTo: TDateTime; Data: TStrings): Boolean; 21 23 function DownloadMonthly(Year, Id: Integer; Data: TStrings): Boolean; 22 24 function DownloadLast(Data: TStrings): Boolean; 23 25 end; 26 27 const 28 DataFormatText: array[TFioDataFormat] of string = ('XML', 'CVS', 'GPC', 'OFX', 29 'JSON', 'HTML', 'STA'); 30 DataFormatURL: array[TFioDataFormat] of string = ('xml', 'cvs', 'gpc', 'ofx', 31 'json', 'html', 'sta'); 24 32 25 33 implementation … … 33 41 HTTPSender := THTTPSend.Create; 34 42 try 35 Format := 'xml';36 Token := 'dd';37 43 HTTPSender.HTTPMethod('GET', URL); 38 44 try … … 63 69 '/' + FormatDateTime('yyyy-mm-dd', TimeFrom) + 64 70 '/' + FormatDateTime('yyyy-mm-dd', TimeTo) + 65 '/transactions.' + Format, Data);71 '/transactions.' + DataFormatURL[Format], Data); 66 72 end; 67 73 … … 70 76 Result := Download('https://www.fio.cz/ib_api/rest/by-id/' + Token + 71 77 '/' + IntToStr(Year) + '/' + IntToStr(Id) + 72 '/transactions.' + Format, Data);78 '/transactions.' + DataFormatURL[Format], Data); 73 79 end; 74 80 … … 76 82 begin 77 83 Result := Download('https://www.fio.cz/ib_api/rest/last/' + Token + 78 '/transactions.' + Format, Data);84 '/transactions.' + DataFormatURL[Format], Data); 79 85 end; 80 86 -
trunk/UFormMain.lfm
r5 r6 1 1 object FormMain: TFormMain 2 Left = 4472 Left = 364 3 3 Height = 368 4 Top = 2474 Top = 183 5 5 Width = 510 6 6 Caption = 'FioInfo' 7 7 ClientHeight = 368 8 8 ClientWidth = 510 9 OnClose = FormClose 10 OnCreate = FormCreate 9 11 LCLVersion = '1.1' 10 object LabeledEdit1: TLabeledEdit 11 Left = 8 12 Height = 27 13 Top = 25 14 Width = 488 15 EditLabel.AnchorSideLeft.Control = LabeledEdit1 16 EditLabel.AnchorSideRight.Control = LabeledEdit1 17 EditLabel.AnchorSideRight.Side = asrBottom 18 EditLabel.AnchorSideBottom.Control = LabeledEdit1 19 EditLabel.Left = 8 20 EditLabel.Height = 17 21 EditLabel.Top = 5 22 EditLabel.Width = 488 23 EditLabel.Caption = 'Token' 24 EditLabel.ParentColor = False 12 object Button2: TButton 13 Left = 376 14 Height = 25 15 Top = 336 16 Width = 112 17 Action = ASettings 18 Anchors = [akTop, akBottom] 25 19 TabOrder = 0 26 20 end 27 object Button1: TButton 21 object GroupBox1: TGroupBox 22 Left = 8 23 Height = 57 24 Top = 8 25 Width = 489 26 Anchors = [akTop, akLeft, akRight] 27 Caption = 'Nové platby od poslednÃho staÅŸenÃ' 28 ClientHeight = 38 29 ClientWidth = 485 30 TabOrder = 1 31 object Button1: TButton 32 Left = 358 33 Height = 25 34 Top = 7 35 Width = 112 36 Action = ADownloadNew 37 Caption = 'Stáhnout' 38 TabOrder = 0 39 end 40 end 41 object GroupBox2: TGroupBox 42 Left = 8 43 Height = 72 44 Top = 80 45 Width = 489 46 Anchors = [akTop, akLeft, akRight] 47 Caption = 'Transakce v zadaném Äasovém rozpÄtÃ' 48 ClientHeight = 53 49 ClientWidth = 485 50 TabOrder = 2 51 object Button3: TButton 52 Left = 358 53 Height = 25 54 Top = 7 55 Width = 112 56 Action = ADownloadInterval 57 Caption = 'Stáhnout' 58 TabOrder = 0 59 end 60 object DateEditStart: TDateEdit 61 Left = 54 62 Height = 27 63 Top = 5 64 Width = 80 65 CalendarDisplaySettings = [dsShowHeadings, dsShowDayNames] 66 OKCaption = 'OK' 67 CancelCaption = 'Cancel' 68 DateOrder = doNone 69 ButtonWidth = 23 70 CharCase = ecNormal 71 NumGlyphs = 1 72 MaxLength = 0 73 TabOrder = 1 74 end 75 object DateEditTo: TDateEdit 76 Left = 230 77 Height = 27 78 Top = 9 79 Width = 80 80 CalendarDisplaySettings = [dsShowHeadings, dsShowDayNames] 81 OKCaption = 'OK' 82 CancelCaption = 'Cancel' 83 DateOrder = doNone 84 ButtonWidth = 23 85 CharCase = ecNormal 86 NumGlyphs = 1 87 MaxLength = 0 88 TabOrder = 2 89 end 90 object Label1: TLabel 91 Left = 22 92 Height = 17 93 Top = 9 94 Width = 22 95 Caption = 'Od:' 96 ParentColor = False 97 end 98 object Label4: TLabel 99 Left = 174 100 Height = 17 101 Top = 15 102 Width = 22 103 Caption = 'Do:' 104 ParentColor = False 105 end 106 end 107 object GroupBox3: TGroupBox 108 Left = 8 109 Height = 65 110 Top = 168 111 Width = 489 112 Caption = 'MÄsÃÄnà vÃœpis' 113 ClientHeight = 46 114 ClientWidth = 485 115 TabOrder = 3 116 object Button4: TButton 117 Left = 358 118 Height = 25 119 Top = 7 120 Width = 112 121 Action = ADownloadMonthly 122 Caption = 'Stáhnout' 123 TabOrder = 0 124 end 125 object SpinEditYear: TSpinEdit 126 Left = 54 127 Height = 27 128 Top = 7 129 Width = 96 130 MaxValue = 9999 131 MinValue = 1000 132 TabOrder = 1 133 Value = 2000 134 end 135 object SpinEditId: TSpinEdit 136 Left = 230 137 Height = 27 138 Top = 7 139 Width = 96 140 MaxValue = 12 141 MinValue = 1 142 TabOrder = 2 143 Value = 1 144 end 145 object Label2: TLabel 146 Left = 20 147 Height = 17 148 Top = 15 149 Width = 28 150 Caption = 'Rok:' 151 ParentColor = False 152 end 153 object Label3: TLabel 154 Left = 174 155 Height = 17 156 Top = 15 157 Width = 36 158 Caption = 'ÄÃslo:' 159 ParentColor = False 160 end 161 end 162 object Button5: TButton 28 163 Left = 16 29 164 Height = 25 30 Top = 3 44165 Top = 336 31 166 Width = 112 32 Action = ADownload 33 TabOrder = 1 34 end 35 object Memo1: TMemo 36 Left = 16 37 Height = 271 38 Top = 56 39 Width = 453 40 TabOrder = 2 167 Action = AExit 168 Anchors = [akLeft, akBottom] 169 TabOrder = 4 41 170 end 42 171 object TrayIcon1: TTrayIcon … … 4329 4458 Hint = 'FioInfo' 4330 4459 Visible = True 4331 left = 2 164332 top = 1764460 left = 224 4461 top = 296 4333 4462 end 4334 4463 object PopupMenuTray: TPopupMenu 4335 4464 Images = ImageList1 4336 left = 1524337 top = 934465 left = 224 4466 top = 240 4338 4467 object MenuItem1: TMenuItem 4339 4468 Action = AShow … … 4346 4475 object ActionList1: TActionList 4347 4476 Images = ImageList1 4348 left = 2 644349 top = 934477 left = 296 4478 top = 240 4350 4479 object AShow: TAction 4351 4480 Caption = 'Ukázat' … … 4356 4485 OnExecute = AExitExecute 4357 4486 end 4358 object ADownload: TAction 4359 Caption = 'Zkontrolovat' 4360 OnExecute = ADownloadExecute 4487 object ASettings: TAction 4488 Caption = 'NastavenÃ' 4489 OnExecute = ASettingsExecute 4490 end 4491 object ADownloadNew: TAction 4492 Caption = 'Stáhnout nové' 4493 OnExecute = ADownloadNewExecute 4494 end 4495 object ADownloadInterval: TAction 4496 Caption = 'Stáhnout dle rozsahu data' 4497 OnExecute = ADownloadIntervalExecute 4498 end 4499 object ADownloadMonthly: TAction 4500 Caption = 'Stáhnout mÄsÃÄnà vÃœpis' 4501 OnExecute = ADownloadMonthlyExecute 4361 4502 end 4362 4503 end 4363 4504 object ImageList1: TImageList 4364 4505 left = 296 4365 top = 1764506 top = 296 4366 4507 end 4367 4508 end -
trunk/UFormMain.pas
r5 r6 1 1 unit UFormMain; 2 2 3 {$mode objfpc}{$H+}3 {$mode delphi{$H+} 4 4 5 5 interface … … 7 7 uses 8 8 Classes, SysUtils, FileUtil, Forms, Controls, Graphics, Dialogs, StdCtrls, 9 ExtCtrls, Menus, ActnList, httpsend, UFioAPI; 9 ExtCtrls, Menus, ActnList, Spin, EditBtn, UFioAPI, URegistry, Registry, 10 DateUtils; 10 11 11 12 type … … 14 15 15 16 TFormMain = class(TForm) 16 ADownload: TAction; 17 ADownloadInterval: TAction; 18 ADownloadMonthly: TAction; 19 ASettings: TAction; 20 ADownloadNew: TAction; 17 21 AExit: TAction; 18 22 AShow: TAction; 19 23 ActionList1: TActionList; 20 24 Button1: TButton; 25 Button2: TButton; 26 Button3: TButton; 27 Button4: TButton; 28 Button5: TButton; 29 DateEditStart: TDateEdit; 30 DateEditTo: TDateEdit; 31 GroupBox1: TGroupBox; 32 GroupBox2: TGroupBox; 33 GroupBox3: TGroupBox; 21 34 ImageList1: TImageList; 22 LabeledEdit1: TLabeledEdit; 23 Memo1: TMemo; 35 Label1: TLabel; 36 Label2: TLabel; 37 Label3: TLabel; 38 Label4: TLabel; 24 39 MenuItem1: TMenuItem; 25 40 MenuItem2: TMenuItem; 26 41 PopupMenuTray: TPopupMenu; 42 SpinEditYear: TSpinEdit; 43 SpinEditId: TSpinEdit; 27 44 TrayIcon1: TTrayIcon; 28 procedure ADownloadExecute(Sender: TObject); 45 procedure ADownloadIntervalExecute(Sender: TObject); 46 procedure ADownloadMonthlyExecute(Sender: TObject); 47 procedure ADownloadNewExecute(Sender: TObject); 29 48 procedure AExitExecute(Sender: TObject); 49 procedure ASettingsExecute(Sender: TObject); 30 50 procedure AShowExecute(Sender: TObject); 51 procedure FormClose(Sender: TObject; var CloseAction: TCloseAction); 52 procedure FormCreate(Sender: TObject); 31 53 private 32 54 { private declarations } 33 55 public 34 { public declarations } 56 RegistryContext: TRegistryContext; 57 Token: string; 58 Format: TFioDataFormat; 59 TargetDirectory: string; 60 ReportYear: Integer; 61 ReportId: Integer; 62 ReportTimeFrom: TDateTime; 63 ReportTimeTo: TDateTime; 64 procedure LoadInterface; 65 procedure SaveInterface; 66 procedure SaveToRegistry(Context: TRegistryContext); 67 procedure LoadFromRegistry(Context: TRegistryContext); 35 68 end; 36 69 … … 42 75 {$R *.lfm} 43 76 77 uses 78 UFormSettings; 79 80 resourcestring 81 SDownloadNotSuccess = 'StaÅŸenà nebylo úspÄÅ¡né'; 82 83 44 84 { TFormMain } 45 85 … … 49 89 end; 50 90 91 procedure TFormMain.FormClose(Sender: TObject; var CloseAction: TCloseAction); 92 begin 93 SaveInterface; 94 SaveToRegistry(RegistryContext); 95 end; 96 97 procedure TFormMain.FormCreate(Sender: TObject); 98 begin 99 RegistryContext := RegContext(HKEY_CURRENT_USER, '\Software\Chronosoft\FioInfo'); 100 LoadFromRegistry(RegistryContext); 101 LoadInterface; 102 end; 103 104 procedure TFormMain.LoadInterface; 105 begin 106 DateEditStart.Date := ReportTimeFrom; 107 DateEditTo.Date := ReportTimeTo; 108 SpinEditYear.Value := ReportYear; 109 SpinEditId.Value := ReportId; 110 end; 111 112 procedure TFormMain.SaveInterface; 113 begin 114 ReportTimeFrom := DateEditStart.Date; 115 ReportTimeTo := DateEditTo.Date; 116 ReportYear := SpinEditYear.Value; 117 ReportId := SpinEditId.Value; 118 end; 119 120 procedure TFormMain.SaveToRegistry(Context: TRegistryContext); 121 begin 122 with TRegistryEx.Create do 123 try 124 RootKey := Context.RootKey; 125 OpenKey(Context.Key, True); 126 WriteString('TargetDir', TargetDirectory); 127 WriteInteger('DataFormat', Integer(Format)); 128 WriteString('Token', Token); 129 WriteDate('ReportTimeFrom', ReportTimeFrom); 130 WriteDateTime('ReportTimeTo', ReportTimeTo); 131 WriteInteger('ReportYear', ReportYear); 132 WriteInteger('ReportId', ReportId); 133 finally 134 Free; 135 end; 136 end; 137 138 procedure TFormMain.LoadFromRegistry(Context: TRegistryContext); 139 begin 140 with TRegistryEx.Create do 141 try 142 RootKey := Context.RootKey; 143 OpenKey(Context.Key, True); 144 TargetDirectory := ReadStringWithDefault('TargetDir', ExtractFileDir(Application.ExeName)); 145 Format := TFioDataFormat(ReadIntegerWithDefault('DataFormat', Integer(dfXML))); 146 Token := ReadStringWithDefault('Token', ''); 147 ReportTimeFrom := ReadDateTimeWithDefault('ReportTimeFrom', Now); 148 ReportTimeTo := ReadDateTimeWithDefault('ReportTimeTo', Now); 149 ReportYear := ReadIntegerWithDefault('ReportYear', YearOf(Now)); 150 ReportId := ReadIntegerWithDefault('ReportId', MonthOf(Now)); 151 finally 152 Free; 153 end; 154 end; 155 51 156 procedure TFormMain.AExitExecute(Sender: TObject); 52 157 begin 53 Application.Terminate; 54 end; 55 56 procedure TFormMain.ADownloadExecute(Sender: TObject); 158 Close; 159 end; 160 161 procedure TFormMain.ASettingsExecute(Sender: TObject); 162 begin 163 FormSettings.Load; 164 if FormSettings.ShowModal = mrOk then begin 165 FormSettings.Save; 166 SaveToRegistry(RegistryContext); 167 end; 168 end; 169 170 procedure TFormMain.ADownloadNewExecute(Sender: TObject); 57 171 var 58 172 FioAPI: TFioAPI; 173 List: TStringList; 59 174 begin 60 175 FioAPI := TFioAPI.Create; 61 try 62 FioAPI.Token := LabeledEdit1.Text; 63 FioAPI.Format := 'xml'; 64 FioAPI.DownloadInterval(EncodeDate(2013, 03, 01), EncodeDate(2013, 03, 14), 65 Memo1.Lines); 176 List := TStringList.Create; 177 try 178 FioAPI.Format := Format; 179 FioAPI.Token := Token; 180 if FioAPI.DownloadLast(List) then begin 181 List.SaveToFile('VÃœpis ' + FormatDateTime('yyyy-mm-dd hh-nn-ss', Now) + 182 ExtensionSeparator + DataFormatURL[FioAPI.Format]); 183 end else ShowMessage(SDownloadNotSuccess); 66 184 finally 67 185 FioAPI.Free; 186 List.Free; 187 end; 188 end; 189 190 procedure TFormMain.ADownloadMonthlyExecute(Sender: TObject); 191 var 192 FioAPI: TFioAPI; 193 List: TStringList; 194 begin 195 FioAPI := TFioAPI.Create; 196 List := TStringList.Create; 197 try 198 FioAPI.Format := Format; 199 FioAPI.Token := Token; 200 if FioAPI.DownloadMonthly(SpinEditYear.Value, SpinEditId.Value, List) then begin 201 List.SaveToFile('VÃœpis mÄsÃÄnà ' + IntToStr(SpinEditYear.Value) + 202 '-' + IntToStr(SpinEditId.Value) + 203 ExtensionSeparator + DataFormatURL[FioAPI.Format]); 204 end else ShowMessage(SDownloadNotSuccess); 205 finally 206 FioAPI.Free; 207 List.Free; 208 end; 209 end; 210 211 procedure TFormMain.ADownloadIntervalExecute(Sender: TObject); 212 var 213 FioAPI: TFioAPI; 214 List: TStringList; 215 begin 216 FioAPI := TFioAPI.Create; 217 List := TStringList.Create; 218 try 219 FioAPI.Format := Format; 220 FioAPI.Token := Token; 221 if FioAPI.DownloadInterval(DateEditStart.Date, DateEditTo.Date, List) then begin 222 List.SaveToFile('VÃœpis ' + FormatDateTime('yyyy-mm-dd', DateEditStart.Date) + 223 ' ' + FormatDateTime('yyyy-mm-dd', DateEditTo.Date) + 224 ExtensionSeparator + DataFormatURL[FioAPI.Format]); 225 end else ShowMessage(SDownloadNotSuccess); 226 finally 227 FioAPI.Free; 228 List.Free; 68 229 end; 69 230 end;
Note:
See TracChangeset
for help on using the changeset viewer.