コード例 #1
0
        public override Result Execute(InputDataProvider data, MergerApplicationOptions options)
        {
            try
            {
                var configuration = GetConfiguration(options);

                var files = data.GetData()
                            .Where(x => x.IsValid())
                            .Select(x => CreateWorkItem(x, configuration))
                            .Cast <UrlWorkUnit>()
                            .Select(x => x.Data)
                            .ToArray();

                var outputFilePath = Path.Combine(
                    HTMLOperationContextScope.Context.OutputFolder,
                    HTMLOperationContextScope.Context.Service.FileNameProvider
                    .GetNextFileName(Application.DEFAULT_NAME_FOR_MERGED_SET_OF_FILES, options.OutputFormat.ToFileExtension()));


                SvgMergeHelper.GetHelper(options)
                .Merge(files, outputFilePath);

                return(Result.FromFiles(outputFilePath));
            }
            catch (Exception e)
            {
                return(Result.Error(e));
            }
        }
コード例 #2
0
        protected virtual Result MergeFiles(InputDataProvider data, ConversionApplicationOptions options)
        {
            using (var configuration = GetConfiguration(options))
            {
                var units = Enumerable.Empty <RenderingWorkUnit>();
                try
                {
                    units = data.GetData()
                            .Where(x => x.IsValid())
                            .Select(x => CreateWorkItem(x, configuration))
                            .ToArray();

                    var outputFilePath = Path.Combine(
                        HTMLOperationContextScope.Context.OutputFolder,
                        HTMLOperationContextScope.Context.Service.FileNameProvider
                        .GetNextFileName(ConversionApplication.DEFAULT_NAME_FOR_MERGED_SET_OF_FILES,
                                         options.OutputFormat.ToFileExtension()));

                    Render(units.Select(x => x).ToArray(), options, outputFilePath);

                    return(Result.FromFiles(outputFilePath));
                }
                catch (Exception e)
                {
                    return(Result.Error(e));
                }
                finally
                {
                    units.ForEach(x => x?.Dispose());
                }
            }
        }
コード例 #3
0
        protected virtual Result ConvertFiles(InputDataProvider data, ConversionApplicationOptions options)
        {
            try
            {
                foreach (var dataSource in data.GetData().Where(x => x.IsValid()))
                {
                    var outputFilePath = Path.Combine(
                        HTMLOperationContextScope.Context.OutputFolder,
                        HTMLOperationContextScope.Context.Service.FileNameProvider
                        .GetNextFileName(dataSource.Name, options.OutputFormat.ToFileExtension()));

                    using (var configuration = GetConfiguration(options))
                        using (var wu = CreateWorkItem(dataSource, configuration))
                        {
                            Render(wu, options, outputFilePath);
                        }
                }

                return(Result.FromDirectory(HTMLOperationContextScope.Context.OutputFolder));
            }
            catch (Exception e)
            {
                return(Result.Error(e));
            }
        }
コード例 #4
0
        public void GetData_Should_Be_Able_To_Read_Json_String_And_Provide_data(string jsonString)
        {
            var inputDataProviderProvider = new InputDataProvider();
            var data = inputDataProviderProvider.GetData(jsonString);

            Assert.NotNull(data);
            Assert.IsType <InputModel>(data);
        }
コード例 #5
0
        public override Result Execute(InputDataProvider data, ConversionApplicationOptions options)
        {
            if (options.Merge && data.GetData().Count(x => x.IsValid()) > 1)
            {
                return(MergeFiles(data, options));
            }

            return(ConvertFiles(data, options));
        }