Ejemplo n.º 1
0
 protected string GetExtraUriParameters(SettingFilter filter)
 {
     if (filter != null && filter.Label != null)
     {
         return($"?label={filter.Label}");
     }
     return(string.Empty);
 }
Ejemplo n.º 2
0
        public VehicleSettingsDialog(
            ISkillConfiguration services,
            IStatePropertyAccessor <AutomotiveSkillState> accessor,
            IServiceManager serviceManager,
            IBotTelemetryClient telemetryClient,
            IHttpContextAccessor httpContext)
            : base(nameof(VehicleSettingsDialog), services, accessor, serviceManager, telemetryClient)
        {
            TelemetryClient = telemetryClient;

            // Initialise supporting LUIS models for followup questions
            vehicleSettingNameSelectionLuisRecognizer  = services.LocaleConfigurations["en"].LuisServices["settings_name"];
            vehicleSettingValueSelectionLuisRecognizer = services.LocaleConfigurations["en"].LuisServices["settings_value"];

            // JSON resource files provided metatadata as to the available car settings, names and the values that can be set
            var resDir = Path.Combine(
                Path.GetDirectoryName(typeof(VehicleSettingsDialog).Assembly.Location),
                "Dialogs\\VehicleSettings\\Resources\\");

            settingList   = new SettingList(resDir + "available_settings.json", resDir + "setting_alternative_names.json");
            settingFilter = new SettingFilter(settingList);

            // Setting Change waterfall
            var processVehicleSettingChangeWaterfall = new WaterfallStep[]
            {
                ProcessSetting,
                ProcessVehicleSettingsChange,
                ProcessChange,
                SendChange
            };

            AddDialog(new WaterfallDialog(Actions.ProcessVehicleSettingChange, processVehicleSettingChangeWaterfall)
            {
                TelemetryClient = telemetryClient
            });

            // Prompts
            AddDialog(new ChoicePrompt(Actions.SettingNameSelectionPrompt, SettingNameSelectionValidator, Culture.English)
            {
                Style = ListStyle.Inline, ChoiceOptions = new ChoiceFactoryOptions {
                    InlineSeparator = string.Empty, InlineOr = string.Empty, InlineOrMore = string.Empty, IncludeNumbers = true
                }
            });
            AddDialog(new ChoicePrompt(Actions.SettingValueSelectionPrompt, SettingValueSelectionValidator, Culture.English)
            {
                Style = ListStyle.Inline, ChoiceOptions = new ChoiceFactoryOptions {
                    InlineSeparator = string.Empty, InlineOr = string.Empty, InlineOrMore = string.Empty, IncludeNumbers = true
                }
            });

            AddDialog(new ConfirmPrompt(Actions.SettingConfirmationPrompt));

            // Set starting dialog for component
            InitialDialogId = Actions.ProcessVehicleSettingChange;

            // Used to resolve image paths (local or hosted)
            _httpContext = httpContext;
        }
Ejemplo n.º 3
0
 public GetMockTransport(string queryKey, SettingFilter filter, params HttpStatusCode[] statusCodes)
     : this(queryKey, filter, result : null)
 {
     Responses.Clear();
     foreach (var statusCode in statusCodes)
     {
         Responses.Add(statusCode);
     }
 }
Ejemplo n.º 4
0
        public override void Initialize()
        {
            base.Initialize();

            var resDir = Path.Combine(Path.GetDirectoryName(typeof(SettingFilterTests).Assembly.Location), "Dialogs\\VehicleSettings\\Resources\\");

            settingList   = new SettingList(resDir + "available_settings.json", resDir + "setting_alternative_names.json");
            settingFilter = new SettingFilter(settingList);
        }
Ejemplo n.º 5
0
        public GetMockTransport(string queryKey, SettingFilter filter, ConfigurationSetting result)
        {
            _expectedMethod         = HttpMethod.Get;
            _expectedUri            = $"https://contoso.azconfig.io/kv/{queryKey}{GetExtraUriParameters(filter)}";
            _expectedRequestContent = null;

            string json = JsonConvert.SerializeObject(result).ToLowerInvariant();

            _responseContent = json.Replace("contenttype", "content_type");
        }
        public override void Initialize()
        {
            base.Initialize();

            // Supporting setting files are stored as embedded resources
            var resourceAssembly = typeof(VehicleSettingsDialog).Assembly;

            var settingFile = resourceAssembly
                              .GetManifestResourceNames()
                              .Where(x => x.Contains("available_settings.yaml"))
                              .First();

            var alternativeSettingFileName = resourceAssembly
                                             .GetManifestResourceNames()
                                             .Where(x => x.Contains("setting_alternative_names.yaml"))
                                             .First();

            settingList   = new SettingList(resourceAssembly, settingFile, alternativeSettingFileName);
            settingFilter = new SettingFilter(settingList);
        }
