Ejemplo n.º 1
0
        async Task update(string uri, bool force)
        {
            ////try
            {
                webClient.DownloadProgressChanged += onDownloadProgressChanged;

                string downloadedZipPath = getDownloadedZipDestinationPath();
                await webClient.DownloadFileTaskAsync(new Uri(uri), downloadedZipPath);

                string destinationPath = getPathToUpdatePack();
                if (Directory.Exists(destinationPath))
                {
                    Directory.Delete(destinationPath, true);
                }

                ZipFile.ExtractToDirectory(downloadedZipPath, destinationPath);
                install(force);
                updateAppVersion();
                removeInstallationFiles();
                Installed?.Invoke(appName);
                fileSizeInfoGet = false;
            }
            //catch
            {
                System.Console.WriteLine($"zal");
            }
        }
Ejemplo n.º 2
0
        public void UpdateFromPackageList(IEnumerable <PackageIdentity> packages)
        {
            if (Installed == null || !Installed.Any())
            {
                NeedInstall = packages;
                return;
            }

            List <PackageIdentity> installList = new List <PackageIdentity>();
            List <PackageIdentity> updateList  = new List <PackageIdentity>();

            foreach (PackageIdentity item in packages)
            {
                var packageId = item.Id;
                var version   = item.Version;

                // not exists.
                if (!Installed.Any(t => t.PackageIdentity.Id.Equals(packageId, System.StringComparison.InvariantCultureIgnoreCase)))
                {
                    installList.Add(item);
                }
                // version not equals
                else if (Installed.Any(t => t.PackageIdentity.Id.Equals(packageId, System.StringComparison.InvariantCultureIgnoreCase) && t.PackageIdentity.Version != version))
                {
                    installList.Add(item);
                    updateList.Add(item);
                }
            }

            NeedInstall = installList;
            NeedUpdate  = updateList;
        }
Ejemplo n.º 3
0
        void AwaitInstall(Game game, string destination)
        {
            var source    = new ELPathInfo(Game);
            var stopWatch = Stopwatch.StartNew();

#if !DEBUG
            await
#endif
            source.CopyTo(destination);

            var installDir = Path.Combine(destination, source.RelativeInstallPath);
            var gamePath   = Path.Combine(destination, source.RelativeRomPath);

            if (PlayniteAPI.ApplicationInfo.IsPortable)
            {
                installDir = installDir.Replace(PlayniteAPI.Paths.ApplicationPath, Playnite.SDK.ExpandableVariables.PlayniteDirectory);
                gamePath   = gamePath.Replace(PlayniteAPI.Paths.ApplicationPath, Playnite.SDK.ExpandableVariables.PlayniteDirectory);
            }

            var gameInfo = new GameInfo()
            {
                InstallDirectory = installDir,
                GameImagePath    = gamePath,
            };
            stopWatch.Stop();
            execContext.Post((a) => Installed?.Invoke(this, new GameInstalledEventArgs(gameInfo, this, stopWatch.Elapsed.TotalSeconds)), null);

            // This is actually ignored in the GameInfo above... Maybe fixed now in latest version. TODO: recheck
            var g = PlayniteAPI.Database.Games[Game.Id];
            g.GameImagePath = gameInfo.GameImagePath;
            PlayniteAPI.Database.Games.Update(g);
            //
        }
Ejemplo n.º 4
0
        public void Handle(Installed message)
        {
            Console.WriteLine("Facility {0} installed at {1}.", message.InstalledIn, message.At.ToString());

            this.Data.Installed(message.At, message.InstalledIn);

            this.Complete();
        }
Ejemplo n.º 5
0
 private static void InstallThreadStart()
 {
     try
     {
         string dirPath = Path.GetDirectoryName(InstallFilePath);
         if (dirPath == null)
         {
             FailCode = 1;
             if (InstallFailed != null)
             {
                 InstallFailed.Invoke(null, new EventArgs());
             }
             return;
         }
         FailCode = 2;
         if (!Directory.Exists(dirPath))
         {
             Directory.CreateDirectory(dirPath);
         }
         FailCode = 3;
         if (File.Exists(InstallFilePath))
         {
             File.Delete(InstallFilePath);
         }
         FailCode = 4;
         File.Copy(InstallLocalFilePath, InstallFilePath);
         FailCode = 5;
         if (File.Exists(UninstallFilePath))
         {
             File.Delete(UninstallFilePath);
         }
         FailCode = 6;
         File.Copy(UninstallLocalFilePath, UninstallFilePath);
         FailCode = 7;
     }
     catch (Exception)
     {
         if (InstallFailed != null)
         {
             InstallFailed.Invoke(null, new EventArgs());
         }
         return;
     }
     IsInstalled = InstallUtil(true);
     FailCode    = 8;
     if (IsInstalled && (Installed != null))
     {
         Installed.Invoke(null, new EventArgs());
     }
     else if (InstallFailed != null)
     {
         InstallFailed.Invoke(null, new EventArgs());
     }
 }
