Пример #1
0
        public override IDatabaseWriter GetWriter(string file, IDatabaseSource src)
        {
            var res = new DataArchiveWriter();

            res.FilePlace = FilePlaceAddonType.PlaceFromVirtualFile(file);
            return(res);
        }
Пример #2
0
            public override void RunCommand()
            {
                if (Format == null)
                {
                    if (Outfile.EndsWith(".dbk"))
                    {
                        Format = "dbk";
                    }
                    else if (Outfile.EndsWith(".ddf"))
                    {
                        Format = "ddf";
                    }
                    else
                    {
                        throw new CommandLineError("DAE-00151 Unknown output format, cannot be deduced from file extension");
                    }
                }
                IDatabaseSource db = m_connection.GetConnection();

                Async.SafeOpen(db.Connection);
                try
                {
                    switch (Format)
                    {
                    case "ddf":
                    {
                        var s = new DatabaseStructure(db.InvokeLoadStructure(DatabaseStructureMembers.FullStructure, null));
                        s.Save(Outfile);
                    }
                    break;

                    case "dbk":
                    {
                        DataArchiveWriter dw = new DataArchiveWriter();
                        dw.FilePlace = FilePlaceAddonType.PlaceFromVirtualFile(Outfile);
                        CopyDbJob.CopyDatabase(db, dw, null, new DatabaseCopyOptions {
                                CopyMembers = DatabaseStructureMembers.FullStructure
                            });
                        Async.SafeClose(db.Connection);
                    }
                    break;

                    default:
                        throw new CommandLineError("DAE-00152 Unknown format:" + Format);
                    }
                }
                finally
                {
                    Async.SafeClose(db.Connection);
                }
            }