Example #1
0
        //-------------------------------------------------------------------------------------------------------------------------------------------------------------------------


        /// <summary>
        /// Sends the RFDeviceList via UDP to any connect client.
        /// This function is not asynchron, so the main thread is blocked when sending data.
        /// Maybe in oen of the next versions me make this function asynchron.
        /// </summary>
        /// <param name="devicelist">The devicelist.</param>
        private void SendDataUDP(RFDeviceList devicelist)
        {
            try
            {
                using (Socket sender = new Socket(AddressFamily.InterNetwork, SocketType.Dgram, ProtocolType.Udp))
                {
                    IPEndPoint endpoint = new IPEndPoint(IPAddress.Parse(this.settings.UDPHost), this.settings.UDPPortSending);

                    foreach (RFDevice device in devicelist)
                    {
                        XElement eDevice = device.ToXml();

                        byte[] baMessage = Encoding.Default.GetBytes(eDevice.ToDefaultString());

                        sender.SendTo(baMessage, endpoint);

                        // Give the poor client some time to process the data when he need or bleed ...
                        if (this.settings.UDPDelay > 0)
                        {
                            Thread.Sleep(this.settings.UDPDelay);
                        }
                    }

                    sender.Close();
                }
            }
            catch (Exception ex)
            {
                MB.Error(ex);
            }
        }
Example #2
0
        /// <summary>
        /// Loads the templates.
        /// </summary>
        /// <param name="strFilename">The string filename.</param>
        private void LoadTemplates(string strFilename)
        {
            this.Cursor = Cursors.Wait;

            ClearTemplates();

            try
            {
                XDocument xdoc = XDocument.Load(strFilename);

                foreach (XElement eTemplate in xdoc.Root.Elements("RFDevice"))
                {
                    RFDevice device = RFDevice.FromXml(eTemplate);

                    if (device != null)
                    {
                        this.RFDeviceTemplateCollection.Add(new RFDeviceTemplate(device));
                    }
                }
            }
            catch (Exception ex)
            {
                MB.Error(ex);
            }

            this.Cursor = Cursors.Arrow;
        }
Example #3
0
        /// <summary>
        /// Saves the templates.
        /// </summary>
        /// <param name="strFilename">The string filename.</param>
        private void SaveTemplates(string strFilename)
        {
            this.Cursor = Cursors.Wait;

            try
            {
                XElement eSIGENCEScenarioTemplates = new XElement("SIGENCEScenarioTemplates", new XAttribute("Version", Tool.Version));

                //-------------------------------------------------------------

                foreach (RFDevice d in from template in this.RFDeviceTemplateCollection select template)
                {
                    if (d.PrimaryKey != Guid.Empty)
                    {
                        eSIGENCEScenarioTemplates.Add(d.ToXml());
                    }
                }

                //-------------------------------------------------------------

                eSIGENCEScenarioTemplates.SaveDefault(strFilename);

                MB.Information("{0}\nsuccessfully saved.", strFilename);
            }
            catch (Exception ex)
            {
                MB.Error(ex);
            }

            this.Cursor = Cursors.Arrow;
        }
