private Boolean ImportFile(String filename, List <int> tenantsToImport, Boolean preserveRecordId)
        {
            String tableName = "tb_" + Path.GetFileNameWithoutExtension(filename);

            progressLog += tableName + Environment.NewLine;
            XmlNode rowCollection;

            ImportData importData = new ImportData(filename);

            currentDatabase = importData.DatabaseName;
            rowCollection   = importData.MainNode;
            if ((currentDatabase == null) || (rowCollection == null))
            {
                lastError = importData.GetLastError();
                return(false);
            }

            // Se o XML não possui registros considera como se tivesse importado e retorna
            if (rowCollection.FirstChild == null)
            {
                return(true);
            }

            DBQuery dbQuery = new DBQuery(sqlConnection);
            // Evita alterar o banco de dados pois o Microsoft Azure não tem suporte a essa operação
            // dbQuery.Query = "use " + currentDatabase;
            // dbQuery.Execute(false);

            // Verifica se a tabela já está populada, se estiver aborta
            ImportController controller = new ImportController(sqlConnection, importData, this);

            if (!controller.TableIsEmpty())
            {
                lastError = "A importação foi cancelada pois a tabela " + tableName + " já possui dados.";
                return(false);
            }

            try // tenta fazer a inserção dos dados na tabela
            {
                controller.MountDependencies(filesToImport, databaseForeignKeys);
                int?lastInsertedId = 0;
                while (controller.MoveNextRecord())
                {
                    int?owner = controller.GetRecordOwner();
                    if ((owner == null) || (tenantsToImport.Contains(owner.Value)))
                    {
                        // Conserta o identity para que seja mantida a numeração original
                        if (preserveRecordId)
                        {
                            controller.FixIdentity(lastInsertedId);
                        }

                        dbQuery.Query = controller.MountInsertStatement();
                        dbQuery.Execute(true);
                        lastInsertedId = dbQuery.ExtractFromResultset();
                    }
                    progressMeter.IncreaseProgress(1);
                }
            }
            catch (Exception exc)
            {
                lastError = exc.Message + Environment.NewLine + progressLog;
                return(false);
            }

            return(true);
        }