Пример #1
0
        public static async Task <bool> RetryDownloadAndExtractTo(string packageName, string version, string tmpName, string destDir, string archiveDir, string message, string archiveDir2 = null)
        {
            List <Installer> failedInstaller = new List <Installer>();

            for (var i = 0; i < 4; i++)
            {
                try
                {
                    var installer = new Installer(destDir, tmpName);
                    try
                    {
                        bool result = await Installer.DownloadAndExtractTo(installer, GetNupkgUrl(packageName, version, i), tmpName, destDir, archiveDir, message, archiveDir2);

                        if (result)
                        {
                            failedInstaller.ForEach(inst =>
                            {
                                try
                                {
                                    inst.Display.Close();
                                }
                                catch
                                {
                                    //ignored
                                }
                            });
                            return(result);
                        }
                        else
                        {
                            //Stored for closing window
                            failedInstaller.Add(installer);
                        }
                    }
                    catch
                    {
                        //Stored for closing window
                        failedInstaller.Add(installer);
                    }
                }
                catch
                {
                    // pass
                }
            }
            return(false);
        }
Пример #2
0
        public static async Task <bool> InstallCef(string cefPath, string archivePath = null)
        {
            var tempNuget = Path.Combine(Path.GetTempPath(), "OverlayPlugin-cefredist");

            Directory.CreateDirectory(cefPath);
            try
            {
                var result = await Installer.DownloadAndExtractTo(GetNupkgUrl("CefSharp.Common", "90.6.70"), "OverlayPluginCef.tmp2", cefPath, "CefSharp/x64/", "第1个,共3个", "lib/net452/");

                if (!result)
                {
                    throw new Exception("下载失败1");
                }

                result = await Installer.DownloadAndExtractTo(GetNupkgUrl("CefSharp.OffScreen", "90.6.70"), "OverlayPluginCef.tmp3", cefPath, "lib/net452/", "第2个,共3个");

                if (!result)
                {
                    throw new Exception("下载失败2");
                }

                result = await Installer.DownloadAndExtractTo(GetNupkgUrl("cef.redist.x64", "90.6.7"), "OverlayPluginCef.tmp1", cefPath, "CEF/", "第3个,共3个");

                if (!result)
                {
                    throw new Exception("下载失败3");
                }

                File.WriteAllText(Path.Combine(cefPath, "version.txt"), CEF_VERSION);
            }
            catch (Exception)
            {
                MessageBox.Show(
                    "安装悬浮窗浏览器组件失败,请尝试:\r\n1. 禁用 WebSocket 悬浮窗插件后重启 ACT\r\n2. 关闭360/腾讯电脑管家等安全软件\r\n3. 重启电脑\r\n如果还不能成功,请加群 163386335",
                    Resources.ErrorTitle,
                    MessageBoxButtons.OK,
                    MessageBoxIcon.Error
                    );

                return(false);
            }
            return(true);
        }