From 25a637b89af431a67c9e080b0c2d095b266e28c7 Mon Sep 17 00:00:00 2001 From: Tommy Parnell Date: Mon, 5 Dec 2016 17:25:14 -0500 Subject: [PATCH] init --- NeverHaveIEver/AlexaResponse.cs | 58 ++++++ NeverHaveIEver/ApplicationInsights.config | 87 +++++++++ NeverHaveIEver/Controllers/AlexaController.cs | 32 ++++ .../Controllers/ValuesController.cs | 39 ---- NeverHaveIEver/Items.cs | 170 ++++++++++++++++++ NeverHaveIEver/NeverHaveIEver.csproj | 101 ++++++++--- .../PublishProfiles/NeverHaveIEver.pubxml | 25 +++ .../ConnectedService.json | 7 + NeverHaveIEver/Web.config | 33 +++- NeverHaveIEver/packages.config | 29 +-- 10 files changed, 499 insertions(+), 82 deletions(-) create mode 100644 NeverHaveIEver/AlexaResponse.cs create mode 100644 NeverHaveIEver/ApplicationInsights.config create mode 100644 NeverHaveIEver/Controllers/AlexaController.cs delete mode 100644 NeverHaveIEver/Controllers/ValuesController.cs create mode 100644 NeverHaveIEver/Items.cs create mode 100644 NeverHaveIEver/Properties/PublishProfiles/NeverHaveIEver.pubxml create mode 100644 NeverHaveIEver/Service References/Application Insights/ConnectedService.json diff --git a/NeverHaveIEver/AlexaResponse.cs b/NeverHaveIEver/AlexaResponse.cs new file mode 100644 index 0000000..ea859a5 --- /dev/null +++ b/NeverHaveIEver/AlexaResponse.cs @@ -0,0 +1,58 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Web; +using AlexaSkillsKit.Authentication; +using AlexaSkillsKit.Json; +using AlexaSkillsKit.Speechlet; +using AlexaSkillsKit.UI; + +namespace NeverHaveIEver +{ + public class AlexaResponse : Speechlet + { + + + public override SpeechletResponse OnIntent(IntentRequest intentRequest, Session session) + { + return CompileResponse(); + } + + public override SpeechletResponse OnLaunch(LaunchRequest launchRequest, Session session) + { + return CompileResponse(); + } + + public override bool OnRequestValidation(SpeechletRequestValidationResult result, DateTime referenceTimeUtc, SpeechletRequestEnvelope requestEnvelope) + { + if(requestEnvelope?.Session?.Application?.Id?.Equals("amzn1.ask.skill.77ffa04a-699d-452d-b8d5-4c128079a1b2") == false) + { + return false; + } + return base.OnRequestValidation(result, referenceTimeUtc, requestEnvelope); + } + + public override void OnSessionEnded(SessionEndedRequest sessionEndedRequest, Session session) + { + } + + public override void OnSessionStarted(SessionStartedRequest sessionStartedRequest, Session session) + { + } + public static SpeechletResponse CompileResponse() + { + var excuse = GetExcuse(); + return new SpeechletResponse() + { + OutputSpeech = new PlainTextOutputSpeech() { Text = excuse }, + ShouldEndSession = true + }; + } + public static string GetExcuse() + { + // Setup the configuration to support document loading + var item = new Random().Next(0, Items.ItemsList.Count); + return Items.ItemsList[item]; + } + } +} \ No newline at end of file diff --git a/NeverHaveIEver/ApplicationInsights.config b/NeverHaveIEver/ApplicationInsights.config new file mode 100644 index 0000000..5f7d215 --- /dev/null +++ b/NeverHaveIEver/ApplicationInsights.config @@ -0,0 +1,87 @@ + + + f004b00c-ab25-4e1e-a97a-8368fb72aa8b + + + + + + + + + + + + + System.Web.Handlers.TransferRequestHandler + Microsoft.VisualStudio.Web.PageInspector.Runtime.Tracing.RequestDataHttpHandler + System.Web.StaticFileHandler + System.Web.Handlers.AssemblyResourceLoader + System.Web.Optimization.BundleHandler + System.Web.Script.Services.ScriptHandlerFactory + System.Web.Handlers.TraceHandler + System.Web.Services.Discovery.DiscoveryRequestHandler + System.Web.HttpDebugHandler + + + + + + + + 5 + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/NeverHaveIEver/Controllers/AlexaController.cs b/NeverHaveIEver/Controllers/AlexaController.cs new file mode 100644 index 0000000..23a3d5e --- /dev/null +++ b/NeverHaveIEver/Controllers/AlexaController.cs @@ -0,0 +1,32 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Net; +using System.Net.Http; +using System.Web.Http; + +namespace NeverHaveIEver.Controllers +{ + public class AlexaController : ApiController + { + [Route("")] + [HttpGet] + [HttpHead] + public IHttpActionResult root() + { + return this.Ok($"Yo, {Items.ItemsList.Count} items"); + } + [Route("")] + [HttpPost] + public HttpResponseMessage Post() + { + return new AlexaResponse().GetResponse(this.Request); + } + [Route("excuse")] + [HttpGet] + public string GetExcuse() + { + return AlexaResponse.GetExcuse(); + } + } +} diff --git a/NeverHaveIEver/Controllers/ValuesController.cs b/NeverHaveIEver/Controllers/ValuesController.cs deleted file mode 100644 index ff6118f..0000000 --- a/NeverHaveIEver/Controllers/ValuesController.cs +++ /dev/null @@ -1,39 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Net; -using System.Net.Http; -using System.Web.Http; - -namespace NeverHaveIEver.Controllers -{ - public class ValuesController : ApiController - { - // GET api/values - public IEnumerable Get() - { - return new string[] { "value1", "value2" }; - } - - // GET api/values/5 - public string Get(int id) - { - return "value"; - } - - // POST api/values - public void Post([FromBody]string value) - { - } - - // PUT api/values/5 - public void Put(int id, [FromBody]string value) - { - } - - // DELETE api/values/5 - public void Delete(int id) - { - } - } -} diff --git a/NeverHaveIEver/Items.cs b/NeverHaveIEver/Items.cs new file mode 100644 index 0000000..d3933a2 --- /dev/null +++ b/NeverHaveIEver/Items.cs @@ -0,0 +1,170 @@ +using System.Collections.Generic; + +namespace NeverHaveIEver +{ + public static class Items + { + //not normally thread safe, but multiple reads are ok, just no writes + public static List ItemsList = new List() + { + "Been Arrested", + "Been in handcuffs", + "injured myself while trying to impress a girl or boy I was interested in.", + + "had to run to save my life.", + + "taken food out of a trash can and eaten it.", + + "cried / flirted my way out of a speeding ticket.", + + "taken part in a talent show.", + + "made money by performing on the street.", + + "broken something at a friend’s house and then not told them.", + + "snooped through a friend’s bathroom or bedroom without them knowing.", + + "ruined someone else’s vacation.", + + "walked for more than six hours.", + + "jumped from a roof.", + + "shoplifted.", + + "seen an alligator or crocodile in the wild.", + + "set my or someone else’s hair on fire on purpose.", + + "ridden an animal.", + + "had a bad fall because I was walking and texting.", + + "been arrested.", + + "pressured someone into getting a tattoo or piercing.", + + "gone surfing.", + + "walked out of a movie because it was bad.", + + "broken a bone.", + + "tried to cut my own hair.", + + "completely forgot my lines in a play.", + + "shot a gun.", + + "had a surprise party thrown for me.", + + "cheated on a test.", + + "dined and dashed.", + + "gotten stitches.", + + "fallen in love at first sight.", + + "had a paranormal experience.", + + "woken up and couldn’t move.", + + "accidentally said “I love you” to someone.", + + "hitchhiked.", + + "been trapped in an elevator.", + + "sung karaoke in front of people.", + + "been on TV or the radio.", + + "pressed send and then immediately regretted it.", + + "been so sun burnt I couldn’t wear a shirt.", + + "had a crush on a friend’s parent.", + + "been awake for two days straight.", + + "thrown up on a roller coaster.", + + "snuck into a movie.", + + "accidentally sent someone to the hospital.", + + "dyed my hair a crazy color.", + + "had a physical fight with my best friend.", + + "fallen in love at first sight.", + + "had someone slap me across the face.", + + "worked with someone I hated with the burning passion of a thousand suns.", + + "danced in an elevator.", + + "cried in public because of a song.", + + "texted for four hours straight.", + + "chipped a tooth.", + + "gone hunting.", + + "had a tree house.", + + "thrown something into a TV or computer screen.", + + "been to a country in Asia.", + + "been screamed at by a customer at my job.", + + "spent a night in the woods with no shelter.", + + "read a whole novel in one day.", + + "gone vegan.", + + "been without heat for a winter or without A/C for a summer.", + + "worn glasses without lenses.", + + "gone scuba diving.", + + "lied about a family member dying as an excuse to get out of doing something.", + + "bungee jumped.", + + "been to a country in Africa.", + + "been on a fad diet.", + + "been to a fashion show.", + + "been electrocuted.", + + "stolen something from a restaurant.", + + "had a bad allergic reaction.", + + "been in an embarrassing video that was uploaded to YouTube.", + + "thought I was going to drown.", + + "worked at a fast food restaurant.", + + "fainted.", + + "looked through someone else’s phone without their permission.", + "Skipped School", + "lied to get a job", + "Woken up drunk", + "lied about my birthday just to get a free dessert", + "gone a week without showering" + }; + } +} \ No newline at end of file diff --git a/NeverHaveIEver/NeverHaveIEver.csproj b/NeverHaveIEver/NeverHaveIEver.csproj index 582c5ec..32a9d4d 100644 --- a/NeverHaveIEver/NeverHaveIEver.csproj +++ b/NeverHaveIEver/NeverHaveIEver.csproj @@ -12,13 +12,15 @@ Properties NeverHaveIEver NeverHaveIEver - v4.5.2 + v4.6.2 true + /subscriptions/6332a4fe-3d5b-4857-9206-6dedd406f451/resourcegroups/Default-ApplicationInsights-EastUS/providers/microsoft.insights/components/NeverHaveIEver + true @@ -38,72 +40,121 @@ 4 + + ..\packages\AlexaSkillsKit.NET.1.5.1\lib\net45\AlexaSkillsKit.dll + True + + + ..\packages\BouncyCastle.1.8.1\lib\BouncyCastle.Crypto.dll + True + + + ..\packages\Microsoft.ApplicationInsights.Agent.Intercept.1.2.1\lib\net45\Microsoft.AI.Agent.Intercept.dll + True + + + ..\packages\Microsoft.ApplicationInsights.DependencyCollector.2.1.0\lib\net45\Microsoft.AI.DependencyCollector.dll + True + + + ..\packages\Microsoft.ApplicationInsights.PerfCounterCollector.2.1.0\lib\net45\Microsoft.AI.PerfCounterCollector.dll + True + + + ..\packages\Microsoft.ApplicationInsights.WindowsServer.TelemetryChannel.2.1.0\lib\net45\Microsoft.AI.ServerTelemetryChannel.dll + True + + + ..\packages\Microsoft.ApplicationInsights.Web.2.1.0\lib\net45\Microsoft.AI.Web.dll + True + + + ..\packages\Microsoft.ApplicationInsights.WindowsServer.2.1.0\lib\net45\Microsoft.AI.WindowsServer.dll + True + + + ..\packages\Microsoft.ApplicationInsights.2.1.0\lib\net46\Microsoft.ApplicationInsights.dll + True + - True ..\packages\Microsoft.Web.Infrastructure.1.0.0.0\lib\net40\Microsoft.Web.Infrastructure.dll + True - + + ..\packages\Newtonsoft.Json.7.0.1\lib\net45\Newtonsoft.Json.dll + True + + ..\packages\Swashbuckle.Core.5.0.0\lib\net40\Swashbuckle.Core.dll + True - + + ..\packages\System.IdentityModel.Tokens.Jwt.4.0.0\lib\net45\System.IdentityModel.Tokens.Jwt.dll + True + + ..\packages\Microsoft.AspNet.WebApi.Client.5.2.3\lib\net45\System.Net.Http.Formatting.dll + True + - - - + + ..\packages\Microsoft.AspNet.WebApi.Core.5.2.3\lib\net45\System.Web.Http.dll + True + + + ..\packages\Microsoft.AspNet.WebApi.WebHost.5.2.3\lib\net45\System.Web.Http.WebHost.dll + True + + + ..\packages\WebActivatorEx.2.0.6\lib\net40\WebActivatorEx.dll + True + - - ..\packages\WebActivatorEx.2.0.6\lib\net40\WebActivatorEx.dll - - - ..\packages\Newtonsoft.Json.6.0.4\lib\net45\Newtonsoft.Json.dll - - - ..\packages\Microsoft.AspNet.WebApi.Client.5.2.3\lib\net45\System.Net.Http.Formatting.dll - - - ..\packages\Microsoft.AspNet.WebApi.Core.5.2.3\lib\net45\System.Web.Http.dll - - - ..\packages\Microsoft.AspNet.WebApi.WebHost.5.2.3\lib\net45\System.Web.Http.WebHost.dll - + + + PreserveNewest + - + + + Global.asax + + Web.config @@ -111,7 +162,9 @@ Web.config - + + + 10.0 $(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion) diff --git a/NeverHaveIEver/Properties/PublishProfiles/NeverHaveIEver.pubxml b/NeverHaveIEver/Properties/PublishProfiles/NeverHaveIEver.pubxml new file mode 100644 index 0000000..23f4554 --- /dev/null +++ b/NeverHaveIEver/Properties/PublishProfiles/NeverHaveIEver.pubxml @@ -0,0 +1,25 @@ + + + + + MSDeploy + AzureWebSite + Release + Any CPU + http://neverhaveiever.azurewebsites.net + True + False + neverhaveiever.scm.azurewebsites.net:443 + NeverHaveIEver + + True + WMSVC + True + $NeverHaveIEver + <_SavePWD>True + <_DestinationType>AzureWebSite + + \ No newline at end of file diff --git a/NeverHaveIEver/Service References/Application Insights/ConnectedService.json b/NeverHaveIEver/Service References/Application Insights/ConnectedService.json new file mode 100644 index 0000000..1ed737b --- /dev/null +++ b/NeverHaveIEver/Service References/Application Insights/ConnectedService.json @@ -0,0 +1,7 @@ +{ + "ProviderId": "Microsoft.ApplicationInsights.ConnectedService.ConnectedServiceProvider", + "Version": "7.14.1128.2", + "GettingStartedDocument": { + "Uri": "https://go.microsoft.com/fwlink/?LinkID=613413" + } +} \ No newline at end of file diff --git a/NeverHaveIEver/Web.config b/NeverHaveIEver/Web.config index 9b973f7..76c7e70 100644 --- a/NeverHaveIEver/Web.config +++ b/NeverHaveIEver/Web.config @@ -4,25 +4,40 @@ http://go.microsoft.com/fwlink/?LinkId=301879 --> - - + + - - + + + + + - + + + + + + + - - + - + @@ -34,4 +49,4 @@ - + \ No newline at end of file diff --git a/NeverHaveIEver/packages.config b/NeverHaveIEver/packages.config index 0cc51ec..4977690 100644 --- a/NeverHaveIEver/packages.config +++ b/NeverHaveIEver/packages.config @@ -1,13 +1,22 @@  - - - - - - - - - - + + + + + + + + + + + + + + + + + + + \ No newline at end of file