public override AmazonWebServiceResponse Unmarshall(XmlUnmarshallerContext context) { BatchPutAttributesResponse response = new BatchPutAttributesResponse(); context.Read(); int targetDepth = context.CurrentDepth; while (context.ReadAtDepth(targetDepth)) { if (context.IsStartElement) { if (context.TestExpression("BatchPutAttributesResult", 2)) { UnmarshallResult(context, response); continue; } if (context.TestExpression("ResponseMetadata", 2)) { response.ResponseMetadata = ResponseMetadataUnmarshaller.Instance.Unmarshall(context); } } } return(response); }
public async Task AddOrUpdateMember(Member member) { var client = GetClient(); if (member.IsNewItem) { member.DbKey = member.GenerateDbKey(IdPrefix); } BatchPutAttributesRequest request = new BatchPutAttributesRequest(); request.DomainName = Domain; // Mandatory properties var attributes = new List <ReplaceableAttribute> { new ReplaceableAttribute { Name = "Name", Value = member.Name, Replace = true }, new ReplaceableAttribute { Name = "MembershipNumber", Value = member.MembershipNumber.ToString(), Replace = true }, new ReplaceableAttribute { Name = "Admin", Value = member.Admin ? "1" : "0", Replace = true }, new ReplaceableAttribute { Name = "LastPaid", Value = dateToString(member.LastPaid), Replace = true }, new ReplaceableAttribute { Name = "Enabled", Value = member.Enabled ? "1" : "0", Replace = true }, new ReplaceableAttribute { Name = "Pin", Value = member.Pin.ToString(), Replace = true }, }; request.Items.Add( new ReplaceableItem { Name = member.DbKey, Attributes = attributes } ); try { BatchPutAttributesResponse response = await client.BatchPutAttributesAsync(request); _logger.LogDebug($"Member added: {member.DbKey} - {member.Name}"); } catch (AmazonSimpleDBException ex) { _logger.LogError(ex, $"Error Code: {ex.ErrorCode}, Error Type: {ex.ErrorType}"); throw; } }
public async Task AddOrUpdateNewsItem(NewsItem newsItem) { var client = GetClient(); if (newsItem.IsNewItem) { newsItem.DbKey = newsItem.GenerateDbKey(IdPrefix); } BatchPutAttributesRequest request = new BatchPutAttributesRequest(); request.DomainName = Domain; // Mandatory properties var attributes = new List <ReplaceableAttribute> { new ReplaceableAttribute { Name = "Date", Value = dateToString(newsItem.Date), Replace = true }, new ReplaceableAttribute { Name = "Title", Value = newsItem.Title, Replace = true }, new ReplaceableAttribute { Name = "Body", Value = newsItem.Body, Replace = true }, }; request.Items.Add( new ReplaceableItem { Name = newsItem.DbKey, Attributes = attributes } ); try { BatchPutAttributesResponse response = await client.BatchPutAttributesAsync(request); _logger.LogDebug($"News Item added: {newsItem.DbKey} - {newsItem.Title}"); } catch (AmazonSimpleDBException ex) { _logger.LogError(ex, $"Error Code: {ex.ErrorCode}, Error Type: {ex.ErrorType}"); throw; } }
public override AmazonWebServiceResponse Unmarshall(XmlUnmarshallerContext context) { BatchPutAttributesResponse response = new BatchPutAttributesResponse(); while (context.Read()) { if (context.IsStartElement) { if (context.TestExpression("ResponseMetadata", 2)) { response.ResponseMetadata = ResponseMetadataUnmarshaller.GetInstance().Unmarshall(context); } } } return(response); }
private static void UnmarshallResult(XmlUnmarshallerContext context, BatchPutAttributesResponse response) { int originalDepth = context.CurrentDepth; int targetDepth = originalDepth + 1; if (context.IsStartOfDocument) { targetDepth += 2; } while (context.ReadAtDepth(originalDepth)) { if (context.IsStartElement || context.IsAttribute) { } } return; }
void BatchPutAttributeWebResponse(object sender, ResponseEventArgs args) { ISimpleDBResponse result = args.Response; SimpleDB.Client.OnSimpleDBResponse -= BatchPutAttributeWebResponse; this.Dispatcher.BeginInvoke(() => { BatchPutAttributesResponse response = result as BatchPutAttributesResponse; if (null != response) { this.BatchPutMessage = "Batch attributes put successfully"; } else { AmazonSimpleDBException exception = result as AmazonSimpleDBException; if (null != exception) { this.BatchPutMessage = "Error: " + exception.Message; } } }); }
public async Task AddOrUpdateEvent(ClubEvent clubEvent) { var client = GetClient(); if (clubEvent.IsNewItem) { clubEvent.DbKey = clubEvent.GenerateDbKey(IdPrefix); } BatchPutAttributesRequest request = new BatchPutAttributesRequest(); request.DomainName = Domain; // Mandatory properties var attributes = new List <ReplaceableAttribute> { new ReplaceableAttribute { Name = "Id", Value = clubEvent.Id, Replace = true }, new ReplaceableAttribute { Name = "Season", Value = ((int)clubEvent.Season).ToString(), Replace = true }, new ReplaceableAttribute { Name = "Date", Value = dateToString(clubEvent.Date), Replace = true }, new ReplaceableAttribute { Name = "EventType", Value = ((int)clubEvent.EventType).ToString(), Replace = true }, new ReplaceableAttribute { Name = "Description", Value = clubEvent.Description, Replace = true } }; // Optional properties if (clubEvent.MatchType != null) { attributes.Add(new ReplaceableAttribute { Name = "MatchType", Value = ((int)clubEvent.MatchType.Value).ToString(), Replace = true }); } if (clubEvent.MatchDraw != null) { attributes.Add(new ReplaceableAttribute { Name = "MatchDraw", Value = dateToString(clubEvent.MatchDraw.Value), Replace = true }); } if (clubEvent.MatchStart != null) { attributes.Add(new ReplaceableAttribute { Name = "MatchStart", Value = dateToString(clubEvent.MatchStart.Value), Replace = true }); } if (clubEvent.MatchEnd != null) { attributes.Add(new ReplaceableAttribute { Name = "MatchEnd", Value = dateToString(clubEvent.MatchEnd.Value), Replace = true }); } if (clubEvent.Number != null) { attributes.Add(new ReplaceableAttribute { Name = "Number", Value = numberToString(clubEvent.Number.Value), Replace = true }); } if (clubEvent.Cup != null) { attributes.Add(new ReplaceableAttribute { Name = "Cup", Value = clubEvent.Cup, Replace = true }); } request.Items.Add( new ReplaceableItem { Name = clubEvent.DbKey, Attributes = attributes } ); try { BatchPutAttributesResponse response = await client.BatchPutAttributesAsync(request); _logger.LogDebug($"Event added: {clubEvent.DbKey} - {clubEvent.Description}"); } catch (AmazonSimpleDBException ex) { _logger.LogError(ex, $"Error Code: {ex.ErrorCode}, Error Type: {ex.ErrorType}"); throw; } }
public async Task AddOrUpdateWater(Water water) { var client = GetClient(); if (water.IsNewItem) { water.DbKey = water.GenerateDbKey(IdPrefix); } BatchPutAttributesRequest request = new BatchPutAttributesRequest(); request.DomainName = Domain; // Mandatory Properties var attributes = new List <ReplaceableAttribute> { new ReplaceableAttribute { Name = "Id", Value = water.Id.ToString(), Replace = true }, new ReplaceableAttribute { Name = "Name", Value = water.Name, Replace = true }, new ReplaceableAttribute { Name = "Type", Value = ((int)water.Type).ToString(), Replace = true }, new ReplaceableAttribute { Name = "Access", Value = ((int)water.Access).ToString(), Replace = true }, new ReplaceableAttribute { Name = "Description", Value = water.Description, Replace = true }, new ReplaceableAttribute { Name = "Species", Value = water.Species, Replace = true }, new ReplaceableAttribute { Name = "Directions", Value = water.Directions, Replace = true }, new ReplaceableAttribute { Name = "Markers", Value = water.Markers, Replace = true }, new ReplaceableAttribute { Name = "MarkerIcons", Value = water.MarkerIcons, Replace = true }, new ReplaceableAttribute { Name = "MarkerLabels", Value = water.MarkerLabels, Replace = true }, new ReplaceableAttribute { Name = "Destination", Value = water.Destination, Replace = true }, new ReplaceableAttribute { Name = "Path", Value = water.Path, Replace = true }, }; request.Items.Add( new ReplaceableItem { Name = water.DbKey, Attributes = attributes } ); try { BatchPutAttributesResponse response = await client.BatchPutAttributesAsync(request); _logger.LogDebug($"Water added"); } catch (AmazonSimpleDBException ex) { _logger.LogError(ex, $"Error Code: {ex.ErrorCode}, Error Type: {ex.ErrorType}"); throw; } }
public async Task AddOrUpdateMatchResult(MatchResult result) { var client = GetClient(); // Validate MatchId { if (!(await _eventRepository.GetEvents()).Any(x => x.Id == result.MatchId)) { throw new KeyNotFoundException($"Match '{result.MatchId}' does not exist"); } } // Validate MembershipNumber { if (!(await _memberRepository.GetMembers()).Any(x => x.MembershipNumber == result.MembershipNumber)) { throw new KeyNotFoundException($"Member '{result.MembershipNumber}' does not exist"); } } if (result.IsNewItem) { result.DbKey = result.GenerateDbKey(IdPrefix); } BatchPutAttributesRequest request = new BatchPutAttributesRequest(); request.DomainName = Domain; // Mandatory properties var attributes = new List <ReplaceableAttribute> { new ReplaceableAttribute { Name = "MatchId", Value = result.MatchId, Replace = true }, new ReplaceableAttribute { Name = "MembershipNumber", Value = result.MembershipNumber.ToString(), Replace = true }, new ReplaceableAttribute { Name = "Peg", Value = result.Peg, Replace = true }, new ReplaceableAttribute { Name = "WeightDecimal", Value = weightToString(result.WeightDecimal), Replace = true }, new ReplaceableAttribute { Name = "Points", Value = pointsToString(result.Points), Replace = true } }; request.Items.Add( new ReplaceableItem { Name = result.DbKey, Attributes = attributes } ); try { BatchPutAttributesResponse response = await client.BatchPutAttributesAsync(request); _logger.LogDebug($"Match result added"); } catch (AmazonSimpleDBException ex) { _logger.LogError(ex, $"Error Code: {ex.ErrorCode}, Error Type: {ex.ErrorType}"); throw; } }