diff --git a/alexa.dev.excuses/ApplicationInsights.config b/alexa.dev.excuses/ApplicationInsights.config new file mode 100644 index 0000000..66d2388 --- /dev/null +++ b/alexa.dev.excuses/ApplicationInsights.config @@ -0,0 +1,87 @@ + + + 69bdd5ac-c992-4daa-89c9-7af1dbd09249 + + + + + + + + + + + + + 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/alexa.dev.excuses/Controllers/AlexaController.cs b/alexa.dev.excuses/Controllers/AlexaController.cs new file mode 100644 index 0000000..1be713f --- /dev/null +++ b/alexa.dev.excuses/Controllers/AlexaController.cs @@ -0,0 +1,26 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Net; +using System.Net.Http; +using System.Threading.Tasks; +using System.Web.Http; + +namespace alexa.dev.excuses.Controllers +{ + public class AlexaController : ApiController + { + [Route("")] + [HttpPost] + public Task Post() + { + return new ExcuseResponse().GetResponseAsync(this.Request); + } + [Route("excuse")] + [HttpGet] + public Task GetExcuse() + { + return ExcuseResponse.GetExcuses(); + } + } +} diff --git a/alexa.dev.excuses/Controllers/ValuesController.cs b/alexa.dev.excuses/Controllers/ValuesController.cs deleted file mode 100644 index 6d572ab..0000000 --- a/alexa.dev.excuses/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 alexa.dev.excuses.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/alexa.dev.excuses/ExcuseResponse.cs b/alexa.dev.excuses/ExcuseResponse.cs new file mode 100644 index 0000000..82645eb --- /dev/null +++ b/alexa.dev.excuses/ExcuseResponse.cs @@ -0,0 +1,74 @@ +using AlexaSkillsKit.Speechlet; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Web; +using AlexaSkillsKit.Authentication; +using AlexaSkillsKit.Json; +using System.Threading.Tasks; +using AlexaSkillsKit.UI; +using AngleSharp; + +namespace alexa.dev.excuses +{ + public class ExcuseResponse : SpeechletAsync + { + + + public override Task OnIntentAsync(IntentRequest intentRequest, Session session) + { + return CompileResponse(); + } + + public override Task OnLaunchAsync(LaunchRequest launchRequest, Session session) + { + return CompileResponse(); + } + + public override Task OnSessionEndedAsync(SessionEndedRequest sessionEndedRequest, Session session) + { + return Task.FromResult(0); + } + + public override Task OnSessionStartedAsync(SessionStartedRequest sessionStartedRequest, Session session) + { + return Task.FromResult(0); + } + public Task CompileResponse() + { + return GetExcuses().ContinueWith(a => + new SpeechletResponse() + { + OutputSpeech = new PlainTextOutputSpeech() { Text = a.GetAwaiter().GetResult() } + }); + } + public static async Task GetExcuses() + { + // Setup the configuration to support document loading + var config = Configuration.Default.WithDefaultLoader(); + // Load the names of all The Big Bang Theory episodes from Wikipedia + var rando = 1; + string address = null; + if (rando == 0) + { + address = "http://programmingexcuses.com/"; + } + if(rando == 1) + { + address = "http://www.devexcuses.com/"; + } + if(address == null) + { + throw new Exception("Something really wrong with the rando generator"); + } + // Asynchronously get the document in a new context using the configuration + var document = await BrowsingContext.New(config).OpenAsync(address); + // This CSS selector gets the desired content + var cellSelector = "a"; + // Perform the query to get all cells with the content + var cells = document.QuerySelectorAll(cellSelector); + // We are only interested in the text - select it with LINQ + return cells.First().TextContent; + } + } +} \ No newline at end of file diff --git a/alexa.dev.excuses/Properties/PublishProfiles/tparnelldevexcuses.pubxml b/alexa.dev.excuses/Properties/PublishProfiles/tparnelldevexcuses.pubxml new file mode 100644 index 0000000..1e84de3 --- /dev/null +++ b/alexa.dev.excuses/Properties/PublishProfiles/tparnelldevexcuses.pubxml @@ -0,0 +1,25 @@ + + + + + MSDeploy + AzureWebSite + Release + Any CPU + http://tparnelldevexcuses.azurewebsites.net + True + False + tparnelldevexcuses.scm.azurewebsites.net:443 + tparnelldevexcuses + + True + WMSVC + True + $tparnelldevexcuses + <_SavePWD>True + <_DestinationType>AzureWebSite + + \ No newline at end of file diff --git a/alexa.dev.excuses/Service References/Application Insights/ConnectedService.json b/alexa.dev.excuses/Service References/Application Insights/ConnectedService.json new file mode 100644 index 0000000..1ed737b --- /dev/null +++ b/alexa.dev.excuses/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/alexa.dev.excuses/Web.config b/alexa.dev.excuses/Web.config index 9b973f7..9f69995 100644 --- a/alexa.dev.excuses/Web.config +++ b/alexa.dev.excuses/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/alexa.dev.excuses/alexa.dev.excuses.csproj b/alexa.dev.excuses/alexa.dev.excuses.csproj index c81438a..ba5cb36 100644 --- a/alexa.dev.excuses/alexa.dev.excuses.csproj +++ b/alexa.dev.excuses/alexa.dev.excuses.csproj @@ -12,13 +12,15 @@ Properties alexa.dev.excuses alexa.dev.excuses - v4.5.2 + v4.6.2 true + /subscriptions/6332a4fe-3d5b-4857-9206-6dedd406f451/resourcegroups/WebResourceGroup/providers/microsoft.insights/components/alexa.dev.excuses + true @@ -38,72 +40,124 @@ 4 + + ..\packages\AlexaSkillsKit.NET.1.5.1\lib\net45\AlexaSkillsKit.dll + True + + + ..\packages\AngleSharp.0.9.9\lib\net45\AngleSharp.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 +165,9 @@ Web.config - + + + 10.0 $(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion) diff --git a/alexa.dev.excuses/packages.config b/alexa.dev.excuses/packages.config index 0cc51ec..fbe1c61 100644 --- a/alexa.dev.excuses/packages.config +++ b/alexa.dev.excuses/packages.config @@ -1,13 +1,23 @@  - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + \ No newline at end of file