示例#1
0
        public XsdFilesRetriever(BulkLoadClientConfiguration configuration,
                                 IXsdMetadataInformationProvider xsdMetadataInformationProvider,
                                 IXsdMetadataFilesProvider xsdMetadataFilesProvider,
                                 IRemoteFileDownloader remoteFileDownloader,
                                 OdsVersionInformation odsVersionInformation)
        {
            _configuration = configuration;
            _xsdMetadataInformationProvider = xsdMetadataInformationProvider;
            _xsdMetadataFilesProvider       = xsdMetadataFilesProvider;
            _remoteFileDownloader           = remoteFileDownloader;
            _odsVersionInformation          = odsVersionInformation;
            _httpClient = new HttpClient {
                Timeout = new TimeSpan(0, 0, 5, 0)
            };

            _xsdMedataUrl  = _configuration.XsdMetadataUrl;
            _extension     = _configuration.Extension;
            _xsdFolder     = Path.GetFullPath(_configuration.XsdFolder);
            _workingFolder = Path.GetFullPath(_configuration.WorkingFolder);

            ValidateXsdFolder();

            void ValidateXsdFolder()
            {
                // create the xsd folder if it does not exists so that the dependencies work.
                if (!Directory.Exists(_xsdFolder))
                {
                    Directory.CreateDirectory(_xsdFolder);
                }
            }
        }
示例#2
0
        private static ILifetimeScope RegisterContainer(IConfiguration configuration,
                                                        OdsVersionInformation odsVersionInformation,
                                                        BulkLoadClientConfiguration bulkLoadClientConfiguration)
        {
            var builder = new ContainerBuilder();

            builder.RegisterInstance(configuration)
            .As <IConfiguration>()
            .As <IConfigurationRoot>()
            .SingleInstance();

            builder.RegisterInstance(odsVersionInformation)
            .SingleInstance();

            builder.RegisterInstance(bulkLoadClientConfiguration)
            .As <IApiConfiguration>()
            .As <IHashCacheConfiguration>()
            .As <IDataConfiguration>()
            .As <IOAuthTokenConfiguration>()
            .As <IApiMetadataConfiguration>()
            .As <IXsdConfiguration>()
            .As <IInterchangeOrderConfiguration>()
            .As <IThrottleConfiguration>()
            .AsSelf()
            .SingleInstance();

            builder.RegisterModule(new LoadToolsModule());

            if (configuration.GetValue <bool>("IncludeStats"))
            {
                builder.RegisterModule(new IncludeStatsModule());
            }

            return(builder.Build());
        }
示例#3
0
        private static async Task LoadXsdFiles(BulkLoadClientConfiguration bulkLoadClientConfiguration,
                                               OdsVersionInformation odsVersionInformation)
        {
            using var xsdFilesRetriever = new XsdFilesRetriever(
                      bulkLoadClientConfiguration,
                      new XsdMetadataInformationProvider(),
                      new XsdMetadataFilesProvider(),
                      new RemoteFileDownloader(),
                      odsVersionInformation);

            await xsdFilesRetriever.DownloadXsdFilesAsync();
        }
示例#4
0
        public async Task Should_get_xsd_metadata_information_and_download_files()
        {
            var odsVersionInformation = new OdsVersionInformation
            {
                DataModels = new List <Dictionary <string, string> >
                {
                    new Dictionary <string, string>
                    {
                        { "name", "Ed-Fi" },
                        { "version", "3.3.1-b" }
                    },
                    new Dictionary <string, string>
                    {
                        { "name", "TPDM" },
                        { "version", "1.1.0" }
                    }
                }
            };

            using var sut = new XsdFilesRetriever(
                      _configuration,
                      new XsdMetadataInformationProvider(),
                      new XsdMetadataFilesProvider(),
                      new RemoteFileDownloader(),
                      odsVersionInformation);

            sut.ShouldNotBeNull();

            await sut.DownloadXsdFilesAsync();

            Directory.Exists(_xsdFolder).ShouldBeTrue();

            string[] files = Directory.GetFiles(_xsdFolder);
            files.Length.ShouldNotBe(0);

            foreach (var file in files)
            {
                var fileInfo = new FileInfo(file);

                fileInfo.Exists.ShouldBe(true);

                // validate we actually wrote the contents of the file
                fileInfo.Length.ShouldBeGreaterThan(0);
            }
        }