Exemplo n.º 1
0
        static void MakeUpRandomData()
        {
            var repo = new ContactDbRepo();

            foreach (var contact in repo.GetList())
            {
                repo.Delete(contact);
            }

            var calls = new[] { "M0LTE", "2E0XLX", "G4RDC", "2E0JPM", "2E1EPQ" };
            var bands = new[] { 21, 14, 7, 3.5, 1.8 };

            for (int i = 0; i < 10000; i++)
            {
                Debug.WriteLine(i);
                DateTime dt = DateTime.Now.AddDays(-1).AddSeconds(i * 10 + rnd.Next(0, 6));
                repo.Add(new ContactDbRow
                {
                    Band            = bands[rnd.Next(0, bands.Length)],
                    Operator        = calls[rnd.Next(0, calls.Length)],
                    Call            = MakeUpCallsign(),
                    ContestNumber   = 10,
                    IsMultiplier1   = rnd.Next(5) == 0,
                    StationName     = "stn-" + (rnd.Next(2) + 1),
                    TimestampUtc_dt = dt
                });
            }
        }
Exemplo n.º 2
0
        public IActionResult GetPeakRateLeaderboard()
        {
            var repo = new ContactDbRepo();

            var sw = Stopwatch.StartNew();
            List <LeaderboardRow> list = repo.GetPeakRateLeaderboard();

            InsertHeader(sw);

            return(Ok(list));
        }
Exemplo n.º 3
0
        static void DeleteContact(string n1mmTimestamp, string stationName)
        {
            var contactRepo = new ContactDbRepo(pathToDb);

            // search for which contact to delete by station name and timestamp
            if (DateTime.TryParse(n1mmTimestamp, out DateTime ts))
            {
                if (ts != new DateTime(1900, 1, 1, 0, 0, 0)) // for some reason n1mm passes us this in some circumstances, no idea what we're supposed to do with it
                {
                    if (!string.IsNullOrWhiteSpace(stationName))
                    {
                        var contacts = contactRepo.GetList(contactTime: ts, stationName: stationName);

                        foreach (var contact in contacts)
                        {
                            contactRepo.Delete(contact);
                        }
                    }
                }
            }
        }
Exemplo n.º 4
0
        static void ProcessContactAdd(N1mmXmlContactInfo ci)
        {
            if (!OnlyProcessOriginals || (OnlyProcessOriginals && ci.IsOriginal == "True"))
            {                            // True = contact was originated on this computer. Without this check, in a multiple n1mm scenario,
                                         // if this computer has All QSOs selected, we will receive the contact twice. We only want
                                         // the one from the PC on which the contact was logged. This does mean every n1mm instance
                                         // will need to be configured to send datagrams to us. That seems reasonable.

                Console.WriteLine($"Adding a contact: {ci.Call}  / {ci.Operator}");

                var contactRepo = new ContactDbRepo(pathToDb);

                ContactDbRow row = Mappers.Map(ci);

                contactRepo.Add(row);
            }
            else
            {
                Console.WriteLine($"Skipping a non-original contact: {ci.Call} / {ci.Operator}");
            }
        }
Exemplo n.º 5
0
        static void ProcessContactReplace(N1mmXmlContactReplace cr)
        {
            if (cr.IsOriginal == "True") // True = contact was originated on this computer. Without this check, in a multiple n1mm scenario,
            {                            // if this computer has All QSOs selected, we will receive the contact twice. We only want
                                         // the one from the PC on which the contact was logged. This does mean every n1mm instance
                                         // will need to be configured to send datagrams to us. That seems reasonable.

                Console.WriteLine($"Replacing a contact: {cr.Call} / {cr.Operator}");

                var contactRepo = new ContactDbRepo(pathToDb);

                DeleteContact(cr.Timestamp, cr.StationName);

                ContactDbRow row = Mappers.Map(cr);

                contactRepo.Add(row);
            }
            else
            {
                Console.WriteLine($"Skipping a replace (non-original): {cr.Call} / {cr.Operator}");
            }
        }