Skip to content

Commit

Permalink
Merge pull request #131 from MarkusMeyer13/master
Browse files Browse the repository at this point in the history
Merge
  • Loading branch information
MarkusMeyer13 authored Mar 4, 2020
2 parents 174a8b1 + 63ecd50 commit 13c9eda
Show file tree
Hide file tree
Showing 20 changed files with 529 additions and 187 deletions.
16 changes: 16 additions & 0 deletions PlanB.Butler.Bot/BotConfig.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,22 @@ namespace PlanB.Butler.Bot
/// </summary>
public class BotConfig
{
/// <summary>
/// Gets or sets the butler service URL.
/// </summary>
/// <value>
/// The butler service URL.
/// </value>
public string ButlerServiceUrl { get; set; }

/// <summary>
/// Gets or sets the butler service key.
/// </summary>
/// <value>
/// The butler service key.
/// </value>
public string ButlerServiceKey { get; set; }

/// <summary>
/// Gets or sets the storage account URL.
/// </summary>
Expand Down
26 changes: 26 additions & 0 deletions PlanB.Butler.Bot/Constants.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
// Copyright (c) PlanB. GmbH. All Rights Reserved.
// Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information.

namespace PlanB.Butler.Bot
{
/// <summary>
/// Constants.
/// </summary>
internal static class Constants
{
/// <summary>
/// The butler correlation trace name.
/// </summary>
internal const string ButlerCorrelationTraceName = "Butler-Correlation-Id";

/// <summary>
/// The butler correlation trace header.
/// </summary>
internal const string ButlerCorrelationTraceHeader = "ButlerCorrelationId";

/// <summary>
/// The functions key header.
/// </summary>
internal const string FunctionsKeyHeader = "x-functions-key";
}
}
2 changes: 1 addition & 1 deletion PlanB.Butler.Bot/Dialogs/CreditDialog.cs
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
using Microsoft.Extensions.Options;
using Newtonsoft.Json;

namespace PlanB.Butler.Bot
namespace PlanB.Butler.Bot.Dialogs
{
public class CreditDialog : ComponentDialog
{
Expand Down
2 changes: 1 addition & 1 deletion PlanB.Butler.Bot/Dialogs/DailyCreditDialog.cs
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
using Microsoft.Extensions.Options;
using Newtonsoft.Json;

namespace PlanB.Butler.Bot
namespace PlanB.Butler.Bot.Dialogs
{
/// <summary>
/// DailyCreditDialog.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
using System;
// Copyright (c) PlanB. GmbH. All Rights Reserved.
// Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information.

using System;
using System.Collections.Generic;
using System.Net;
using System.Net.Http;
using System.Reflection;
using System.Resources;
using System.Threading;
Expand All @@ -13,44 +16,44 @@
using Microsoft.Bot.Schema;
using Microsoft.Extensions.Options;
using Newtonsoft.Json;
using PlanB.Butler.Bot;

namespace PlanB.Butler.Bot
namespace PlanB.Butler.Bot.Dialogs
{
/// <summary>
/// DeleteOrderDialog.
/// </summary>
/// <seealso cref="Microsoft.Bot.Builder.Dialogs.ComponentDialog" />
public class DeleteOrderDialog : ComponentDialog
{
/// <summary>
/// The client factory.
/// </summary>
private readonly IHttpClientFactory clientFactory;

/// <summary>
/// The bot configuration.
/// </summary>
private readonly IOptions<BotConfig> botConfig;

static Plan plan = new Plan();
static Plan orderedfood = new Plan();
static int valueDay;
const double grand = 3.30;
static string dayName;
[Obsolete("Why is this still in use?")]
static string[] weekDays = { "Montag", "Dienstag", "Mitwoch", "Donnerstag", "Freitag" };
[Obsolete("Why is this still in use?")]
static string[] weekDaysEN = { "monday", "tuesday", "wednesday", "thursday", "friday" };
static int indexer = 0;
[Obsolete("Why is this still in use?")]
static string[] companyStatus = { "intern", "extern", "internship" };
[Obsolete("Why is this still in use?")]
static string[] companyStatusD = { "Für mich", "Kunde", "Praktikant" };
[Obsolete("Naming Conventions!")]
static Order obj = new Order();

/// <summary>
/// DeletDialogTimePrompt.
/// DeletDialogWhoPrompt
/// NextOrderDialogMyself
/// NextOrderDialolTrainee
/// NextOrderDialogCostumer
/// DeletDialogNoOrder
/// DeletDialogDeleteSucess
/// DeletDialogDeletePrompt
/// DeletDialogYes
/// DeletDialogNo
/// OtherDayDialogError2.
/// </summary>

private static string deletDialogTimePrompt = string.Empty;
private static string deletDialogWhoPrompt = string.Empty;
private static string deletDialogWhoPrompt = string.Empty;
private static string nextOrderDialogMyself = string.Empty;
private static string nextOrderDialogTrainee = string.Empty;
private static string nextOrderDialogCostumer = string.Empty;
Expand All @@ -61,20 +64,18 @@ public class DeleteOrderDialog : ComponentDialog
private static string deletDialogNo = string.Empty;
private static string otherDayDialogError2 = string.Empty;


/// <summary>
/// The bot configuration.
/// </summary>
private readonly IOptions<BotConfig> botConfig;

/// <summary>
/// Initializes a new instance of the <see cref="DeleteOrderDialog"/> class.
/// Initializes a new instance of the <see cref="DeleteOrderDialog" /> class.
/// </summary>
/// <param name="config">The configuration.</param>
public DeleteOrderDialog(IOptions<BotConfig> config, IBotTelemetryClient telemetryClient)
/// <param name="telemetryClient">The telemetry client.</param>
/// <param name="httpClientFactory">The HTTP client factory.</param>
public DeleteOrderDialog(IOptions<BotConfig> config, IBotTelemetryClient telemetryClient, IHttpClientFactory httpClientFactory)
: base(nameof(DeleteOrderDialog))
{
ResourceManager rm = new ResourceManager("PlanB.Butler.Bot.Dictionary.Dialogs", Assembly.GetExecutingAssembly());
this.clientFactory = httpClientFactory;
this.botConfig = config;

deletDialogTimePrompt = rm.GetString("DeletDialog_TimePrompt");
deletDialogWhoPrompt = rm.GetString("DeletDialog_WhoPrompt");
Expand All @@ -88,15 +89,10 @@ public DeleteOrderDialog(IOptions<BotConfig> config, IBotTelemetryClient telemet
deletDialogNo = rm.GetString("no");
otherDayDialogError2 = rm.GetString("OtherDayDialog_Error2");

//// Get the Plan
//string food = BotMethods.GetDocument("eatingplan", "ButlerOverview.json", this.botConfig.Value.StorageAccountUrl, this.botConfig.Value.StorageAccountKey);



this.botConfig = config;

// Get the Plan
string food = BotMethods.GetDocument("eatingplan", "ButlerOverview.json", this.botConfig.Value.StorageAccountUrl, this.botConfig.Value.StorageAccountKey);

plan = JsonConvert.DeserializeObject<Plan>(food);
//plan = JsonConvert.DeserializeObject<Plan>(food);
// This array defines how the Waterfall will execute.
var waterfallSteps = new WaterfallStep[]
{
Expand Down
3 changes: 2 additions & 1 deletion PlanB.Butler.Bot/Dialogs/ExcellDialog.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,15 @@
using Microsoft.Bot.Builder.Dialogs.Choices;
using Microsoft.Extensions.Options;

namespace PlanB.Butler.Bot
namespace PlanB.Butler.Bot.Dialogs
{
/// <summary>
/// ExcellDialog.
/// </summary>
/// <seealso cref="Microsoft.Bot.Builder.Dialogs.ComponentDialog" />
public class ExcellDialog : ComponentDialog
{
[Obsolete("This has to be replaced")]
private static string[] months = { "Januar", "Februar", "März", "April", "Mai", "Juni", "Juli", "August", "September", "Oktober", "November", "Dezember" };
private static string indexer = "0";

Expand Down
6 changes: 3 additions & 3 deletions PlanB.Butler.Bot/Dialogs/InterruptDialog.cs
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
using Microsoft.Extensions.Options;
using Newtonsoft.Json;

namespace PlanB.Butler.Bot
namespace PlanB.Butler.Bot.Dialogs
{
/// <summary>
/// InterruptDialog.
Expand All @@ -35,14 +35,14 @@ public class InterruptDialog : ComponentDialog
private static Plan plan = new Plan();
private readonly IOptions<BotConfig> botConfig;

public InterruptDialog(string v, IOptions<BotConfig> config, IBotTelemetryClient telemetryClient)
public InterruptDialog(string v, IOptions<BotConfig> config, IBotTelemetryClient telemetryClient, IHttpClientFactory clientFactory)
: base(nameof(InterruptDialog))
{
ResourceManager rm = new ResourceManager("PlanB.Butler.Bot.Dictionary.Dialogs", Assembly.GetExecutingAssembly());
interruptDialogHelpText = rm.GetString("InterruptDialog_HelpText");

this.botConfig = config;
this.AddDialog(new OverviewDialog(config, telemetryClient));
this.AddDialog(new OverviewDialog(config, telemetryClient, clientFactory));
this.AddDialog(new ExcellDialog(config, telemetryClient));
}

Expand Down
53 changes: 37 additions & 16 deletions PlanB.Butler.Bot/Dialogs/MainDialog.cs
Original file line number Diff line number Diff line change
@@ -1,25 +1,46 @@
namespace PlanB.Butler.Bot
{
using System.Collections.Generic;
using System.Linq;
using System.Threading;
using System.Threading.Tasks;
using AdaptiveCards;
using Microsoft.Bot.Builder;
using Microsoft.Bot.Builder.Dialogs;
using Microsoft.Bot.Builder.Dialogs.Choices;
using Microsoft.Bot.Schema;
using Microsoft.Extensions.Options;
using Newtonsoft.Json.Linq;
using PlanB.Butler.Bot;
// Copyright (c) PlanB. GmbH. All Rights Reserved.
// Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information.

using System.Collections.Generic;
using System.Linq;
using System.Net.Http;
using System.Threading;
using System.Threading.Tasks;

using AdaptiveCards;
using Microsoft.Bot.Builder;
using Microsoft.Bot.Builder.Dialogs;
using Microsoft.Bot.Builder.Dialogs.Choices;
using Microsoft.Bot.Schema;
using Microsoft.Extensions.Options;
using Newtonsoft.Json.Linq;
using PlanB.Butler.Bot;

namespace PlanB.Butler.Bot.Dialogs
{
/// <summary>
/// MainDialog.
/// </summary>
/// <seealso cref="PlanB.Butler.Bot.Dialogs.InterruptDialog" />
public class MainDialog : InterruptDialog
{
public MainDialog(IBotTelemetryClient telemetryClient, IOptions<BotConfig> config)
: base(nameof(MainDialog), config,telemetryClient)
/// <summary>
/// The client factory.
/// </summary>
private readonly IHttpClientFactory clientFactory;

/// <summary>
/// Initializes a new instance of the <see cref="MainDialog"/> class.
/// </summary>
/// <param name="telemetryClient">The telemetry client.</param>
/// <param name="config">The configuration.</param>
/// <param name="httpClientFactory">The HTTP client factory.</param>
public MainDialog(IBotTelemetryClient telemetryClient, IOptions<BotConfig> config, IHttpClientFactory httpClientFactory)
: base(nameof(MainDialog), config, telemetryClient, httpClientFactory)
{
// Set the telemetry client for this and all child dialogs.
this.TelemetryClient = telemetryClient;
this.clientFactory = httpClientFactory;

// This array defines how the Waterfall will execute.
var waterfallSteps = new WaterfallStep[]
Expand Down
2 changes: 1 addition & 1 deletion PlanB.Butler.Bot/Dialogs/NextOrder.cs
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
using Microsoft.Extensions.Options;
using Newtonsoft.Json;

namespace PlanB.Butler.Bot
namespace PlanB.Butler.Bot.Dialogs
{
/// <summary>
/// NextOrder.
Expand Down
28 changes: 14 additions & 14 deletions PlanB.Butler.Bot/Dialogs/OrderDialog.cs
Original file line number Diff line number Diff line change
@@ -1,18 +1,18 @@
namespace PlanB.Butler.Bot
using System;
using System.Collections.Generic;
using System.Net;
using System.Threading;
using System.Threading.Tasks;

using BotLibraryV2;
using Microsoft.Bot.Builder;
using Microsoft.Bot.Builder.Dialogs;
using Microsoft.Bot.Builder.Dialogs.Choices;
using Microsoft.Extensions.Options;
using Newtonsoft.Json;

namespace PlanB.Butler.Bot.Dialogs
{
using System;
using System.Collections.Generic;
using System.Net;
using System.Threading;
using System.Threading.Tasks;
using BotLibraryV2;
using Microsoft.Bot.Builder;
using Microsoft.Bot.Builder.Dialogs;
using Microsoft.Bot.Builder.Dialogs.Choices;
using Microsoft.Bot.Schema;
using Microsoft.Extensions.Options;
using Newtonsoft.Json;

public class OrderDialog : ComponentDialog
{
private static Plan plan = new Plan();
Expand Down
2 changes: 1 addition & 1 deletion PlanB.Butler.Bot/Dialogs/OrderForOtherDayDialog.cs
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
using Microsoft.Extensions.Options;
using Newtonsoft.Json;

namespace PlanB.Butler.Bot
namespace PlanB.Butler.Bot.Dialogs
{
/// <summary>
/// OrderForOtherDayDialog.
Expand Down
Loading

0 comments on commit 13c9eda

Please sign in to comment.