Ejemplo n.º 1
0
        public bool UnzipPackage()
        {
            var path     = GetLocalFolderPath();
            var filename = GetLocalFilename();

            if (string.IsNullOrEmpty(path) || string.IsNullOrEmpty(filename))
            {
                return(false);
            }

            lock (waitForDigest)
            {
                if (!string.IsNullOrEmpty(_sha256sum) &&
                    Misc.Utils.GetSha256SumFromFile(filename) != _sha256sum)
                {
                    setting.SendLog(I18N.FileCheckSumFail);
                    return(false);
                }
            }

            VgcApis.Misc.Utils.Sleep(2000);
            try
            {
                Misc.Utils.ZipFileDecompress(filename, path);
            }
            catch
            {
                setting.SendLog(I18N.DecompressFileFail);
                return(false);
            }
            return(true);
        }
Ejemplo n.º 2
0
        public bool UnzipPackage()
        {
            var path     = GetLocalFolderPath();
            var filename = GetLocalFilename();

            if (string.IsNullOrEmpty(path) || string.IsNullOrEmpty(filename))
            {
                setting.SendLog(I18N.LocateTargetFolderFail);
                return(false);
            }

            lock (waitForDigest)
            {
                if (!string.IsNullOrEmpty(_sha256sum) &&
                    Misc.Utils.GetSha256SumFromFile(filename) != _sha256sum)
                {
                    setting.SendLog(I18N.FileCheckSumFail);
                    return(false);
                }
            }

            VgcApis.Misc.Utils.Sleep(1000);
            try
            {
                RemoveOldExe(path);
                Misc.Utils.ZipFileDecompress(filename, path);
            }
            catch (Exception ex)
            {
                setting.SendLog(I18N.DecompressFileFail + Environment.NewLine + ex.ToString());
                return(false);
            }
            return(true);
        }
Ejemplo n.º 3
0
 public void Log(string message)
 {
     qLogger.Log(message);
     try
     {
         setting.SendLog($"[{coreInfo.GetName()}] {message}");
     }
     catch { }
 }
Ejemplo n.º 4
0
 public void Log(string message)
 {
     try
     {
         setting.SendLog($"[{coreInfo.GetIndex()}.{coreInfo.GetShortName()}] {message}");
         OnLog?.Invoke(this, message);
     }
     catch { }
 }
Ejemplo n.º 5
0
        private void InitCtrlBatchOperation(
            ToolStripMenuItem stopSelected,
            ToolStripMenuItem restartSelected,

            ToolStripMenuItem runBatchSpeedtest,
            ToolStripMenuItem stopBatchSpeedtest,
            ToolStripMenuItem clearSpeedtestResults,

            ToolStripMenuItem modifySelected)
        {
            clearSpeedtestResults.Click += RunWhenSelectionIsNotEmptyHandler(() =>
            {
                if (Misc.UI.Confirm(I18N.ConfirmClearSpeedTestResults))
                {
                    ClearSelectedServersSpeedTestResults();
                }
            });

            modifySelected.Click += RunWhenSelectionIsNotEmptyHandler(
                () => Views.WinForms.FormBatchModifyServerSetting.GetForm());

            runBatchSpeedtest.Click += RunWhenSelectionIsNotEmptyHandler(() =>
            {
                if (!Misc.UI.Confirm(I18N.TestWillTakeALongTime))
                {
                    return;
                }

                servers.RunSpeedTestOnSelectedServersBg();
            });

            stopBatchSpeedtest.Click += (s, a) =>
            {
                settings.SendLog(I18N.StoppingSpeedtest);
                settings.isSpeedtestCancelled = true;
            };

            stopSelected.Click += RunWhenSelectionIsNotEmptyHandler(() =>
            {
                if (Misc.UI.Confirm(I18N.ConfirmStopAllSelectedServers))
                {
                    servers.StopSelectedServersThen();
                }
            });

            restartSelected.Click += RunWhenSelectionIsNotEmptyHandler(() =>
            {
                if (Misc.UI.Confirm(I18N.ConfirmRestartAllSelectedServers))
                {
                    servers.RestartSelectedServersThen();
                }
            });
        }
Ejemplo n.º 6
0
        private void LogDownloadFails(IEnumerable <string> links)
        {
            var downloadFailUrls = links.ToList();

            if (downloadFailUrls.Count() <= 0)
            {
                return;
            }

            downloadFailUrls.Insert(0, "");
            setting.SendLog(string.Join(
                                Environment.NewLine + I18N.DownloadFail + @" ",
                                downloadFailUrls));
        }
Ejemplo n.º 7
0
        public bool UnzipPackage()
        {
            var path     = GetLocalFolderPath();
            var filename = GetLocalFilename();

            if (string.IsNullOrEmpty(path) || string.IsNullOrEmpty(filename))
            {
                setting.SendLog(I18N.LocateTargetFolderFail);
                return(false);
            }

            VgcApis.Misc.Utils.Sleep(1000);
            try
            {
                RemoveOldExe(path);
                Misc.Utils.ZipFileDecompress(filename, path);
            }
            catch (Exception ex)
            {
                setting.SendLog(I18N.DecompressFileFail + Environment.NewLine + ex.ToString());
                return(false);
            }
            return(true);
        }
Ejemplo n.º 8
0
 Tuple <string, string, int> GetInboundInfoFromCustomInboundsSetting()
 {
     try
     {
         var    jobj     = JArray.Parse(setting.CustomDefInbounds)[0];
         var    protocol = Misc.Utils.GetValue <string>(jobj, "protocol");
         string ip       = Misc.Utils.GetValue <string>(jobj, "listen");
         int    port     = Misc.Utils.GetValue <int>(jobj, "port");
         return(new Tuple <string, string, int>(protocol, ip, port));
     }
     catch
     {
         setting.SendLog(I18N.ParseCustomInboundsSettingFail);
     }
     return(null);
 }
Ejemplo n.º 9
0
        private void lbScanQRCode_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e)
        {
            void Success(string text)
            {
                var msg = VgcApis.Misc.Utils.AutoEllipsis(text, VgcApis.Models.Consts.AutoEllipsis.QrcodeTextMaxLength);

                setting.SendLog($"QRCode: {msg}");
                slinkMgr.ImportLinkWithOutV2cfgLinks(text);
            }

            void Fail()
            {
                MessageBox.Show(I18N.NoQRCode);
            }

            Libs.QRCode.QRCode.ScanQRCode(Success, Fail);
        }
Ejemplo n.º 10
0
        private void lbScanQRCode_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e)
        {
            void Success(string text)
            {
                var msg = Misc.Utils.CutStr(text, 90);

                setting.SendLog($"QRCode: {msg}");
                slinkMgr.ImportLinkWithOutV2cfgLinks(text);
            }

            void Fail()
            {
                MessageBox.Show(I18N.NoQRCode);
            }

            Libs.QRCode.QRCode.ScanQRCode(Success, Fail);
        }