aboutsummaryrefslogtreecommitdiffstats
path: root/Software/Visual_Studio/PPC/UpdatePackages/Tango.PPC.Packages.CefInstaller/CefInstaller.cs
blob: a4ea5dc4fe6673e7b76a2d681ee18add1950bdbf (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
using System;
using System.Collections.Generic;
using System.IO.Compression;
using System.Linq;
using System.Reflection;
using System.Text;
using System.Threading;
using System.Threading.Tasks;
using Tango.Core;
using Tango.Core.Helpers;
using Tango.PPC.Common.UpdatePackages;
using Tango.PPC.Shared.Updates;
using Tango.Transport.Web;

namespace Tango.PPC.Packages.CefInstaller
{
    [PPCPackage(PackageType.Post, "Installing Web Browser", true)]
    public class CefInstaller : ExtendedObject, IPPCPackage
    {
        public Task Run(PackageContext context)
        {
            return Task.Factory.StartNew(() =>
            {
                LogManager.Log("Downloading cef binaries...");

                var zipFile = TemporaryManager.CreateImaginaryFile();

                try
                {
                    using (AutoFileDownloader downloader = new AutoFileDownloader("https://tangostorage.blob.core.windows.net/resources/CefSharpOutput.zip", "https://tango.azureedge.net/resources/CefSharpOutput.zip", zipFile))
                    {
                        downloader.Progress += (x, e) =>
                        {
                            context.ReportProgress("Downloading cef binaries...", false, e.Current, e.Total);
                        };

                        downloader.Download().GetAwaiter().GetResult();
                    }

                    using (ZipArchive zip = ZipFile.OpenRead(zipFile))
                    {
                        zip.ExtractToDirectory(context.ApplicationManager.StartPath, true);
                    }
                }
                catch (Exception ex)
                {
                    LogManager.Log(ex, "Error installing cef binaries.");
                    throw;
                }
                finally
                {
                    zipFile.Delete();
                }

            });
        }
    }
}