Exemplo n.º 1
0
        /// <summary>
        /// The warn user on load.
        /// </summary>
        /// <returns>
        /// The list of temporary files generated
        /// </returns>
        private static List <string> DownloadAndNotifyUser(ChromelyPlatform platform)
        {
            var tempFiles = new List <string>();

            try
            {
                var stopwatch = new Stopwatch();
                stopwatch.Start();

                var startTempFile = ShowDownloadStartedPage();
                tempFiles.Add(startTempFile);

                CefLoader.Download(platform);

                stopwatch.Stop();
                var competedTempFile = ShowDownloadCompletedPage($"Time elapsed: {stopwatch.Elapsed}.");

                if (competedTempFile != null)
                {
                    tempFiles.Add(competedTempFile);
                }

                Thread.Sleep(TimeSpan.FromSeconds(2));
            }
            catch (Exception ex)
            {
                Logger.Instance.Log.Error(ex);
                var onErrorTempFile = ShowErrorPage(ex);
                tempFiles.Add(onErrorTempFile);
                Environment.Exit(0);
            }

            return(tempFiles);
        }
Exemplo n.º 2
0
    /// <summary>
    /// Download CEF runtime files.
    /// </summary>
    /// <exception cref="Exception"></exception>
    public static void Download(ChromelyPlatform platform)
    {
        Logger.Instance.Log.LogInformation("CefLoader: Installing CEF runtime from " + CefBuildsDownloadUrl);

        var loader = new CefLoader(platform);

        try
        {
            var watch = new Stopwatch();
            watch.Start();
            loader.GetDownloadUrl();
            if (!loader.ParallelDownload())
            {
                loader.Download();
            }
            Logger.Instance.Log.LogInformation("CefLoader: Download took {watch.ElapsedMilliseconds}ms", watch.ElapsedMilliseconds);
            watch.Restart();
            loader.DecompressArchive();
            Logger.Instance.Log.LogInformation("CefLoader: Decompressing archive took {watch.ElapsedMilliseconds}ms", watch.ElapsedMilliseconds);
            watch.Restart();
            loader.CopyFilesToAppDirectory();
            Logger.Instance.Log.LogInformation("CefLoader: Copying files took {watch.ElapsedMilliseconds}ms", watch.ElapsedMilliseconds);
        }
        catch (Exception ex)
        {
            Logger.Instance.Log.LogError("CefLoader: {ex.Message}", ex.Message);
            throw;
        }
        finally
        {
            if (!string.IsNullOrEmpty(loader._tempBz2File))
            {
                File.Delete(loader._tempBz2File);
            }

            if (!string.IsNullOrEmpty(loader._tempTarStream))
            {
                File.Delete(loader._tempTarStream);
            }

            if (!string.IsNullOrEmpty(loader._tempTarFile))
            {
                File.Delete(loader._tempTarFile);
            }
            if (!string.IsNullOrEmpty(loader._tempDirectory) && Directory.Exists(loader._tempDirectory))
            {
                Directory.Delete(loader._tempDirectory, true);
            }
        }
    }
Exemplo n.º 3
0
        /// <summary>Load Cef binaries</summary>
        /// <param name="config">The chromely configuration.</param>
        /// <returns>The list of temporary files generated</returns>
        public static List <string> Load(IChromelyConfiguration config)
        {
            try
            {
                var platform = CefRuntime.Platform;
                var version  = CefRuntime.ChromeVersion;
                Logger.Instance.Log.Info($"Running {platform} chromium {version}");

                try
                {
                    CefRuntime.Load();
                }
                catch (Exception ex)
                {
                    Logger.Instance.Log.Error(ex);
                    if (config.CefDownloadOptions.AutoDownloadWhenMissing)
                    {
                        if (config.CefDownloadOptions.DownloadSilently)
                        {
                            CefLoader.Download(config.Platform);
                            CefLoader.SetMacOSAppName(config);
                        }
                        else
                        {
                            var fileList = DownloadAndNotifyUser(config.Platform);
                            CefLoader.SetMacOSAppName(config);
                            return(fileList);
                        }
                    }
                    else
                    {
                        Environment.Exit(0);
                    }
                }
            }
            catch (Exception ex)
            {
                Logger.Instance.Log.Error(ex);
                Environment.Exit(0);
            }

            return(null);
        }
Exemplo n.º 4
0
        /// <summary>Load Cef binaries</summary>
        /// <param name="options">The config.</param>
        /// <param name="chromelyPlatform">The chromely platform.</param>
        /// <returns>The list of temporary files generated</returns>
        public static List <string> Load(ICefDownloadOptions options, ChromelyPlatform chromelyPlatform)
        {
            try
            {
                var platform = CefRuntime.Platform;
                var version  = CefRuntime.ChromeVersion;
                Logger.Instance.Log.Info($"Running {platform} chromium {version}");

                try
                {
                    CefRuntime.Load();
                }
                catch (Exception ex)
                {
                    Logger.Instance.Log.Error(ex);
                    if (options.AutoDownloadWhenMissing)
                    {
                        if (options.DownloadSilently)
                        {
                            CefLoader.Download(chromelyPlatform);
                        }
                        else
                        {
                            return(DownloadAndNotifyUser(chromelyPlatform));
                        }
                    }
                    else
                    {
                        Environment.Exit(0);
                    }
                }
            }
            catch (Exception ex)
            {
                Logger.Instance.Log.Error(ex);
                Environment.Exit(0);
            }

            return(null);
        }
 /// <inheritdoc/>
 public void Download(IChromelyConfiguration config)
 {
     CefLoader.Download(config.Platform);
 }