/
YakuninAV
/
Convertors
Обзор
Документация
Войти
/
YakuninAV
/
Convertors
Код
Запросы
0
Задачи
Вики
Пакеты
0
Релизы
0
Аналитика
Безопасность
master
AUP/RTMIntfs.pas
166 строк
5 KB
YakuninAV
begin with gitflick
31 июл 2026, 15:21
31 июл 2026, 15:21
1dc0fc6
Код
Авторство
О чём код?
unit RTMIntfs; {$IFDEF FPC} {$mode DELPHI} {$H+} {$codepage UTF8} {$ENDIF} {$IFDEF MORMOT_V1_18} {$I Synopse.inc} {$ELSE} {$I mormot.defines.inc} {$ENDIF} interface uses SysUtils, {$IFDEF MORMOT_V1_18} SynCommons, {$ELSE} mormot.core.base, mormot.core.os, mormot.core.unicode, mormot.core.data, {$ENDIF} DBDIntfs, DBDNotifiers, DBDCommons, DBDStrUtils; type /// Интерфейс чтения информации для формирования Укрупненных расценок IAUPImporterV2 = interface function GetDoc: Variant; function GetOnFileEvent: TDBDOnFileEvent; function GetPriceListFileName: TFileName; function GetSource: TFileName; function GetSrcFilesMask: string; procedure SetOnFileEvent(Value: TDBDOnFileEvent); procedure SetPriceListFileName(Value: TFileName); procedure SetSource(Value: TFileName); procedure SetSrcFilesMask(Value: string); /// Функция читает информацию РСР и, в случае успеха, возвращает true function Execute(aOptions: Variant): Boolean; /// Функция возвращает true, если можно выполнить импорт данных function IsReady: Boolean; /// Наименование файла с каталогом цен property PriceListFileName: TFileName read GetPriceListFileName write SetPriceListFileName; /// Источник информации для загрузки property Source: TFileName read GetSource write SetSource; /// Маска имени файлов для загрузки property SrcFilesMask: string read GetSrcFilesMask write SetSrcFilesMask; /// Событие зозбуждаемое по завершении чтения файла property OnFileEvent: TDBDOnFileEvent read GetOnFileEvent write SetOnFileEvent; /// Загруженный документ property Doc: Variant read GetDoc; end; { TAUPImporter } TAUPImporter = class(TInterfacedObject, IAUPImporterV2) private function GetDoc: Variant; function GetOnFileEvent: TDBDOnFileEvent; function GetPriceListFileName: TFileName; function GetSource: TFileName; function GetSrcFilesMask: string; procedure SetOnFileEvent(Value: TDBDOnFileEvent); procedure SetPriceListFileName(Value: TFileName); procedure SetSource(Value: TFileName); procedure SetSrcFilesMask(Value: string); protected FDoc: Variant; FOnFileEvent: TDBDOnFileEvent; FNotifier: IDBDNotifierV1; FOptions: Variant; FSource: TFilename; FSrcFileMask: string; FPriceListFileName: TFileName; function Notify(const MsgKind: TDBDMessageKind; const MsgCode: Integer; const MsgTxt: string): Boolean; public /// Загруженный документ property Doc: Variant read GetDoc; /// Наименование файла с каталогом цен property PriceListFileName: TFileName read GetPriceListFileName write SetPriceListFileName; /// Источник инфрмации для загрузки (файл или папка с файлами property Source: TFileName read GetSource write SetSource; /// Событие зозбуждаемое по завершении чтения файла property OnFileEvent: TDBDOnFileEvent read GetOnFileEvent write SetOnFileEvent; /// Маска имени файлов для загрузки property SrcFilesMask: string read GetSrcFilesMask write SetSrcFilesMask; /// Конструктор constructor Create(Notifier: IDBDNotifierV1); /// Функция читает информацию РСР и, в случае успеха, возвращает true function Execute(aOptions: Variant): Boolean; virtual; abstract; /// Функция возвращает true, если можно выполнить импорт данных function IsReady: Boolean; virtual; /// Функция class function SameName(const S1,S2: string; const Exactly: Boolean=True): Boolean; static; end; implementation { TRecImporter } function TAUPImporter.GetDoc: Variant; begin Result:=FDoc; end; function TAUPImporter.GetOnFileEvent: TDBDOnFileEvent; begin Result:=FOnFileEvent; end; function TAUPImporter.GetPriceListFileName: TFileName; begin Result:=FPriceListFileName; end; function TAUPImporter.GetSource: TFileName; begin Result:=FSource; end; function TAUPImporter.GetSrcFilesMask: string; begin Result:=FSrcFileMask; end; class function TAUPImporter.SameName(const S1, S2: string; const Exactly: boolean): Boolean; begin if Exactly then Result:=S1=S2 else Result:=DBDStartsWith(S1,S2); end; procedure TAUPImporter.SetOnFileEvent(Value: TDBDOnFileEvent); begin FOnFileEvent:=Value; end; procedure TAUPImporter.SetPriceListFileName(Value: TFileName); begin FPriceListFileName:=Value; end; procedure TAUPImporter.SetSource(Value: TFileName); begin FSource:=Value; end; procedure TAUPImporter.SetSrcFilesMask(Value: string); begin FSrcFileMask:=Value; end; function TAUPImporter.Notify(const MsgKind: TDBDMessageKind; const MsgCode: Integer; const MsgTxt: string): Boolean; begin if Assigned(FNotifier) then Result:=FNotifier.Log(MsgKind, MsgCode, MsgTxt); end; constructor TAUPImporter.Create(Notifier: IDBDNotifierV1); begin inherited Create; FNotifier:=Notifier; end; function TAUPImporter.IsReady: Boolean; begin Result:=(FSource<>'') and DirectoryExists(FSource) and (FPriceListFileName<>''); end; end.