Exemple #1
0
        private void ExportButton_Click(object sender, EventArgs e)
        {
            if (ExportSaveFileDialog.ShowDialog() == DialogResult.OK)
            {
                if (ExportSaveFileDialog.FileName != "")
                {
                    try
                    {
                        //Pass the filepath and filename to the StreamWriter Constructor
                        StreamWriter sw = new StreamWriter(ExportSaveFileDialog.FileName);

                        sw.Write(StartCode + Environment.NewLine);
                        for (int rows = 0; rows < StateDataGridView.RowCount; rows++)
                        {
                            if (StateDataGridView.Rows[rows].Cells[3].Value != null)
                            {
                                sw.Write(Environment.NewLine + ";" + StateDataGridView.Rows[rows].Cells[3].Value.ToString() + Environment.NewLine);
                                sw.Write(StateDataGridView.Rows[rows].Cells[4].Value.ToString());
                            }
                        }

                        sw.Write(Environment.NewLine + EndCode + Environment.NewLine + "M23 " + System.IO.Path.GetFileName(ExportSaveFileDialog.FileName) + Environment.NewLine);

                        //Close the file
                        sw.Close();

                        MessageBox.Show("File save successfully.");
                    }
                    catch (Exception ex)
                    {
                        MessageBox.Show("Exception: " + ex.Message);
                    }
                }
            }
        }
        private void exportToolStripMenuItem_Click(object sender, EventArgs e)
        {
            using (var dialog = new ExportSaveFileDialog(_directory, "Export Test Document Data", ImportExportType.Document))
            {
                if (dialog.ShowDialog() == DialogResult.OK)
                {
                    using (new BusyCursor())
                    {
                        try
                        {
                            string exportFile = dialog.Base.FileName;
                            _directory = Path.GetDirectoryName(exportFile);

                            DocumentContractCollection documentContracts = new DocumentContractCollection();

                            var documents = radGridViewDocuments
                                            .SelectedRows.Cast <DataGridViewRow>()
                                            .Select(x => x.DataBoundItem).Cast <TestDocument>();

                            documentContracts.Load(documents, true);
                            documentContracts.Export(exportFile);
                            MessageBox.Show("Data successfully exported", "STB Data Export", MessageBoxButtons.OK, MessageBoxIcon.Information);
                        }
                        catch (Exception ex)
                        {
                            MessageBox.Show(ex.Message);
                        }
                    }
                }
            }
        }
        private void ExportResultButton_Click(object sender, EventArgs e)
        {
            if (ExportSaveFileDialog.ShowDialog() == DialogResult.OK)
            {
                try
                {
                    List <string> ResultToExport = new List <string>();
                    ResultToExport.Add(TitleLabel.Text);
                    ResultToExport.Add(TypeLabel.Text);
                    if (NameLabel.Text != "   Nombre de lista de reproducción/canal   ")
                    {
                        ResultToExport.Add(NameLabel.Text);
                    }
                    ResultToExport.Add("Vídeos descargados y convertidos a MP3: " + MP3CheckBox.Checked);
                    ResultToExport.Add("Datos del vídeo añadidos al archivo (Metadata): " + MetadataCheckBox.Checked);
                    ResultToExport.AddRange(InfoTextBox.Lines);

                    File.WriteAllLines(ExportSaveFileDialog.FileName, ResultToExport.ToArray());

                    MessageBox.Show("Resultado de la descarga exportado con éxito", "Exportado con éxito", MessageBoxButtons.OK, MessageBoxIcon.Information);
                }
                catch (IOException ioex)
                {
                    MessageBox.Show("Error exportando el resultado de la descarga\n\n" + ioex.ToString(), "Error exportando", MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
            }
        }
Exemple #4
0
        private void exportToolStripMenuItem_Click(object sender, EventArgs e)
        {
            using (var dialog = new ExportSaveFileDialog(_directory, "Export Printer Definition Data", ImportExportType.Printer))
            {
                if (dialog.ShowDialog() == DialogResult.OK)
                {
                    using (new BusyCursor())
                    {
                        Refresh();
                        try
                        {
                            var file = dialog.Base.FileName;
                            _directory = Path.GetDirectoryName(file);

                            var printerContracts = new AssetContractCollection <PrinterContract>();
                            var printers         = radGridViewPrinters
                                                   .SelectedRows
                                                   .Cast <GridViewRowInfo>()
                                                   .Select(x => x.DataBoundItem)
                                                   .Cast <Printer>();

                            printerContracts.Load(printers);
                            printerContracts.Export(file);

                            MessageBox.Show("Data successfully exported", "STB Data Export", MessageBoxButtons.OK, MessageBoxIcon.Information);
                        }
                        catch (Exception ex)
                        {
                            MessageBox.Show(ex.Message);
                        }
                    }
                }
            }
        }
Exemple #5
0
        private void ExportButton_Click(object sender, EventArgs e)
        {
            ExportSaveFileDialog.ShowDialog();

            var serializer = new JsonSerializer();

            serializer.Formatting                 = Formatting.Indented;
            serializer.NullValueHandling          = NullValueHandling.Include;
            serializer.PreserveReferencesHandling = PreserveReferencesHandling.All;

            using (StreamWriter sw = new StreamWriter(ExportSaveFileDialog.FileName))
                using (JsonWriter writer = new JsonTextWriter(sw))
                {
                    serializer.Serialize(writer, VM.StarSystems);
                }
        }
        private void exportSoftwarePackagesToolStripMenuItem_Click(object sender, EventArgs e)
        {
            string metadataTypeName = string.Empty;

            if (metadataTypes_DataGridView.SelectedRows.Count > 0)
            {
                metadataTypeName = (string)metadataTypes_DataGridView.SelectedRows[0].Cells["metadataTypeName_Column"].Value;
            }
            else
            {
                return;
            }

            using (var dialog = new ExportSaveFileDialog(_directory, "Export Software Installer Package", ImportExportType.Installer))
            {
                string exportFile = string.Empty;
                if (dialog.ShowDialog() == DialogResult.OK)
                {
                    exportFile = dialog.Base.FileName;
                    _directory = Path.GetDirectoryName(exportFile);
                }
                else
                {
                    return;
                }

                try
                {
                    Cursor = Cursors.WaitCursor;
                    var contract = new MetadataTypeInstallerContract();
                    contract.Export(metadataTypeName, exportFile);
                    Cursor = Cursors.Default;

                    MessageBox.Show("Data successfully exported", "STB Data Export", MessageBoxButtons.OK, MessageBoxIcon.Information);
                }
                catch (Exception ex)
                {
                    MessageBox.Show(ex.Message);
                }
                finally
                {
                    Cursor = Cursors.Default;
                }
            }
        }
Exemple #7
0
        private void exportToolStripButton_Click(object sender, EventArgs e)
        {
            using (var dialog = new ExportSaveFileDialog(_directory, "Export Test Scenario Data", ImportExportType.Scenario))
            {
                if (dialog.ShowDialog() == DialogResult.OK)
                {
                    _directory = Path.GetDirectoryName(dialog.Base.FileName);

                    using (SqlConnection reportDb = new SqlConnection(ReportingSqlConnection.ConnectionString))
                    {
                        reportDb.Open();
                        // Get the schema of the 'SessionConfiguration' table in the reporting database server so we know if we are pointing to the long term data server.
                        string[] columnRestrictions = new string[4];
                        columnRestrictions[2] = "SessionConfiguration";
                        columnRestrictions[3] = "STF_SessionId";
                        DataTable columnSchema = reportDb.GetSchema(SqlClientMetaDataCollectionNames.Columns, columnRestrictions);

                        using (SqlCommand command = reportDb.CreateCommand())
                        {
                            string sessionConfigQuery = "SELECT ConfigurationData FROM SessionConfiguration WHERE {0} LIKE ('{1}')";
                            if (columnSchema.Rows.Count > 0)
                            {
                                command.CommandText = sessionConfigQuery.FormatWith("STF_SessionId", SelectedSessionId);
                            }
                            else
                            {
                                command.CommandText = sessionConfigQuery.FormatWith("SessionId", SelectedSessionId);
                            }

                            using (SqlDataReader reader = command.ExecuteReader())
                            {
                                if (reader.HasRows && reader.Read())
                                {
                                    string sessionConfigData = reader.GetValue(0).ToString();

                                    File.WriteAllText(dialog.Base.FileName, sessionConfigData);
                                }
                            }
                        }
                    }
                }
            }
        }