Esempio n. 1
0
        /// <summary>
        /// 设置成功。
        /// </summary>
        /// <param name="status">状态。</param>
        /// <returns>返回保存结果。</returns>
        public async Task <bool> SuccessAsync(InstallerStatus status)
        {
            var registration = await GetRegistrationAsync();

            registration.Status = status;
            return(await SaveRegistrationAsync(registration));
        }
Esempio n. 2
0
 private void Worker_RunWorkerCompleted(object sender, RunWorkerCompletedEventArgs e)
 {
     WriteToFile();
     mainButton.Text      = "Close";
     mainButton.ForeColor = SystemColors.ControlText;
     Status = InstallerStatus.Completed;
 }
Esempio n. 3
0
 public InstallerForm(IProcessOutput process, string workingPath)
 {
     InitializeComponent();
     _process     = process;
     _workingPath = workingPath;
     Status       = InstallerStatus.Processing;
     Text         = $"{_process.Label} Log";
 }
Esempio n. 4
0
        /// <summary>
        /// Executes the process.
        /// </summary>
        public void Execute()
        {
            BackgroundWorker worker = new BackgroundWorker();

            worker.RunWorkerCompleted += Worker_RunWorkerCompleted;
            worker.DoWork             += Worker_DoWork;
            worker.RunWorkerAsync();
            Status = InstallerStatus.Processing;
        }
Esempio n. 5
0
        public StateDescription(WuStateId stateId, string displayName, string description, InstallerStatus installerStatus, WuEnviroment enviroment, ProgressDescription progress = null)
        {
            if (String.IsNullOrWhiteSpace(displayName))
            {
                throw new ArgumentException("Null or white space not allowed.", nameof(displayName));
            }

            Progress        = progress;
            StateId         = stateId;
            DisplayName     = displayName;
            Description     = description;
            InstallerStatus = installerStatus;
            Enviroment      = enviroment;
        }
Esempio n. 6
0
 private void mainButton_Click(object sender, EventArgs e)
 {
     if (_process != null && _process.Processing)
     {
         _process.OnMessageUpdate -= Installer_OnMessageUpdate;
         _process.Cancel();
         UpdateDisplay(Environment.NewLine);
         UpdateDisplay("Installer Build Cancelled!");
         Status = InstallerStatus.Canceled;
     }
     else
     {
         Close();
     }
 }
        /// <summary>
        /// 执行的后台任务方法。
        /// </summary>
        /// <param name="cancellationToken">取消标识。</param>
        /// <returns>返回任务实例。</returns>
        protected override async Task ExecuteAsync(CancellationToken cancellationToken)
        {
            //数据库迁移
            _logger.LogInformation("数据库迁移开始...");
            await _serviceProvider.GetRequiredService <IDataMigrator>().MigrateAsync();

            _logger.LogInformation("数据库迁移完成。");

            //启动网站
            _logger.LogInformation("启动网站...");
            var registration = await _installerManager.GetRegistrationAsync();

            if (registration.Expired < DateTimeOffset.Now)
            {
                registration.Status = InstallerStatus.Expired;
            }

            if (registration.Status == InstallerStatus.Initializing)
            {
                try
                {
                    using (var scope = _serviceProvider.GetRequiredService <IServiceScopeFactory>().CreateScope())
                        registration.Status = await scope.ServiceProvider.GetRequiredService <IInstaller>().ExecuteAsync();
                }
                catch (Exception exception)
                {
                    _logger.LogError(exception, "网站初始化失败!");
                }
            }
            await _installerManager.SaveRegistrationAsync(registration);

            Current = registration.Status;
            if (Current == InstallerStatus.Failured)
            {
                _logger.LogInformation("启动网站失败。");
            }
            else
            {
                _logger.LogInformation("启动网站完成。");
            }
        }
Esempio n. 8
0
 private void Worker_RunWorkerCompleted(object sender, RunWorkerCompletedEventArgs e)
 {
     WriteToFile();
     Status = InstallerStatus.Completed;
 }