Exemple #1
0
        private async Task SetUpAsync()
        {
            string localFullName = $"{DownloadPath}setup.exe";
            Uri    uri           = new Uri("http://Public.mujiannan.me/1Math/setup.exe");

            Reportor.Report($"下载{uri.AbsolutePath}至{localFullName},请耐心等待...");
            await DownloadAsync(uri, localFullName);

            System.Diagnostics.Process.Start(localFullName);
        }
Exemple #2
0
 private void Initialize()
 {
     if (_target == null)
     {
         throw new Exception("PleaseGiveMeAnExcelRange");
     }
     if (_target.Areas.Count > 1)
     {
         throw new Exception("DiscontinuousExcelRange");
     }
     _application = _target.Application;
     Reportor     = new Reportor(this);
 }
Exemple #3
0
 public Installer()
 {
     this.Reportor = new Reportor(this);
 }
Exemple #4
0
        private async Task DownloadAsync(Uri uri, string localFullName)
        {
            HttpClientHandler httpClientHandler = new HttpClientHandler();

            ProgressMessageHandler progressMessageHandler = new ProgressMessageHandler(httpClientHandler);
            HttpClient             httpClient             = new HttpClient(progressMessageHandler);

            progressMessageHandler.HttpReceiveProgress += (object sender, HttpProgressEventArgs e) => Reportor.Report(e.ProgressPercentage);//捕获下载进度,向外汇报
            FileStream fileStream = File.Create(localFullName, 1024, FileOptions.Asynchronous);

            byte[] bytes = await httpClient.GetByteArrayAsync(uri);

            fileStream.Write(bytes, 0, bytes.Length);
            fileStream.Flush();
            fileStream.Close();
        }