public override IQuery GetHsql(Object data) { StringBuilder sql = new StringBuilder("select a from NodeRoute a where "); NodeRoute noderoute = (NodeRoute)data; if (noderoute != null) { Parms = new List <Object[]>(); if (noderoute.RowID != 0) { sql.Append(" a.RowID = :id and "); Parms.Add(new Object[] { "id", noderoute.RowID }); } if (noderoute.NextNode != null && noderoute.NextNode.NodeID != 0) { sql.Append(" a.NextNode.NodeID = :id1 and "); Parms.Add(new Object[] { "id1", noderoute.NextNode.NodeID }); } if (noderoute.CurNode != null && noderoute.CurNode.NodeID != 0) { sql.Append(" a.CurNode.NodeID = :id2 and "); Parms.Add(new Object[] { "id2", noderoute.CurNode.NodeID }); } } sql = new StringBuilder(sql.ToString()); sql.Append("1=1 order by a.RowID asc "); IQuery query = Factory.Session.CreateQuery(sql.ToString()); SetParameters(query); return(query); }
protected override void AddItem() { IMainForm mainForm = Instances.MainForm; // Show the new account. NodeRoute newNode = new NodeRoute(0, ""); mainForm.ShowItem(newNode); }
public IList <NodeRoute> Select(NodeRoute data) { IList <NodeRoute> datos = new List <NodeRoute>(); datos = GetHsql(data).List <NodeRoute>(); if (!Factory.IsTransactional) { Factory.Commit(); } return(datos); }
public Boolean ValidateNodeRoute(Label label, Node node, Boolean autoThrow) { NodeRoute nodeRoute = new NodeRoute { NextNode = node, CurNode = label.Node }; if (Factory.DaoNodeRoute().Select(nodeRoute).Count == 0) { if (autoThrow) { Factory.Rollback(); throw new Exception("Transaction from " + label.Node.Name + " to " + node.Name + " not allowed."); } else { return(false); } } return(true); }
public void DeleteNodeRoute(NodeRoute data) { try { SetService(); SerClient.DeleteNodeRoute(data); } finally { SerClient.Close(); if (SerClient.State == CommunicationState.Faulted) SerClient.Abort(); } }
public NodeRoute SaveNodeRoute(NodeRoute data) { try { SetService(); return SerClient.SaveNodeRoute(data); } finally { SerClient.Close(); if (SerClient.State == CommunicationState.Faulted) SerClient.Abort(); } }
public void BuildStoryNode() { Adventure adv = new Adventure(); adv.VoiceId = Amazon.Polly.VoiceId.Joey.Value; adv.VoiceId = Amazon.Polly.VoiceId.Emma; AdventureNode startNode = new AdventureNode(); startNode.Name = "PathStart"; startNode.OutputSpeech = new List <SpeechFragement>(); string fullIntro = "You stand on a mountain side overlooking a slope that descends into a valley that disappears into forest. Miles away, it ends in a beach where land yields to sea in a crumble of sand. You are at a fork in the road. Would you like to go left or right?"; startNode.OutputSpeech.Add( SpeechFragement.CreateTextFragment(fullIntro)); startNode.Card = new CardInfo() { Title = "A Fork in the Road", Text = fullIntro }; adv.StartNodeName = "PathStart"; startNode.Reprompt = new List <SpeechFragement>(); startNode.Reprompt.Add(SpeechFragement.CreateTextFragment("Left or right?")); adv.Nodes = new List <AdventureNode>(); adv.Nodes.Add(startNode); AdventureNode trollinPath = new AdventureNode(); trollinPath.Name = "TrollInPath"; trollinPath.OutputSpeech = new List <SpeechFragement>(); trollinPath.OutputSpeech.Add(SpeechFragement.CreateAudioFragment("trollgrowl.mp3")); trollinPath.OutputSpeech.Add(SpeechFragement.CreateTextFragment("There's a troll in your way.")); trollinPath.OutputSpeech.Add(SpeechFragement.CreateAudioFragment("trollsniff.mp3")); trollinPath.OutputSpeech.Add(SpeechFragement.CreateTextFragment("Would you like to punch him or serve him tea?")); trollinPath.Card = new CardInfo() { Title = "Rabid Possum", Text = "There's a troll in your way. You can punch him or serve him tea.", LargeImage = "troll_lg.jpg", SmallImage = "troll_sm.jpg" }; trollinPath.Reprompt = new List <SpeechFragement>(); trollinPath.Reprompt.Add(SpeechFragement.CreateTextFragment("Punch him or serve him tea?")); trollinPath.NodeRoutes = new List <NodeRoute>(); trollinPath.NodeRoutes.Add( new NodeRoute { IntentName = "PunchIntent", NextNodeName = TROLLLAUNGHS_NAME }); trollinPath.NodeRoutes.Add( new NodeRoute { IntentName = "TeaIntent", NextNodeName = GOODTEA_NAME }); adv.Nodes.Add(trollinPath); AdventureNode animalInBush = new AdventureNode(); animalInBush.Name = "HedgeNode"; animalInBush.OutputSpeech = new List <SpeechFragement>(); animalInBush.OutputSpeech.Add(SpeechFragement.CreateAudioLibraryFragment(Whetstone.Alexa.Audio.AmazonSoundLibrary.Foley.SWOOSH_FAST_1X_01)); animalInBush.OutputSpeech.Add(SpeechFragement.CreateTextFragment("You see a small animal dart into a bush. Would you like to look in the bush or keep walking?")); animalInBush.Reprompt = new List <SpeechFragement>(); animalInBush.Reprompt.Add(SpeechFragement.CreateTextFragment("Look in bush or keep walking?")); animalInBush.NodeRoutes = new List <NodeRoute>(); animalInBush.NodeRoutes.Add(new NodeRoute { IntentName = "WalkIntent", NextNodeName = OUTOFWOODS_NAME }); animalInBush.NodeRoutes.Add(new NodeRoute { IntentName = "SearchHedgeIntent", NextNodeName = SEARCHHEDGE_NAME }); adv.Nodes.Add(animalInBush); startNode.NodeRoutes = new List <NodeRoute>(); NodeRoute leftRoute = new NodeRoute(); leftRoute.IntentName = "LeftIntent"; leftRoute.NextNodeName = trollinPath.Name; startNode.NodeRoutes.Add(leftRoute); NodeRoute rightRoute = new NodeRoute(); rightRoute.IntentName = "RightIntent"; rightRoute.NextNodeName = animalInBush.Name; startNode.NodeRoutes.Add(rightRoute); AdventureNode stopNode = GetStopNode(); adv.StopNodeName = stopNode.Name; adv.Nodes.Add(stopNode); adv.Nodes.Add(GetSearchHedgeNode()); adv.Nodes.Add(GetOutOfWoodsNode()); adv.Nodes.Add(GetTrollLaughsNode()); adv.Nodes.Add(GetGoodTeaNode()); adv.Nodes.Add(GetTrollTalksNode()); AdventureNode helpNode = GetHelpNode(); adv.Nodes.Add(helpNode); adv.HelpNodeName = helpNode.Name; AdventureNode unknownNode = GetUnknownNode(); adv.Nodes.Add(unknownNode); adv.UnknownNodeName = unknownNode.Name; var serializer = new Serializer(); string yamlOut; StringBuilder builder = new StringBuilder(); using (StringWriter writer = new StringWriter(builder)) { serializer.Serialize(writer, adv); yamlOut = builder.ToString(); } }
public Boolean Delete(NodeRoute data) { return(base.Delete(data)); }
public NodeRoute SelectById(NodeRoute data) { return((NodeRoute)base.SelectById(data)); }
public Boolean Update(NodeRoute data) { return(base.Update(data)); }
public NodeRoute Save(NodeRoute data) { return((NodeRoute)base.Save(data)); }
/// <summary> /// Hightlight a route. /// </summary> /// <param name="route">Route to highlight.</param> /// <param name="g">Graphics to draw on.</param> private void HighLightRoute(NodeRoute route, Graphics g) { if (!route.Visible && this.NodeFolded) { return; } CostNodeGlyph prevNode = null; Brush brush = Brushes.LightSeaGreen; foreach (CostNode node in route.CostNodes) { CostNodeGlyph glyph = CostNodeClusterGlyphs[node.ClusterIndex].CostNodeGlyphs[node.Index]; if (prevNode == null || !prevNode.IsPreceed(node)) { if (brush == Brushes.LightSeaGreen) { brush = Brushes.LightGreen; } else { brush = Brushes.LightSeaGreen; } } glyph.Draw(g, glyph.Rectangle, null, brush, false); if (prevNode == null) { prevNode = glyph; continue; } ConnectNodes(g, prevNode, glyph, Pens.Blue); prevNode = glyph; } }
/// <summary> /// Handle Tag.RouteDump. /// </summary> /// <param name="utterance">Utterance to fill in.</param> /// <param name="line">Section starting line.</param> /// <param name="tr">Text data.</param> /// <returns>Next tag, or null for end.</returns> private static string HandleTagRouteDump(TtsUtterance utterance, string line, TextReader tr) { System.Diagnostics.Debug.Assert(ParseTag(line) == Tag.RouteDump); while ((line = tr.ReadLine()) != null) { DO_WITH_CANDIDATE: if (string.IsNullOrEmpty(line)) { continue; } if (IsTag(line)) { return line; } if (line.StartsWith("route", StringComparison.Ordinal)) { NodeRoute route = new NodeRoute(); string[] items = line.Split(new char[] { ' ' }, StringSplitOptions.RemoveEmptyEntries); route.Index = int.Parse(items[1], CultureInfo.InvariantCulture); while ((line = tr.ReadLine()) != null) { if (string.IsNullOrEmpty(line)) { continue; } if (line.StartsWith("unit", StringComparison.Ordinal)) { CostNode tempnode = ParseCostNode(line); CostNodeCluster cluster = utterance.Viterbi.CostNodeClusters[tempnode.Index]; CostNode node = cluster.IndexedNodes[tempnode.Key]; route.CostNodes.Add(node); continue; } break; } route.ReverseCostNodes(); // route.CostNodes.Sort(); utterance.Viterbi.NodeRoutes.Add(route); goto DO_WITH_CANDIDATE; } } return MoveToNextTag(tr); }
private async Task <AlexaResponse> GetIntentResponseAsync(AlexaRequest request) { string intentName = request?.Request?.Intent?.Name; if (string.IsNullOrWhiteSpace(intentName)) { throw new Exception("No intent name found"); } Adventure adv = await _adventureRep.GetAdventureAsync(); AdventureNode curNode = await _curNodeRep.GetCurrentNodeAsync(request, adv.Nodes); string nextNodeName = null; AlexaResponse resp = null; if (intentName.Equals("BeginIntent", StringComparison.OrdinalIgnoreCase) || intentName.Equals(BuiltInIntents.StartOverIntent)) { AdventureNode startNode = adv.GetStartNode(); if (startNode == null) { throw new Exception($"Start node {adv.StartNodeName} not found"); } nextNodeName = startNode.Name; resp = startNode.ToAlexaResponse(_linkProcessor, adv.VoiceId); } else if (intentName.Equals(BuiltInIntents.CancelIntent) || intentName.Equals(BuiltInIntents.StopIntent)) { AdventureNode stopNode = adv.GetStopNode(); if (stopNode == null) { throw new Exception($"Start node {adv.StopNodeName} not found"); } resp = stopNode.ToAlexaResponse(_linkProcessor, adv.VoiceId); } else if (intentName.Equals("ResumeIntent", StringComparison.OrdinalIgnoreCase)) { resp = curNode.ToAlexaResponse(_linkProcessor, adv.VoiceId); } else if (intentName.Equals(BuiltInIntents.HelpIntent)) { AdventureNode helpNode = adv.GetHelpNode(); if (helpNode == null) { throw new Exception($"Help node {helpNode.Name} not found"); } resp = MergeNodeResponses(helpNode, curNode, adv.VoiceId); } else if (intentName.Equals(BuiltInIntents.FallbackIntent)) { resp = GenerateFallbackResponse(adv, curNode); } else { if (curNode != null) { // Process the route NodeRoute selectedRoute = curNode.NodeRoutes.FirstOrDefault(x => x.IntentName.Equals(intentName, StringComparison.OrdinalIgnoreCase)); if (selectedRoute != null) { nextNodeName = selectedRoute.NextNodeName; if (!string.IsNullOrWhiteSpace(nextNodeName)) { AdventureNode nextNode = adv.GetNode(nextNodeName); if (nextNode != null) { resp = nextNode.ToAlexaResponse(_linkProcessor, adv.VoiceId); } else { _logger.LogWarning($"Next node {nextNodeName} on node {curNode} not found for intent {intentName}"); } } else { _logger.LogWarning($"Node name missing for node route for {intentName} provided on node {curNode.Name}"); } } else { resp = GenerateFallbackResponse(adv, curNode); // unsupported intent. Send reprompt. _logger.LogWarning($"Node route not found for {intentName} provided on node {curNode.Name}"); } } else { resp = GenerateFallbackResponse(adv, null); // unsupported intent. Send reprompt. _logger.LogWarning($"Node {curNode.Name} on session attribute {AdventureNode.CURNODE_ATTRIB} not found"); } } // If the next node is known, then set it. Otherwise, keep the user on the current node. if (string.IsNullOrWhiteSpace(nextNodeName)) { if (curNode != null) { await _curNodeRep.SetCurrentNodeAsync(request, resp, curNode.Name); } } else { await _curNodeRep.SetCurrentNodeAsync(request, resp, nextNodeName); } return(resp); }