Changeset 14 for trunk/UCore.pas
- Timestamp:
- Mar 19, 2013, 8:38:28 PM (11 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/UCore.pas
r13 r14 57 57 MenuItem7: TMenuItem; 58 58 MenuItem8: TMenuItem; 59 MenuItem9: TMenuItem; 59 60 PopupMenuTray: TPopupMenu; 60 61 TrayIcon1: TTrayIcon; … … 70 71 procedure DataModuleDestroy(Sender: TObject); 71 72 private 72 { private declarations }73 function GetFileName: string; 73 74 public 74 75 RegistryContext: TRegistryContext; … … 81 82 ReportTimeFrom: TDateTime; 82 83 ReportTimeTo: TDateTime; 84 OutputFormat: string; 85 SelectedAccountIndex: Integer; 83 86 procedure LoadAccount(Account: TAccount); 84 87 procedure LoadAccounts; … … 101 104 SReport = 'Dump %s'; 102 105 SSavedToFile = 'Dump saved to file %s'; 106 SDumpFormat = 'Dump %d %t.%f'; 103 107 104 108 { TAccount } … … 121 125 Name := UTF8Encode(ReadStringWithDefault('Name', UTF8Decode('UÄet'))); 122 126 Time := ReadDateTimeWithDefault('Time', 0); 123 Token := UTF8Encode(ReadStringWithDefault('Token', ''));127 Token := UTF8Encode(ReadStringWithDefault('Token', '')); 124 128 Balance := ReadFloatWithDefault('Balance', 0); 125 129 Number := UTF8Encode(ReadStringWithDefault('Number', '')); … … 227 231 SaveToRegistry(RegistryContext); 228 232 FreeAndNil(Accounts); 233 end; 234 235 function TCore.GetFileName: string; 236 begin 237 Result := OutputFormat; 238 Result := StringReplace(Result, '%f', DataFormatURL[DataFormat], [rfReplaceAll]); 239 Result := StringReplace(Result, '%d', DateToStr(Now), [rfReplaceAll]); 240 Result := StringReplace(Result, '%t', TimeToStr(Now), [rfReplaceAll]); 241 Result := StringReplace(Result, '%a', CurrentAccount.Number, [rfReplaceAll]); 242 Result := StringReplace(Result, '%n', CurrentAccount.Name, [rfReplaceAll]); 243 Result := StringReplace(Result, '%%', '%', [rfReplaceAll]); 229 244 end; 230 245 … … 302 317 WriteInteger('ReportId', ReportId); 303 318 WriteString('Language', CoolTranslator1.Language.Code); 319 WriteString('FileNameFormat', OutputFormat); 320 WriteInteger('SelectedAccountIndex', SelectedAccountIndex); 304 321 finally 305 322 Free; … … 321 338 ReportId := ReadIntegerWithDefault('ReportId', MonthOf(Now)); 322 339 CoolTranslator1.Language := CoolTranslator1.Languages.SearchByCode(ReadStringWithDefault('Language', 'cs')); 340 OutputFormat := UTF8Encode(ReadStringWithDefault('FileNameFormat', UTF8Decode(SDumpFormat))); 341 SelectedAccountIndex := ReadIntegerWithDefault('SelectedAccountIndex', 0); 323 342 finally 324 343 Free; … … 353 372 FioAPI.Token := CurrentAccount.Token; 354 373 if FioAPI.DownloadLast(List) then begin 355 FileName := TargetDirectory + DirectorySeparator + Format(SReport, [FormatDateTime('yyyy-mm-dd hh-nn-ss', Now) + 356 ExtensionSeparator + DataFormatURL[FioAPI.Format]]); 374 FileName := TargetDirectory + DirectorySeparator + GetFileName; 357 375 List.SaveToFile(UTF8Decode(FileName)); 358 376 ShowMessage(Format(SSavedToFile, [FileName])); … … 376 394 FioAPI.Token := CurrentAccount.Token; 377 395 if FioAPI.DownloadMonthly(ReportYear, ReportId, List) then begin 378 FileName := TargetDirectory + DirectorySeparator + Format(SReport, [IntToStr(ReportYear) + 379 '-' + IntToStr(ReportId) + 380 ExtensionSeparator + DataFormatURL[FioAPI.Format]]); 396 FileName := TargetDirectory + DirectorySeparator + GetFileName; 381 397 List.SaveToFile(UTF8Decode(FileName)); 382 398 ShowMessage(Format(SSavedToFile, [FileName])); … … 400 416 FioAPI.Token := CurrentAccount.Token; 401 417 if FioAPI.DownloadInterval(ReportTimeFrom, ReportTimeTo, List) then begin 402 FileName := TargetDirectory + DirectorySeparator + Format(SReport, [FormatDateTime('yyyy-mm-dd', ReportTimeFrom) + 403 ' ' + FormatDateTime('yyyy-mm-dd', ReportTimeTo) + 404 ExtensionSeparator + DataFormatURL[FioAPI.Format]]); 418 FileName := TargetDirectory + DirectorySeparator + GetFileName; 405 419 List.SaveToFile(UTF8Decode(FileName)); 406 420 ShowMessage(Format(SSavedToFile, [FileName]));
Note:
See TracChangeset
for help on using the changeset viewer.