Ejemplo n.º 1
0
 public void installSet(Windows.UpdateChecker wnd, Octgn.Data.Game game)
 {
     wnd.UpdateStatus("Retrieving xml...");
     XmlSetParser xmls = xml_set;
     wnd.UpdateStatus("Parsing retrieved xml...");
     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.UpdateStatus("Downloading new definition...");
     if (xmls.user() != null && xmls.user() != "")
         cli.Credentials = new System.Net.NetworkCredential(xmls.user(), xmls.password());
     cli.DownloadFile(xmls.link(), downloadto);
     wnd.UpdateStatus( "Checking for existence of old definition...");
     try
     {
         set = game.Sets.First<Data.Set>(_set => _set.Id.ToString() == xmls.uuid());
     }
     catch
     {
         is_spoiler_installed = false;
     }
     if (is_spoiler_installed)
     {
         wnd.UpdateStatus("Removing old definition...");
         game.DeleteSet(set);
     }
     wnd.UpdateStatus("Installing new definition...");
     game.InstallSet(downloadto);
     wnd.UpdateStatus("Set installed correctly");
 }