Skip to content

Commit

Permalink
PlanBGmbH#47 Clean Up
Browse files Browse the repository at this point in the history
  • Loading branch information
MarkusMeyer13 committed Mar 2, 2020
1 parent c622d64 commit a3f8c78
Show file tree
Hide file tree
Showing 10 changed files with 112 additions and 70 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; }
}
}
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,
}
}

0 comments on commit a3f8c78

Please sign in to comment.