Example #1
0
        public ClubLogImportForm(ContactStore contactStore = null)
        {
            ContactStore = contactStore;
            InitializeComponent();

            m_Username.Text = RegistryHelper.GetString(RegistryValue.ClublogUsername, string.Empty);
            m_Password.Text = RegistryHelper.GetString(RegistryValue.ClublogPassword, string.Empty);
        }
Example #2
0
        private void RunHrdSync()
        {
            using (ContactStore cs = new ContactStore(m_Server, m_Database, m_Username, m_Password))
            {
                Exception storedEx = null;

                using (OdbcConnection localConn = new OdbcConnection(m_ConnString))
                {
                    localConn.Open();
                    List<int> keysToMarkUploaded = new List<int>();
                    using (OdbcCommand localCmd = localConn.CreateCommand())
                    {
                        try
                        {
                            localCmd.CommandText = @"SELECT * FROM TABLE_HRD_CONTACTS_V01 WHERE COL_USER_DEFINED_1 IS NULL OR COL_USER_DEFINED_1 <> 'CamLogUploadDone'";
                            using (OdbcDataReader reader = localCmd.ExecuteReader())
                            {
                                while (reader.Read())
                                {
                                    Contact c = new Contact();
                                    c.SourceId = cs.SourceId;
                                    c.Callsign = (string)reader["COL_CALL"];
                                    c.StartTime = (DateTime)reader["COL_TIME_ON"];
                                    c.EndTime = (DateTime)reader["COL_TIME_OFF"];
                                    c.Band = BandHelper.Parse(reader["COL_BAND"] as string);
                                    c.Frequency = GetFrequency(reader.GetInt32(reader.GetOrdinal("COL_FREQ")).ToString());
                                    c.Mode = ModeHelper.Parse(reader["COL_MODE"] as string);
                                    c.Operator = (reader["COL_OPERATOR"] as string) ?? m_DefaultOperator.Text;
                                    c.Station = m_Station;
                                    c.LocatorReceived = new Locator(0, 0);
                                    c.ReportReceived = c.ReportSent = "599";
                                    cs.SaveContact(c);
                                    Invoke(new MethodInvoker(() => m_LastQsoLabel.Text = c.Callsign));
                                    keysToMarkUploaded.Add(reader.GetInt32(reader.GetOrdinal("COL_PRIMARY_KEY")));
                                }
                            }
                        }
                        catch (Exception ex)
                        {
                            storedEx = ex;
                        }
                    }

                    using (OdbcCommand updateCommand = localConn.CreateCommand())
                    {
                        foreach (int key in keysToMarkUploaded)
                        {
                            updateCommand.CommandText =
                                "UPDATE TABLE_HRD_CONTACTS_V01 SET COL_USER_DEFINED_1='CamLogUploadDone' WHERE COL_PRIMARY_KEY=" + key;
                            updateCommand.ExecuteNonQuery();
                        }
                    }

                    if (storedEx != null)
                        throw storedEx;
                }
            }
        }
Example #3
0
 protected override void OnActionExecuting(ActionExecutingContext filterContext)
 {
     m_ContactStore = Session["ContactStore"] as ContactStore;
     if (m_ContactStore == null)
     {
         filterContext.Result = Redirect("~/Login");
         return;
     }
     base.OnActionExecuting(filterContext);
 }
Example #4
0
        public void FixAdifDates()
        {
            List<Contact> adifContacts = AdifHandler.ImportAdif(File.ReadAllText(@"C:\temp\test.adi"), string.Empty, 0, "M0VFC");
            ContactStore store = new ContactStore("localhost", "fp2011", "root", "aopen");

            foreach (Contact adifContact in adifContacts)
            {
                // Find the matching one in the DB
                List<Contact> existingContacts = store.GetPreviousContacts(adifContact.Callsign);
                List<Contact> probableMatches = existingContacts.FindAll(c => c.StartTime.TimeOfDay == adifContact.StartTime.TimeOfDay && c.Band == adifContact.Band);
                if (probableMatches.Count == 1)
                {
                    probableMatches[0].StartTime = probableMatches[0].EndTime = adifContact.StartTime;
                    store.SaveContact(probableMatches[0]);
                }
                else
                {
                    Assert.Fail("Failed to find single matching QSO: " + adifContact);
                }
            }
        }
