示例#1
0
    Dictionary <string, List <State> > WriteRows(string jsonPath, List <IGrouping <string, PostCodeRow> > groupByCountry)
    {
        IoHelpers.PurgeDirectory(jsonPath);
        var dictionary = new Dictionary <string, List <State> >();

        foreach (var group in groupByCountry)
        {
            dictionary.Add(group.Key, ProcessCountry(@group.Key, @group.ToList(), jsonPath));
        }

        return(dictionary);
    }
示例#2
0
    static IDictionary <string, List <State> > WriteRows(string jsonPath, List <IGrouping <string, PostCodeRow> > groupByCountry)
    {
        IoHelpers.PurgeDirectory(jsonPath);
        SortedDictionary <string, List <State> > dictionary = new();

        foreach (var group in groupByCountry)
        {
            dictionary.Add(group.Key, ProcessCountry(group.Key, group.OrderBy(x => x.CountryCode).ToList(), jsonPath));
        }

        return(dictionary);
    }
示例#3
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);
    }
    public async Task SyncData()
    {
        IoHelpers.PurgeDirectory(DataLocations.MapsPath);
        IoHelpers.PurgeDirectory(DataLocations.TempPath);

        await Get2016();
        await Get2019();


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

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

        var electorates = await WriteElectoratesMetaData();

        WriteNamedCs(electorates);
        Export.ExportElectorates();
        Zipper.ZipDir(DataLocations.MapsCuratedZipPath, DataLocations.MapsCuratedPath);
    }
示例#5
0
    public void Test()
    {
        var project    = Path.GetFullPath(Path.Combine(SourceDirectory, @"..\MyConsole\MyConsole.csproj"));
        var publishDir = Path.GetFullPath(Path.Combine(SourceDirectory, @"..\MyConsole\publish"));

        IoHelpers.PurgeDirectory(publishDir);
        var includesDir = Path.GetFullPath(Path.Combine(SourceDirectory, @"..\includes"));

        Directory.CreateDirectory(includesDir);
        var dictionary = new Dictionary <string, string>
        {
            { "Default", "Default" },
            { "Trimmed", "Trimmed" },
            { "Fdd", "Framework Dependent" },
            { "SingleFile", "Single File" },
            { "SingleFileFdd", "Single File and Framework Dependent" },
            { "SingleFileTrimmed", "Single File, Framework Dependent, and Trimmed" }
        };

        foreach (var profile in dictionary)
        {
            var output = ProcessRunner.StartDotNet("dotnet", $"publish {project} -c Release /p:PublishProfile={profile.Key}");
            WriteLine(output);
            Assert.True(Directory.Exists(Path.Combine(publishDir, profile.Key)));
        }

        foreach (var profile in dictionary)
        {
            var profileDir = Path.GetFullPath(Path.Combine(publishDir, profile.Key));
            WriteDoco(includesDir, profile.Key, profileDir);
            var exePath = Path.Combine(profileDir, "MyConsole.exe");
            var output  = ProcessRunner.StartDotNet(exePath, "");
            Assert.Contains("Hello World", output);
            Assert.Contains("SettingValue", output);
        }
    }