public DynamoDBEntry ToEntry(object value) { Monitor_Video_Source MonVidSrc = value as Monitor_Video_Source; if (MonVidSrc == null) { throw new ArgumentOutOfRangeException(); } //string data = string.Format("\"DeviceType\":\"{1}\"{0}\"Instance\":\"{2}\"{0}\"MonitorLocation\":\"{3}\"", ",", //MonVidSrc.DeviceType, MonVidSrc.Instance.ToString(), MonVidSrc.MonitorLocation); string data = JsonConvert.SerializeObject(MonVidSrc); DynamoDBEntry entry = new Primitive { Value = data }; return(entry); }
public object FromEntry(DynamoDBEntry entry) { Primitive primitive = entry as Primitive; if (primitive == null || !(primitive.Value is String) || string.IsNullOrEmpty((string)primitive.Value)) { throw new ArgumentOutOfRangeException(); } string[] data = ((string)(primitive.Value)).Split(new string[] { " x " }, StringSplitOptions.None); if (data.Length != 3) { throw new ArgumentOutOfRangeException(); } Monitor_Video_Source complexData = new Monitor_Video_Source { DeviceType = data[0], Instance = Convert.ToInt32(data[1]), MonitorLocation = data[2] }; return(complexData); }
async public override Task <SkillResponse> HandleIntentRequest(IntentRequest request) { var log = curContext.Logger; slots = request.Intent.Slots; Slot monAirshowSlot = null; Slot monLocSlot = null; if (slots.ContainsKey(MONAIRSHOW)) { monAirshowSlot = slots[MONAIRSHOW]; log.LogLine($"Slot : Monitor_Video_Src : Value -" + monAirshowSlot.Value); } if (slots.ContainsKey(MONITORLOC)) { monLocSlot = slots[MONITORLOC]; log.LogLine($"Slot : Monitor_Loc : Value - " + monLocSlot.Value); } //if (String.IsNullOrEmpty(monVidSrcSlot.Value) || String.IsNullOrWhiteSpace(monVidSrcSlot.Value)) //{ // log.LogLine($"Dialog State - " + request.DialogState); // // Using Alexa sdk's DialogDelegate // dlgElicitSlot = new DialogElicitSlot(monVidSrcSlot.Name); // outSpeech = new PlainTextOutputSpeech(); // (outSpeech as PlainTextOutputSpeech).Text = "Ok!. I can help you on that!. Tell me the name of the video source that you wanted to watch. " + "You can say, " + vidSrcHandler.GetRandomVidSrcName() + ", or , " + vidSrcHandler.GetRandomVidSrcName(); // dlgElicitSlot.UpdatedIntent = request.Intent; // skillResponse.Response.Directives.Add(dlgElicitSlot); // skillResponse.Response.OutputSpeech = outSpeech; // return skillResponse; //} //else if (String.IsNullOrEmpty(monLocSlot.Value) || String.IsNullOrWhiteSpace(monLocSlot.Value)) //{ // dlgElicitSlot = new DialogElicitSlot(monLocSlot.Name); // outSpeech = new PlainTextOutputSpeech(); // (outSpeech as PlainTextOutputSpeech).Text = "Tell me the location of the monitor where you wanted to watch " + monVidSrcSlot.Value + ". You can say, forward, or, Aft!"; // dlgElicitSlot.UpdatedIntent = request.Intent; // skillResponse.Response.Directives.Add(dlgElicitSlot); // skillResponse.Response.OutputSpeech = outSpeech; // return skillResponse; //} //if (!vidSrcHandler.IsConfigured(monVidSrcSlot.Value.ToLower())) //{ // log.LogLine($"Not Configured - " + monVidSrcSlot.Value); // dlgElicitSlot = new DialogElicitSlot(monVidSrcSlot.Name); // outSpeech = new PlainTextOutputSpeech(); // StringBuilder vidSources = new StringBuilder(); // vidSrcHandler.GetAvailableVidSources().ForEach(vidSrc => vidSources.AppendLine(vidSrc)); // (outSpeech as PlainTextOutputSpeech).Text = monVidSrcSlot.Value + " is not available on your aircraft! " + "Currently available video sources are \n" + vidSources.ToString(); // dlgElicitSlot.UpdatedIntent = request.Intent; // skillResponse.Response.Directives.Add(dlgElicitSlot); // skillResponse.Response.OutputSpeech = outSpeech; // return skillResponse; //} //else //{ Monitor_Video_Source monAirshowModeMsg = new Monitor_Video_Source { DeviceType = vidSrcHandler.ConfiguredVidSrcList[monAirshowSlot.Value.ToLower()].DeviceType, Instance = vidSrcHandler.ConfiguredVidSrcList[monAirshowSlot.Value.ToLower()].Instance, MonitorLocation = monLocSlot.Value }; AlexaMsg msg = new AlexaMsg { ID = 1010, IntentName = request.Intent.Name, Slot = monAirshowModeMsg }; await DynamoDB.PutAlexaMsg(msg); outSpeech = new PlainTextOutputSpeech(); (outSpeech as PlainTextOutputSpeech).Text = "Alright. " + monAirshowSlot.Value + " Airshow mode is pushed on " + monLocSlot.Value + " Monitor. Have a nice flight!"; //(outSpeech as PlainTextOutputSpeech).Text = "Have a nice flight!."; skillResponse.Response.OutputSpeech = outSpeech; skillResponse.Response.ShouldEndSession = true; //} return(skillResponse); }