Example #5
0
 public void CountCountries()
 {
     ContactStore store = new ContactStore("localhost", "zd92012", "root", "g3pyeflossie");
     List<Contact> contacts = store.GetAllContacts(null);
     CallsignLookup cl = new CallsignLookup("cty.xml.gz");
     Dictionary<string, int> countries = new Dictionary<string,int>();
     foreach (Contact c in contacts)
     {
         try
         {
             PrefixRecord pr = cl.LookupPrefix(c.Callsign);
             int count;
             if (countries.TryGetValue(pr.Entity, out count))
             {
                 countries[pr.Entity] = count + 1;
             }
             else
             {
                 countries[pr.Entity] = 1;
             }
         }
         catch
         {
             Debug.WriteLine("Unable to get entity: " + c.Callsign);
         }
     }
     List<KeyValuePair<string, int>> countryList = new List<KeyValuePair<string,int>>();
     foreach (var kvp in countries)
         countryList.Add(kvp);
     countryList.Sort((k1, k2) => {
         if (k1.Value == k2.Value)
             return string.CompareOrdinal(k1.Key, k2.Key);
         else
             return k2.Value - k1.Value;
     });
     foreach (var kvp in countryList)
         Console.WriteLine("{0}: {1}", kvp.Key, kvp.Value);
 }
Example #6
0
        public void OpenLog()
        {
            // Get the login details
            using (LogonForm lf = new LogonForm())
            {
                DialogResult dr = lf.ShowDialog();
                if (dr != DialogResult.OK)
                    return;

                ContactStore = new ContactStore(lf.Server, lf.Database, lf.Username, lf.Password);
                if (ContactStoreChanged != null)
                    ContactStoreChanged(this, new EventArgs());

                if (!string.IsNullOrEmpty(lf.CivSerialPort) && lf.RadioModel.HasValue)
                {
                    Radio = new RadioFactory().GetRadio(lf.RadioModel.Value, new RadioConnectionSettings { BaudRate = lf.CivSpeed, FlowControl = FlowControl.None, Port = lf.CivSerialPort, UseDTR = lf.CivDtr, UseRTS = lf.CivRts});
                    if (Radio is IWinKey)
                        CWMacro.WinKey = (IWinKey)Radio;
                    if (CivServerChanged != null)
                        CivServerChanged(this, new EventArgs());
                }
            }
        }