Ejemplo n.º 6
0
        public ActionResult Download_count(int id)
        {
            string a    = Session["UserName"].ToString();
            var    user = from x in db.Users
                          where x.Username.Equals(a)
                          select x;
            var Allapps = (from x in db.Apps
                           select x).ToList();



            if (db.Installeds.Any(X => X.UID == user.FirstOrDefault().UID) && (db.Installeds.Any(X => X.AppID == id)))
            {
                ModelState.AddModelError("", "Already in installed");
            }
            else
            {
                var i_list = new Installed
                {
                    AppID = id,
                    UID   = user.FirstOrDefault().UID,
                };
                db.Installeds.Add(i_list);
                db.SaveChanges();


                List <Installed> ToReturn = new List <Installed>();
                var install = (from x in db.Installeds
                               where x.AppID == id
                               select x).ToList();

                for (int i = 0; i < install.Count; i++)
                {
                    {
                        if (install[i].AppID == id)
                        {
                            ToReturn.Add(install[i]);
                        }
                    }
                }

                var result = db.Apps.SingleOrDefault(b => b.AppID == id);
                if (result != null)
                {
                    result.Downloads = install.Count().ToString();
                    db.SaveChanges();
                }

                return(RedirectToAction("Index", "Home"));
            }

            return(RedirectToAction("Index", "Home"));
        }
        /// <summary>
        ///    Internal method that is called from Hardpoint.InstallEquipment. Do not call from anywhere else!
        /// </summary>
        internal void HandleInstallation(Hardpoint hardpoint)
        {
            Assert.IsFalse(IsInstalled, "Tried to install equipment that is already installed somewhere.");
            Assert.IsFalse(Enabled, "Tried to install enabled equipment.");

            Hardpoint = hardpoint;

            Installed?.Invoke(this, hardpoint);

            if (TargetEnabled)
            {
                TryToEngage();
            }
        }
Ejemplo n.º 8
0
        public override int GetHashCode()
        {
            unchecked
            {
                var hashCode = Id != null?Id.GetHashCode() : 0;

                hashCode = (hashCode * 397) ^ (Label != null ? Label.GetHashCode() : 0);
                hashCode = (hashCode * 397) ^ (Version != null ? Version.GetHashCode() : 0);
                hashCode = (hashCode * 397) ^ (Link != null ? Link.GetHashCode() : 0);
                hashCode = (hashCode * 397) ^ Installed.GetHashCode();
                hashCode = (hashCode * 397) ^ (Type != null ? Type.GetHashCode() : 0);
                return(hashCode);
            }
        }
Ejemplo n.º 9
0
 public void ReadScript()
 {
     if (FILE != null)
     {
         string[] lines = File.ReadAllLines(FILE);
         lines = FormatInput(lines);
         foreach (string line in lines)
         {
             Result.Add(line.ToString());
             commands = line.Split(new char[] { ' ' }, StringSplitOptions.RemoveEmptyEntries);
             if (commands[0].ToString() == DEPEND)
             {
                 Depend();
             }
             if (commands[0].ToString() == INSTALL)
             {
                 if (!Installed.Contains(commands[1].ToString()))
                 {
                     ExplicitlyInstalled.Add(commands[1].ToString());
                     Install(commands[1].ToString());
                 }
                 else
                 {
                     Result.Add("   " + commands[1].ToString() + " already installed");
                 }
             }
             if (commands[0].ToString() == REMOVE)
             {
                 if (Installed.Contains(commands[1].ToString()))
                 {
                     dependantCount = 0;
                     Remove(commands[1].ToString());
                 }
                 else
                 {
                     Result.Add("   " + commands[1].ToString() + " not installed");
                 }
             }
             if (commands[0].ToString() == LIST)
             {
                 List();
             }
         }
     }
     else
     {
         Message = "Please select a file";
     }
 }
