Ejemplo n.º 1
0
        private void Execute(ExportType exportType, string fileName)
        {
            // Make sure our server is connected...
            Dataphoria.EnsureServerConnection();

            using (var statusForm = new StatusForm(Strings.Exporting))
            {
                using (var connection = new DAEConnection())
                {
                    if (DesignerID == "SQL")
                    {
                        SwitchToSQL();
                    }
                    try
                    {
                        using (var adapter = new DAEDataAdapter(GetTextToExecute(), connection))
                        {
                            using (var dataSet = new DataSet())
                            {
                                var process =
                                    DataSession.ServerSession.StartProcess(new ProcessInfo(DataSession.ServerSession.SessionInfo));
                                try
                                {
                                    connection.Open(DataSession.Server, DataSession.ServerSession, process);
                                    try
                                    {
                                        switch (exportType)
                                        {
                                        case ExportType.Data:
                                            adapter.Fill(dataSet);
                                            dataSet.WriteXml(fileName, XmlWriteMode.IgnoreSchema);
                                            break;

                                        case ExportType.Schema:
                                            adapter.FillSchema(dataSet, SchemaType.Source);
                                            dataSet.WriteXmlSchema(fileName);
                                            break;

                                        default:
                                            adapter.Fill(dataSet);
                                            dataSet.WriteXml(fileName, XmlWriteMode.WriteSchema);
                                            break;
                                        }
                                    }
                                    finally
                                    {
                                        connection.Close();
                                    }
                                }
                                finally
                                {
                                    DataSession.ServerSession.StopProcess(process);
                                }
                            }
                        }
                    }
                    finally
                    {
                        if (DesignerID == "SQL")
                        {
                            SwitchFromSQL();
                        }
                    }
                }
            }
        }
Ejemplo n.º 2
0
 private void PrepareForExecute()
 {
     Dataphoria.EnsureServerConnection();
     Dataphoria.Warnings.ClearErrors(this);
     SetStatus(String.Empty);
 }