Skip to content

Commit a4e3454

Browse files
committed
Add sample projects from the Microsoft Developer Meetup Regensburg
1 parent 7650df7 commit a4e3454

File tree

99 files changed

+7058
-0
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

99 files changed

+7058
-0
lines changed

examples/.gitignore

Lines changed: 83 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,83 @@
1+
# Visual Studio cache/options directory
2+
.vs/
3+
4+
# Build Folders (you can keep bin if you'd like, to store dlls and pdbs)
5+
[Bb]in/
6+
[Oo]bj/
7+
8+
# mstest test results
9+
TestResults
10+
11+
## Ignore Visual Studio temporary files, build results, and
12+
## files generated by popular Visual Studio add-ons.
13+
14+
# User-specific files
15+
*.suo
16+
*.user
17+
*.sln.docstates
18+
19+
# Build results
20+
[Dd]ebug/
21+
[Rr]elease/
22+
x64/
23+
*_i.c
24+
*_p.c
25+
*.ilk
26+
*.meta
27+
*.obj
28+
*.pch
29+
*.pdb
30+
*.pgc
31+
*.pgd
32+
*.rsp
33+
*.sbr
34+
*.tlb
35+
*.tli
36+
*.tlh
37+
*.tmp
38+
*.log
39+
*.vspscc
40+
*.vssscc
41+
.builds
42+
43+
# Visual Studio profiler
44+
*.psess
45+
*.vsp
46+
*.vspx
47+
48+
# Guidance Automation Toolkit
49+
*.gpState
50+
51+
# ReSharper
52+
_ReSharper*
53+
54+
# NCrunch
55+
*.ncrunch*
56+
.*crunch*.local.xml
57+
58+
# DocProject is a documentation generator add-in
59+
DocProject/buildhelp/
60+
DocProject/Help/*.HxT
61+
DocProject/Help/*.HxC
62+
DocProject/Help/*.hhc
63+
DocProject/Help/*.hhk
64+
DocProject/Help/*.hhp
65+
DocProject/Help/Html2
66+
DocProject/Help/html
67+
68+
# Others
69+
[Bb]in
70+
[Oo]bj
71+
sql
72+
TestResults
73+
[Tt]est[Rr]esult*
74+
*.Cache
75+
ClientBin
76+
~$*
77+
*.dbmdl
78+
79+
# Backup & report files from converting an old project file to a newer
80+
# Visual Studio version. Backup files are not needed, because we have git ;-)
81+
_UpgradeReport_Files/
82+
Backup*/
83+
UpgradeLog*.XML

