public QueryResult GetMessageForVertexes(ContextManager contextMgmt, List <Vertex> vertexes) { string resultForAllItems = ""; Dictionary <int, Vertex> candidates = new Dictionary <int, Vertex>(); List <Object> items = new List <Object>(); int index = 1; foreach (Vertex aVertex in vertexes) { candidates.Add(index, aVertex); OptionItem item = new OptionItem(); item.seqNo = index; item.vertex = aVertex; items.Add(item); resultForAllItems += "[" + item.seqNo.ToString() + "]: " + aVertex.name + "\n"; index += 1; } ResponseItemType itemType = ResponseItemType.Option; QueryResult result = new QueryResult(true, resultForAllItems + quitPromptStr, itemType); result.AddResponseItems(items); contextMgmt.SetCandidates(candidates); return(result); }
public QueryResult(bool success, string msg, ResponseItemType itemType) { this.success = success; this.responseMessage = msg; this.itemType = itemType; this.items = null; }
public QueryResult GetChildren(ContextManager contextMgmt, Vertex parentVertex, HashSet <string> relationTypeSet) { Dictionary <string, List <Vertex> > childrenDict = dsFrame.GetChildren(parentVertex, relationTypeSet, contextMgmt.GetSavedAttributes(), contextMgmt.GetSecnarioName()); string headMessage = msgGenerator.GetInformationOfVertex(parentVertex); if ((childrenDict == null || childrenDict.Count == 0) && (relationTypeSet != null && relationTypeSet.Count > 0)) { childrenDict = dsFrame.GetChildren(parentVertex, null, contextMgmt.GetSavedAttributes(), contextMgmt.GetSecnarioName()); } if (childrenDict == null || childrenDict.Count == 0) { contextMgmt.ExitDialog(); return(msgGenerator.GenerateErrorMessage(parentVertex.id + "没有子节点")); } else { string resultStr = headMessage; List <Object> items = new List <Object>(); int index = 1; Dictionary <int, Vertex> candidates = new Dictionary <int, Vertex>(); foreach (string relationType in childrenDict.Keys) { List <Vertex> vertexs = childrenDict[relationType]; string resultForAllItems = ""; foreach (Vertex aVertex in vertexs) { candidates.Add(index, aVertex); OptionItem item = new OptionItem(); item.seqNo = index; item.vertex = aVertex; item.relationType = relationType; items.Add(item); resultForAllItems += "[" + item.seqNo.ToString() + "]: (" + relationType + ") " + aVertex.name + "\n"; index += 1; } resultStr += resultForAllItems; } ResponseItemType itemType = ResponseItemType.Option; QueryResult result = new QueryResult(true, resultStr + quitPromptStr, itemType); result.AddResponseItems(items); contextMgmt.SetCandidates(candidates); return(result); } }
private QueryResult GenerateItemsMessage(string headMessage, Dictionary <string, List <Vertex> > vertexDict, ContextManager contextMgmt) { if (vertexDict == null || vertexDict.Count == 0) { return(GenerateErrorMessage("要返回的项目为空。", contextMgmt)); } string resultStr = headMessage; List <Object> items = new List <Object>(); int index = 1; Dictionary <int, Vertex> candidates = new Dictionary <int, Vertex>(); foreach (string relationType in vertexDict.Keys) { List <Vertex> vertexs = vertexDict[relationType]; string resultForAllItems = ""; foreach (Vertex vertex in vertexs) { candidates.Add(index, vertex); OptionItem item = new OptionItem(); item.seqNo = index; item.vertex = vertex; item.relationType = relationType; items.Add(item); resultForAllItems += "[" + item.seqNo.ToString() + "]: (" + relationType + ") " + vertex.name + "\n"; index += 1; } resultStr += resultForAllItems; } ResponseItemType itemType = ResponseItemType.Option; QueryResult result = new QueryResult(true, resultStr + quitPromptStr, itemType); result.AddResponseItems(items); contextMgmt.SetCandidates(candidates); return(result); }
static String XMLResponseItemTypeToString(ResponseItemType type) { switch (type) { case ResponseItemType.DICT: return("DICT"); case ResponseItemType.INT: return("INT"); case ResponseItemType.LIST: return("LIST"); case ResponseItemType.STRING: return("STRING"); default: return("UNKNOWN"); } }
static String XMLResponseItemTypeToString(ResponseItemType type) { switch (type) { case ResponseItemType.DICT: return "DICT"; case ResponseItemType.INT: return "INT"; case ResponseItemType.LIST: return "LIST"; case ResponseItemType.STRING: return "STRING"; default: return "UNKNOWN"; } }