private async Task OnExecuteExport()
        {
            if (string.IsNullOrWhiteSpace(Model.GenFileFullPath) || Model.LineStart <= 0)
            {
                ShowFadingStatusBarMessage(MessageType.Error, "Yra įvesties klaidų, patikrinkite ar pasirinkti failai ir nustatytas eilutes numeris");
                return;
            }

            Model.IsLoading = true;
            try
            {
                var eipData = await _eipReader.GetParsedEipContentsAsync(Model.GenFileFullPath);

                var output = _mapper.MapToOutput(eipData.Where(e => e.LineNr >= Model.LineStart));
                await _eipWriter.WriteAsync(new IO.Dto.I06Output(output.ToArray()));

                ShowFadingStatusBarMessage(MessageType.Information, "Baigta. Sugeneruotas failas išvesties aplanke");
            }
            catch (Exception ex)
            {
                _logger.Error("Failed to generate eip export", ex);
                ShowFadingStatusBarMessage(MessageType.Error, $"Klaida vykdant exportą: {ex.Message}");
            }

            Model.IsLoading = false;
        }
Пример #2
0
        public async Task When_EipIsMissingRequiredFields_Result_ThrowsInvalidOperation()
        {
            //Arrange
            IEipReader eipEipReader = ArrangedEipReaderWithDifferentFileContents(EipWithoutRequiredFields);

            //Act & Assert
            await Assert.ThrowsAsync <InvalidOperationException>(() => eipEipReader.GetParsedEipContentsAsync("dummy.txt"));
        }
Пример #3
0
        public async Task When_TrimmedEipIsUsed_Result_OutputsValidI07Array()
        {
            //Arrange
            IEipReader eipEipReader = ArrangedEipReaderWithDifferentFileContents(TrimmedQualifiedEip);

            //Act
            var products = await eipEipReader.GetParsedEipContentsAsync("dummy.txt");

            //Assert
            Assert.NotEmpty(products);
            Assert.True(products.All(p => !string.IsNullOrWhiteSpace(p.Code.First())));
        }
Пример #4
0
        public async Task When_ValidEipIsProvided_Result_IsSerializedCorrectly()
        {
            //Arrange
            IEipReader eipEipReader = ArrangedEipReaderWithDifferentFileContents(EipWithTestData);

            //Act
            var products = await eipEipReader.GetParsedEipContentsAsync("dummy.txt");

            //Assert
            Assert.True(products.Count() == 2);

            var first  = products.First();
            var second = products.Last();

            Assert.True(
                first.Code.First() == "kodas1" &&
                first.LineNr == 1 &&
                first.Name == "pav1" &&
                first.Maker == "K3" &&
                first.Amount == 1 &&
                first.DateDateTime == new DateTime(2020, 3, 1) &&
                first.Details1 == "" &&
                first.Details2 == "" &&
                first.Details3 == "" &&
                first.Pap2 == 1 &&
                first.DimDateDateTime == default);

            Assert.True(
                second.Code.First() == "kodas2" &&
                second.LineNr == 2 &&
                second.Name == "pav2" &&
                second.Maker == "K1" &&
                second.Amount == 2 &&
                second.DateDateTime == new DateTime(2020, 3, 2) &&
                second.Details1 == "1" &&
                second.Details2 == "2" &&
                second.Details3 == "3" &&
                second.Pap2 == 2 &&
                second.DimDate == "2020.10.10" &&
                second.DimDateDateTime == new DateTime(2020, 10, 10));
        }