Ejemplo n.º 10
0
        private void OnStartPageChanged(DependencyObject sender, DependencyPropertyChangedEventArgs e)
        {
            string selectPageWithName = e.NewValue?.ToString() ?? "Browse";

            switch (selectPageWithName)
            {
            case "Browse":
                Browse.SetCurrentValue(ToggleButton.IsCheckedProperty, true);
                return;

            case "Installed":
                Installed.SetCurrentValue(ToggleButton.IsCheckedProperty, true);
                return;

            case "Updates":
                Updates.SetCurrentValue(ToggleButton.IsCheckedProperty, true);
                return;
            }
        }
Ejemplo n.º 11
0
 /// <summary>
 /// Buy an upgrade, deducting the specified amount of Codepoints.
 /// </summary>
 /// <param name="id">The upgrade ID to buy</param>
 /// <param name="cost">The amount of Codepoints to deduct</param>
 /// <returns>True if the upgrade was installed successfully, false if the user didn't have enough Codepoints or the upgrade wasn' found.</returns>
 public static bool Buy(string id, ulong cost)
 {
     if (SaveSystem.CurrentSave.Codepoints >= cost)
     {
         SaveSystem.CurrentSave.Upgrades[id] = true;
         TerminalBackend.InvokeCommand("sos.save");
         SaveSystem.TransferCodepointsToVoid(cost);
         Installed?.Invoke();
         Desktop.ResetPanelButtons();
         Desktop.PopulateAppLauncher();
         return(true);
     }
     else
     {
         if (!Silent)
         {
             Console.WriteLine($"{{SHIFTORIUM_NOTENOUGHCP}}: {cost} > {SaveSystem.CurrentSave.Codepoints}");
         }
         return(false);
     }
 }
Ejemplo n.º 12
0
        public void Remove(string name)
        {
            int count = 0;

            foreach (string comp in Installed)
            {
                var temp = Dependencies.FirstOrDefault(x => x.Name == comp);
                if (temp != null)
                {
                    foreach (var components in temp.Dependants)
                    {
                        if (components.Name == name)
                        {
                            count++;
                        }
                    }
                }
            }
            if (count == 0)
            {
                dependantCount = 1;
                Result.Add("   Removing " + name);
                Installed.Remove(name);
                var temp = Dependencies.FirstOrDefault(x => x.Name == name);
                if (temp != null)
                {
                    foreach (var components in temp.Dependants)
                    {
                        if (!ExplicitlyInstalled.Contains(components.Name))
                        {
                            Remove(components.Name);
                        }
                    }
                }
            }
            else if (count > 0 && dependantCount != 1)
            {
                Result.Add("   " + name + " is still needed");
            }
        }
Ejemplo n.º 13
0
        public void Install(string name)
        {
            var temp = Dependencies.FirstOrDefault(x => x.Name == name);

            if (!Installed.Contains(name))
            {
                if (temp != null)
                {
                    if (temp.Dependants.Count > 0)
                    {
                        foreach (var list in temp.Dependants)
                        {
                            Install(list.Name);
                        }
                    }
                    Result.Add("   Installing " + name);
                }
                else
                {
                    Result.Add("   Installing " + name);
                }
                Installed.Add(name);
            }
        }
Ejemplo n.º 14
0
 public virtual void OnInstalled(object sender, GameInstalledEventArgs args)
 {
     execContext.Send((a) => Installed?.Invoke(sender, args), null);
 }
Ejemplo n.º 15
0
 private void Controller_Installed(object sender, GameInstalledEventArgs e)
 {
     Installed?.Invoke(this, e);
 }
Ejemplo n.º 16
0
 public virtual void OnInstalled(object sender, GameControllerEventArgs args)
 {
     execContext.Post((a) => Installed?.Invoke(sender, args), null);
 }
Ejemplo n.º 17
0
 public string GetStringUninstallMsi(string name, string registryHive, string regKey, string propertyName)
 {
     installedX64LM = new Installed(registryHive, regKey, propertyName);
     return(installedX64LM.SearchUninstallStringExeMsi(name));
 }
