コード例 #1
0
        private async void Button_Click(object sender, RoutedEventArgs e)
        {
            try
            {
                this.Logs.Text += $"{DateTime.Now.ToString() } 代码已经生成在 {Directory.GetCurrentDirectory()} \r\n";
                if (string.IsNullOrWhiteSpace(this.CompanyName.Text))
                {
                    this.Logs.Text += $"{DateTime.Now.ToString() } 请输入CompanyName....... \r\n";

                    return;
                }
                if (string.IsNullOrWhiteSpace(this.ProjectName.Text))
                {
                    this.Logs.Text += $"{DateTime.Now.ToString() } 请输入ProjectName....... \r\n";
                    return;
                }


                this.Logs.Text += $"{DateTime.Now.ToString() } 开始下载 {this.Source.Text}....... \r\n";
                var sourcePath = await _generateAppService.DownloadSourceAsync(this.Source.Text);

                this.Logs.Text += $"{DateTime.Now.ToString() } Abp-Vnext-Pro下载完成. \r\n";

                this.Logs.Text += $"{DateTime.Now.ToString() } 开始解压 {this.Source.Text}....... \r\n";
                var zipPath = _generateAppService.ExtractZips(sourcePath, this.CompanyName.Text.Trim(), this.ProjectName.Text.Trim());
                this.Logs.Text += $"{DateTime.Now.ToString() } 解压 {this.Source.Text} 完成. \r\n";

                this.Logs.Text += $"{DateTime.Now.ToString() } 开始生成 {this.Source.Text} 模板....... \r\n";
                _generateAppService.GenerateTemplate(zipPath, this.CompanyName.Text.Trim(), this.ProjectName.Text.Trim());
                this.Logs.Text += $"{DateTime.Now.ToString() } {this.Source.Text} 模板生成成功. \r\n";
                this.Logs.Text += $"{DateTime.Now.ToString() } 代码已经生成在 {Directory.GetCurrentDirectory()}\\code下 \r\n";

                Process.Start("explorer.exe", $"{Directory.GetCurrentDirectory()}\\code");
            }
            catch (Exception ex)
            {
                this.Logs.Text += ex.Message;
            }
        }