Ebben a cikkben megtudhatja, hogyan valósíthatja meg a FiscalClient-et a nuget segítségével.
Elvárások
- .NET-fejlesztési ismeretek
- A nuget-packages használatának ismerete
-
A csomagok letöltése
RetailForce.Fiscalisation - A .NET Standard 2.0-t támogató környezeti platform
Megvalósítás
Konfigurációs szolgáltató
A konfiguráció mentéséhez szükség van egy FileConfigurationProvider-re, amely tartalmazza a konfigurációs fájl elérési útját és egy naplózót:
FileConfigurationProvider fileConfigurationProvider = new FileConfigurationProvider(System.IO.Path.Combine(this.FilesDir.ToString(), "fiscalclient.config.json"), _logger);(Android).
Pénzügyi modulkezelés
Ügyfelek létrehozásához vagy a konfiguráció Cloudból való betöltéséhez szükség van a FiscalModuleManagement osztályra:
IClientStatusReporter clientStatusReporter = new EmptyClientStatusReporter();
FiscalModuleManagement moduleManagement = new FiscalModuleManagement(_logger, fileConfigurationProvider, clientStatusReporter);A naplózó a Microsoft.Extensions.Logging.ILogger osztályból származik.
Szükség van a client-állapot-jelentőre (IClientStatusReporter). Ha nem dolgozza fel saját maga az állapotjelentéseket, használja az EmptyClientStatusReporter osztályt.
Ügyfél betöltése a Cloudból
Az ügyfél betöltéséhez a Cloudból használhatja a CreateClientByCloud parancsot:
uniqueClientId = moduleManagement.CreateClientByCloud(new CompanyIdentification() { Identification = "ATU1234567", Type = CompanyIdentification.IdentificationType.VatNumber }, "T001", "T001", cloudApiKey, cloudApiSecret);Client kézi létrehozása
The client can also be created manually (FiscalClient). Once this class is created, the client can be created with the CreateClient command.
Adóügyi modul létrehozása
Adómodul a FiscalModuleCreator osztály segítségével hozható létre:
CloudService cloudService = new CloudService(_logger, storageBasePath, uniqueClientId.Value, cloudApiKey, cloudApiSecret);
FiscalModulCreator creator = new FiscalModulCreator(fileConfigurationProvider, _logger, cloudService, null, clientStatusReporter);Ezzel létrehozza a fiskális modult. A CloudService egy olyan osztály, amelyet a szoftverben a teljes futási idő alatt meg kell tartani. Ez gondoskodik a háttérben történő átvitelről a felhőbe.
A negyedik paraméter (IotService) opcionális, és null értékre állítható. A FiscalModulCreator a CloudService esetében is elfogadja a null értéket, de az alábbiakban használt LocalMonitoringClient megköveteli a CloudService-t.
A fiskális modul létrehozása
A FiscalModuleCreator osztály inicializálása után létrehozható a fiskális modul.
A fiskális modul adatait két tárolószolgáltatón keresztül tárolja: a fiskális adatokhoz a FiscalDataStorageProvider-t, az ellenőrzési naplóhoz pedig az AuditLogStorageProvider-t. Helyi tároláshoz használja a LocalFiscalDataStorageProvider és a LocalAuditLogStorageProvider szolgáltatókat. A storageBasePath az ügyfélazonosító nélküli alapkönyvtár (Android: this.GetExternalFilesDir(Android.OS.Environment.DirectoryDocuments).AbsolutePath); az auditnapló elérési útjának tartalmaznia kell az ügyfélazonosítót.
IMonitoringClient monitoringClient = new LocalMonitoringClient(cloudService);
FiscalDataStorageProvider storageProvider = new LocalFiscalDataStorageProvider(_logger, uniqueClientId.Value, monitoringClient, storageBasePath);
AuditLogStorageProvider auditLogStorageProvider = new LocalAuditLogStorageProvider(uniqueClientId.Value, _logger, System.IO.Path.Combine(storageBasePath, uniqueClientId.Value.ToString()));
TrustedFiscalModule fiscalModule = creator.CreateFiscalModuleForClient(uniqueClientId.Value, storageProvider, auditLogStorageProvider, cloudApiKey: cloudApiKey, cloudApiSecret: cloudApiSecret);Itt is, ha nincs szükség felhőalapú támogatásra, a felhőbiztonsági adatok (cloudApiKey, cloudApiSecret) elhagyhatók.
FONTOS: Az ügyfélkonfigurációt előzetesen létre kell hozni. Ez történhet a Cloudból való letöltéssel vagy a CreateClient hívással (lásd fent).
Ezt a cikket automatikusan lefordították.
Hozzászólások
0 hozzászólás
Hozzászólások írásához jelentkezzen be.