private void ExportList()
        {
            // Check if there are any entries
            if (this.lstDriverStoreEntries.Objects != null)
            {
                try
                {
                    List <DriverStoreEntry> ldse = this.lstDriverStoreEntries.Objects as List <DriverStoreEntry>;
                    string fileName = new CsvExporter().Export(ldse);

                    if (!string.IsNullOrEmpty(fileName))
                    {
                        string message = string.Format(Language.Export_Complete, fileName);
                        this.ShowStatus(Status.Normal, message, usePopup: true);
                    }
                }
                catch (Exception ex)
                {
                    this.ShowStatus(Status.Error, string.Format(Language.Export_Failed, ex), usePopup: true);
                }
            }
        }
        private void ExportList()
        {
            // Check if there are any entries.
            if (this.lstDriverStoreEntries.Objects != null)
            {
                List <DriverStoreEntry> driverStoreEntries = this.lstDriverStoreEntries
                                                             .Objects
                                                             .OfType <DriverStoreEntry>()
                                                             .ToList();

                if (driverStoreEntries.Count == 0)
                {
                    this.ShowMessageBox(
                        Language.Message_No_Entries,
                        Language.Export_Error,
                        MessageBoxButtons.OK,
                        MessageBoxIcon.Warning);

                    return;
                }

                try
                {
                    string fileName = new CsvExporter().Export(driverStoreEntries);

                    if (!string.IsNullOrEmpty(fileName))
                    {
                        string message = string.Format(Language.Export_Complete, fileName);
                        this.ShowStatus(Status.Normal, message, usePopup: true);
                    }
                }
                catch (Exception ex) when(ex is IOException || ex is SecurityException)
                {
                    this.ShowStatus(Status.Error, string.Format(Language.Export_Failed, ex), usePopup: true);
                }
            }
        }
Exemple #3
0
        private void ExportList()
        {
            // Check if there are any entries
            if (this.lstDriverStoreEntries.Objects != null)
            {
                try
                {
                    string fileName = new CsvExporter().Export(this.lstDriverStoreEntries
                                                               .Objects
                                                               .OfType <DriverStoreEntry>()
                                                               .ToList());

                    if (!string.IsNullOrEmpty(fileName))
                    {
                        string message = string.Format(Language.Export_Complete, fileName);
                        this.ShowStatus(Status.Normal, message, usePopup: true);
                    }
                }
                catch (Exception ex) when(ex is IOException || ex is SecurityException)
                {
                    this.ShowStatus(Status.Error, string.Format(Language.Export_Failed, ex), usePopup: true);
                }
            }
        }