Skip to content

Commit

Permalink
Merge pull request #126 from MarkusMeyer13/master
Browse files Browse the repository at this point in the history
Merge
  • Loading branch information
MarkusMeyer13 authored Mar 2, 2020
2 parents 995c622 + be0a6bd commit 7769760
Show file tree
Hide file tree
Showing 13 changed files with 123 additions and 83 deletions.
30 changes: 18 additions & 12 deletions PlanB.Butler.Bot/Bots/TeamsBot.cs
Original file line number Diff line number Diff line change
@@ -1,18 +1,24 @@
namespace PlanB.Butler.Bot
{
using System.Collections.Generic;
using System.Threading;
using System.Threading.Tasks;
using Microsoft.Bot.Builder;
using Microsoft.Bot.Builder.Dialogs;
using Microsoft.Bot.Schema;
using Microsoft.Extensions.Logging;
using System.Resources;
using System.Reflection;
// Copyright (c) PlanB. GmbH. All Rights Reserved.
// Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information.

// This bot is derived (view DialogBot<T>) from the TeamsACtivityHandler class currently included as part of this sample.
using System.Collections.Generic;
using System.Reflection;
using System.Resources;
using System.Threading;
using System.Threading.Tasks;

using Microsoft.Bot.Builder;
using Microsoft.Bot.Builder.Dialogs;
using Microsoft.Bot.Schema;
using Microsoft.Extensions.Logging;

namespace PlanB.Butler.Bot
{
/// <summary>
/// This bot is derived (view DialogBot<T>) from the TeamsACtivityHandler class currently included as part of this sample.
/// </summary>
/// <typeparam name="T"></typeparam>
/// <seealso cref="PlanB.Butler.Bot.DialogBot{T}" />
public class TeamsBot<T> : DialogBot<T> where T : Dialog
{
/// <summary>
Expand Down
25 changes: 18 additions & 7 deletions PlanB.Butler.Bot/Dialogs/NextOrder.cs
Original file line number Diff line number Diff line change
Expand Up @@ -121,14 +121,14 @@ public NextOrder(IOptions<BotConfig> config, IBotTelemetryClient telemetryClient
// This array defines how the Waterfall will execute.
var waterfallSteps = new WaterfallStep[]
{
CompanyStepAsync,
this.CompanyStepAsync,
NameStepAsync,
RestaurantStepAsync,
QuantatyStepAsync,
QuantityStepAsync,
FoodStepAsync,
MealQuantatyStepAsync,
MealQuantityStepAsync,
PriceStepAsync,
SummaryStepAsync,
this.SummaryStepAsync,
};

// Add named dialogs to the DialogSet. These names are saved in the dialog state.
Expand Down Expand Up @@ -280,7 +280,13 @@ private static async Task<DialogTurnResult> RestaurantStepAsync(WaterfallStepCon
}
}

private static async Task<DialogTurnResult> QuantatyStepAsync(WaterfallStepContext stepContext, CancellationToken cancellationToken)
/// <summary>
/// Quantities the step asynchronous.
/// </summary>
/// <param name="stepContext">The step context.</param>
/// <param name="cancellationToken">The cancellation token.</param>
/// <returns>DialogTurnResult.</returns>
private static async Task<DialogTurnResult> QuantityStepAsync(WaterfallStepContext stepContext, CancellationToken cancellationToken)
{
try
{
Expand Down Expand Up @@ -364,8 +370,13 @@ private static async Task<DialogTurnResult> FoodStepAsync(WaterfallStepContext s
}
}


private static async Task<DialogTurnResult> MealQuantatyStepAsync(WaterfallStepContext stepContext, CancellationToken cancellationToken)
/// <summary>
/// Meals the quantity step asynchronous.
/// </summary>
/// <param name="stepContext">The step context.</param>
/// <param name="cancellationToken">The cancellation token.</param>
/// <returns>DialogTurnResult.</returns>
private static async Task<DialogTurnResult> MealQuantityStepAsync(WaterfallStepContext stepContext, CancellationToken cancellationToken)
{
var obj = ((FoundChoice)stepContext.Result).Value;
if (stepContext.Values["rest1"].ToString() == "yes")
Expand Down
8 changes: 8 additions & 0 deletions PlanB.Butler.Bot/GlobalSuppressions.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
// This file is used by Code Analysis to maintain SuppressMessage
// attributes that are applied to this project.
// Project-level suppressions either have no target or are given
// a specific target and scoped to a namespace, type, member, etc.

using System.Diagnostics.CodeAnalysis;

[assembly: SuppressMessage("StyleCop.CSharp.DocumentationRules", "SA1649:File name should match first type name", Justification = "Makes no sense due to Generic", Scope = "type", Target = "~T:PlanB.Butler.Bot.TeamsBot`1")]
7 changes: 7 additions & 0 deletions PlanB.Butler.Bot/PlanB.Butler.Bot.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,21 @@
<PropertyGroup>
<TargetFramework>netcoreapp2.2</TargetFramework>
<LangVersion>latest</LangVersion>
<Company>PlanB. GmbH</Company>
<Product>PlanB Butler Bot</Product>
<Authors>PlanB. GmbH</Authors>
</PropertyGroup>

<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|AnyCPU'">
<CodeAnalysisRuleSet />
<OutputPath>bin\Release\netcoreapp2.2\</OutputPath>
<DocumentationFile>bin\Release\netcoreapp2.2\PlanB.Butler.Bot.xml</DocumentationFile>
</PropertyGroup>

<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|AnyCPU'">
<CodeAnalysisRuleSet />
<OutputPath>bin\Debug\netcoreapp2.2\</OutputPath>
<DocumentationFile>bin\Debug\netcoreapp2.2\PlanB.Butler.Bot.xml</DocumentationFile>
</PropertyGroup>

<ItemGroup>
Expand Down
18 changes: 15 additions & 3 deletions PlanB.Butler.Bot/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,18 +3,30 @@
//
// Generated with Bot Builder V4 SDK Template for Visual Studio EchoBot v4.5.0

using Microsoft.AspNetCore;
using Microsoft.AspNetCore.Hosting;

namespace PlanB.Butler.Bot
{
using Microsoft.AspNetCore;
using Microsoft.AspNetCore.Hosting;

/// <summary>
/// Program.
/// </summary>
public class Program
{
/// <summary>
/// Defines the entry point of the application.
/// </summary>
/// <param name="args">The arguments.</param>
public static void Main(string[] args)
{
CreateWebHostBuilder(args).Build().Run();
}

/// <summary>
/// Creates the web host builder.
/// </summary>
/// <param name="args">The arguments.</param>
/// <returns>IWebHostBuilder.</returns>
public static IWebHostBuilder CreateWebHostBuilder(string[] args) =>
WebHost.CreateDefaultBuilder(args)
.UseStartup<Startup>();
Expand Down
1 change: 1 addition & 0 deletions PlanB.Butler.Bot/Startup.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
using System.Collections;
using System.Collections.Generic;
using System.Globalization;

using Microsoft.ApplicationInsights.Extensibility;
using Microsoft.AspNetCore.Builder;
using Microsoft.AspNetCore.Hosting;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ public class BackendCommunication
/// <param name="storageAccountUrl">The storage account URL.</param>
/// <param name="storageAccountKey">The storage account key.</param>
/// <returns></returns>
[Obsolete("Call function instead")]
public string GetDocument(string container, string resourceName, string storageAccountUrl, string storageAccountKey)
{
using (HttpClient httpClient = new HttpClient())
Expand Down Expand Up @@ -92,6 +93,7 @@ public string GenerateStorageSasTokenWrite(string resourceName, string storageAc
return sasToken;
}

[Obsolete("Call function instead")]
public HttpStatusCode PutDocument(string container, string resourceName, string body, string queueName, string serviceBusConnectionString)
{
string label = $"{container}/{resourceName}";
Expand Down Expand Up @@ -121,6 +123,7 @@ public HttpStatusCode PutDocument(string container, string resourceName, string
/// <param name="queueName">Name of the queue.</param>
/// <param name="serviceBusConnectionString">The service bus connection string.</param>
/// <returns></returns>
[Obsolete("Call function instead")]
public HttpStatusCode PutDocumentByteArray(string container, string resourceName, byte[] body, string queueName, string serviceBusConnectionString)
{
string label = $"{container}/{resourceName}";
Expand All @@ -139,6 +142,7 @@ public HttpStatusCode PutDocumentByteArray(string container, string resourceName
}
}

[Obsolete("Call function instead")]
public string GenerateServiceBusSasToken(string serviceBusConnectionString, string que)
{
var connectionString = serviceBusConnectionString;
Expand Down
9 changes: 9 additions & 0 deletions PlanB.Butler.Library/PlanB.Butler.Library/BotModels/Order.cs
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,17 @@ public class Order

public double Price { get; set; }

[Obsolete("Please use 'Quantity'")]
public int Quantaty { get; set; }

/// <summary>
/// Gets or sets the quantity.
/// </summary>
/// <value>
/// The quantity.
/// </value>
public int Quantity { get; set; }

public double Grand { get; set; }
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -198,7 +198,6 @@ public void IsDateInRangeCheckEndEqualCheck()
[TestMethod]
public void ValidateMealTestOk()
{
ErrorModel errorModel = null;
Guid correlationId = Guid.NewGuid();

MealModel mealModel = new MealModel()
Expand All @@ -208,7 +207,7 @@ public void ValidateMealTestOk()
Date = DateTime.Now,
};

var result = MealService.Validate(mealModel, correlationId, out errorModel);
var result = MealService.Validate(mealModel, correlationId, out ErrorModel errorModel);
Assert.AreEqual(true, result);
Assert.IsNull(errorModel);
}
Expand All @@ -219,7 +218,6 @@ public void ValidateMealTestOk()
[TestMethod]
public void ValidateMealTestMissingMeal()
{
ErrorModel errorModel = null;
Guid correlationId = Guid.NewGuid();

MealModel mealModel = new MealModel()
Expand All @@ -228,7 +226,7 @@ public void ValidateMealTestMissingMeal()
Date = DateTime.Now,
};

var result = MealService.Validate(mealModel, correlationId, out errorModel);
var result = MealService.Validate(mealModel, correlationId, out ErrorModel errorModel);
Assert.AreEqual(false, result);
Assert.IsNotNull(errorModel);
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFramework>netcoreapp3.0</TargetFramework>
<TargetFramework>netcoreapp3.1</TargetFramework>

<IsPackable>false</IsPackable>
</PropertyGroup>

<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|AnyCPU'">
<OutputPath>bin\Debug\netcoreapp3.0\</OutputPath>
<OutputPath>bin\Debug\netcoreapp3.1\</OutputPath>
<DocumentationFile>bin\Debug\netcoreapp3.1\PlanB.Butler.Services.Test.xml</DocumentationFile>
</PropertyGroup>

Expand Down
49 changes: 1 addition & 48 deletions PlanB.Butler.Services/PlanB.Butler.Services/Models/OrderModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
// Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information.

using System;
using System.Collections.Generic;

namespace PlanB.Butler.Services.Models
{
Expand All @@ -12,33 +11,7 @@ namespace PlanB.Butler.Services.Models
public class OrderModel
{
/// <summary>
/// Gets or sets the company status Enum.
/// </summary>
public enum OrderRelationship
{
/// <summary>
/// External.
/// </summary>
External = 1,

/// <summary>
/// Internal.
/// </summary>
Internal = 2,

/// <summary>
/// Client.
/// </summary>
Client = 3,

/// <summary>
/// Intership.
/// </summary>
Intership = 4,
}

/// <summary>
/// Gets or sets the name.
/// Gets or sets the Relationship.
/// </summary>
/// <value>
/// The name.
Expand Down Expand Up @@ -108,25 +81,5 @@ public enum OrderRelationship
/// The benefit.
/// </value>
public double Benefit { get; set; }

//public OrderModel(string companyStatus, DateTime date, string name, string companyName, string restaurant, string meal, double price, int quantity, double benefit)
//{
// Dictionary<string, OrderRelationship> lookUpCompanyStatus = new Dictionary<string, OrderRelationship>();
// lookUpCompanyStatus.Add("Extern", OrderRelationship.External);
// lookUpCompanyStatus.Add("Intern", OrderRelationship.Internal);
// lookUpCompanyStatus.Add("Kunde", OrderRelationship.Client);
// lookUpCompanyStatus.Add("Praktikant", OrderRelationship.Intership);

// OrderRelationship selected = lookUpCompanyStatus[companyStatus];
// this.Relationship = selected;
// this.Date = date;
// this.Name = name;
// this.CompanyName = companyName;
// this.Restaurant = restaurant;
// this.Meal = meal;
// this.Price = price;
// this.Quantity = quantity;
// this.Benefit = benefit;
//}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
// 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.Services.Models
{
/// <summary>
/// OrderRelationship.
/// </summary>
public enum OrderRelationship
{
/// <summary>
/// External.
/// </summary>
External = 1,

/// <summary>
/// Internal.
/// </summary>
Internal = 2,

/// <summary>
/// Client.
/// </summary>
Client = 3,

/// <summary>
/// Intership.
/// </summary>
Intership = 4,
}
}
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>netcoreapp3.0</TargetFramework>
<TargetFramework>netcoreapp3.1</TargetFramework>
<AzureFunctionsVersion>v2</AzureFunctionsVersion>
<RootNamespace>PlanB.Butler.Services</RootNamespace>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|AnyCPU'">
<OutputPath>bin\Debug\netcoreapp3.0\</OutputPath>
<DocumentationFile>bin\Debug\netcoreapp3.0\PlanB.Butler.Services.xml</DocumentationFile>
<OutputPath></OutputPath>
<DocumentationFile>bin\Debug\netcoreapp3.1\PlanB.Butler.Services.xml</DocumentationFile>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|AnyCPU'">
<DocumentationFile>bin\Release\netcoreapp3.0\PlanB.Butler.Services.xml</DocumentationFile>
<OutputPath>bin\Release\netcoreapp3.0\</OutputPath>
<DocumentationFile>bin\Release\netcoreapp3.1\PlanB.Butler.Services.xml</DocumentationFile>
<OutputPath>bin\Release\netcoreapp3.1\</OutputPath>
</PropertyGroup>
<ItemGroup>
<None Remove="Settings.StyleCop" />
Expand All @@ -24,9 +24,9 @@
</ItemGroup>
<ItemGroup>
<PackageReference Include="AzureFunctions.Extensions.Swashbuckle" Version="1.4.4" />
<PackageReference Include="Microsoft.Azure.WebJobs.Extensions.ServiceBus" Version="3.0.3" />
<PackageReference Include="Microsoft.Azure.WebJobs.Extensions.ServiceBus" Version="4.1.0" />
<PackageReference Include="Microsoft.Azure.WebJobs.Extensions.Storage" Version="3.0.10" />
<PackageReference Include="Microsoft.NET.Sdk.Functions" Version="1.0.29" />
<PackageReference Include="Microsoft.NET.Sdk.Functions" Version="3.0.3" />
<PackageReference Include="Newtonsoft.Json" Version="12.0.3" />
<PackageReference Include="StyleCop.Analyzers" Version="1.1.118">
<PrivateAssets>all</PrivateAssets>
Expand Down

0 comments on commit 7769760

Please sign in to comment.