Exemplo n.º 1
0
        public void CheckRepository(string arma3SyncPath, string javaPath, Repository repository)
        {
            repository.Status = RepositoryStatus.Checking;

            //Extract A3SDS
            Logger.LogDebug("Arma3SyncService", "Extracting deserializer");
            _fileAccessor.WriteAllBytes(ApplicationConfig.A3SdsPath, Properties.Resources.A3SDS);

            Logger.LogDebug("Arma3SyncService", "Deserializing local repository");
            DeserializeLocalRepository(arma3SyncPath, javaPath, repository);

            Logger.LogDebug("Arma3SyncService", "Deserializing remote repository");
            DeserializeRemoteRepository(javaPath, repository);

            //Delete A3SDS
            Logger.LogDebug("Arma3SyncService", "Cleaning up deserializer");
            _fileAccessor.DeleteFile(ApplicationConfig.A3SdsPath);

            if (repository.LocalRevision != null && repository.RemoteRevision != null)
            {
                repository.Status = repository.LocalRevision.Equals(repository.RemoteRevision)
                    ? RepositoryStatus.Updated
                    : RepositoryStatus.Outdated;
            }
            else
            {
                repository.Status = RepositoryStatus.Unknown;
            }

            Logger.LogDebug("Arma3SyncService", $"Finished checking repository status, status is {repository.Status}");
        }
Exemplo n.º 2
0
        /// <summary>
        /// Extract and execute external updater, then close the application
        /// </summary>
        private void RunUpdater()
        {
            Logger.LogDebug("UpdaterService", "Preparing to run updater");

            try
            {
                //Extract updater
                _fileAccessor.WriteAllBytes(ApplicationConfig.UpdaterPath, Properties.Resources._11thLauncher_Updater);

                var appPath     = Path.GetFullPath(Assembly.GetExecutingAssembly().Location);
                var downloadUrl = _release.assets.First().browser_download_url;
                var hashUrl     = _release.assets.ElementAt(1).browser_download_url;

                //Execute updater
                var p = new Process
                {
                    StartInfo =
                    {
                        FileName  = ApplicationConfig.UpdaterPath,
                        Arguments = string.Concat("\"",           appPath,"\" ", downloadUrl, " ", hashUrl)
                    }
                };
                _processAccessor.Start(p);
            }
            catch (Exception e)
            {
                Logger.LogException("UpdaterService", "Error trying to launch updater", e);
                return;
            }

            Logger.LogDebug("UpdaterService", "Updater started, shutting down...");

            Application.Current.Shutdown();
        }