Example #4
0
        //-------------------------------------------------------------------------------------------------------------------------------------------------------------------------


        /// <summary>
        /// Handles the UnhandledException event of the CurrentDomain control.
        /// </summary>
        /// <param name="sender">The source of the event.</param>
        /// <param name="e">The <see cref="UnhandledExceptionEventArgs"/> instance containing the event data.</param>
        private void CurrentDomain_UnhandledException(object sender, UnhandledExceptionEventArgs e)
        {
            if (e.ExceptionObject is Exception)
            {
                MB.Error(e.ExceptionObject as Exception);
            }
        }
        /// <summary>
        /// Executes the specified string content.
        /// </summary>
        /// <param name="strContent">Content of the string.</param>
        private void Execute(string strContent)
        {
            this.Cursor = Cursors.Wait;

            this.LastOutput = "";
            //ExecutionTime = "-";

            try
            {
                //TODO: Hier muss natrülich ein eigener TextWriter her der das dann direkt in die
                //      TextBox schreibt, das hier ist nur für das schnelle MockUp sinnvoll ...
                using (StringWriter sw = new StringWriter())
                {
                    DateTime dtStarted = DateTime.Now;
                    sw.WriteLine("[{0}] Execution Started ...", dtStarted.Fmt_DD_MM_YYYY_HH_MM_SS());
                    //Console.SetOut(TextWriter.Synchronized(sw));
                    Console.SetOut(sw);

                    ScriptEngine engine = Python.CreateEngine();
                    ScriptScope  scope  = engine.CreateScope();

                    // Hier nur die Devices übergeben, aber nicht das komplette MainWindow ...
                    scope.SetVariable("devices", this.mw.RFDeviceViewModelCollection);

                    engine.Runtime.IO.RedirectToConsole();

                    engine.Execute(strContent, scope);

                    //MB.Information(sw.ToString());
                    DateTime dtStopped = DateTime.Now;
                    this.ExecutionTime = (dtStopped - dtStarted).ToShortString();

                    sw.WriteLine("[{0}] Execution Ended ...", dtStopped.Fmt_DD_MM_YYYY_HH_MM_SS());
                    sw.WriteLine("[{0}] Execution Time: {1}", DateTime.Now.Fmt_DD_MM_YYYY_HH_MM_SS(), this.ExecutionTime);

                    this.LastOutput = sw.ToString();

                    // Hier kann man nun die erzeugten Variablen abfragen ...
                    //StringBuilder sb = new StringBuilder();
                    //foreach (String strVariable in scope.GetVariableNames())
                    //{
                    //    sb.AppendLine(strVariable);
                    //    //var r = scope.GetVariable(strVariable);
                    //    //sb.AppendLine("{0}",strVariable,r. );
                    //}

                    //MB.Information(sb.ToString());
                }
            }
            catch (Exception ex)
            {
                MB.Error(ex);
            }

            this.tecTextEditorControl.Focus();

            this.Cursor = Cursors.Arrow;
        }
        /// <summary>
        /// Opens the file.
        /// </summary>
        /// <param name="strInputFilename">The string input filename.</param>
        internal void LoadFile(string strInputFilename)
        {
            this.Cursor = Cursors.Wait;

            this.CurrentFile = strInputFilename;

            try
            {
                XDocument xdoc = XDocument.Load(strInputFilename);

                //---------------------------------------------------------

                XElement eGeneralSettings = xdoc.Root.Element("GeneralSettings");
                this.Zoom = eGeneralSettings.GetDoubleFromNode("Zoom") ?? this.Zoom;
                //ShowCenter = eGeneralSettings.GetBoolFromNode("ShowCenter") ?? ShowCenter;
                //this.ScenarioDescription = eGeneralSettings.GetStringFromCData( "ScenarioDescription" );

                string strMapProvider = eGeneralSettings.GetStringFromNode("MapProvider") ?? this.MapProvider.Name;
                this.MapProvider = GetProviderFromString(strMapProvider);

                XElement eCenterPosition = eGeneralSettings.Element("CenterPosition");
                this.Latitude  = eCenterPosition.GetDoubleFromNodePoint("Latitude") ?? this.Latitude;
                this.Longitude = eCenterPosition.GetDoubleFromNodePoint("Longitude") ?? this.Longitude;

                //---------------------------------------------------------

                // Create not an new instance, only load the data into the existing one ...
                this.MetaInformation.LoadFromXml(xdoc.Root);

                // Ist ja noch nix passiert ...
                this.DescriptionMarkdownChanged   = false;
                this.DescriptionStylesheetChanged = false;

                //this.tecDescription.Text = this.MetaInformation.Description;
                //this.tecStyleSheet.Text = this.MetaInformation.Stylesheet;

                //---------------------------------------------------------

                XElement eRFDeviceCollection = xdoc.Root.Element("RFDeviceCollection");

                foreach (XElement e in eRFDeviceCollection.Elements())
                {
                    AddRFDevice(RFDevice.FromXml(e));
                }

                AddFileHistory(strInputFilename);
            }
            catch (Exception ex)
            {
                MB.Error(ex);
            }

            this.Cursor = Cursors.Arrow;
        }
        /// <summary>
        /// Exports the settings.
        /// </summary>
        /// <param name="strFileName">Name of the string file.</param>
        private void ExportSettings(string strFileName)
        {
            try
            {
                string strContent = Tool.GetFlatXmlStringFromObject(this.settings);

                File.WriteAllText(strFileName, strContent, Encoding.GetEncoding("ISO-8859-1"));
            }
            catch (Exception ex)
            {
                MB.Error(ex);
            }
        }
        /// <summary>
        /// Saves the file.
        /// </summary>
        /// <param name="strOutputFilename">The string output filename.</param>
        internal void SaveFile(string strOutputFilename)
        {
            this.Cursor = Cursors.Wait;

            try
            {
                XElement eSIGENCEScenarioTool = new XElement("SIGENCEScenarioTool", new XAttribute("Version", Tool.Version));

                //-------------------------------------------------------------

                XElement eGeneralSettings = new XElement("GeneralSettings");

                //eGeneralSettings.Add(new XElement("ScenarioDescription", new XCData(this.ScenarioDescription ?? "")));
                eGeneralSettings.Add(new XElement("Zoom", this.Zoom));
                //eGeneralSettings.Add(new XElement("ShowCenter", mcMapControl.ShowCenter));
                eGeneralSettings.Add(new XElement("CenterPosition",
                                                  new XElement("Latitude", this.Latitude),
                                                  new XElement("Longitude", this.Longitude))
                                     );
                eGeneralSettings.Add(new XElement("MapProvider", this.MapProvider));

                eSIGENCEScenarioTool.Add(eGeneralSettings);

                //-------------------------------------------------------------

                eSIGENCEScenarioTool.Add(this.MetaInformation.ToXml());

                //-------------------------------------------------------------

                XElement eRFDeviceCollection = new XElement("RFDeviceCollection");

                foreach (RFDevice d in from rfdevice in this.RFDeviceViewModelCollection select rfdevice.RFDevice)
                {
                    eRFDeviceCollection.Add(d.ToXml());
                }

                eSIGENCEScenarioTool.Add(eRFDeviceCollection);

                //-------------------------------------------------------------

                eSIGENCEScenarioTool.SaveDefault(strOutputFilename);
            }
            catch (Exception ex)
            {
                MB.Error(ex);
            }

            this.Cursor = Cursors.Arrow;
        }
        /// <summary>
        /// Imports the settings.
        /// </summary>
        /// <param name="strFileName">Name of the string file.</param>
        private void ImportSettings(string strFileName)
        {
            try
            {
                string strContent = File.ReadAllText(strFileName);

                this.settings = Tool.GetObjectFromFlatXmlString <Properties.Settings>(strContent);

                this.settings.Save();
            }
            catch (Exception ex)
            {
                MB.Error(ex);
            }
        }
