示例#1
0
        private void localsCommandButton_OnClick(object sender, EventArgs e)
        {
            updateLocalsCommandStatusText(string.Format(Resources.ShowMessage_LocalsCommandWorking), visibility: true);
            var arguments = new List <string> {
                "all"
            };
            var settings       = ServiceLocator.GetInstance <ISettings>();
            var logError       = new LocalsArgs.Log(LogError);
            var logInformation = new LocalsArgs.Log(LogInformation);
            var localsArgs     = new LocalsArgs(arguments, settings, logInformation, logError, clear: true, list: false);

            _outputConsoleLogger.Start();
            try
            {
                _localsCommandRunner.ExecuteCommand(localsArgs);
                updateLocalsCommandStatusText(string.Format(Resources.ShowMessage_LocalsCommandSuccess, DateTime.Now.ToString(Resources.Culture)), visibility: true);
            }
            catch (Exception ex)
            {
                updateLocalsCommandStatusText(string.Format(Resources.ShowMessage_LocalsCommandFailure, DateTime.Now.ToString(Resources.Culture), ex.Message), visibility: true);
                LogError(string.Format(Resources.ShowMessage_LocalsCommandFailure, DateTime.Now.ToString(Resources.Culture), ex.Message));
                ActivityLog.LogError(NuGetUI.LogEntrySource, ex.ToString());
            }
            finally
            {
                _outputConsoleLogger.End();
            }
        }
        private void OnLocalsCommandButtonOnClick(object sender, EventArgs e)
        {
            ThreadHelper.ThrowIfNotOnUIThread();
            UpdateLocalsCommandStatusText(string.Format(CultureInfo.CurrentCulture, Resources.ShowMessage_LocalsCommandWorking), visibility: true);

            NuGetUIThreadHelper.JoinableTaskFactory.RunAsync(async() =>
            {
                try
                {
                    _outputConsoleLogger.Start();
                    await TaskScheduler.Default;
                    var arguments = new List <string> {
                        "all"
                    };
                    var settings       = await ServiceLocator.GetComponentModelServiceAsync <ISettings>();
                    var logError       = new LocalsArgs.Log(LogError);
                    var logInformation = new LocalsArgs.Log(LogInformation);
                    var localsArgs     = new LocalsArgs(arguments, settings, logInformation, logError, clear: true, list: false);
                    _localsCommandRunner.ExecuteCommand(localsArgs);
                    await UpdateLocalsCommandStatusTextAsync(string.Format(CultureInfo.CurrentCulture, Resources.ShowMessage_LocalsCommandSuccess, DateTime.Now.ToString(Resources.Culture)), visibility: true);
                }
                catch (Exception ex)
                {
                    await UpdateLocalsCommandStatusTextAsync(string.Format(CultureInfo.CurrentCulture, Resources.ShowMessage_LocalsCommandFailure, DateTime.Now.ToString(Resources.Culture), ex.Message), visibility: true);
                    LogError(string.Format(Resources.ShowMessage_LocalsCommandFailure, DateTime.Now.ToString(Resources.Culture), ex.Message));
                    ActivityLog.LogError(NuGetUI.LogEntrySource, ex.ToString());
                }
                finally
                {
                    _outputConsoleLogger.End();
                }
            }).PostOnFailure(nameof(GeneralOptionControl), nameof(OnLocalsCommandButtonOnClick));
        }
 internal void End()
 {
     _logger.End();
 }