示例#1
0
        /// <inheritdoc />
        public override string GetPrettyString()
        {
            var selectList = ConfigPage.GetViewById(LogTypeSelectListId) as SelectListView;
            var message    = ConfigPage?.GetViewById(LogMessageInputId)?.GetStringValue() ?? "Error retrieving log message";

            return($"write the message \"{message}\" to the log with the type of {selectList?.GetSelectedOption() ?? "Unknown Selection"}");
        }
示例#2
0
        /// <inheritdoc />
        /// <remarks>
        /// This action type is only fully configured once a message is specified in the input view
        /// </remarks>
        public override bool IsFullyConfigured()
        {
            switch (ConfigPage.ViewCount)
            {
            case 3:
                var inputView = ConfigPage.GetViewById(LogMessageInputId) as InputView;
                return((inputView?.Value?.Length ?? 0) > 0);

            default:
                return(false);
            }
        }
示例#3
0
 /// <summary>
 /// Get the currently selected required option count
 /// </summary>
 /// <returns>The number of options that must be selected</returns>
 private int GetSelectedOptionCount()
 {
     try {
         var optionCountSl = ConfigPage?.GetViewById(OptionCountSlId) as SelectListView;
         return(optionCountSl?.Selection ?? -1);
     }
     catch (Exception exception) {
         if (LogDebug)
         {
             Console.WriteLine(exception);
         }
         return(-1);
     }
 }
示例#4
0
        /// <inheritdoc />
        public override string GetPrettyString()
        {
            switch (SelectedSubTriggerIndex)
            {
            case 0:
                try {
                    var optionCountSl = ConfigPage?.GetViewById(OptionCountSlId) as SelectListView;
                    return($"the button on the Sample Plugin Trigger Feature page is clicked and {(optionCountSl?.GetSelectedOption() ?? "???")} options are checked");
                }
                catch (Exception exception) {
                    if (LogDebug)
                    {
                        Console.WriteLine(exception);
                    }
                    return("the button on the Sample Plugin Trigger Feature page is clicked and ??? options are checked");
                }

            case 1:
                try {
                    var optionNumSl = ConfigPage?.GetViewById(OptionNumSlId) as SelectListView;
                    return($"the button on the Sample Plugin Trigger Feature page is clicked and option number {(optionNumSl?.GetSelectedOption() ?? "???")} is checked");
                }
                catch (Exception exception) {
                    if (LogDebug)
                    {
                        Console.WriteLine(exception);
                    }
                    return("the button on the Sample Plugin Trigger Feature page is clicked and option number ??? is checked");
                }

            case 2:
                return("the button the Sample Plugin Trigger Feature page is clicked and no options are checked");

            default:
                return("the button the Sample Plugin Trigger Feature page is clicked");
            }
        }
示例#5
0
        /// <inheritdoc />
        /// <remarks>
        /// This will call to HSPI through the <see cref="IWriteLogActionListener"/> interface to write a log message
        /// </remarks>
        public override bool OnRunAction()
        {
            var      iLogType = (ConfigPage?.GetViewById(LogTypeSelectListId) as SelectListView)?.Selection ?? 0;
            ELogType logType;

            switch (iLogType)
            {
            case 0:
                logType = ELogType.Trace;
                break;

            case 1:
                logType = ELogType.Debug;
                break;

            case 2:
                logType = ELogType.Info;
                break;

            case 3:
                logType = ELogType.Warning;
                break;

            case 4:
                logType = ELogType.Error;
                break;

            default:
                logType = ELogType.Info;
                break;
            }

            var message = ConfigPage?.GetViewById(LogMessageInputId)?.GetStringValue() ?? "Error retrieving log message";

            Listener?.WriteLog(logType, message);
            return(true);
        }
示例#6
0
        /// <inheritdoc />
        /// <remarks>
        /// This is where we validate data entry and update the <see cref="AbstractActionType.ConfigPage"/>
        ///  so that it represents the next state it should be in for configuration.
        /// </remarks>
        protected override bool OnConfigItemUpdate(AbstractView configViewChange)
        {
            if (configViewChange.Id != LogTypeSelectListId)
            {
                //When the ID being changed is not the log type select list, always save and continue.
                // No more configuration is needed
                return(true);
            }

            //Log Type selection change
            //Make sure the change is to a select list view
            if (!(configViewChange is SelectListView changedLogTypeSl))
            {
                return(false);
            }

            //Make sure the target select list view casts correctly
            if (!(ConfigPage.GetViewById(LogTypeSelectListId) is SelectListView currentLogTypeSl))
            {
                return(false);
            }

            if (currentLogTypeSl.Selection == changedLogTypeSl.Selection)
            {
                //If the selection didn't change then return false because the user may still need to supply a message
                return(false);
            }

            //Initialize the new state of the page so it asks for a message
            var newConfPage = InitConfigPageWithInput();

            ConfigPage = newConfPage.Page;

            //Save the change to the log type select list
            return(true);
        }