Example #10
0
        /// <summary>
        /// Exports the RFDevices.
        /// </summary>
        /// <param name="devicelist">The devicelist.</param>
        /// <param name="fiExportFile">The fi export file.</param>
        private void ExportRFDevices(RFDeviceList devicelist, FileInfo fiExportFile)
        {
            this.Cursor = Cursors.Wait;

            try
            {
                switch (fiExportFile.Extension.ToLower())
                {
                case ".csv":
                    devicelist.SaveAsCsv(fiExportFile.FullName);
                    MB.Information("File {0} successful created.", fiExportFile.Name);
                    break;

                case ".json":
                    devicelist.SaveAsJson(fiExportFile.FullName);
                    MB.Information("File {0} successful created.", fiExportFile.Name);
                    break;

                case ".xml":
                    devicelist.SaveAsXml(fiExportFile.FullName);
                    MB.Information("File {0} successful created.", fiExportFile.Name);
                    break;

                //case ".sqlite":
                //    devicelist.SaveAsSQLite( fiExportFile.FullName );
                //    MB.Information( "File {0} successful created." , fiExportFile.Name );
                //    break;

                case ".xlsx":
                    SaveAsExcel(devicelist, fiExportFile.FullName);
                    break;

                default:
                    MB.Warning("The FileType '{0}' Is Currently Not Supported For Export!", fiExportFile.Extension.ToLower());
                    break;
                }
            }
            catch (Exception ex)
            {
                MB.Error(ex);
            }

            this.Cursor = Cursors.Arrow;
        }
        /// <summary>
        /// Creates the screenshot.
        /// </summary>
        private void CreateScreenshot()
        {
            try
            {
                if (this.CurrentFile != null)
                {
                    this.sfdSaveScreenshot.FileName = new FileInfo(this.CurrentFile).Name;
                }

                if (this.sfdSaveScreenshot.ShowDialog() == true)
                {
                    System.Windows.Media.Imaging.BitmapSource screenshot = Tools.Windows.GetWPFScreenshot(this.mcMapControl);

                    Tools.Windows.SaveWPFScreenshot(screenshot, this.sfdSaveScreenshot.FileName);

                    Tools.Windows.OpenWithDefaultApplication(this.sfdSaveScreenshot.FileName);
                }
            }
            catch (Exception ex)
            {
                MB.Error(ex);
            }
        }
        /// <summary>
        /// Executes the non query.
        /// </summary>
        /// <param name="dbConnection">The database connection.</param>
        /// <param name="iTimeout">The i timeout.</param>
        /// <param name="bTransaction">if set to <c>true</c> [b transaction].</param>
        /// <param name="strFormat">The string format.</param>
        /// <param name="args">The arguments.</param>
        /// <returns></returns>
        public static int ExecuteNonQuery(this IDbConnection dbConnection, int iTimeout, bool bTransaction, string strFormat, params object[] args)
        {
            string strSQLStatement = args != null && args.Length > 0 ? string.Format(strFormat, args) : strFormat;

            using (IDbCommand dbCommand = dbConnection.CreateCommand())
            {
                IDbTransaction dbTransaction = null;

                if (bTransaction == true)
                {
                    dbTransaction         = dbConnection.BeginTransaction();
                    dbCommand.Transaction = dbTransaction;
                }

                dbCommand.CommandText    = strSQLStatement;
                dbCommand.CommandTimeout = iTimeout;

                int iResult = -1;

                try
                {
                    iResult = dbCommand.ExecuteNonQuery();
                }
                catch (Exception ex)
                {
                    // TODO: Hmmmm, das können wir so natürlich nicht stehen lassen ...
                    MB.Error(ex);
                }

                if (dbTransaction != null)
                {
                    dbTransaction.Commit();
                }

                return(iResult);
            }
        }
