From a3f8c782af054ede8f0b32366de9859d9fec46f2 Mon Sep 17 00:00:00 2001 From: Markus Meyer Date: Mon, 2 Mar 2020 19:13:15 +0100 Subject: [PATCH] #47 Clean Up --- PlanB.Butler.Bot/Bots/TeamsBot.cs | 30 +++++++----- PlanB.Butler.Bot/Dialogs/NextOrder.cs | 25 +++++++--- PlanB.Butler.Bot/GlobalSuppressions.cs | 8 +++ PlanB.Butler.Bot/PlanB.Butler.Bot.csproj | 7 +++ PlanB.Butler.Bot/Program.cs | 18 +++++-- PlanB.Butler.Bot/Startup.cs | 1 + .../BackendCommunication.cs | 4 ++ .../PlanB.Butler.Library/BotModels/Order.cs | 9 ++++ .../Models/OrderModel.cs | 49 +------------------ .../Models/OrderRelationship.cs | 31 ++++++++++++ 10 files changed, 112 insertions(+), 70 deletions(-) create mode 100644 PlanB.Butler.Bot/GlobalSuppressions.cs create mode 100644 PlanB.Butler.Services/PlanB.Butler.Services/Models/OrderRelationship.cs diff --git a/PlanB.Butler.Bot/Bots/TeamsBot.cs b/PlanB.Butler.Bot/Bots/TeamsBot.cs index 0792c6b..65751c8 100644 --- a/PlanB.Butler.Bot/Bots/TeamsBot.cs +++ b/PlanB.Butler.Bot/Bots/TeamsBot.cs @@ -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) 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 +{ + /// + /// This bot is derived (view DialogBot) from the TeamsACtivityHandler class currently included as part of this sample. + /// + /// + /// public class TeamsBot : DialogBot where T : Dialog { /// diff --git a/PlanB.Butler.Bot/Dialogs/NextOrder.cs b/PlanB.Butler.Bot/Dialogs/NextOrder.cs index fb7b599..2bb11ad 100644 --- a/PlanB.Butler.Bot/Dialogs/NextOrder.cs +++ b/PlanB.Butler.Bot/Dialogs/NextOrder.cs @@ -121,14 +121,14 @@ public NextOrder(IOptions 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. @@ -280,7 +280,13 @@ private static async Task RestaurantStepAsync(WaterfallStepCon } } - private static async Task QuantatyStepAsync(WaterfallStepContext stepContext, CancellationToken cancellationToken) + /// + /// Quantities the step asynchronous. + /// + /// The step context. + /// The cancellation token. + /// DialogTurnResult. + private static async Task QuantityStepAsync(WaterfallStepContext stepContext, CancellationToken cancellationToken) { try { @@ -364,8 +370,13 @@ private static async Task FoodStepAsync(WaterfallStepContext s } } - - private static async Task MealQuantatyStepAsync(WaterfallStepContext stepContext, CancellationToken cancellationToken) + /// + /// Meals the quantity step asynchronous. + /// + /// The step context. + /// The cancellation token. + /// DialogTurnResult. + private static async Task MealQuantityStepAsync(WaterfallStepContext stepContext, CancellationToken cancellationToken) { var obj = ((FoundChoice)stepContext.Result).Value; if (stepContext.Values["rest1"].ToString() == "yes") diff --git a/PlanB.Butler.Bot/GlobalSuppressions.cs b/PlanB.Butler.Bot/GlobalSuppressions.cs new file mode 100644 index 0000000..8054593 --- /dev/null +++ b/PlanB.Butler.Bot/GlobalSuppressions.cs @@ -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")] diff --git a/PlanB.Butler.Bot/PlanB.Butler.Bot.csproj b/PlanB.Butler.Bot/PlanB.Butler.Bot.csproj index a903ae9..f997d18 100644 --- a/PlanB.Butler.Bot/PlanB.Butler.Bot.csproj +++ b/PlanB.Butler.Bot/PlanB.Butler.Bot.csproj @@ -3,14 +3,21 @@ netcoreapp2.2 latest + PlanB. GmbH + PlanB Butler Bot + PlanB. GmbH + bin\Release\netcoreapp2.2\ + bin\Release\netcoreapp2.2\PlanB.Butler.Bot.xml + bin\Debug\netcoreapp2.2\ + bin\Debug\netcoreapp2.2\PlanB.Butler.Bot.xml diff --git a/PlanB.Butler.Bot/Program.cs b/PlanB.Butler.Bot/Program.cs index 7125613..a119161 100644 --- a/PlanB.Butler.Bot/Program.cs +++ b/PlanB.Butler.Bot/Program.cs @@ -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; - + /// + /// Program. + /// public class Program { + /// + /// Defines the entry point of the application. + /// + /// The arguments. public static void Main(string[] args) { CreateWebHostBuilder(args).Build().Run(); } + /// + /// Creates the web host builder. + /// + /// The arguments. + /// IWebHostBuilder. public static IWebHostBuilder CreateWebHostBuilder(string[] args) => WebHost.CreateDefaultBuilder(args) .UseStartup(); diff --git a/PlanB.Butler.Bot/Startup.cs b/PlanB.Butler.Bot/Startup.cs index 06a263b..2c9c8fa 100644 --- a/PlanB.Butler.Bot/Startup.cs +++ b/PlanB.Butler.Bot/Startup.cs @@ -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; diff --git a/PlanB.Butler.Library/PlanB.Butler.Library/BackendCommunication.cs b/PlanB.Butler.Library/PlanB.Butler.Library/BackendCommunication.cs index 4a58b85..58f77f8 100644 --- a/PlanB.Butler.Library/PlanB.Butler.Library/BackendCommunication.cs +++ b/PlanB.Butler.Library/PlanB.Butler.Library/BackendCommunication.cs @@ -27,6 +27,7 @@ public class BackendCommunication /// The storage account URL. /// The storage account key. /// + [Obsolete("Call function instead")] public string GetDocument(string container, string resourceName, string storageAccountUrl, string storageAccountKey) { using (HttpClient httpClient = new HttpClient()) @@ -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}"; @@ -121,6 +123,7 @@ public HttpStatusCode PutDocument(string container, string resourceName, string /// Name of the queue. /// The service bus connection string. /// + [Obsolete("Call function instead")] public HttpStatusCode PutDocumentByteArray(string container, string resourceName, byte[] body, string queueName, string serviceBusConnectionString) { string label = $"{container}/{resourceName}"; @@ -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; diff --git a/PlanB.Butler.Library/PlanB.Butler.Library/BotModels/Order.cs b/PlanB.Butler.Library/PlanB.Butler.Library/BotModels/Order.cs index e8bbcf5..82a6bcb 100644 --- a/PlanB.Butler.Library/PlanB.Butler.Library/BotModels/Order.cs +++ b/PlanB.Butler.Library/PlanB.Butler.Library/BotModels/Order.cs @@ -21,8 +21,17 @@ public class Order public double Price { get; set; } + [Obsolete("Please use 'Quantity'")] public int Quantaty { get; set; } + /// + /// Gets or sets the quantity. + /// + /// + /// The quantity. + /// + public int Quantity { get; set; } + public double Grand { get; set; } } } diff --git a/PlanB.Butler.Services/PlanB.Butler.Services/Models/OrderModel.cs b/PlanB.Butler.Services/PlanB.Butler.Services/Models/OrderModel.cs index 0a6081d..ead99e6 100644 --- a/PlanB.Butler.Services/PlanB.Butler.Services/Models/OrderModel.cs +++ b/PlanB.Butler.Services/PlanB.Butler.Services/Models/OrderModel.cs @@ -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 { @@ -12,33 +11,7 @@ namespace PlanB.Butler.Services.Models public class OrderModel { /// - /// Gets or sets the company status Enum. - /// - public enum OrderRelationship - { - /// - /// External. - /// - External = 1, - - /// - /// Internal. - /// - Internal = 2, - - /// - /// Client. - /// - Client = 3, - - /// - /// Intership. - /// - Intership = 4, - } - - /// - /// Gets or sets the name. + /// Gets or sets the Relationship. /// /// /// The name. @@ -108,25 +81,5 @@ public enum OrderRelationship /// The benefit. /// 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 lookUpCompanyStatus = new Dictionary(); - // 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; - //} } } diff --git a/PlanB.Butler.Services/PlanB.Butler.Services/Models/OrderRelationship.cs b/PlanB.Butler.Services/PlanB.Butler.Services/Models/OrderRelationship.cs new file mode 100644 index 0000000..b7c267d --- /dev/null +++ b/PlanB.Butler.Services/PlanB.Butler.Services/Models/OrderRelationship.cs @@ -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 +{ + /// + /// OrderRelationship. + /// + public enum OrderRelationship + { + /// + /// External. + /// + External = 1, + + /// + /// Internal. + /// + Internal = 2, + + /// + /// Client. + /// + Client = 3, + + /// + /// Intership. + /// + Intership = 4, + } +}