Beispiel #1
0
        /// <summary>
        /// Look up a call sign.
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void ButtonCallLookup_Click(object sender, EventArgs e)
        {
            IEnumerable <CallSignInfo> hitCollection;
            string heading;
            string distance;
            string grid = "";

            ListViewResults.Items.Clear();

            try
            {
                if (TextBoxCallSign.Text != "")
                {
                    if (CheckBoxQRZ.Checked)
                    {
                        if (!string.IsNullOrEmpty(settings.QRZLogonId) && !string.IsNullOrEmpty(settings.QRZLogonId))
                        {
                            hitCollection = CallLookUp.LookUpCall(TextBoxCallSign.Text, settings.QRZLogonId, settings.QRZPassword);
                        }
                        else
                        {
                            MessageBox.Show("Please go to Plugin Settings and add your QRZ.com credentials", "Missing Credentials", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                            return;
                        }
                    }
                    else
                    {
                        hitCollection = CallLookUp.LookUpCall(TextBoxCallSign.Text);
                    }

                    if (hitCollection != null)
                    {
                        var hitList = hitCollection.ToList();
                        foreach (CallSignInfo hit in hitList)
                        {
                            if (settings.Grid != "")
                            {
                                grid     = GetGridFromLatLong(hit.Latitude, hit.Longitude);
                                heading  = GetHeading(grid);
                                distance = GetDistance(grid);
                            }
                            else
                            {
                                heading  = "0";
                                distance = "0";
                            }

                            UpdateListViewResults(hit, heading, distance, grid);
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message, "An Error Occurred", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
Beispiel #2
0
        public void CallLookUp()
        {
            List <Hit> result;
            int        expected;

            _PrefixFileParser = new PrefixFileParser();
            _PrefixFileParser.ParsePrefixFile("");
            _CallLookUp = new CallLookUp(_PrefixFileParser);

            // Add calls where mask ends with '.' ie: KG4AA and as compare KG4AAA
            string[] testCallSigns = new string[16] {
                "TX9", "TX4YKP/R", "/KH0PR", "W6OP/4", "OEM3SGU/3", "AM70URE/8", "5N31/OK3CLA", "BV100", "BY1PK/VE6LB",
                "VE6LB/BY1PK", "DC3RJ/P/W3", "RAEM", "AJ3M/BY1RX", "4D71/N0NM", "OEM3SGU", "KG4AA"
            };                                                                                         //, "4X130RISHON", "9N38", "AX3GAMES", "DA2MORSE", "DB50FIRAC", "DL50FRANCE", "FBC5AGB", "FBC5NOD", "FBC5YJ", "FBC6HQP", "GB50RSARS", "HA80MRASZ", "HB9STEVE", "HG5FIRAC", "HG80MRASZ", "II050SCOUT", "IP1METEO", "J42004A", "J42004Q", "LM1814", "LM2T70Y", "LM9L40Y", "LM9L40Y/P", "OEM2BZL", "OEM3SGU", "OEM3SGU/3", "OEM6CLD", "OEM8CIQ", "OM2011GOOOLY", "ON1000NOTGER", "ON70REDSTAR", "PA09SHAPE", "PA65VERON", "PA90CORUS", "PG50RNARS", "PG540BUFFALO", "S55CERKNO", "TM380", "TYA11", "U5ARTEK/A", "V6T1", "VI2AJ2010", "VI2FG30", "VI4WIP50", "VU3DJQF1", "VX31763", "WD4", "XUF2B", "YI9B4E", "YO1000LEANY", "ZL4RUGBY", "ZS9MADIBA" };
            int[] testResult = new int[16] {
                0, 7, 1, 1, 1, 1, 1, 0, 0, 1, 1, 0, 1, 1, 1, 1
            };

            for (int counter = 0; counter <= testCallSigns.Length - 1; counter++)
            {
                result   = _CallLookUp.LookUpCall(testCallSigns[counter]).ToList();
                expected = testResult[counter];

                Assert.AreEqual(expected, result.Count());
            }
        }
Beispiel #3
0
        public void CallLookUpEx()
        {
            List <Hit> result;

            (double dxcc, string entity)expected;
            bool isMatchFound;

            _PrefixFileParser = new PrefixFileParser();
            _PrefixFileParser.ParsePrefixFile("");
            _CallLookUp = new CallLookUp(_PrefixFileParser);

            // Add calls where mask ends with '.' ie: KG4AA and as compare KG4AAA

            foreach (var key in goodDataCheck.Keys)
            {
                isMatchFound = false;
                result       = _CallLookUp.LookUpCall(key).ToList();

                switch (result.Count)
                {
                case 0:
                    Assert.IsTrue(badDataCheck.ContainsKey(key));
                    break;

                case 1:
                    if (result[0].Kind == PrefixKind.Province)
                    {
                        expected = (result[0].DXCC, result[0].Province);
                        Assert.AreEqual(goodDataCheck[key], expected);     //W6OP/3B7
                    }
                    else
                    {
                        expected = (result[0].DXCC, result[0].Country);
                        Assert.AreEqual(goodDataCheck[key], expected);
                    }
                    break;

                default:     // multiple hits
                    foreach (Hit hit in result)
                    {
                        if (hit.Kind == PrefixKind.Province)
                        {
                            expected = (hit.DXCC, hit.Province);
                            if (expected == goodDataCheck[key])
                            {
                                isMatchFound = true;
                            }
                        }
                        else
                        {
                            expected = (hit.DXCC, hit.Country);
                            if (expected == goodDataCheck[key])
                            {
                                isMatchFound = true;
                            }
                        }
                    }

                    Assert.IsTrue(isMatchFound);
                    break;
                }
            }
        }
Beispiel #4
0
        public void CallLookUpBatch()
        {
            List <Hit>    result;
            List <string> callSigns = new List <string>();

            (double dxcc, string entity)expected;
            bool isMatchFound;

            _PrefixFileParser = new PrefixFileParser();
            _PrefixFileParser.ParsePrefixFile("");
            _CallLookUp = new CallLookUp(_PrefixFileParser);

            foreach (var key in goodDataCheck.Keys)
            {
                callSigns.Add(key);
            }

            List <Hit> hitList = _CallLookUp.LookUpCall(callSigns).ToList();

            foreach (var hit in hitList)
            {
                isMatchFound = false;
                result       = hitList; // _CallLookUp.LookUpCall(key).ToList();

                switch (result.Count)
                {
                case 0:
                    Assert.IsTrue(badDataCheck.ContainsKey(hit.CallSign));
                    break;

                case 1:
                    if (result[0].Kind == PrefixKind.Province)
                    {
                        expected = (result[0].DXCC, result[0].Province);
                        Assert.AreEqual(goodDataCheck[hit.CallSign], expected);     //W6OP/3B7
                    }
                    else
                    {
                        expected = (result[0].DXCC, result[0].Country);
                        Assert.AreEqual(goodDataCheck[hit.CallSign], expected);
                    }
                    break;

                default:     // multiple hits
                    foreach (Hit hit2 in result)
                    {
                        if (hit2.Kind == PrefixKind.Province)
                        {
                            expected = (hit2.DXCC, hit2.Province);
                            if (expected == goodDataCheck[hit2.CallSign])
                            {
                                isMatchFound = true;
                            }
                        }
                        else
                        {
                            expected = (hit2.DXCC, hit2.Country);
                            if (expected == goodDataCheck[hit2.CallSign])
                            {
                                isMatchFound = true;
                            }
                        }
                    }

                    Assert.IsTrue(isMatchFound);
                    break;
                }
            }
        }
Beispiel #5
0
        /// <summary>
        /// Look up a single call in the input text box.
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void ButtonSingleCallLookup_Click(object sender, EventArgs e)
        {
            IEnumerable <Hit> hitCollection;
            List <Hit>        hitList;

            if (_CallLookUp == null)
            {
                MessageBox.Show("Please load the prefix file before doing a lookup.", "Missng Prefix file", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                return;
            }

            ListViewResults.Items.Clear();
            LabelCallsLoaded.Text = "";

            if (CheckBoxQRZ.CheckState == CheckState.Checked && (TextBoxQRZuserId.Text == "QRZ User Id" || TextBoxQRZPassword.Text == "QRZ Password"))
            {
                MessageBox.Show("The QRZ User Id and Password are required", "Missing Credentials", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                return;
            }

            try
            {
                if (!string.IsNullOrEmpty(TextBoxCall.Text))
                {
                    if (CheckBoxQRZ.CheckState == CheckState.Checked)
                    {
                        hitCollection = _CallLookUp.LookUpCall(TextBoxCall.Text, TextBoxQRZuserId.Text, TextBoxQRZPassword.Text);
                    }
                    else
                    {
                        hitCollection = _CallLookUp.LookUpCall(TextBoxCall.Text);
                    }

                    if (hitCollection != null)
                    {
                        hitList = hitCollection.ToList();

                        Console.WriteLine(hitList.Count.ToString() + " hits returned");
                        LabelHitCount.Text = "Finished - hitcount = " + hitList.Count.ToString();

                        foreach (Hit hit in hitList)
                        {
                            var flags = string.Join(",", hit.CallSignFlags);

                            // TODO: add back in
                            //if (!hit.IsMergedHit)
                            //{
                            UpdateListViewResults(hit.CallSign, hit.Kind, hit.Country, hit.Province, hit.DXCC.ToString(), flags);
                            //}
                            //else
                            //{
                            //    var merged = MergeDXCCList(hit.DXCCMerged);
                            //    UpdateListViewResults(hit.CallSign, hit.Kind, hit.Country, hit.Province, hit.DXCC.ToString() + "," + merged, flags);
                            //}
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }

            Cursor.Current = Cursors.Default;
            Console.WriteLine("Finished");
        }