Ejemplo n.º 1
0
        private void CheckXmlClick(object sender, RoutedEventArgs e)
        {
            var wnd = new Windows.ChangeSetsProgressDialog("Testing xml...") {Owner = Program.MainWindowNew};
            String urlLink = urlBox.Text;
            bool is_ok = false;
            ThreadPool.QueueUserWorkItem(_ =>
                                             {
                                                 try
                                                 {
                                                     int current = 0, max = 10;
                                                     wnd.UpdateProgress(current, max, "Retrieving xml...", false);
                                                     XmlSetParser xmls = new XmlSetParser(urlLink);
                                                     current++;
                                                     XmlSimpleValidate validator = new XmlSimpleValidate(xmls);
                                                     validator.CheckVerboseXml(wnd, max, game);
                                                     is_ok = true;
                                                 }
                                                 catch (Exception ex)
                                                 {
                                                     wnd.UpdateProgress(10, 10, string.Format("Caught exception when retrieving / parsing xml: '{0}'", ex.Message), false);
                                                 }

                                             });
            wnd.ShowDialog();
            button3.IsEnabled = is_ok;
            button2.IsEnabled = is_ok;
        }
Ejemplo n.º 2
0
        public void installSet(Windows.ChangeSetsProgressDialog wnd, int max, Octgn.Data.Game game)
        {
            wnd.UpdateProgress(0, max, "Retrieving xml...", false);
            XmlSetParser xmls = xml_set;

            wnd.UpdateProgress(1, max, "Parsing retrieved xml...", false);
            xmls.check();
            bool is_spoiler_installed = true;

            Data.Set set        = null;
            string   path       = Path.Combine(Prefs.DataDirectory, "Games", game.Id.ToString(), "Sets");
            string   downloadto = Path.Combine(path) + xmls.name() + ".o8s";
            var      cli        = new WebClient();

            wnd.UpdateProgress(2, max, "Downloading new definition...", false);
            cli.Credentials = new System.Net.NetworkCredential(xmls.user(), xmls.password());
            cli.DownloadFile(xmls.link(), downloadto);
            wnd.UpdateProgress(3, max, "Checking for existence of old definition...", false);
            try
            {
                set = game.Sets.First <Data.Set>(_set => _set.Id.ToString() == xmls.uuid());
            }
            catch
            {
                is_spoiler_installed = false;
            }
            if (is_spoiler_installed)
            {
                wnd.UpdateProgress(4, max, "Removing old definition...", false);
                game.DeleteSet(set);
            }
            wnd.UpdateProgress(5, max, "Installing new definition...", false);
            game.InstallSet(downloadto);
            wnd.UpdateProgress(6, max, "Set installed correctly", false);
        }
Ejemplo n.º 3
0
        public void CheckXml(DataNew.Entities.Game game)
        {
            XmlSetParser xmls = xml_set;

            if (game.Id.ToString() != xmls.game())
            {
                throw new Exception("Error! Wrong game specified in xml");
            }
            xmls.check();
        }
Ejemplo n.º 4
0
        public void CheckXml(Windows.ChangeSetsProgressDialog wnd, int max, DataNew.Entities.Game game)
        {
            XmlSetParser xmls = xml_set;

            if (game.Id.ToString() != xmls.game())
            {
                wnd.UpdateProgress(max, max, string.Format("Error! Wrong game specified in xml"), false);
                return;
            }
            xmls.check();
        }
Ejemplo n.º 5
0
        public void CheckVerboseXml(Windows.ChangeSetsProgressDialog wnd, int max, DataNew.Entities.Game game)
        {
            XmlSetParser xmls = xml_set;

            wnd.UpdateProgress(1, max, "Parsing retrieved xml...", false);
            xmls.check();
            if (game.Id.ToString() != xmls.game())
            {
                wnd.UpdateProgress(10, 10, string.Format("Error! Wrong game specified in xml"), false);
                return;
            }
            wnd.UpdateProgress(2, max, "Name: " + xmls.name(), false);
            wnd.UpdateProgress(3, max, "Game: " + xmls.game(), false);
            wnd.UpdateProgress(4, max, "UUID: " + xmls.uuid(), false);
            wnd.UpdateProgress(5, max, "Version: " + xmls.version(), false);
            wnd.UpdateProgress(6, max, "Date: " + xmls.date(), false);
            wnd.UpdateProgress(7, max, "Link: " + xmls.link(), false);
            wnd.UpdateProgress(8, max, "Login: "******"Password: "******"Xml seems ok"), false);
        }
Ejemplo n.º 6
0
        private void DownloadAndInstallClick(object sender, RoutedEventArgs e)
        {
            var wnd = new Windows.ChangeSetsProgressDialog("Downloading and installing...") { Owner = Program.MainWindowNew };
            String urlLink = urlBox.Text;
            ThreadPool.QueueUserWorkItem(_ =>
            {
                try
                {
                    int max = 6;
                    wnd.UpdateProgress(0, max, "Retrieving xml...", false);
                    XmlSetParser xmls = new XmlSetParser(urlLink);
                    XmlInstaller xmli = new XmlInstaller(xmls);
                    xmli.installSet(wnd, max, game);

                }
                catch (Exception ex)
                {
                    wnd.UpdateProgress(6, 6, string.Format("Caught exception: '{0}'", ex.Message), false);
                }

            });
            wnd.ShowDialog();
        }
Ejemplo n.º 7
0
 public XmlSimpleValidate(XmlSetParser _xml_set)
 {
     xml_set = _xml_set;
 }
Ejemplo n.º 8
0
 public XmlSimpleValidate(XmlSetParser _xml_set)
 {
     xml_set = _xml_set;
 }
Ejemplo n.º 9
0
 public XmlInstaller(XmlSetParser _xml_set)
 {
     xml_set = _xml_set;
 }
Ejemplo n.º 10
0
 public XmlInstaller(XmlSetParser _xml_set)
 {
     xml_set = _xml_set;
 }