Ejemplo n.º 7
0
        public IEnumerable <Setting> GetSettings(SettingFilter settingFiler = null)
        {
            var collection = Database.GetCollection <MongoSetting>(Settings);
            var builder    = Builders <MongoSetting> .Filter;
            var filterDefs = new List <FilterDefinition <MongoSetting> >();

            if (settingFiler != null)
            {
                if (!string.IsNullOrWhiteSpace(settingFiler.Key))
                {
                    filterDefs.Add(builder.Eq(x => x.Key, settingFiler.Key));
                }

                if (!string.IsNullOrWhiteSpace(settingFiler.Value))
                {
                    filterDefs.Add(builder.Eq(x => x.Value, settingFiler.Value));
                }
            }

            var filterDef = filterDefs.Any() ? filterDefs.Aggregate((x, y) => x & y) : builder.Empty;
            var data      = collection.Find <MongoSetting>(filterDef).ToList();

            return(data);
        }
Ejemplo n.º 8
0
        public VehicleSettingsDialog(
            BotSettings settings,
            BotServices services,
            ResponseManager responseManager,
            ConversationState conversationState,
            IBotTelemetryClient telemetryClient,
            IHttpContextAccessor httpContext)
            : base(nameof(VehicleSettingsDialog), settings, services, responseManager, conversationState, telemetryClient)
        {
            TelemetryClient = telemetryClient;

            // Initialise supporting LUIS models for followup questions
            vehicleSettingNameSelectionLuisRecognizer  = services.CognitiveModelSets["en"].LuisServices["settings_name"];
            vehicleSettingValueSelectionLuisRecognizer = services.CognitiveModelSets["en"].LuisServices["settings_value"];

            // Initialise supporting LUIS models for followup questions
            vehicleSettingNameSelectionLuisRecognizer  = services.CognitiveModelSets["en"].LuisServices["settings_name"];
            vehicleSettingValueSelectionLuisRecognizer = services.CognitiveModelSets["en"].LuisServices["settings_value"];

            // Supporting setting files are stored as embedded resources
            var resourceAssembly = typeof(VehicleSettingsDialog).Assembly;

            var settingFile = resourceAssembly
                              .GetManifestResourceNames()
                              .Where(x => x.Contains(AvailableSettingsFileName))
                              .First();

            var alternativeSettingFileName = resourceAssembly
                                             .GetManifestResourceNames()
                                             .Where(x => x.Contains(AlternativeSettingsFileName))
                                             .First();

            if (string.IsNullOrEmpty(settingFile) || string.IsNullOrEmpty(alternativeSettingFileName))
            {
                throw new FileNotFoundException($"Unable to find Available Setting and/or Alternative Names files in \"{resourceAssembly.FullName}\" assembly.");
            }

            settingList   = new SettingList(resourceAssembly, settingFile, alternativeSettingFileName);
            settingFilter = new SettingFilter(settingList);

            // Setting Change waterfall
            var processVehicleSettingChangeWaterfall = new WaterfallStep[]
            {
                ProcessSetting,
                ProcessVehicleSettingsChange,
                ProcessChange,
                SendChange
            };

            AddDialog(new WaterfallDialog(Actions.ProcessVehicleSettingChange, processVehicleSettingChangeWaterfall)
            {
                TelemetryClient = telemetryClient
            });

            // Prompts
            AddDialog(new ChoicePrompt(Actions.SettingNameSelectionPrompt, SettingNameSelectionValidator, Culture.English)
            {
                Style = ListStyle.Auto, ChoiceOptions = new ChoiceFactoryOptions {
                    InlineSeparator = string.Empty, InlineOr = string.Empty, InlineOrMore = string.Empty, IncludeNumbers = true
                }
            });
            AddDialog(new ChoicePrompt(Actions.SettingValueSelectionPrompt, SettingValueSelectionValidator, Culture.English)
            {
                Style = ListStyle.Auto, ChoiceOptions = new ChoiceFactoryOptions {
                    InlineSeparator = string.Empty, InlineOr = string.Empty, InlineOrMore = string.Empty, IncludeNumbers = true
                }
            });

            AddDialog(new ConfirmPrompt(Actions.SettingConfirmationPrompt));

            // Set starting dialog for component
            InitialDialogId = Actions.ProcessVehicleSettingChange;

            // Used to resolve image paths (local or hosted)
            _httpContext = httpContext;
        }
Ejemplo n.º 9
0
 public IEnumerable <Setting> GetSettings(SettingFilter settingFilter = null)
 {
     return(Repository.GetSettings(settingFilter));
 }
Ejemplo n.º 10
0
 public DeleteMockTransport(string key, SettingFilter filter, HttpStatusCode statusCode)
     : this(key, filter, result : null)
 {
     Responses.Clear();
     Responses.Add(statusCode);
 }