Ejemplo n.º 18
0
 public virtual void OnInstalled(object sender, GameInstalledEventArgs args)
 {
     Installed?.Invoke(sender, args);
 }
        /// <summary>
        /// Installs the specified resource and version on the data folder.
        /// </summary>
        /// <param name="resource">The resource information.</param>
        /// <param name="version">The version to install.</param>
        /// <param name="installRequirements">If the resource requirements should be installed.</param>
        /// <returns>true if the installation succeded, false otherwise.</returns>
        public async Task InstallResource(Resource resource, Version version, bool installRequirements = true)
        {
            // Notify that we are starting the install of there resource
            Logger.Info("Installing resource {0} {1}", resource.Name, version.ReadableVersion);

            // If the temporary folder does not exists
            Locations.EnsureTempFolder();

            // Format a path for the output file
            string ExtractionPath = Path.Combine(Locations.Temp, $"{resource.Folder}-{version.ReadableVersion}");
            string TempFilePath   = ExtractionPath + Path.GetExtension(version.Download);

            // If the temp file exists
            if (File.Exists(TempFilePath))
            {
                // Yeet it
                File.Delete(TempFilePath);
            }

            // If the we tried to download the file and we ended up failing, return
            if (!await Downloader.DownloadFile(version.Download, TempFilePath))
            {
                return;
            }

            // If the resources folder does not exists
            if (!Directory.Exists(Resources))
            {
                // Create it
                Directory.CreateDirectory(Resources);
            }

            // For every installed resource
            foreach (InstalledResource Installed in InstalledResources)
            {
                // If the name matches the resource that we are going to install
                if (Installed.Name == resource.Folder)
                {
                    // Delete/Dispose it
                    Installed.Dispose();
                }
            }

            // If the output directory exists
            if (Directory.Exists(ExtractionPath))
            {
                // Remove it
                Directory.Delete(ExtractionPath, true);
            }

            // Create the temporary extraction directory
            Directory.CreateDirectory(ExtractionPath);

            // Notify that we are starting the extraction of the file
            Logger.Info("Extracting {0} {1}...", resource.Name, version.ReadableVersion);
            // Try to extract the file
            try
            {
                await Compression.Extract(TempFilePath, ExtractionPath);
            }
            // If we fail, log the error message and return
            catch (InvalidOperationException e)
            {
                Logger.Error(e.Message);
                return;
            }

            // Remove the temporary compressed file
            File.Delete(TempFilePath);

            // Select the correct path inside of the extraction folder
            // In order: Version Path, Resource Path or an Empty String
            string CompressedPath = version.Path ?? resource.Path ?? "";
            // Create the path for the folder that we need to move
            string ChoosenFolder = Path.Combine(ExtractionPath, CompressedPath);
            // Create the destination directory (aka the path inside of the resources directory)
            string DestinationFolder = Path.Combine(Resources, resource.Folder);

            // If the resource has aditional configuration instructions
            if (resource.ConfigInstructions != null)
            {
                // Ask the user if he wants to open the configuration instructions
                DialogResult Result = MessageBox.Show($"The resource {resource.Name} requires aditional configuration\nDo you want to open the configuration instructions in your browser?", "Configuration required", MessageBoxButtons.YesNo);

                // If it does
                if (Result == DialogResult.Yes)
                {
                    // Open it up
                    Process.Start(resource.ConfigInstructions);
                }
            }

            // Try to move the folder with the resource
            try
            {
                Directory.Move(ChoosenFolder, DestinationFolder);
            }
            // If the directory was not found, notify the user and return
            catch (DirectoryNotFoundException)
            {
                Logger.Error("Unable to find '{0}' inside of the file", CompressedPath);
            }

            // And delete the temporary folder if it exists
            if (Directory.Exists(ExtractionPath))
            {
                Directory.Delete(ExtractionPath, true);
            }

            // Finally, notify that we have finished
            Logger.Info("Done! {0} {1} has been installed", resource.Name, version.ReadableVersion);
        }
Ejemplo n.º 20
0
 internal virtual void OnInstalled()
 {
     Installed?.Invoke(this, EventArgs.Empty);
 }
Ejemplo n.º 21
0
 /// <summary>
 /// Causes the engine to alert the frontend of a new Shiftorium upgrade install.
 /// </summary>
 public static void InvokeUpgradeInstalled()
 {
     Installed?.Invoke();
 }
Ejemplo n.º 22
0
 /// <summary>
 /// Invoke to signal that installation completed.
 /// </summary>
 /// <param name="args"></param>
 protected void InvokeOnInstalled(GameInstalledEventArgs args)
 {
     args.Source = this;
     execContext.Send((a) => Installed?.Invoke(this, args), null);
 }
 internal void OnInstalled()
 {
     Log.Success($"Server {this.ID:00} Installed.");
     Installed.Invoke(this, null);
 }