Exemplo n.º 1
0
        public Update(UpdateNode node)
        {
            this.request = node.getRequest();
            this.url     = node.getUrl();
            this.version = node.getVersion();
            this.dir     = node.getDir();
            this.success = false;

            this.changelog = new Changelog(version);
        }
Exemplo n.º 2
0
        public Update(UpdateNode node)
        {
            this.request = node.getRequest();
            this.url = node.getUrl();
            this.version = node.getVersion();
            this.dir = node.getDir();
            this.success = false;

            this.changelog = new Changelog(version);
        }
Exemplo n.º 3
0
        private Update compileUpdate(UpdateNode node, XDocument xml)
        {
            Update update = new Update(node);
            if (isDead()) {
                return update;
            }

            try {
                var root = from item in xml.Descendants("Update")
                    select new {
                        changelog = item.Descendants("Changelog"),
                        files = item.Descendants("File"),
                        archives = item.Descendants("Archive"),
                        name = item.Attribute("name"),
                        baseType = item.Attribute("base")
                    };

                foreach (var data in root) {

                    // Set Attributes
                    update.setName(data.name.Value);
                    if (data.baseType != null) {
                        update.setBaseType(data.baseType.Value);
                    }

                    // Add the changelog data
                    foreach (var clog in data.changelog) {
                        Changelog changelog = new Changelog(update.getVersion());
                        foreach (var log in clog.Descendants("Log")) {
                            changelog.addLog(new Changelog.Log(log.Value.Trim()));
                        }
                        update.setChangelog(changelog);
                        break;
                    }

                    // Add the file data
                    foreach (var f in data.files) {
                        String name = Xml.getAttributeValue(f.Attribute("name"));
                        String destination = Xml.getAttributeValue(f.Attribute("destination"));
                        String mime = Xml.getAttributeValue(f.Attribute("mime"), "none");

                        update.addFile(new GhostFile(name, destination, mime,
                            new Uri(url + "/" + node.getDir() + "/" + name)));
                    }

                    // Add the archive data
                    foreach (var f in data.archives) {
                        String name = Xml.getAttributeValue(f.Attribute("name"));
                        String extractTo = Xml.getAttributeValue(f.Attribute("extractTo"));
                        String mime = Xml.getAttributeValue(f.Attribute("mime"), "none");

                        Boolean cleanDirs = false;
                        if (f.Attribute("cleanDirs") != null) {
                            cleanDirs = Convert.ToBoolean(f.Attribute("cleanDirs").Value.Trim());
                        }

                        update.addFile(new Archive(name, extractTo, mime,
                            new Uri(url + "/" + node.getDir() + "/" + name), cleanDirs));
                    }
                }
            }
            catch (Exception ex) {
                Logger.log(Logger.TYPE.ERROR, "Problem while compiling updates "
                    + ex.Message + ex.StackTrace);
            }

            return update;
        }
Exemplo n.º 4
0
        private Update compileUpdate(UpdateNode node, XDocument xml)
        {
            Update update = new Update(node);

            if (isDead())
            {
                return(update);
            }

            try {
                var root = from item in xml.Descendants("Update")
                           select new {
                    changelog = item.Descendants("Changelog"),
                    files     = item.Descendants("File"),
                    archives  = item.Descendants("Archive"),
                    name      = item.Attribute("name"),
                    baseType  = item.Attribute("base")
                };

                foreach (var data in root)
                {
                    // Set Attributes
                    update.setName(data.name.Value);
                    if (data.baseType != null)
                    {
                        update.setBaseType(data.baseType.Value);
                    }

                    // Add the changelog data
                    foreach (var clog in data.changelog)
                    {
                        Changelog changelog = new Changelog(update.getVersion());
                        foreach (var log in clog.Descendants("Log"))
                        {
                            changelog.addLog(new Changelog.Log(log.Value.Trim()));
                        }
                        update.setChangelog(changelog);
                        break;
                    }

                    // Add the file data
                    foreach (var f in data.files)
                    {
                        String name        = Xml.getAttributeValue(f.Attribute("name"));
                        String destination = Xml.getAttributeValue(f.Attribute("destination"));
                        String mime        = Xml.getAttributeValue(f.Attribute("mime"), "none");

                        update.addFile(new GhostFile(name, destination, mime,
                                                     new Uri(url + "/" + node.getDir() + "/" + name)));
                    }

                    // Add the archive data
                    foreach (var f in data.archives)
                    {
                        String name      = Xml.getAttributeValue(f.Attribute("name"));
                        String extractTo = Xml.getAttributeValue(f.Attribute("extractTo"));
                        String mime      = Xml.getAttributeValue(f.Attribute("mime"), "none");

                        Boolean cleanDirs = false;
                        if (f.Attribute("cleanDirs") != null)
                        {
                            cleanDirs = Convert.ToBoolean(f.Attribute("cleanDirs").Value.Trim());
                        }

                        update.addFile(new Archive(name, extractTo, mime,
                                                   new Uri(url + "/" + node.getDir() + "/" + name), cleanDirs));
                    }
                }
            }
            catch (Exception ex) {
                Logger.log(Logger.TYPE.ERROR, "Problem while compiling updates "
                           + ex.Message + ex.StackTrace);
            }

            return(update);
        }