/// <summary> /// prompts user to select one of the pre-defined <see cref="OutputReportingProfile"/>s. /// </summary> /// <param name="commandArguments"></param> /// <returns> /// <seealso cref="Command.Execute(string[])"/> /// </returns> protected override bool Execute(string[] commandArguments) { bool commandExecutedSuccessfuly; // display menu allowing user to select desired reporting profile int userSelectedReportingProfileIndex = ConsoleIOManager.Instance.ShowMenuDialog( outputReportingProfileMenuDialog, ConsoleIOManager.eOutputReportType.CommandExecution); // menu indexing starts at 1, while profile indexing starts at 0 userSelectedReportingProfileIndex--; // get OutputReportingProfile user selected by index OutputReportingProfile userSelectedOutputReportingProfile = OutputReportingProfile.GetOutputReportingProfile(userSelectedReportingProfileIndex); try { // set user selected OutputReportingProfile in SettingManager ConfigurationManager.Instance.OutputReportingProfile = userSelectedOutputReportingProfile; // log success notice ConsoleIOManager.Instance.LogNoticeFormat( false, eOutputReportType.CommandExecution, "Reporting Profile '{0}' set successfully.", userSelectedOutputReportingProfile.Title); commandExecutedSuccessfuly = true; } catch (SettingsUpdateException settingsUpdateException) { // log failure notice ConsoleIOManager.Instance.LogError( "An exception occurred while trying to update Reporting Profile setting", eOutputReportType.CommandExecution); ExceptionManager.Instance.ConsoleLogReferToErrorLogFileMessage( eOutputReportType.CommandExecution); // log exception in error log file ExceptionManager.Instance.LogException(settingsUpdateException); commandExecutedSuccessfuly = false; } return(commandExecutedSuccessfuly); }
/// <summary> /// parses <see cref="SettingsContainer"/> from <paramref name="settingsContainerJsonObject"/>, /// which is expected to be a <see cref="JObject"/>. /// </summary> /// <param name="settingsContainerJsonObject"></param> /// <returns> /// <see cref="SettingsContainer"/> parsed from <paramref name="settingsContainerJsonObject"/> /// </returns> /// <exception cref="SettingsContainerJsonObjectParseException"> /// thrown if <see cref="SettingsContainer"/> parse failed /// </exception> internal static SettingsContainer Parse(dynamic settingsContainerJsonObject) { try { // get index of OutputReportingProfile int outputReportingProfileIndex = settingsContainerJsonObject.OutputReportingProfile.Index; // get OutputReportingProfile corresponding to index OutputReportingProfile outputReportingProfile = OutputReportingProfile.GetOutputReportingProfile(outputReportingProfileIndex); // init a new SettingsContainer return(new SettingsContainer(outputReportingProfile)); } catch (RuntimeBinderException runtimeBinderException) { throw new SettingsContainerJsonObjectParseException( settingsContainerJsonObject, runtimeBinderException); } }