examples/26FragenZurWurst.sln

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
2+
Microsoft Visual Studio Solution File, Format Version 12.00
3+
# Visual Studio Version 16
4+
VisualStudioVersion = 16.0.29403.142
5+
MinimumVisualStudioVersion = 10.0.40219.1
6+
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "26FragenZurWurst00", "26FragenZurWurst00\26FragenZurWurst00.csproj", "{855BF46F-5172-4B3D-8084-E9C224122FE0}"
7+
EndProject
8+
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "26FragenZurWurst01", "26FragenZurWurst01\26FragenZurWurst01.csproj", "{13101C13-F5A1-47E5-B2B7-FD8064C8B921}"
9+
EndProject
10+
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "26FragenZurWurst02", "26FragenZurWurst02\26FragenZurWurst02.csproj", "{29467917-D754-4CB9-8710-E40F7D0C477D}"
11+
EndProject
12+
Global
13+
GlobalSection(SolutionConfigurationPlatforms) = preSolution
14+
Debug|Any CPU = Debug|Any CPU
15+
Release|Any CPU = Release|Any CPU
16+
EndGlobalSection
17+
GlobalSection(ProjectConfigurationPlatforms) = postSolution
18+
{855BF46F-5172-4B3D-8084-E9C224122FE0}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
19+
{855BF46F-5172-4B3D-8084-E9C224122FE0}.Debug|Any CPU.Build.0 = Debug|Any CPU
20+
{855BF46F-5172-4B3D-8084-E9C224122FE0}.Release|Any CPU.ActiveCfg = Release|Any CPU
21+
{855BF46F-5172-4B3D-8084-E9C224122FE0}.Release|Any CPU.Build.0 = Release|Any CPU
22+
{13101C13-F5A1-47E5-B2B7-FD8064C8B921}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
23+
{13101C13-F5A1-47E5-B2B7-FD8064C8B921}.Debug|Any CPU.Build.0 = Debug|Any CPU
24+
{13101C13-F5A1-47E5-B2B7-FD8064C8B921}.Release|Any CPU.ActiveCfg = Release|Any CPU
25+
{13101C13-F5A1-47E5-B2B7-FD8064C8B921}.Release|Any CPU.Build.0 = Release|Any CPU
26+
{29467917-D754-4CB9-8710-E40F7D0C477D}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
27+
{29467917-D754-4CB9-8710-E40F7D0C477D}.Debug|Any CPU.Build.0 = Debug|Any CPU
28+
{29467917-D754-4CB9-8710-E40F7D0C477D}.Release|Any CPU.ActiveCfg = Release|Any CPU
29+
{29467917-D754-4CB9-8710-E40F7D0C477D}.Release|Any CPU.Build.0 = Release|Any CPU
30+
EndGlobalSection
31+
GlobalSection(SolutionProperties) = preSolution
32+
HideSolutionNode = FALSE
33+
EndGlobalSection
34+
GlobalSection(ExtensibilityGlobals) = postSolution
35+
SolutionGuid = {30ADE6CA-2A19-41B0-87DE-EB766036843A}
36+
EndGlobalSection
37+
EndGlobal
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
<Project Sdk="Microsoft.NET.Sdk.Web">
2+
3+
<PropertyGroup>
4+
<TargetFramework>netcoreapp2.1</TargetFramework>
5+
<LangVersion>latest</LangVersion>
6+
<AssemblyName>FragenZurWurst00</AssemblyName>
7+
<RootNamespace>FragenZurWurst00</RootNamespace>
8+
<Nullable>enable</Nullable>
9+
<TreatWarningsAsErrors>True</TreatWarningsAsErrors>
10+
</PropertyGroup>
11+
12+
<ItemGroup>
13+
<PackageReference Include="Microsoft.AspNetCore.App" />
14+
<PackageReference Include="Microsoft.Bot.Builder.Dialogs" Version="4.5.1" />
15+
<PackageReference Include="Microsoft.Bot.Builder.Integration.AspNet.Core" Version="4.5.1" />
16+
</ItemGroup>
17+
18+
<ItemGroup>
19+
<Content Update="appsettings.json">
20+
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
21+
</Content>
22+
</ItemGroup>
23+
24+
<ItemGroup>
25+
<Folder Include="Dialogs\" />
26+
</ItemGroup>
27+
28+
</Project>
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
// Copyright (c) Microsoft Corporation. All rights reserved.
2+
// Licensed under the MIT License.
3+
4+
using System;
5+
using Microsoft.Bot.Builder;
6+
using Microsoft.Bot.Builder.Integration.AspNet.Core;
7+
using Microsoft.Extensions.Configuration;
8+
using Microsoft.Extensions.Logging;
9+
10+
namespace FragenZurWurst
11+
{
12+
public class AdapterWithErrorHandler : BotFrameworkHttpAdapter
13+
{
14+
public AdapterWithErrorHandler(IConfiguration configuration, ILogger<BotFrameworkHttpAdapter> logger)
15+
: base(configuration, logger)
16+
{
17+
OnTurnError = async (turnContext, exception) =>
18+
{
19+
// Log any leaked exception from the application.
20+
logger.LogError($"Exception caught : {exception.Message}");
21+
22+
// Send a catch-all apology to the user.
23+
await turnContext.SendActivityAsync("Sorry, it looks like something went wrong.");
24+
};
25+
}
26+
}
27+
}
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
using FragenZurWurst.Model;
2+
using Microsoft.Bot.Builder;
3+
using System.Threading.Tasks;
4+
5+
namespace FragenZurWurst.Bot
6+
{
7+
internal static class ConversationStateExtensions
8+
{
9+
public static async Task<Order> GetOrder(this ConversationState conversationState, ITurnContext turnContext)
10+
{
11+
var accessor = conversationState.CreateProperty<Order>(nameof(Order));
12+
return await accessor.GetAsync(turnContext, () => new Order());
13+
}
14+
}
15+
}
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
using System.Collections.Generic;
2+
using System.Threading;
3+
using System.Threading.Tasks;
4+
using Microsoft.Bot.Builder;
5+
using Microsoft.Bot.Builder.Dialogs;
6+
using Microsoft.Bot.Schema;
7+
8+
namespace FragenZurWurst.Bot
9+
{
10+
public class DialogAndWelcomeBot<T> : DialogBot<T> where T : Dialog
11+
{
12+
public DialogAndWelcomeBot(ConversationState conversationState, UserState userState, T dialog)
13+
: base(conversationState, userState, dialog)
14+
{
15+
}
16+
17+
protected override async Task OnMembersAddedAsync(
18+
IList<ChannelAccount> membersAdded,
19+
ITurnContext<IConversationUpdateActivity> turnContext,
20+
CancellationToken cancellationToken)
21+
{
22+
foreach (var member in membersAdded)
23+
{
24+
if (member.Id != turnContext.Activity.Recipient.Id)
25+
{
26+
var reply = MessageFactory.Text("Seas! I bin CurryWursch26, wöltweit da beste Currywurscht-Bot! Ba mia koanst du a gschmackige Currywurscht b'stelln, natiarli mit Senf und oder Ketchup und Gurkerl oder Pfeffaroni.");
27+
28+
await turnContext.SendActivityAsync(reply, cancellationToken);
29+
30+
await Dialog.RunAsync(turnContext, ConversationState.CreateProperty<DialogState>("DialogState"), cancellationToken);
31+
}
32+
}
33+
}
34+
}
35+
}
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
using System.Threading;
2+
using System.Threading.Tasks;
3+
using Microsoft.Bot.Builder;
4+
using Microsoft.Bot.Builder.Dialogs;
5+
using Microsoft.Bot.Schema;
6+
7+
namespace FragenZurWurst.Bot
8+
{
9+
public class DialogBot<T> : ActivityHandler where T : Dialog
10+
{
11+
protected readonly BotState ConversationState;
12+
protected readonly Dialog Dialog;
13+
protected readonly BotState UserState;
14+
15+
public DialogBot(ConversationState conversationState, UserState userState, T dialog)
16+
{
17+
ConversationState = conversationState;
18+
UserState = userState;
19+
Dialog = dialog;
20+
}
21+
22+
public override async Task OnTurnAsync(ITurnContext turnContext, CancellationToken cancellationToken)
23+
{
24+
await base.OnTurnAsync(turnContext, cancellationToken);
25+
26+
await ConversationState.SaveChangesAsync(turnContext, false, cancellationToken);
27+
await UserState.SaveChangesAsync(turnContext, false, cancellationToken);
28+
}
29+
30+
protected override async Task OnMessageActivityAsync(ITurnContext<IMessageActivity> turnContext, CancellationToken cancellationToken)
31+
{
32+
await Dialog.RunAsync(turnContext, ConversationState.CreateProperty<DialogState>(nameof(DialogState)), cancellationToken);
33+
}
34+
}
35+
}
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
using System.Collections.Generic;
2+
using System.Threading;
3+
using System.Threading.Tasks;
4+
using FragenZurWurst.Dialogs;
5+
using Microsoft.Bot.Builder;
6+
using Microsoft.Bot.Schema;
7+
8+
namespace FragenZurWurst.Bot
9+
{
10+
public class FragenZurWurstBot : DialogAndWelcomeBot<MainDialog>
11+
{
12+
public FragenZurWurstBot(ConversationState conversationState, UserState userState, MainDialog dialog) : base(conversationState, userState, dialog)
13+
{
14+
}
15+
}
16+
}
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
// Copyright (c) Microsoft Corporation. All rights reserved.
2+
// Licensed under the MIT License.
3+
//
4+
// Generated with Bot Builder V4 SDK Template for Visual Studio EchoBot v4.5.0
5+
6+
using System.Threading.Tasks;
7+
using Microsoft.AspNetCore.Mvc;
8+
using Microsoft.Bot.Builder;
9+
using Microsoft.Bot.Builder.Integration.AspNet.Core;
10+
11+
namespace FragenZurWurst.Controllers
12+
{
13+
// This ASP Controller is created to handle a request. Dependency Injection will provide the Adapter and IBot
14+
// implementation at runtime. Multiple different IBot implementations running at different endpoints can be
15+
// achieved by specifying a more specific type for the bot constructor argument.
16+
[Route("api/messages")]
17+
[ApiController]
18+
public class BotController : ControllerBase
19+
{
20+
private readonly IBotFrameworkHttpAdapter Adapter;
21+
private readonly IBot Bot;
22+
23+
public BotController(IBotFrameworkHttpAdapter adapter, IBot bot)
24+
{
25+
Adapter = adapter;
26+
Bot = bot;
27+
}
28+
29+
[HttpPost]
30+
public async Task PostAsync()
31+
{
32+
// Delegate the processing of the HTTP POST to the adapter.
33+
// The adapter will invoke the bot.
34+
await Adapter.ProcessAsync(Request, Response, Bot);
35+
}
36+
}
37+
}
Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
{
2+
"$schema": "https://schema.management.azure.com/schemas/2015-01-01/deploymentParameters.json#",
3+
"contentVersion": "1.0.0.0",
4+
"parameters": {
5+
"groupLocation": {
6+
"value": ""
7+
},
8+
"groupName": {
9+
"value": ""
10+
},
11+
"appId": {
12+
"value": ""
13+
},
14+
"appSecret": {
15+
"value": ""
16+
},
17+
"botId": {
18+
"value": ""
19+
},
20+
"botSku": {
21+
"value": ""
22+
},
23+
"newAppServicePlanName": {
24+
"value": ""
25+
},
26+
"newAppServicePlanSku": {
27+
"value": {
28+
"name": "S1",
29+
"tier": "Standard",
30+
"size": "S1",
31+
"family": "S",
32+
"capacity": 1
33+
}
34+
},
35+
"newAppServicePlanLocation": {
36+
"value": ""
37+
},
38+
"newWebAppName": {
39+
"value": ""
40+
}
41+
}
42+
}

0 commit comments

Comments
 (0)