Verifier Plugin: how to add suggestions to verification message (Sdl.Verification.Sdk.EditAndApplyChanges)

Hi,

I need to add a sveral suggestions to custom verification message. I'm using code and form from SDK sample Sdl.Verification.Sdk.EditAndApplyChanges.MessageUI plugin to display it.

I'm not sure how to construct extended data for message reporter.

I try doing it as below:

 #region ReportingMessage
                if (MessageReporter is IBilingualContentMessageReporterWithExtendedData)
                        {
                    #region CreateExtendedData
                    CustomMessageData extendedData = new CustomMessageData("MessageType", "Detailed description");
                    extendedData.SuggestedChanges.Add(new KeyValuePair<string, string>("Markup","Label"));
                    extendedData.SuggestedChanges.Add(new KeyValuePair<string, string>("Markup2","Label2"));
                    extendedData.SuggestedChanges.Add(new KeyValuePair<string, string>("Markup3","Label3"));
                    #endregion
                    #region ReportingMessageWithExtendedData
                    IBilingualContentMessageReporterWithExtendedData extendedMessageReporter = (IBilingualContentMessageReporterWithExtendedData)MessageReporter;
                            extendedMessageReporter.ReportMessage(this, PluginResources.Plugin_Name,
                                ErrorLevel.Warning, PluginResources.Error_LT,
                                new TextLocation(new Location(segmentPair.Target, true), 0),
                                new TextLocation(new Location(segmentPair.Target, false), segmentPair.Target.ToString().Length - 1),
                                extendedData);
                            #endregion
                        }
                        else
                        {
                            #region ReportingMessageWithoutExtendedData
                            MessageReporter.ReportMessage(this, PluginResources.Plugin_Name,
                                ErrorLevel.Warning, PluginResources.Error_LT,
                                new TextLocation(new Location(segmentPair.Target, true), 0),
                                new TextLocation(new Location(segmentPair.Target, false), segmentPair.Target.ToString().Length - 1));
                            #endregion
                        }
           

Results are partially okay. Added suggestions are in list. Suggestions have correct markup values assigned and I can replace target text, but suggestions have wrong labels in list.

 

What do I wrong? How should I construct extendedData for MessageReporter?

DArek 

Parents
  • I checked again SDK sample pluging Sdl.Verification.Sdk.EditAndApplyChanges.MessageUI and I add line in CustomMessageControl.cs.

    I'm not sure it is best place to set DisplayMember property but it works.

    DArek

     

     /// <summary>
            /// Reads the suggestions from ExtendedMessageEventData
            /// </summary>
            /// <param name="messageEventArgs"></param>
            private void UpdateSuggestions(MessageEventArgs messageEventArgs)
            {
                CustomMessageData messageData = messageEventArgs.ExtendedData as CustomMessageData;
                foreach (var item in messageData.SuggestedChanges)
                {
                    Suggestion suggestion = new Suggestion(messageEventArgs.FromLocation, messageEventArgs.UptoLocation,
                        CreateSuggestionMarkup(item.Key));
                   
                    _suggestionsList.Items.Add(suggestion);
                }
                if (_suggestionsList.Items.Count > 0)
                {
                    _suggestionsList.SelectedIndex = 0;
                }
                _suggestionsList.DisplayMember = "SuggestionMarkup";
            }

     

     

Reply
  • I checked again SDK sample pluging Sdl.Verification.Sdk.EditAndApplyChanges.MessageUI and I add line in CustomMessageControl.cs.

    I'm not sure it is best place to set DisplayMember property but it works.

    DArek

     

     /// <summary>
            /// Reads the suggestions from ExtendedMessageEventData
            /// </summary>
            /// <param name="messageEventArgs"></param>
            private void UpdateSuggestions(MessageEventArgs messageEventArgs)
            {
                CustomMessageData messageData = messageEventArgs.ExtendedData as CustomMessageData;
                foreach (var item in messageData.SuggestedChanges)
                {
                    Suggestion suggestion = new Suggestion(messageEventArgs.FromLocation, messageEventArgs.UptoLocation,
                        CreateSuggestionMarkup(item.Key));
                   
                    _suggestionsList.Items.Add(suggestion);
                }
                if (_suggestionsList.Items.Count > 0)
                {
                    _suggestionsList.SelectedIndex = 0;
                }
                _suggestionsList.DisplayMember = "SuggestionMarkup";
            }

     

     

Children
No Data