Ejemplo n.º 1
0
        public override LongRunningTaskResult Start()
        {
            LongRunningTaskResult result = LongRunningTaskResult.Completed;

            try
            {
                if (ValidateInstaller(_installer))
                {
                    if (_installer.IsUpdate)
                    {
                        UpdatePartialGame(_installer);
                    }
                    else
                    {
                        UpdateFullGame(_installer);
                    }
                }
                else
                {
                    result = LongRunningTaskResult.Error;
                }
            }
            catch (Exception ex)
            {
                Logger.Current.Write(ex, "Install failed");
                result = LongRunningTaskResult.Error;
            }
            finally
            {
                Cleanup();
            }

            return(result);
        }
Ejemplo n.º 2
0
        public override LongRunningTaskResult Start()
        {
            LongRunningTaskResult result = LongRunningTaskResult.Completed;

            try
            {
                UpdateFramework();
            }
            catch (Exception ex)
            {
                Logger.Current.Write(ex, "Framework installation failed");
                result = LongRunningTaskResult.Error;
            }
            finally
            {
                Cleanup();
            }
            return(result);
        }
Ejemplo n.º 3
0
        public override LongRunningTaskResult Start()
        {
            LongRunningTaskResult result = LongRunningTaskResult.Completed;

            try
            {
                CreateSystemIcon();
                AddToInstalledPrograms();
                AddToGamesExplorer();
                AddToStartMenu();
                AddDesktopShortcut();
                DependencyInstaller.Install();
            }
            catch (Exception ex)
            {
                Logger.Current.Write(ex, "Install failed");
                result = LongRunningTaskResult.Error;
            }

            return(result);
        }
Ejemplo n.º 4
0
        public override LongRunningTaskResult Start()
        {
            LongRunningTaskResult result = LongRunningTaskResult.Completed;

            try
            {
                ServicePointManager.ServerCertificateValidationCallback += OnCheckRemoteCallback;

                long total;
                using (Stream responseSteam = HttpRequestManager.Current.GetResponseStream(_sourceUrl, 0, _getCredentials, out total))
                {
                    uint uTotal = total > uint.MaxValue ? uint.MaxValue : (uint)total;
                    Total = uTotal;
                    using (Stream saveFileStream = FileSystem.Current.GetFile(_destinationFileName).OpenStream(FileMode.Create, FileAccess.Write, FileShare.ReadWrite))
                    {
                        int    bytesRead;
                        byte[] downloadBuffer = new byte[DownloadBufferSize];

                        while ((bytesRead = responseSteam.Read(downloadBuffer, 0, downloadBuffer.Length)) > 0)
                        {
                            saveFileStream.Write(downloadBuffer, 0, bytesRead);

                            Progress = Progress + (uint)bytesRead;
                            if (_cancelPending)
                            {
                                result = LongRunningTaskResult.Cancelled;
                            }
                        }
                    }
                }

                if (result != LongRunningTaskResult.Cancelled)
                {
                    string actualMd5 = FileSystem.Current.GetFile(_destinationFileName).ComputeMD5();
                    if (_expectedMd5 != actualMd5)
                    {
                        Logger.Current.Write(LogInfoLevel.Error, string.Format("Downloaded file {0} MD5 file hash {1} does not match the expected value {2}", _destinationFileName, actualMd5, _expectedMd5));
                        result = LongRunningTaskResult.Error;
                    }
                }
            }
            catch (Exception ex)
            {
                Logger.Current.Write(ex, string.Format("Unable to download {0} to {1}", _sourceUrl, _destinationFileName));
                result = LongRunningTaskResult.Error;
            }

            if (result == LongRunningTaskResult.Cancelled)
            {
                try
                {
                    FileSystem.Current.GetFile(_destinationFileName).DeleteWithTimeout();
                }
                catch (Exception ex)
                {
                    Logger.Current.Write(ex, string.Format("Unable to delete partially downloaded file {0}", _destinationFileName));
                }
            }

            return(result);
        }