public ContainedFile ExtractFromContainer(String container, String fileName)
        {
            XmlDocument xmlDoc = new XmlDocument();

            xmlDoc.Load(container);
            XmlNode fileNode = xmlDoc.SelectSingleNode("//files/file[@name='" + fileName + "']");

            if (fileNode == null)
            {
                return(null);
            }

            ContainedFile containedFile = new ContainedFile();

            containedFile.fileName    = fileNode.Attributes["name"].Value;
            containedFile.fileContent = TextEncoder.Decode(fileNode.InnerText);

            return(containedFile);
        }
        private List <ContainedFile> GetContainedFiles(String container)
        {
            // Os dados do arquivo são obtidos do xml sem nenhuma transformação (mantendo o encode)
            List <ContainedFile> files = new List <ContainedFile>();

            XmlDocument xmlDoc = new XmlDocument();

            xmlDoc.Load(container);
            XmlNode mainNode = xmlDoc.SelectSingleNode("//files");

            foreach (XmlNode childNode in mainNode.ChildNodes)
            {
                ContainedFile containedFile = new ContainedFile();
                containedFile.fileName    = childNode.Attributes["name"].Value;
                containedFile.fileContent = childNode.InnerText;
                files.Add(containedFile);
            }

            return(files);
        }
        public void RunAll(String scriptsDirectory, IProgressListener progressListener)
        {
            listener.NotifyObject("Origem: [DatabaseScripts]   Destino(database): " + sqlConnection.Database);

            String        path       = PathFormat.Adjust(scriptsDirectory);
            List <String> scriptList = new List <String>();

            TextReader textReader = new StreamReader(path + "ExecutionOrder.txt");
            String     line       = "";

            while (line != null)
            {
                line = textReader.ReadLine();
                if (line != null)
                {
                    scriptList.Add(line);
                }
            }
            textReader.Close();

            scriptsExecuted = 0;
            progressMeter   = new ProgressMeter(scriptList.Count, progressListener);
            foreach (String script in scriptList)
            {
                currentScript = script;
                ContainedFile file = containerHandler.ExtractFromContainer(path + "ScriptFiles.xml", script);
                if (file == null)
                {
                    throw new Exception("Script não encontrado no XML: " + script);
                }

                ExecuteQuery(file.fileContent);
                scriptsExecuted++;
                progressMeter.IncreaseProgress(1);
            }
        }