Пример #1
0
        public bool CreateDestination()
        {
            WriteLog(Status.Running, "Creating CDM database...", 0);

            var dbDestination = new DbDestination(_settings.DestinationConnectionString,
                                                  _settings.ConversionSettings.DestinationSchema);

            try
            {
                dbDestination.CreateDatabase(_settings.CreateCdmDatabaseScript);
                WriteLog(Status.Running, "CDM database created", 0);
            }
            catch (Exception e)
            {
                WriteLog(Status.Running, "Warning: CDM database exists", 0);
            }

            try
            {
                dbDestination.CreateSchema();
                WriteLog(Status.Running, "Schema created", 0);
            }
            catch (Exception e)
            {
                WriteLog(Status.Running, "Warning: CDM schema exists", 0);
            }

            bool successful;

            try
            {
                dbDestination.ExecuteQuery(_settings.CreateCdmTablesScript);
                WriteLog(Status.Running, "CDM tables created", 0);

                successful = true;
            }
            catch (Exception e)
            {
                WriteLog(Status.Running, "Warning: CDM tables exists", 0);
                try
                {
                    dbDestination.ExecuteQuery(_settings.TruncateTablesScript);
                    WriteLog(Status.Running, "CDM tables truncated", 0);
                    successful = true;
                }
                catch (Exception e2)
                {
                    WriteLog(Status.Failed, e2.Message, 0);
                    throw e2;
                }
            }

            return(successful);
        }