Esempio n. 1
0
        private async Task <PackageSessionResult> SetupResultProgress(IViewUpdater viewUpdater, LoggingScope scope)
        {
            EditorViewModel.LoadingStatus = new LoadingStatus(LoadingStatus.LoadingMode.Indeterminate);
            await viewUpdater.UpdateView();

            // in this result will be any errors from loading the project
            var sessionResult = new PackageSessionResult();

            sessionResult.MessageLogged   += (_, e) => scope.Log(e.Message);
            sessionResult.ProgressChanged += async(_, e) =>
            {
                if (e.HasKnownSteps && e.CurrentStep > 0)
                {
                    var percentage    = EditorViewModel.LoadingStatus.PercentCompleted;
                    var newPercentage = 100 * e.CurrentStep / e.StepCount;
                    EditorViewModel.LoadingStatus.Mode             = LoadingStatus.LoadingMode.Percentage;
                    EditorViewModel.LoadingStatus.PercentCompleted = newPercentage;
                }
                else
                {
                    EditorViewModel.LoadingStatus.Mode = LoadingStatus.LoadingMode.Indeterminate;
                }
                EditorViewModel.LoadingStatus.Message = e.Message;

                await viewUpdater.UpdateView();
            };
            return(sessionResult);
        }
        /// <summary>
        /// Invokes the specified environment.
        /// </summary>
        /// <param name="context">The context.</param>
        /// <returns></returns>
        public override async Task Invoke(IOwinContext context)
        {
            var method    = context.Request.Method;
            var path      = context.Request.Path;
            var scopeName = $"{path} [{method}]";

            using (var scope = new LoggingScope(scopeName))
            {
                await Next.Invoke(context);

                scope.Log("Status Code: {0}", context.Response.StatusCode);
            }
        }