Esempio 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.LogError(ex, ex.Message);
                var onErrorTempFile = ShowErrorPage(ex);
                tempFiles.Add(onErrorTempFile);
                Environment.Exit(0);
            }

            return(tempFiles);
        }
Esempio 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.Restart();
                loader.DecompressArchive();
                Logger.Instance.Log.LogInformation($"CefLoader: Decompressing archive took {watch.ElapsedMilliseconds}ms");
                watch.Restart();
                loader.CopyFilesToAppDirectory();
                Logger.Instance.Log.LogInformation($"CefLoader: Copying files took {watch.ElapsedMilliseconds}ms");
            }
            catch (Exception ex)
            {
                Logger.Instance.Log.LogError("CefLoader: " + 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);
                }
            }
        }
Esempio 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.LogInformation($"Running {platform} chromium {version}");

                try
                {
                    CefRuntime.Load();
                }
                catch (Exception ex)
                {
                    Logger.Instance.Log.LogError(ex, ex.Message);
                    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.LogError(ex, ex.Message);
                Environment.Exit(0);
            }

            return(null);
        }
 public void Download(IChromelyConfiguration config)
 {
     CefLoader.Download(config.Platform);
 }