#pragma warning disable CS0628 // New protected member declared in sealed class
        protected override async Task InitializeAsync(CancellationToken cancellationToken, IProgress <ServiceProgressData> progress)
#pragma warning restore CS0628 // New protected member declared in sealed class
        {
            // When initialized asynchronously, the current thread may be a background thread at this point.
            // Do any initialization that requires the UI thread after switching to the UI thread.
            await this.JoinableTaskFactory.SwitchToMainThreadAsync(cancellationToken);

            try
            {
                await SharedRapidXamlPackage.InitializeAsync(cancellationToken, this);

                SharedRapidXamlPackage.Logger?.RecordNotice(StringRes.Info_LaunchVersionAnalysis.WithParams(CoreDetails.GetVersion()));
                SharedRapidXamlPackage.Logger?.RecordNotice(string.Empty);

                await FeedbackCommand.InitializeAsync(this, SharedRapidXamlPackage.Logger);

                await MoveAllHardCodedStringsToResourceFileCommand.InitializeAsync(this, SharedRapidXamlPackage.Logger);

                await this.SetUpRunningDocumentTableEventsAsync(cancellationToken);

                RapidXamlDocumentCache.Initialize(this, SharedRapidXamlPackage.Logger);

                Microsoft.VisualStudio.Shell.Events.SolutionEvents.OnAfterCloseSolution += this.HandleCloseSolution;
            }
            catch (Exception exc)
            {
                SharedRapidXamlPackage.Logger?.RecordException(exc);
            }
        }
示例#2
0
        public async Task <IActionResult> Feedback([FromBody] FeedbackRequest feedback)
        {
            var request = new FeedbackCommand(User.GetCustomerId(), feedback.FeedbackOrigin, feedback.CustomerFeedback, feedback.SuggestedLimit);

            var response = await _mediator.Send(request);

            if (response.IsFailure)
            {
                return(BadRequest(response));
            }

            return(Ok(response));
        }
示例#3
0
        public async Task <IActionResult> Post([FromBody] FeedbackCommand command)
        {
            try
            {
                var user = await _userManager.FindByNameAsync(User.Identity.Name);

                var receiver = (await _userInfo.GetUserProfileById(command.ReceiverId)).User;

                await _repository.AddAsync(new Feedback
                {
                    CreatorId    = user.Id,
                    ReceiverId   = receiver.Id,
                    Description  = command.Description,
                    ProposalId   = command.ProposalId,
                    CreationDate = DateTime.Now
                });

                if (command.Achievement != null)
                {
                    var achievement = _achievements.GetAll().Where(x => x.User.UserInfoId == command.ReceiverId && x.Code == command.Achievement).FirstOrDefault();

                    if (achievement == null)
                    {
                        await _achievements.AddAsync(new Achievement
                        {
                            Points = 1,
                            Code   = command.Achievement.GetValueOrDefault(),
                            UserId = receiver.Id
                        });
                    }
                    else
                    {
                        achievement.Points++;
                    }
                }

                await _unitOfWork.Commit();

                return(Ok());
            }
            catch (Exception ex)
            {
                return(BadRequest(ex.Message));
            }
        }
#pragma warning disable CS0628 // New protected member declared in sealed class
        protected override async Task InitializeAsync(CancellationToken cancellationToken, IProgress <ServiceProgressData> progress)
#pragma warning restore CS0628 // New protected member declared in sealed class
        {
            // When initialized asynchronously, the current thread may be a background thread at this point.
            // Do any initialization that requires the UI thread after switching to the UI thread.
            await this.JoinableTaskFactory.SwitchToMainThreadAsync(cancellationToken);

            try
            {
                await SharedRapidXamlPackage.InitializeAsync(cancellationToken, this);

                SharedRapidXamlPackage.Logger?.RecordNotice(StringRes.Info_LaunchVersionAnalysis.WithParams(CoreDetails.GetVersion()));
                SharedRapidXamlPackage.Logger?.RecordNotice(string.Empty);

                await FeedbackCommand.InitializeAsync(this, SharedRapidXamlPackage.Logger);

                await MoveAllHardCodedStringsToResourceFileCommand.InitializeAsync(this, SharedRapidXamlPackage.Logger);

                await AnalyzeCurrentDocumentCommand.InitializeAsync(this, SharedRapidXamlPackage.Logger);

                await OpenAnalysisOptionsCommand.InitializeAsync(this, SharedRapidXamlPackage.Logger);

                await this.SetUpRunningDocumentTableEventsAsync(cancellationToken);

                RapidXamlDocumentCache.Initialize(this, SharedRapidXamlPackage.Logger);

                Microsoft.VisualStudio.Shell.Events.SolutionEvents.OnAfterCloseSolution += this.HandleCloseSolution;

                // Handle the ability to resolve assemblies when loading custom analyzers.
                // Hat-tip: https://weblog.west-wind.com/posts/2016/dec/12/loading-net-assemblies-out-of-seperate-folders
                AppDomain.CurrentDomain.AssemblyResolve += (object sender, ResolveEventArgs args) =>
                {
                    // Ignore missing resources
                    if (args.Name.Contains(".resources"))
                    {
                        return(null);
                    }

                    if (args.RequestingAssembly == null)
                    {
                        return(null);
                    }

                    // check for assemblies already loaded
                    var assembly = AppDomain.CurrentDomain.GetAssemblies().FirstOrDefault(a => a.FullName == args.Name);
                    if (assembly != null)
                    {
                        return(assembly);
                    }

                    // Try to load by filename - split out the filename of the full assembly name
                    // and append the base path of the original assembly (ie. look in the same dir)
                    string filename = args.Name.Split(',')[0] + ".dll".ToLower();

                    var asmFile = Path.Combine(Path.GetDirectoryName(args.RequestingAssembly.CodeBase), filename);

                    if (asmFile.StartsWith("file:\\"))
                    {
                        asmFile = asmFile.Substring(6);
                    }

                    try
                    {
                        return(Assembly.LoadFrom(asmFile));
                    }
                    catch (Exception ex)
                    {
                        System.Diagnostics.Debug.WriteLine(ex);
                        return(null);
                    }
                };

                // Track this so don't try and load CustomAnalyzers while VS is still starting up.
                RapidXamlAnalysisPackage.IsLoaded = true;

                RapidXamlAnalysisPackage.Options = (AnalysisOptionsGrid)this.GetDialogPage(typeof(AnalysisOptionsGrid));

                var ass = Assembly.GetExecutingAssembly().GetName();

                SharedRapidXamlPackage.Logger?.RecordFeatureUsage(StringRes.Info_PackageLoad.WithParams(ass.Name, ass.Version), quiet: true);
            }
            catch (Exception exc)
            {
                SharedRapidXamlPackage.Logger?.RecordException(exc);
            }
        }
