using API; using Microsoft.Extensions.DependencyInjection; using Microsoft.Extensions.Hosting; using Serilog; using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.Linq; using System.Text; using System.Threading.Tasks; using System.Windows.Forms; using Volo.Abp; using Volo.Abp.DependencyInjection; namespace WinFormsApp { public partial class Form1 : Form,ITransientDependency { //private readonly IHost _host; //private readonly IAbpApplicationWithExternalServiceProvider _application; //private IBackgroundJobManagerApplication _service; private IBackgroundJobManagerApplication _service; public Form1(IBackgroundJobManagerApplication service) { //_host = CreateHostBuilder(); //_service = _host.Services.GetService(); _service= service; InitializeComponent(); } private IHost CreateHostBuilder() { return Host .CreateDefaultBuilder(null) .UseAutofac() .UseSerilog() .ConfigureServices((hostContext, services) => { services.AddApplication(); }).Build(); } private void button1_Click(object sender, EventArgs e) { ToDo(); } private async void ToDo() { try { List dtos = new List(); RequestDto dto = new RequestDto(); dto.SheetCode = "TO_CWC14"; dto.SheetName = "TO_CWC14"; dto.Year = 2020; dto.Month = 1; dtos.Add(dto); // var aa = await _service.AddBackgroundJob(dtos); var str = _service.SayHello(); } catch (Exception ex ) { throw; } } } }