Ejemplo n.º 1
0
    public async Task SyncData()
    {
        // Hasher.Clear(DataLocations.DataPath);
        IoHelpers.PurgeDirectory(DataLocations.MapsPath);
        IoHelpers.PurgeDirectory(DataLocations.TempPath);

        await PartyScraper.Run();

        await Get2016();
        await Get2019();

        File.Copy(DataLocations.Australia2019JsonPath, DataLocations.FutureAustraliaJsonPath);
        await StatesToCountryDownloader.RunFuture();

        await ProcessYear(DataLocations.Maps2016Path, electorates2016);
        await ProcessYear(DataLocations.Maps2019Path, electorates2019);
        await ProcessYear(DataLocations.MapsFuturePath, electoratesFuture);

        var electorates = await WriteElectoratesMetaData();

        IoHelpers.PurgeDirectoryRecursive(DataLocations.MapsDetail);
        foreach (var electorate in electorates)
        {
            var targetPath = Path.Combine(DataLocations.MapsDetail, $"{electorate.ShortName}.pdf");
            await Downloader.DownloadFile(targetPath, electorate.MapUrl);
        }

        foreach (var file in Directory.EnumerateFiles(DataLocations.MapsDetail))
        {
            var pngPath = await PdfToPng.Convert(file);

            File.Delete(file);

            CreatePortraitAndLandscape(pngPath);
        }

        WriteNamedCs(electorates);
        Export.ExportElectorates();
        // await Hasher.Create(DataLocations.DataPath);
        Zipper.ZipDir(DataLocations.MapsCuratedZipPath, DataLocations.MapsCuratedPath);
    }
Ejemplo n.º 2
0
    public Task ConvertSingle()
    {
        var fullPath = Path.GetFullPath("sample_electorate_map.pdf");

        return(PdfToPng.Convert(fullPath));
    }