Changeset 10 for trunk/UCore.pas


Ignore:
Timestamp:
Mar 14, 2013, 11:35:29 PM (11 years ago)
Author:
chronos
Message:
  • Opraveno: České znaky v názvu ukládaných výpisů.
  • Opraveno: Název exportu CVS na CSV.
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/UCore.pas

    r9 r10  
    5050    RegistryContext: TRegistryContext;
    5151    Token: string;
    52     Format: TFioDataFormat;
     52    DataFormat: TFioDataFormat;
    5353    TargetDirectory: string;
    5454    ReportYear: Integer;
     
    7272resourcestring
    7373  SDownloadNotSuccess = 'Download failed';
     74  SReport = 'Dump %s';
     75  SSavedToFile = 'Dump saved to file %s';
    7476
    7577{ TCore }
     
    105107    OpenKey(Context.Key, True);
    106108    WriteString('TargetDir', TargetDirectory);
    107     WriteInteger('DataFormat', Integer(Format));
     109    WriteInteger('DataFormat', Integer(DataFormat));
    108110    WriteString('Token', Token);
    109111    WriteDate('ReportTimeFrom', ReportTimeFrom);
     
    124126    OpenKey(Context.Key, True);
    125127    TargetDirectory := ReadStringWithDefault('TargetDir', ExtractFileDir(Application.ExeName));
    126     Format := TFioDataFormat(ReadIntegerWithDefault('DataFormat', Integer(dfXML)));
     128    DataFormat := TFioDataFormat(ReadIntegerWithDefault('DataFormat', Integer(dfXML)));
    127129    Token := ReadStringWithDefault('Token', '');
    128130    ReportTimeFrom := ReadDateTimeWithDefault('ReportTimeFrom', Now);
     
    154156  FioAPI: TFioAPI;
    155157  List: TStringList;
     158  FileName: string;
    156159begin
    157160  FioAPI := TFioAPI.Create;
    158161  List := TStringList.Create;
    159162  try
    160     FioAPI.Format := Format;
     163    FioAPI.Format := DataFormat;
    161164    FioAPI.Token := Token;
    162165    if FioAPI.DownloadLast(List) then begin
    163       List.SaveToFile('VÃœpis ' + FormatDateTime('yyyy-mm-dd hh-nn-ss', Now) +
    164         ExtensionSeparator + DataFormatURL[FioAPI.Format]);
     166      FileName := Format(SReport, [FormatDateTime('yyyy-mm-dd hh-nn-ss', Now) +
     167        ExtensionSeparator + DataFormatURL[FioAPI.Format]]);
     168      List.SaveToFile(UTF8Decode(FileName));
     169      ShowMessage(Format(SSavedToFile, [FileName]));
    165170    end else ShowMessage(SDownloadNotSuccess);
    166171  finally
     
    174179  FioAPI: TFioAPI;
    175180  List: TStringList;
     181  FileName: string;
    176182begin
    177183  FioAPI := TFioAPI.Create;
    178184  List := TStringList.Create;
    179185  try
    180     FioAPI.Format := Format;
     186    FioAPI.Format := DataFormat;
    181187    FioAPI.Token := Token;
    182188    if FioAPI.DownloadMonthly(ReportYear, ReportId, List) then begin
    183       List.SaveToFile('VÃœpis měsíční ' + IntToStr(ReportYear) +
     189      FileName := Format(SReport, [IntToStr(ReportYear) +
    184190        '-' + IntToStr(ReportId) +
    185         ExtensionSeparator + DataFormatURL[FioAPI.Format]);
     191        ExtensionSeparator + DataFormatURL[FioAPI.Format]]);
     192      List.SaveToFile(UTF8Decode(FileName));
     193      ShowMessage(Format(SSavedToFile, [FileName]));
    186194    end else ShowMessage(SDownloadNotSuccess);
    187195  finally
     
    195203  FioAPI: TFioAPI;
    196204  List: TStringList;
     205  FileName: string;
    197206begin
    198207  FioAPI := TFioAPI.Create;
    199208  List := TStringList.Create;
    200209  try
    201     FioAPI.Format := Format;
     210    FioAPI.Format := DataFormat;
    202211    FioAPI.Token := Token;
    203212    if FioAPI.DownloadInterval(ReportTimeFrom, ReportTimeTo, List) then begin
    204       List.SaveToFile('VÃœpis ' + FormatDateTime('yyyy-mm-dd', ReportTimeFrom) +
     213      FileName := Format(SReport, [FormatDateTime('yyyy-mm-dd', ReportTimeFrom) +
    205214        ' ' + FormatDateTime('yyyy-mm-dd', ReportTimeTo) +
    206         ExtensionSeparator + DataFormatURL[FioAPI.Format]);
     215        ExtensionSeparator + DataFormatURL[FioAPI.Format]]);
     216      List.SaveToFile(UTF8Decode(FileName));
     217      ShowMessage(Format(SSavedToFile, [FileName]));
    207218    end else ShowMessage(SDownloadNotSuccess);
    208219  finally
Note: See TracChangeset for help on using the changeset viewer.