Beispiel #1
0
        private async void MasterServerRefreshButton_Click(object sender, EventArgs e)
        {
            if (!string.IsNullOrWhiteSpace(MasterServerBox.Text))
            {
                try
                {
                    serverList.Clear();

                    await LoadServerInfoFromFile("http://" + MasterServerBox.Text + "/serverlist.txt");

                    ServerListView.BeginUpdate();
                    ServerListView.Clear();

                    if (serverList.Count > 0)
                    {
                        var ColumnName = new ColumnHeader();
                        ColumnName.Text      = "Name";
                        ColumnName.TextAlign = HorizontalAlignment.Center;
                        ColumnName.Width     = 284;
                        ServerListView.Columns.Add(ColumnName);

                        var ColumnClient = new ColumnHeader();
                        ColumnClient.Text      = "Client";
                        ColumnClient.TextAlign = HorizontalAlignment.Center;
                        ColumnClient.Width     = 75;
                        ServerListView.Columns.Add(ColumnClient);

                        foreach (var server in serverList)
                        {
                            var serverItem = new ListViewItem(server.ServerName);

                            var serverClient = new ListViewSubItem(serverItem, server.ServerClient);
                            serverItem.SubItems.Add(serverClient);

                            ServerListView.Items.Add(serverItem);
                        }
                    }
                    else
                    {
                        MessageBox.Show("There are no servers available on this master server.");
                    }

                    ServerListView.EndUpdate();
                }
                catch (Exception ex)
                {
                    MessageBox.Show("Unable to load servers. (" + ex + ")");
                }
            }
        }
Beispiel #2
0
        /// <summary>
        /// Display the server information in the listview.
        /// </summary>
        private void ShowServerInformation()
        {
            ListViewItem ServerListViewItem;

            try
            {
                ServerListView.BeginUpdate();

                // Clear control
                ServerListView.Items.Clear();

                // Initialize the server settings
                SqlServerSelection.Settings.Initialize(true);

                // Initialize the server information settings
                SqlServerSelection.Information.Initialize(true);

                // Initialize the server
                SqlServerSelection.Initialize(true);

                // Iterate through all the properties and add each one to the list
                foreach (Property prop in SqlServerSelection.Settings.
                         Properties)
                {
                    ServerListViewItem = ServerListView.Items.Add(prop.
                                                                  Name);
                    ServerListViewItem.SubItems.Add(prop.Value == null ?
                                                    string.Empty : prop.Value.ToString());
                }

                // Iterate through all the properties and add each one to the list
                foreach (Property prop in SqlServerSelection.Properties)
                {
                    ServerListViewItem = ServerListView.Items.Add(prop.Name);
                    ServerListViewItem.SubItems.Add(prop.Value == null ?
                                                    string.Empty : prop.Value.ToString());
                }

                ServerListView.EndUpdate();

                ConnectionListView.BeginUpdate();

                // Clear control
                ConnectionListView.Items.Clear();

                // Iterate through all the properties and add each one to the list
                foreach (Property prop in SqlServerSelection.Information.Properties)
                {
                    ServerListViewItem = ConnectionListView.Items.Add(
                        prop.Name);
                    ServerListViewItem.SubItems.Add(prop.Value == null ?
                                                    string.Empty : prop.Value.ToString());
                }

                ConnectionListView.EndUpdate();
            }
            catch (SmoException ex)
            {
                ExceptionMessageBox emb = new ExceptionMessageBox(ex);
                emb.Show(this);
            }
        }
Beispiel #3
0
        async Task LoadServers()
        {
            string oldText = Text;

            Text = Text + " (Loading Servers...)";

            if (!string.IsNullOrWhiteSpace(MasterServerBox.Text))
            {
                try
                {
                    serverList.Clear();
                    Task info = await Task.Factory.StartNew(() => LoadServerInfoFromFile("http://" + MasterServerBox.Text + "/serverlist.txt"));

                    Task.WaitAll(info);

                    ServerListView.BeginUpdate();
                    ServerListView.Clear();

                    if (serverList.Count > 0)
                    {
                        var ColumnName = new ColumnHeader();
                        ColumnName.Text      = "Name";
                        ColumnName.TextAlign = HorizontalAlignment.Center;
                        ColumnName.Width     = 284;
                        ServerListView.Columns.Add(ColumnName);

                        var ColumnClient = new ColumnHeader();
                        ColumnClient.Text      = "Client";
                        ColumnClient.TextAlign = HorizontalAlignment.Center;
                        ColumnClient.Width     = 75;
                        ServerListView.Columns.Add(ColumnClient);

                        var ColumnVersion = new ColumnHeader();
                        ColumnVersion.Text      = "Version";
                        ColumnVersion.TextAlign = HorizontalAlignment.Center;
                        ColumnVersion.Width     = 110;
                        ServerListView.Columns.Add(ColumnVersion);

                        foreach (var server in serverList)
                        {
                            var serverItem = new ListViewItem(server.ServerName);
                            serverItem.UseItemStyleForSubItems = false;

                            var serverClient = new ListViewItem.ListViewSubItem(serverItem, server.ServerClient);
                            serverItem.SubItems.Add(serverClient);

                            var serverVersion = new ListViewItem.ListViewSubItem(serverItem, server.ServerVersion);

                            if (serverVersion.Text != GlobalVars.ProgramInformation.Version)
                            {
                                serverVersion.ForeColor = Color.Red;
                            }

                            serverItem.SubItems.Add(serverVersion);

                            ServerListView.Items.Add(serverItem);
                        }
                    }
                    else
                    {
                        MessageBox.Show("There are no servers available on this master server.", "Novetus - Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    }

                    ServerListView.EndUpdate();
                }
                catch (Exception ex)
                {
                    string message = "Unable to load servers (" + ex.GetBaseException().Message + ").\n\nMake sure you have a master server address other than 'localhost' in the textbox.\nIf the server still does not load properly, consult the administrator of the server for more information.";
                    if (ex.GetBaseException().Message.Contains("404"))
                    {
                        message = "There are no servers available on this master server.";
                    }

                    GlobalFuncs.LogExceptions(ex);
                    MessageBox.Show(message, "Novetus - Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    ServerListView.Clear();
                }
                finally
                {
                    Text = oldText;
                }
            }
        }