public string GetCurrentStatus(UserSelectedData userSelectedData) { try { var client = GetDbClient(); // get device of location var deviceInLocations = GetDevicesInLocation(client, userSelectedData); if (deviceInLocations.Any()) { var rooms = QueryInformationOfRooms(client, deviceInLocations); return(_messageBuilderService.BuildStatusInfoMessage(userSelectedData.KeyInfo, rooms)); } else { return(_messageBuilderService.BuildNotFoundMessage(userSelectedData)); } } catch (Exception ex) { } return(Resources.Resource.HelpWithInstruction); }
public string ProccessWaitingMessage(UserSelectedData userSelectedData) { (bool isHasLocation, string locationStr) = GetLocationString(userSelectedData); if (userSelectedData.IsHasKeyInfo && isHasLocation) { return(string.Format(Resources.Resource.LookForInforOfDefine, userSelectedData.KeyInfo, locationStr)); } else { if (userSelectedData.IsHasKeyInfo || isHasLocation) { if (userSelectedData.IsHasKeyInfo) { return(string.Format(Resources.Resource.LookForDefine, userSelectedData.KeyInfo)); } else { return(string.Format(Resources.Resource.LookForCurrentDefine, locationStr)); } } else { return(string.Format(Resources.Resource.HelpNotUnderstand, userSelectedData.LastInputMessage)); } } }
public string BuildHelpMessage(UserSelectedData userSelectedData) { if (!userSelectedData.IsHasKeyInfo && !userSelectedData.IsHasLocationName && !userSelectedData.IsHasRoomName) { return(Resources.Resource.HelpWithInstruction); } return(string.Empty); }
public static UserSelectedData GetUserSelectedData(IDialogContext context) { UserSelectedData userSelectedData = null; context.UserData.TryGetValue(AppConstants.UserSelectedDataKey, out userSelectedData); if (userSelectedData == null) { userSelectedData = new UserSelectedData(); } return(userSelectedData); }
public string BuildNotFoundMessage(UserSelectedData userSelectedData) { (bool isHasLocation, string locationStr) = GetLocationString(userSelectedData); if (isHasLocation) { return(string.Format(Resources.Resource.HelpNotFoundLocationInput, locationStr)); } else { return(Resources.Resource.HelpNotFoundLocation); } }
private (bool isHasLocation, string locationStr) GetLocationString(UserSelectedData userSelectedData) { var isHasLocation = userSelectedData.IsHasLocationName || userSelectedData.IsHasRoomName; var locationStr = ""; if (isHasLocation) { if (userSelectedData.IsHasLocationName && userSelectedData.IsHasRoomName) { locationStr = string.Format(Resources.Resource.InDefine2Phrase, userSelectedData.RoomName, userSelectedData.LocationName); } else { locationStr = userSelectedData.IsHasLocationName ? userSelectedData.LocationName : userSelectedData.RoomName; } } return(isHasLocation, locationStr); }
private List <DevicesInLocation> GetDevicesInLocation(AmazonDynamoDBClient client, UserSelectedData userSelectedData) { List <DevicesInLocation> devicesInLocations = new List <DevicesInLocation>(); if (userSelectedData.IsHasLocationName) { var keyConditionExpression = "location_id = :v_locationName"; var expressionAttributeValues = new Dictionary <string, AttributeValue> { { ":v_locationName", new AttributeValue { S = userSelectedData.LocationName } } }; var request = new QueryRequest { TableName = "devices-in-location", KeyConditionExpression = keyConditionExpression, ExpressionAttributeValues = expressionAttributeValues }; var response = client.Query(request); devicesInLocations = DevicesInLocationMapper.MapFromResponse(response); if (userSelectedData.IsHasRoomName) { devicesInLocations = devicesInLocations.Where(c => c.Room.Equals(userSelectedData.RoomName)).ToList(); } } return(devicesInLocations); }