Example #13
0
        //-------------------------------------------------------------------------------------------------------------------------------------------------------------------------


        /// <summary>
        /// Imports the rf devices.
        /// </summary>
        /// <param name="fiImportFile">The fi import file.</param>
        private void ImportRFDevices(FileInfo fiImportFile)
        {
            this.Cursor = Cursors.Wait;

            try
            {
                switch (fiImportFile.Extension.ToLower())
                {
                //case ".csv":
                //    MB.Information("File {0} successful imported.", fiImportFile.Name);
                //    break;

                //case ".json":
                //    MB.Information("File {0} successful imported.", fiImportFile.Name);
                //    break;

                //case ".xml":
                //    MB.Information("File {0} successful imported.", fiImportFile.Name);
                //    break;

                case ".xlsx":
                    LoadFromExcel(fiImportFile.FullName);
                    break;

                default:
                    MB.Information("Currently The Import Of {0} Is Not Implemented!", fiImportFile.Extension);
                    break;
                }
            }
            catch (Exception ex)
            {
                MB.Error(ex);
            }

            this.Cursor = Cursors.Arrow;
        }
        //-------------------------------------------------------------------------------------------------------------------------------------------------------------------------


        /// <summary>
        /// Messages the mocker.
        /// </summary>
        /// <param name="strFilename">The string filename.</param>
        private void MessageMocker(string strFilename)
        {
            const int MARGIN_LEFT_RIGHT = 10;
            const int MARGIN_TOP_BOTTOM = 5;

            try
            {
                XDocument xdoc = XDocument.Load(strFilename);

                Window w = new Window
                {
                    Title                 = "SIGENCE XML MQTT Message Mocker",
                    Width                 = 600,
                    Height                = 600,
                    ResizeMode            = ResizeMode.NoResize,
                    WindowStartupLocation = WindowStartupLocation.CenterScreen
                };

                Grid grid = new Grid();

                grid.ColumnDefinitions.Add(new ColumnDefinition {
                    Width = new GridLength(1, GridUnitType.Auto)
                });
                grid.ColumnDefinitions.Add(new ColumnDefinition {
                    Width = new GridLength(1, GridUnitType.Star)
                });

                int iCurrentRow = 0;

                Action <UIElement, UIElement> AddRow = (e1, e2) =>
                {
                    grid.RowDefinitions.Add(new RowDefinition {
                        Height = new GridLength(1, GridUnitType.Auto)
                    });

                    grid.Children.Add(e1);
                    grid.Children.Add(e2);

                    Grid.SetColumn(e1, 0);
                    Grid.SetRow(e1, iCurrentRow);

                    Grid.SetColumn(e2, 1);
                    Grid.SetRow(e2, iCurrentRow);

                    iCurrentRow++;
                };

                //-----------------------------------------------------------------------------------------------------

                AddRow(
                    new Label
                {
                    Content    = "MQTT Topic",
                    Margin     = new Thickness(MARGIN_LEFT_RIGHT, MARGIN_TOP_BOTTOM, MARGIN_LEFT_RIGHT, MARGIN_TOP_BOTTOM),
                    FontWeight = FontWeights.Bold
                },
                    new TextBox
                {
                    Text   = "",
                    Margin = new Thickness(MARGIN_LEFT_RIGHT, MARGIN_TOP_BOTTOM, MARGIN_LEFT_RIGHT, MARGIN_TOP_BOTTOM),
                    VerticalContentAlignment = VerticalAlignment.Center
                }
                    );

                //-----------------------------------------------------------------------------------------------------

                XElement root = xdoc.Root;

                AddRow(
                    new Label
                {
                    Content    = "Name",
                    Margin     = new Thickness(MARGIN_LEFT_RIGHT),
                    FontWeight = FontWeights.Bold
                },
                    new Label
                {
                    Content         = root.Element("name").Value,
                    Margin          = new Thickness(MARGIN_LEFT_RIGHT, MARGIN_TOP_BOTTOM, MARGIN_LEFT_RIGHT, MARGIN_TOP_BOTTOM),
                    BorderBrush     = Brushes.Black,
                    BorderThickness = new Thickness(1)
                }
                    );

                AddRow(
                    new Label
                {
                    Content    = "Id",
                    Margin     = new Thickness(MARGIN_LEFT_RIGHT, MARGIN_TOP_BOTTOM, MARGIN_LEFT_RIGHT, MARGIN_TOP_BOTTOM),
                    FontWeight = FontWeights.Bold
                },
                    new Label
                {
                    Content         = root.Element("id").Value,
                    Margin          = new Thickness(MARGIN_LEFT_RIGHT, MARGIN_TOP_BOTTOM, MARGIN_LEFT_RIGHT, MARGIN_TOP_BOTTOM),
                    BorderBrush     = Brushes.Black,
                    BorderThickness = new Thickness(1)
                }
                    );

                AddRow(
                    new Label
                {
                    Content    = "Version",
                    Margin     = new Thickness(MARGIN_LEFT_RIGHT, MARGIN_TOP_BOTTOM, MARGIN_LEFT_RIGHT, MARGIN_TOP_BOTTOM),
                    FontWeight = FontWeights.Bold
                },
                    new Label
                {
                    Content         = root.Element("version").Value,
                    Margin          = new Thickness(MARGIN_LEFT_RIGHT, MARGIN_TOP_BOTTOM, MARGIN_LEFT_RIGHT, MARGIN_TOP_BOTTOM),
                    BorderBrush     = Brushes.Black,
                    BorderThickness = new Thickness(1)
                }
                    );

                foreach (XElement eField in root.Elements("key"))
                {
                    string strFieldName = eField.Element("name").Value;

                    AddRow(
                        new Label
                    {
                        Content    = strFieldName,
                        Margin     = new Thickness(MARGIN_LEFT_RIGHT, MARGIN_TOP_BOTTOM, MARGIN_LEFT_RIGHT, MARGIN_TOP_BOTTOM),
                        FontWeight = FontWeights.Bold
                    },
                        new TextBox
                    {
                        Text   = "",
                        Margin = new Thickness(MARGIN_LEFT_RIGHT, MARGIN_TOP_BOTTOM, MARGIN_LEFT_RIGHT, MARGIN_TOP_BOTTOM),
                        VerticalContentAlignment = VerticalAlignment.Center,
                        Tag = eField.Element("name").Value
                    }
                        );
                }

                //-----------------------------------------------------------------------------------------------------

                grid.RowDefinitions.Add(new RowDefinition {
                    Height = new GridLength(1, GridUnitType.Star)
                });

                Button btnSend = new Button {
                    Content = "Send", Width = 100, Height = 40, Margin = new Thickness(20)
                };
                btnSend.Click += (s, a) => MB.NotYetImplemented();

                Button btnCancel = new Button {
                    Content = "Cancel", Width = 100, Height = 40, Margin = new Thickness(20)
                };
                btnCancel.Click += (s, a) => w.Close();

                StackPanel sp = new StackPanel {
                    Orientation = Orientation.Horizontal, HorizontalAlignment = HorizontalAlignment.Center
                };
                sp.Children.Add(btnSend);
                sp.Children.Add(btnCancel);

                grid.Children.Add(sp);

                Grid.SetColumn(sp, 0);
                Grid.SetRow(sp, iCurrentRow);
                Grid.SetColumnSpan(sp, 2);

                //-----------------------------------------------------------------------------------------------------

                w.Content = new ScrollViewer {
                    Content = grid, VerticalScrollBarVisibility = ScrollBarVisibility.Auto
                };

                w.ShowDialog();
            }
            catch (Exception ex)
            {
                MB.Error(ex);
            }
        }
        private void LoadStreets()
        {
            RemoveStreets();

            string strFilename = $"{Tool.StartupPath}\\streets_bw.sqlite";

            RectLatLng bb = this.mcMapControl.ViewArea;

            //TODO: Check if the area is not to big ... But what is big ?

            SQLiteConnectionStringBuilder csbDatabase = new SQLiteConnectionStringBuilder
            {
                DataSource = strFilename
            };

            using (SQLiteConnection dbConnection = new SQLiteConnection(csbDatabase.ConnectionString))
            {
                dbConnection.Open();

                try
                {
                    //                                     0     1   2   3
                    //const string strSelectStatement = "select highway,ref,name,way from streets_bw where highway in ('motorway','motorway_link','trunk','trunk_link','primary','secondary','primary_link','secondary_link','residential')";
                    const string strSelectStatement = "select highway,ref,name,way from streets_bw";

                    uint iCounter = 0;

                    DateTime dtStart = DateTime.Now;

                    using (SQLiteCommand dbSelectCommand = new SQLiteCommand(strSelectStatement, dbConnection))
                    {
                        using (SQLiteDataReader dbResult = dbSelectCommand.ExecuteReader())
                        {
                            while (dbResult.Read())
                            {
                                Highway type = Highway.Unknown;

                                try
                                {
                                    type = (Highway)Enum.Parse(typeof(Highway), dbResult.GetString(0), true);
                                }
                                catch (Exception ex)
                                {
                                    Debug.WriteLine(ex.Message);
                                }

                                string strRef  = dbResult.GetStringOrNull(1);
                                string strName = dbResult.GetStringOrNull(2);

                                LineString way = (LineString)dbResult.GetGeometryFromWKB(3);

                                if (bb.Contains(way.Coordinate.ToPointLatLng()))
                                {
                                    List <PointLatLng> list = new List <PointLatLng>(way.Count);

                                    list.AddRange(way.Coordinates.Select(pos => pos.ToPointLatLng()));

                                    this.Dispatcher.Invoke(() =>
                                    {
                                        PathMarker mrWay = new PathMarker(this.mcMapControl, list, type, $"{( strName.IsNotEmpty() ? strName : "Unknown" )}{( strRef.IsNotEmpty() ? $" ({strRef})" : "" )}")
                                        {
                                            Tag = type
                                        };

                                        this.mcMapControl.Markers.Add(mrWay);
                                    });

                                    iCounter++;
                                }
                            }
                        }
                    }

                    DateTime dtStop = DateTime.Now;

                    MB.Information("Load {0} Ways In {1}.", iCounter, (dtStop - dtStart).ToHHMMSSString());
                }
                catch (Exception ex)
                {
                    MB.Error(ex);
                }
                finally
                {
                    if (dbConnection.State == ConnectionState.Open)
                    {
                        dbConnection.Close();
                    }
                }
            }
        }