示例#5
0
        protected override void OnPreLoad(EventArgs e)
        {
            base.OnPreLoad(e);

            // Menu Commands
            _connect    = ToolboxApp.Services.Get <ConnectCommand>();
            _disconnect = ToolboxApp.Services.Get <DisconnectCommand>();

            var log      = ToolboxApp.Services.Get <ShowLogViewerCommand>();
            var quit     = ToolboxApp.Services.Get <QuitCommand>();
            var settings = ToolboxApp.Services.Get <SettingsCommand>();
            var onTop    = ToolboxApp.Services.Get <ToggleStayOnTopCommand>();

            _newPage = ToolboxApp.Services.Get <NewPageCommand>();
            _save    = ToolboxApp.Services.Get <SaveXamlCommand>();

            var feedback     = new FeedbackCommand();
            var update       = new UpdateCommand();
            var releaseNotes = new ReleaseNotesCommand();
            var lpac         = new LoadProjectAssembliesCommand();
            var newType      = new RegisterNewTypeCommand();
            var newView      = new RegisterNewViewCommand();

            // Styling
            _save.Enabled    = false;
            _newPage.Enabled = false;

            Title       = AppResource.Title_disconnected;
            Padding     = new Padding(5);
            Maximizable = false;
            Resizable   = true;
            Icon        = AppImages.Xf;
            ClientSize  = new Size(FormWidth, FormHeight);
            Location    = GetFormLocation();

            // Menubar
            Menu = new MenuBar
            {
                Items =
                {
                    // File
                    new ButtonMenuItem
                    {
                        Text  = AppResource.File_menu_label,
                        Items =
                        {
                            _connect,
                            _disconnect,
                            new SeparatorMenuItem(),
                            _newPage,
                            new SeparatorMenuItem(),
                            _save
                        }
                    },

                    new ButtonMenuItem
                    {
                        Text  = "&Edit",
                        Items =
                        {
                            new ButtonMenuItem {
                                Text = "&Undo", Enabled = false
                            },
                            new ButtonMenuItem {
                                Text = "&Redo", Enabled = false
                            },
                            new SeparatorMenuItem(),
                            new ButtonMenuItem {
                                Text = "&Cut", Enabled = false
                            },
                            new ButtonMenuItem {
                                Text = "&Copy", Enabled = false
                            },
                            new ButtonMenuItem {
                                Text = "&Paste", Enabled = false
                            },
                        }
                    },

                    // Tools
                    new ButtonMenuItem
                    {
                        Text  = AppResource.Tools_menu_label,
                        Items =
                        {
                            newView,
                            newType,
                            lpac,
                            new SeparatorMenuItem(),
                            settings
                        }
                    },

                    // Plugins
                    // This item will be replaced on connect & disconnect from a design server
                    new ButtonMenuItem
                    {
                        Text    = AppResource.Plugins_menu_label,
                        Enabled = false
                    },

                    // Window
                    new ButtonMenuItem
                    {
                        Text  = AppResource.Window_menu_label,
                        Items =
                        {
                            onTop,
                            new SeparatorMenuItem(),
                            new ResetViewCommand()
                        }
                    }
                },

                // Help
                HelpItems =
                {
                    feedback,
                    releaseNotes,
                    log,
                    new SeparatorMenuItem(),
                    update
                },

                QuitItem  = quit,
                AboutItem = new AboutCommand(),
            };

            ToolBar = new ToolBar
            {
                Items =
                {
                    _connect,
                    _newPage,
                    _save,
                    settings,
                    new SeparatorToolItem(),
                    onTop,
                    feedback,
                }
            };

            Application.Instance.Terminating += (s, _) => ToolboxApp.IsTerminating = true;
        }