Exemple #1
0
        private void SelectTargetDirAction(object obj)
        {
            FolderBrowserDialog folderDia = new FolderBrowserDialog();
            DialogResult        rst       = folderDia.ShowDialog();

            if (rst == DialogResult.Cancel)
            {
                return;
            }
            TargetDir = folderDia.SelectedPath;
            AppSettingUtils.Update(Key_TargetDir, TargetDir);
        }
Exemple #2
0
        private void SelectMngFileAction(object obj)
        {
            Microsoft.Win32.OpenFileDialog openFileDia = new Microsoft.Win32.OpenFileDialog();
            openFileDia.Filter = "Excel Files|*.xls;*.xlsx";
            var rst = openFileDia.ShowDialog();

            if (rst.HasValue && rst == true)
            {
                MngFile = openFileDia.FileName;
                AppSettingUtils.Update(Key_MngFile, MngFile);
            }
        }
Exemple #3
0
        private void SelectTempFileAction(object obj)
        {
            Microsoft.Win32.OpenFileDialog openFileDia = new Microsoft.Win32.OpenFileDialog();
            openFileDia.Filter = "Word Files|*.doc;*.docx";
            var rst = openFileDia.ShowDialog();

            if (rst.HasValue && rst == true)
            {
                TempFile = openFileDia.FileName;
                AppSettingUtils.Update(Key_TempFile, TempFile);
            }
        }
Exemple #4
0
        private async Task UnZipAndProcess()
        {
            Notify("开始解压升级包upgrade.zip...");
            ZipCompresser.Decompress(zipFile, tempPath);
            Notify("升级包upgrade.zip解压完毕");
            //1、获取更新配置文件
            var upgradeConf = tempPath + "/files.json";

            if (!File.Exists(upgradeConf))
            {
                Notify("未找到升级配置文件,升级包不完整!");
                return;
            }

            var confStr  = File.ReadAllText(upgradeConf);
            var confs    = JsonConvert.DeserializeObject <IList <UpgradeConf> >(confStr);
            var progress = 0;

            for (var idx = 0; idx < confs.Count; idx++)
            {
                var conf = confs[idx];
                var from = conf.path.Replace("~", tempPath);
                var to   = conf.path.Replace("~", ClientContext.TargetAppPath);
                _logger.LogInfo(string.Format("开始\t——\t{0}", conf.ToString()));
                if (conf.type == ItemType.file)
                {
                    HandleFile(from, to, conf);
                }
                else
                {
                    HandleFolder(to, conf);
                }
                progress          = Convert.ToInt32(((idx + 1) * 1.0 / confs.Count * 100));
                progressBar.Value = progress;
                Notify(string.Format("正在应用更新:{0},{1}", (progress + "/%"), conf.path), false);
                _logger.LogInfo(string.Format("结束\t——\t{0}", conf.ToString()));
            }
            Notify("更新完毕!将在5s后重新启动主程序。");
            //更新客户端版本信息
            _logger.LogInfo("修改主程序版本信息,最新版本:" + ClientContext.NewestVersion);
            AppSettingUtils.Update("version", ClientContext.NewestVersion);
            linkRetry.IsEnabled = true;
            _cntTimer.Start();
            SetSecondCount(5);
            await Task.Delay(5000);

            this.DialogResult = true;
            this.Close();
        }