Example #16
0
        //-------------------------------------------------------------------------------------------------------------------------------------------------------------------------


        #region Specialied Excel Import

        /// <summary>
        /// Loads from excel.
        /// </summary>
        /// <param name="strInputFilename">The string input filename.</param>
        private void LoadFromExcel(string strInputFilename)
        {
            if (strInputFilename.IsEmpty())
            {
                throw new ArgumentException("The input filename can not be empty!", nameof(strInputFilename));
            }

            Excel.Application excel = new Excel.Application();

            try
            {
                Excel.Workbook wb = excel.Workbooks.Open(strInputFilename);

                // We guess, the RF Device Data is on sheet #1, starting @ row 1 ...
                Excel.Worksheet maindatasheet = wb.Sheets[1] as Excel.Worksheet;

                Excel.Range range = maindatasheet.UsedRange;

                int iColumnCount = range.Columns.Count;

                if (iColumnCount < 17)
                {
                    throw new Exception(
                              $"The Current Excel File Can Not Be Imported Because There Are Only {iColumnCount} Columns!\nWe Need At Least 17 Columns For A Good Import.");
                }

                int iRowCount = range.Rows.Count;

                if (iRowCount < 2)
                {
                    throw new Exception(
                              $"The Current Excel File Can Not Be Imported Because There Are Only {iRowCount} Rows!\nWe Need At Least 2 Rows For A Good Import.");
                }

                RFDeviceList dlImportedDevices = new RFDeviceList();

                for (int iRow = 2; iRow < iRowCount + 1; iRow++)
                {
                    RFDevice device = new RFDevice
                    {
                        DeviceSource = DeviceSource.DataImport,
                    };

                    for (int iColumn = 1; iColumn < 19 + 1; iColumn++)
                    {
                        object value = (range.Cells[iRow, iColumn] as Excel.Range).Value2;

                        if (value == null)
                        {
                            continue;
                        }

                        // Hier ist zu überlegen wie wir das ganze generisch machen können falls sich das Model nochmal ändert ...
                        switch (iColumn)
                        {
                        case 1:
                            device.StartTime = Convert.ToDouble(value);
                            break;

                        case 2:
                            device.Id = Convert.ToInt32(value);
                            break;

                        case 3:
                            device.Latitude = Convert.ToDouble(value);
                            break;

                        case 4:
                            device.Longitude = Convert.ToDouble(value);
                            break;

                        case 5:
                            device.Altitude = Convert.ToInt32(value);
                            break;

                        case 6:
                            device.Roll = Convert.ToDouble(value);
                            break;

                        case 7:
                            device.Pitch = Convert.ToDouble(value);
                            break;

                        case 8:
                            device.Yaw = Convert.ToDouble(value);
                            break;

                        case 9:
                            device.RxTxType = RxTxTypes.FromInt(device.Id, Convert.ToInt32(value));
                            break;

                        case 10:
                            device.AntennaType = (AntennaType)Convert.ToInt32(value);
                            break;

                        case 11:
                            device.Gain_dB = Convert.ToDouble(value);
                            break;

                        case 12:
                            device.CenterFrequency_Hz = Convert.ToDouble(value);
                            break;

                        case 13:
                            device.Bandwidth_Hz = Convert.ToDouble(value);
                            break;

                        case 14:
                            device.SignalToNoiseRatio_dB = Convert.ToDouble(value);
                            break;

                        case 15:
                            device.XPos = Convert.ToInt32(value);
                            break;

                        case 16:
                            device.YPos = Convert.ToInt32(value);
                            break;

                        case 17:
                            device.ZPos = Convert.ToInt32(value);
                            break;

                        case 18:
                            device.Remark = Convert.ToString(value);
                            break;

                        case 19:
                            device.TechnicalParameters = Convert.ToString(value);
                            break;
                        }
                    }

                    dlImportedDevices.Add(device);
                }

                AddRFDevices(dlImportedDevices);
            }
            catch (Exception ex)
            {
                MB.Error(ex);
            }

            excel.Quit();
            excel = null;

            GC.WaitForPendingFinalizers();
            GC.Collect();
        }