예제 #1
0
        public XElement getXML()
        {
            XElement xml = new XElement("Update");

            Changelog changeLog    = getChangelog();
            XElement  changeLogXML = null;

            if (changeLog != null && !changeLog.isEmpty())
            {
                changeLogXML = new XElement("Changelog");
                foreach (Changelog.Log log in changeLog.getLogs())
                {
                    XElement logXML = new XElement("Log");
                    logXML.SetValue(log.getText());
                    changeLogXML.Add(logXML);
                }
                xml.Add(changeLogXML);
            }

            xml.SetAttributeValue("name", getName());
            xml.SetAttributeValue("version", getVersion());
            xml.SetAttributeValue("base", getBaseType());
            xml.SetAttributeValue("url", getFullPath());
            return(xml);
        }
예제 #2
0
        public List <Update> getPreviousUpdates()
        {
            XDocument xml = getUpdateXML();

            List <Update> updates = new List <Update>();
            var           root    = from item in updateXML.get().Descendants("Updates")
                                    select new {
                updates = item.Descendants("Update")
            };

            try {
                foreach (var data in root)
                {
                    var udates = from item in data.updates
                                 select new {
                        name       = item.Attribute("name"),
                        version    = item.Attribute("version"),
                        url        = item.Attribute("url"),
                        baseType   = item.Attribute("base"),
                        changelogs = item.Descendants("Changelog")
                    };

                    foreach (var u in udates)
                    {
                        Update update = new Update();
                        update.setName(u.name.Value);
                        update.setVersion(Convert.ToDouble(u.version.Value));
                        update.setUrl(u.url.Value);

                        XAttribute baseType = u.baseType;
                        if (baseType != null)
                        {
                            update.setBaseType(baseType.Value);
                        }

                        Changelog changelog = new Changelog(update.getVersion());
                        foreach (var clog in u.changelogs)
                        {
                            foreach (var log in clog.Descendants("Log"))
                            {
                                changelog.addLog(new Changelog.Log(log.Value));
                            }
                            update.setChangelog(changelog);
                            break;
                        }
                        update.setChangelog(changelog);

                        updates.Add(update);
                    }
                }
            }
            catch (Exception e) {
                Logger.log(Logger.TYPE.ERROR, "Failed to get previous updates "
                           + e.Message + e.StackTrace);
            }

            return(updates);
        }
예제 #3
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);
        }
예제 #4
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);
        }
예제 #5
0
        public void addChangeLog(ImageListBox listBox, Changelog changelog,
                                 String updateName, String baseType, int imageIndex)
        {
            Logger.log(Logger.TYPE.DEBUG, "Add changelog.");

            String           text = "[" + changelog.getVersion() + baseType + "] " + updateName;
            ImageListBoxItem item = new ImageListBoxItem(text, imageIndex);

            listBox.Items.Add(item);
        }
예제 #6
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;
        }
예제 #7
0
 public void setChangelog(Changelog changelog)
 {
     this.changelog = changelog;
 }
예제 #8
0
 public void setChangelog(Changelog changelog)
 {
     this.changelog = changelog;
 }
예제 #9
0
        public void addChangeLog(ImageListBox listBox, Changelog changelog, 
                String updateName, String baseType, int imageIndex)
        {
            Logger.log(Logger.TYPE.DEBUG, "Add changelog.");

            String text = "[" + changelog.getVersion() + baseType + "] " + updateName;
            ImageListBoxItem item = new ImageListBoxItem(text, imageIndex);

            listBox.Items.Add(item);
        }
예제 #10
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);
        }
예제 #11
0
        public List<Update> getPreviousUpdates()
        {
            XDocument xml = getUpdateXML();

            List<Update> updates = new List<Update>();
            var root = from item in updateXML.get().Descendants("Updates")
                select new {
                    updates = item.Descendants("Update")
                };

            try {
                foreach (var data in root) {
                    var udates = from item in data.updates
                        select new {
                            name = item.Attribute("name"),
                            version = item.Attribute("version"),
                            url = item.Attribute("url"),
                            baseType = item.Attribute("base"),
                            changelogs = item.Descendants("Changelog")
                        };

                    foreach (var u in udates) {
                        Update update = new Update();
                        update.setName(u.name.Value);
                        update.setVersion(Convert.ToDouble(u.version.Value));
                        update.setUrl(u.url.Value);

                        XAttribute baseType = u.baseType;
                        if (baseType != null) {
                            update.setBaseType(baseType.Value);
                        }

                        Changelog changelog = new Changelog(update.getVersion());
                        foreach (var clog in u.changelogs) {
                            foreach(var log in clog.Descendants("Log")) {
                                changelog.addLog(new Changelog.Log(log.Value));
                            }
                            update.setChangelog(changelog);
                            break;
                        }
                        update.setChangelog(changelog);

                        updates.Add(update);
                    }
                }
            }
            catch (Exception e) {
                Logger.log(Logger.TYPE.ERROR, "Failed to get previous updates "
                    + e.Message + e.StackTrace);
            }

            return updates;
        }