Пример #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;
            }
        }
Пример #2
0
        /// <summary>
        /// Update our timestamp for a particular item
        /// </summary>
        /// <param name="DataType"></param>
        /// <param name="Rows"></param>
        public static void UpdateTimestamp(Type DataType, int Rows)
        {
            int FoundIndex;

            if (DataCollections.TryGetValue(DataType, out FoundIndex))
            {
                Timestamps[FoundIndex].MarkUpdate(Rows);
            }
            else
            {
                lock (LockObjectForNewTimestamp)
                {
                    //Find the retrieval command for this type.
                    RetrievalCommandAttribute FoundRetr = null;
                    foreach (object obj in DataType.GetCustomAttributes(false))
                    {
                        if (obj is RetrievalCommandAttribute)
                        {
                            FoundRetr = (RetrievalCommandAttribute)obj;
                        }
                    }

                    //Determine our new index, and update accordingly.
                    int NewIndex = DataCollections.Count;
                    MM_Data_Collection[] NewColl = new MM_Data_Collection[NewIndex + 1];
                    Array.Copy(Timestamps, 0, NewColl, 0, Timestamps.Length);
                    NewColl[NewIndex] = new MM_Data_Collection()
                    {
                        UpdateMessage = FoundRetr.RetrievalCommand, LastUpdate = DateTime.Now, LastRowCount = Rows
                    };
                    Timestamps = NewColl;
                }
            }
        }
Пример #3
0
        /// <summary>
        /// Read our XML configuration file
        /// </summary>
        public static void DetermineFileTypes()
        {
            //Add in our list of file paths
            foreach (Type FoundType in typeof(MM_Line_Data).Assembly.GetTypes())
            {
                UpdateCommandAttribute    UpdateCommand    = null;
                RetrievalCommandAttribute RetrievalCommand = null;
                FileNameAttribute         FileName         = null;

                foreach (object obj in FoundType.GetCustomAttributes(false))
                {
                    if (obj is UpdateCommandAttribute)
                    {
                        UpdateCommand = (UpdateCommandAttribute)obj;
                    }
                    else if (obj is FileNameAttribute)
                    {
                        FileName = (FileNameAttribute)obj;
                    }
                    else if (obj is RetrievalCommandAttribute)
                    {
                        RetrievalCommand = (RetrievalCommandAttribute)obj;
                    }
                }

                if (UpdateCommand != null && FileName != null)
                {
                    MM_EMSReader_TCP.InputTypes.Add(FileName.FileName, FoundType);
                    MM_EMSReader_TCP.UpdateCommands.Add(FileName.FileName, UpdateCommand.UpdateCommand);
                    if (!String.IsNullOrEmpty(Settings.Default.TEDESourceFolder))
                    {
                        MM_EMSReader_File.FileInfo.Add(FileName.FileName, new MM_EMSReader_File(Path.Combine(Settings.Default.TEDESourceFolder, FileName.FileName), UpdateCommand.UpdateCommand, FoundType));
                    }
                }

                // FileInfo.Add(FileName.FileName, new MM_EMSReader_FileInformation(Path.Combine(Settings.Default.SourceFolder,FileName.FileName), UpdateCommand.UpdateCommand, FoundType));

                //Check our update command, make sure it's okay
                if (UpdateCommand != null && FileName != null && typeof(IMM_ConversationMessage_Types).GetMethod(UpdateCommand.UpdateCommand) == null)
                {
                    MM_Notification.WriteLine(ConsoleColor.Yellow, "Unable to find update command {0} for type {1}", UpdateCommand.UpdateCommand, FileName.FileName);
                }
                if (RetrievalCommand != null && FileName != null && typeof(IMM_EMS_Types).GetMethod(RetrievalCommand.RetrievalCommand) == null)
                {
                    MM_Notification.WriteLine(ConsoleColor.Yellow, "Unable to find retrieval command {0} for type {1}", RetrievalCommand.RetrievalCommand, FileName.FileName);
                }
            }
        }
Пример #4
0
        /// <summary>
        /// Initialize a new test form
        /// </summary>
        public frmTest()
        {
            InitializeComponent();

            //Add in all known message types
            foreach (Type t in typeof(MM_Line_Data).Assembly.GetTypes())
            {
                RetrievalCommandAttribute FoundAttr = null;
                foreach (Object obj in t.GetCustomAttributes(false))
                {
                    if (obj is RetrievalCommandAttribute)
                    {
                        FoundAttr = (RetrievalCommandAttribute)obj;
                    }
                }
                if (FoundAttr != null)
                {
                    btnFillData.DropDownItems.Add(t.Name).Tag = FoundAttr.RetrievalCommand;
                }
            }
        }