public void FileObjectFromString() { string adif = @" <adif_ver:5>3.1.0 <programid:6>WSJT-X <EOH> <call:6>DL8RBL <gridsquare:4>JN68 <mode:3>FT8 <rst_sent:3>+01 <rst_rcvd:3>-01 <qso_date:8>20200823 <time_on:6>153730 <qso_date_off:8>20200823 <time_off:6>153830 <band:3>10m <freq:9>28.074712 <station_callsign:5>M0LTE <my_gridsquare:6>IO91LK <tx_pwr:3>30W <EOR> <call:6>2E1EPQ <EOR>"; AdifFile.TryParse(adif, out var adifFile).Should().BeTrue(); adifFile.Header.Should().NotBeNull(); adifFile.Header.AdifVersion.Should().Be("3.1.0"); adifFile.Header.ProgramId.Should().Be("WSJT-X"); adifFile.Records.Should().NotBeNull(); adifFile.Records.Should().HaveCount(2); adifFile.Records[0].Call.Should().Be("DL8RBL"); adifFile.Records[0].GridSquare.Should().Be("JN68"); adifFile.Records[0].Mode.Should().Be("FT8"); adifFile.Records[0].RstSent.Should().Be("+01"); adifFile.Records[0].RstReceived.Should().Be("-01"); adifFile.Records[0].QsoStart.Should().Be(DateTime.Parse("2020-08-23T15:37:30Z", CultureInfo.InvariantCulture, DateTimeStyles.AssumeUniversal | DateTimeStyles.AdjustToUniversal)); adifFile.Records[0].QsoEnd.Should().Be(DateTime.Parse("2020-08-23T15:38:30Z", CultureInfo.InvariantCulture, DateTimeStyles.AssumeUniversal | DateTimeStyles.AdjustToUniversal)); adifFile.Records[0].Band.Should().Be("10m"); adifFile.Records[0].FreqMHz.Should().Be("28.074712"); adifFile.Records[0].StationCallsign.Should().Be("M0LTE"); adifFile.Records[0].MyGridSquare.Should().Be("IO91LK"); adifFile.Records[0].TxPower.Should().Be("30W"); adifFile.Records[1].Call.Should().Be("2E1EPQ"); }
static void Main(string[] args) { bool showProgress = args.Any(a => a == "--show-progress"); if (args.Any(a => a.EndsWith("configure", StringComparison.OrdinalIgnoreCase))) { DoConfigureDialogue(); return; } if (!File.Exists(ConfigFile)) { Console.WriteLine("Config not found - run again with --configure"); return; } ILinePusher linePusher = new CloudlogLinePusher(); if (!args.Any()) { using var client = new WsjtxClient(RecordReceived, IPAddress.Parse("239.1.2.3"), multicast: true, debug: true); Console.WriteLine($"Cloudlog instance: {linePusher.InstanceUrl}"); Console.WriteLine($"Listening for WSJT-X, ctrl-c to quit..."); Thread.CurrentThread.Join(); void RecordReceived(WsjtxMessage message) { if (!(message is LoggedAdifMessage loggedAdifMessage)) { return; } if (!AdifFile.TryParse(loggedAdifMessage.AdifText, out AdifFile adifFile)) { return; } string adifRecord = adifFile.Records.Single().ToString(); PushLineResult[] results = linePusher.PushLines(new[] { adifRecord }, false, default).Result; foreach (var result in results) { if (result.Success) { Console.WriteLine($"Uploaded QSO with {result.Record.Call}"); } else { Console.WriteLine($"Error uploading: {result.ErrorContent}"); } } } } else { // one-off upload if (!args.Any(File.Exists)) { Console.WriteLine("No existing ADIF file specified"); return; } foreach (var file in args.Where(File.Exists)) { var lines = GetRecords(file) .Select(ar => ar.ToString()) .ToArray(); PushLineResult[] results = linePusher.PushLines(lines, showProgress, default).Result; Console.WriteLine($"{file}: {results.Count(r => r.Success)} successful, {results.Count(r => !r.Success)} failure(s)"); for (int i = 0; i < results.Length; i++) { if (results[i].Success) { continue; } Console.WriteLine($" Line {i + 1}: {results[i].ErrorContent}"); } } } }