예제 #1
0
    private void btnConnect_Click(object sender, EventArgs e)
    {
      if (!ClientSettings.IsValid())
      {
        MessageBox.Show("The settings are invalid.\nPlease check the configuration.", "ERROR", MessageBoxButtons.OK,
                        MessageBoxIcon.Error);
        return;
      }
      string connStr;
      string provider;
      if (!serverIntf.GetDatabaseConnectionString(out connStr, out provider))
      {
        SetupDatabaseForm frm = new SetupDatabaseForm();
        frm.ShowDialog();
        return;
      }
      if (ClientSettings.alwaysPerformConnectionChecks)
      {
        StBarLabel.Text = "Running connection test...";
        StBar.Update();
        frmConnectionTest connTest = new frmConnectionTest();
        connTest.RunChecks(ClientSettings.serverHostname, provider);
        if (connTest.GetFailedCount() > 0)
        {
          if (
            MessageBox.Show(
              "Some ports on the TvServer machine are not reachable.\n\nDo you want to try to connect nevertheless?",
              "Confirmation", MessageBoxButtons.YesNo, MessageBoxIcon.Question) != DialogResult.Yes)
          {
            StBarLabel.Text = "Not connected";
            return;
          }
        }
      }
      StBarLabel.Text = "Connecting to TvServer and loading groups/channels...";
      StBar.Update();
      serverIntf.ResetConnection();
      if (!serverIntf.Connect(ClientSettings.serverHostname))
      {
        SetDisconected();
        return;
      }
      cbGroups.Items.Clear();
      List<string> groups = serverIntf.GetGroupNames();
      if (groups == null)
      {
        SetDisconected();
        return;
      }
      foreach (string group in groups)
      {
        if (!cbAllChannels.Checked && group == "All Channels")
          continue;
        cbGroups.Items.Add(group);
      }
      if (cbGroups.Items.Count > 0)
        cbGroups.SelectedIndex = 0;

      cbRadioGroups.Items.Clear();
      List<string> radioGroups = serverIntf.GetRadioGroupNames();
      if (radioGroups == null)
      {
        SetDisconected();
        return;
      }
      foreach (string group in radioGroups)
      {
        if (!cbAllChannels.Checked && group == "All Channels")
          continue;
        cbRadioGroups.Items.Add(group);
      }
      if (cbRadioGroups.Items.Count > 0)
        cbRadioGroups.SelectedIndex = 0;

      StBarLabel.Text = "";
      tmrRefresh.Enabled = true;
      btnConnect.Visible = false;
    }
예제 #2
0
        private void btnConnect_Click(object sender, EventArgs e)
        {
            if (!ClientSettings.IsValid())
            {
                MessageBox.Show("The settings are invalid.\nPlease check the configuration.", "ERROR", MessageBoxButtons.OK,
                                MessageBoxIcon.Error);
                return;
            }
            string connStr;
            string provider;

            if (!serverIntf.GetDatabaseConnectionString(out connStr, out provider))
            {
                SetupDatabaseForm frm = new SetupDatabaseForm();
                frm.ShowDialog();
                return;
            }
            if (ClientSettings.alwaysPerformConnectionChecks)
            {
                StBarLabel.Text = "Running connection test...";
                StBar.Update();
                frmConnectionTest connTest = new frmConnectionTest();
                connTest.RunChecks(ClientSettings.serverHostname, provider);
                if (connTest.GetFailedCount() > 0)
                {
                    if (
                        MessageBox.Show(
                            "Some ports on the TvServer machine are not reachable.\n\nDo you want to try to connect nevertheless?",
                            "Confirmation", MessageBoxButtons.YesNo, MessageBoxIcon.Question) != DialogResult.Yes)
                    {
                        StBarLabel.Text = "Not connected";
                        return;
                    }
                }
            }
            StBarLabel.Text = "Connecting to TvServer and loading groups/channels...";
            StBar.Update();
            serverIntf.ResetConnection();
            if (!serverIntf.Connect(ClientSettings.serverHostname))
            {
                SetDisconected();
                return;
            }
            cbGroups.Items.Clear();
            List <string> groups = serverIntf.GetGroupNames();

            if (groups == null)
            {
                SetDisconected();
                return;
            }
            foreach (string group in groups)
            {
                if (!cbAllChannels.Checked && group == "All Channels")
                {
                    continue;
                }
                cbGroups.Items.Add(group);
            }
            if (cbGroups.Items.Count > 0)
            {
                cbGroups.SelectedIndex = 0;
            }

            cbRadioGroups.Items.Clear();
            List <string> radioGroups = serverIntf.GetRadioGroupNames();

            if (radioGroups == null)
            {
                SetDisconected();
                return;
            }
            foreach (string group in radioGroups)
            {
                if (!cbAllChannels.Checked && group == "All Channels")
                {
                    continue;
                }
                cbRadioGroups.Items.Add(group);
            }
            if (cbRadioGroups.Items.Count > 0)
            {
                cbRadioGroups.SelectedIndex = 0;
            }

            StBarLabel.Text    = "";
            tmrRefresh.Enabled = true;
            btnConnect.Visible = false;
        }