Example #7
0
        private void m_Connect_Click(object sender, EventArgs e)
        {
            try
            {
                try
                {
                    ContactStore = new ContactStore(Server, Database, Username, Password);
                }
                catch (ContactStore.DatabaseNotFoundException)
                {
                    DialogResult dr = MessageBox.Show(string.Format("Database '{0}' doesn't exist, or you don't have permission to use it. Try and create it as a new log?", Database), "Database not found", MessageBoxButtons.YesNo, MessageBoxIcon.Question);
                    if (dr == System.Windows.Forms.DialogResult.No)
                        return;

                    // OK, so try and create the new DB...
                    ContactStore = ContactStore.Create(Server, Database, Username, Password);
                }

                if (ContactStore != null)
                {
                    using (RegistryKey key = Registry.CurrentUser.CreateSubKey(c_RegistryRoot))
                    {
                        key.SetValue("Server", Server);
                        key.SetValue("Database", Database);
                        key.SetValue("Username", Username);
                        key.SetValue("Password", Password);
                    }

                    DialogResult = DialogResult.OK;
                    Close();
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
        }
Example #8
0
 public CWMacro(ContactStore store)
 {
     ContactStore = store;
     LoadMacros();
 }
Example #9
0
 public ClubLogCSVHandler(ContactStore contactStore, PdfEngine engine)
 {
     m_ContactStore = contactStore;
     m_PdfEngine = engine;
 }
Example #10
0
 public void TryImportAdif()
 {
     List<Contact> contacts = AdifHandler.ImportAdif(File.ReadAllText(@"c:\users\rob\Documents\win-test\DXPED-HF-ALL_2012@ZD9UW\ZD9-2012-10-04-1230.ADI"), "LUNGA", 2, "GS6PYE/P");
     ContactStore store = new ContactStore("localhost", "zd92012", "root", "g3pyeflossie");
     contacts.ForEach(store.SaveContact);
 }
Example #11
0
        private bool ShowLogon()
        {
            using (LogonForm lf = new LogonForm())
            {
                DialogResult dr = lf.ShowDialog();
                if (dr != System.Windows.Forms.DialogResult.OK)
                    return false;

                m_ContactStore = lf.ContactStore;
                m_SourceIdCallsigns = m_ContactStore.GetSources();
                m_CallsignsInLog = m_ContactStore.GetAllCallsigns();

                m_OurCallsign.BeginUpdate();
                m_OurCallsign.Items.Clear();
                foreach (SourceCallsign src in m_SourceIdCallsigns)
                {
                    m_OurCallsign.Items.Add(src);
                }
                if (m_OurCallsign.Items.Count > 0)
                    m_OurCallsign.SelectedIndex = 0;
                m_OurCallsign.EndUpdate();

                return true;
            }
        }
Example #12
0
        private void ContactStoreChanged(object sender, EventArgs e)
        {
            m_ContactStore = Controller.ContactStore;

            m_RedrawTimer.Enabled = true;
            m_SerialSent.Text = m_ContactStore.GetSerial(Band.Unknown).ToString().PadLeft(3, '0');
        }
Example #13
0
        private void RunMixWSync()
        {
            DateTime lastQsoThisRun = m_LastQsoSeen;

            using (ContactStore cs = new ContactStore(m_Server, m_Database, m_Username, m_Password))
            {
                Exception storedEx = null;

                string[] logLines = File.ReadAllLines(m_ConnString);
                foreach (string line in logLines)
                {
                    string[] lineBits = line.Split(';');
                    Contact c = new Contact();
                    long freq = long.Parse(lineBits[6]) / 1000 * 1000;
                    string dateString = lineBits[2];

                    c.Band = BandHelper.FromFrequency(freq);
                    c.Callsign = lineBits[1].Trim().ToUpperInvariant();
                    c.EndTime = c.StartTime = new DateTime(
                        int.Parse(dateString.Substring(0, 4)),
                        int.Parse(dateString.Substring(4, 2)),
                        int.Parse(dateString.Substring(6, 2)),
                        int.Parse(dateString.Substring(8, 2)),
                        int.Parse(dateString.Substring(10, 2)),
                        int.Parse(dateString.Substring(12, 2)));
                    c.Frequency = freq;
                    c.Mode = ModeHelper.Parse(lineBits[9]);
                    c.Operator = m_DefaultOperator.Text;
                    c.ReportReceived = lineBits[10];
                    c.ReportSent = lineBits[11];
                    c.Station = m_Station;

                    // If we've already uploaded something more recent, don't bother hitting the DB...
                    if (m_LastQsoSeen >= c.StartTime)
                    {
                        continue;
                    }
                    if (c.StartTime > lastQsoThisRun)
                        lastQsoThisRun = c.StartTime;

                    Contact previousQso = cs.GetPreviousContacts(c.Callsign).Find(previousContact => previousContact.StartTime == c.StartTime);
                    if (previousQso == null)
                    {
                        cs.SaveContact(c);

                        Invoke(new MethodInvoker(() => m_LastQsoLabel.Text = c.Callsign));
                    }
                }

                m_LastQsoSeen = lastQsoThisRun;

                if (storedEx != null)
                    throw storedEx;
            }
        }
Example #14
0
        private void m_Connect_Click(object sender, EventArgs e)
        {
            try
            {
                // Try making a connection
                using (MySqlConnection conn = new MySqlConnection())
                {
                    MySqlConnectionStringBuilder csb = new MySqlConnectionStringBuilder();
                    csb.Server = Server;
                    //csb.Database = Database;
                    csb.UserID = Username;
                    csb.Password = Password;
                    conn.ConnectionString = csb.ConnectionString;
                    conn.Open();
                    conn.Close();

                    Settings.Set("Server", Server);
                    Settings.Set("Database", Database);
                    Settings.Set("Username", Username);
                    Settings.Set("Password", Password);
                    if (CivSerialPort != null)
                        Settings.Set("SerialPort", CivSerialPort);
                    else
                        Settings.Set("SerialPort", string.Empty);
                    Settings.Set("CivDtr", CivDtr.ToString());
                    Settings.Set("CivRts", CivRts.ToString());
                    Settings.Set("CivSpeed", m_Speed.Text);
                    Settings.Set("RadioModel", m_RadioModel.Text);
                }

                try
                {
                    ContactStore = new ContactStore(Server, Database, Username, Password);
                }
                catch (ContactStore.DatabaseNotFoundException)
                {
                    DialogResult dr = MessageBox.Show(string.Format("Database '{0}' doesn't exist, or you don't have permission to use it. Try and create it as a new log?", Database), "Database not found", MessageBoxButtons.YesNo, MessageBoxIcon.Question);
                    if (dr == System.Windows.Forms.DialogResult.No)
                        return;

                    // OK, so try and create the new DB...
                    ContactStore = ContactStore.Create(Server, Database, Username, Password);
                }
                DialogResult = DialogResult.OK;
                Close();
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
        }
Example #15
0
 public ActionResult Index(string server, string database, string username, string password)
 {
     ContactStore cs = new ContactStore(server, database, username, password);
     Session["ContactStore"] = cs;
     return Redirect("~/");
 }