Ejemplo n.º 1
0
        /// <summary>
        /// Retrieve our data
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void btnRetrieveData_Click(object sender, EventArgs e)
        {
            if (MM_Server_Interface.Client == null && cmbMacomberMapServer.SelectedIndex != -1)
            {
                MM_Server_Information FoundServer = MM_Server_Interface.MMServers.Values.FirstOrDefault <MM_Server_Information>(t => t.ServerName == cmbMacomberMapServer.Text);
                if (FoundServer != null)
                {
                    LoginToServer(FoundServer.ServerName, FoundServer.ServerURI);
                }
            }

            if (MM_Server_Interface.Client == null || MM_Server_Interface.Client.State != System.ServiceModel.CommunicationState.Opened)
            {
                MessageBox.Show("Not connected to a Macomber Map Server", Application.ProductName, MessageBoxButtons.OK, MessageBoxIcon.Stop);
            }
            else if (cmbDataType.SelectedItem == null)
            {
                MessageBox.Show("No data type selected", Application.ProductName, MessageBoxButtons.OK, MessageBoxIcon.Stop);
            }
            else
            {
                Type TargetType = DataTypes[cmbDataType.Text];
                RetrievalCommandAttribute rca = TargetType.GetCustomAttribute <RetrievalCommandAttribute>();
                MethodInfo mI = typeof(MM_WCF_Interface).GetMethod(rca.RetrievalCommand);

                BoundList = (IBindingList)Activator.CreateInstance(typeof(BindingList <>).MakeGenericType(new[] { TargetType }));
                Object InResult = mI.Invoke(MM_Server_Interface.Client, null);
                foreach (Object obj in (IEnumerable)InResult)
                {
                    BoundList.Add(obj);
                }
                dgvData.DataSource = BoundList;
            }
        }
        /// <summary>
        /// Every interval, update all of our statuses.
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void UpdateDisplay(object sender, EventArgs e)
        {
            if (Data_Integration.CommLoaded)
            {
                UpdateCommunicationsLinkages();
            }
            UpdateMMCommStatus();
            UpdateLogText();
            MM_Server_Information.UpdateServerInformation(MMServers, lvMacomberMapServers);

            long Mem;

            UIHelper.UpdateCPUAndMemory(out Mem);
            lblUptime.Text = "Uptime: " + MM_Repository.TimeSpanToText(DateTime.Now - Data_Integration.ModelLoadCompletion);


            //Update the status of all of our queries
            ListViewItem FoundListView;
            int          WorstColor = 0;

            foreach (KeyValuePair <Type, MM_DataRetrieval_Information> kvp in MM_Server_Interface.DataRetrievalInformation)
            {
                Color DrawColor = kvp.Value.ProperColor();
                if (DrawColor == MM_Repository.OverallDisplay.WarningColor)
                {
                    WorstColor = Math.Max(WorstColor, 1);
                }
                else if (DrawColor == MM_Repository.OverallDisplay.ErrorColor)
                {
                    WorstColor = 2;
                }

                if (!Queries.TryGetValue(kvp.Key, out FoundListView))
                {
                    Queries.Add(kvp.Key, FoundListView = lvQueryStatus.Items.Add(kvp.Key.Name.Replace("MM_", "").Replace('_', ' ')));
                    FoundListView.Tag = kvp.Value;
                    FoundListView.SubItems.Add(MM_Repository.TimeSpanToText(DateTime.Now - kvp.Value.LastUpdate));
                    FoundListView.UseItemStyleForSubItems = true;
                    FoundListView.ForeColor = DrawColor;
                }
                else
                {
                    FoundListView.SubItems[1].Text = MM_Repository.TimeSpanToText(DateTime.Now - kvp.Value.LastUpdate);
                    FoundListView.ForeColor        = DrawColor;
                }
            }

            CommStatus.SetQueryAndServerStatus(WorstColor, MM_Server_Interface.Client == null ? 2 : MM_Server_Interface.Client.InnerChannel.State == System.ServiceModel.CommunicationState.Opened ? 0 : 2);
        }
Ejemplo n.º 3
0
        /// <summary>
        /// Handle the update timer by checking for new events
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void tmrUpdate_Tick(object sender, EventArgs e)
        {
            if (Data_Integration.InitializationComplete)
            {
                tmrUpdate.Enabled = false;
            }
            else
            {
                while (MM_System_Interfaces.Events.Count > 0)
                {
                    LogEvent(MM_System_Interfaces.Events.Dequeue());
                }

                MM_Server_Information.UpdateServerInformation(MMServers, lvMacomberMapServers);
            }
        }
Ejemplo n.º 4
0
        /// <summary>
        /// Connect to our optimal server
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void btnOptimalServer_Click(object sender, EventArgs e)
        {
            MM_Server_Information BestServer = null;

            lock (MM_Server_Interface.MMServers)
            {
                foreach (MM_Server_Information ServerInfo in MM_Server_Interface.MMServers.Values.ToArray())
                {
                    if (BestServer == null || ServerInfo.UserCount < BestServer.UserCount)
                    {
                        BestServer = ServerInfo;
                    }
                }
            }
            if (BestServer != null)
            {
                LoginToServer(BestServer.ServerName, BestServer.ServerURI);
            }
        }
Ejemplo n.º 5
0
 /// <summary>
 /// When our timer triggers, update our server information
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 private void tmrUpdate_Tick(object sender, EventArgs e)
 {
     MM_Server_Information.UpdateServerInformation(MMServers, cmbMacomberMapServer);
 }