public UploadDocumentsResponse DeleteSingleConnectRecordInAwsCloudsearch(int participantId, int pinType) { var cloudSearch = new AmazonCloudSearchDomainClient(AwsAccessKeyId, AwsSecretAccessKey, AmazonSearchUrl); var results = SearchConnectAwsCloudsearch($"(and participantid:{participantId} pintype:{pinType})", "_no_fields"); var deletelist = new List <AwsCloudsearchDto>(); foreach (var hit in results.Hits.Hit) { var deleterec = new AwsCloudsearchDto { id = hit.Id, type = "delete" }; deletelist.Add(deleterec); } // serialize var json = JsonConvert.SerializeObject(deletelist, new JsonSerializerSettings { NullValueHandling = NullValueHandling.Ignore }); var ms = new MemoryStream(Encoding.UTF8.GetBytes(json)); var upload = new UploadDocumentsRequest() { ContentType = ContentType.ApplicationJson, Documents = ms }; return(cloudSearch.UploadDocuments(upload)); }
private List <AwsCloudsearchDto> GetDataForCloudsearch() { var pins = _finderRepository.GetAllPinsForAws().Select(Mapper.Map <AwsConnectDto>).ToList(); var pinlist = new List <AwsCloudsearchDto>(); foreach (var pin in pins) { var awsRecord = new AwsCloudsearchDto { type = "add", id = pin.AddressId + "-" + pin.PinType + "-" + pin.ParticipantId + "-" + pin.GroupId, fields = pin }; pinlist.Add(awsRecord); } return(pinlist); }
public UploadDocumentsRequest GetObjectToUploadToAws(PinDto pin) { AwsConnectDto awsPinObject = Mapper.Map <AwsConnectDto>(pin); if (pin.PinType == PinType.GATHERING) { awsPinObject.AddressId = pin.Gathering.Address.AddressID; awsPinObject.Latitude = pin.Gathering.Address.Latitude; awsPinObject.Longitude = pin.Gathering.Address.Longitude; awsPinObject.City = pin.Gathering.Address.City; awsPinObject.LatLong = (pin.Gathering.Address.Latitude == null || pin.Gathering.Address.Longitude == null) ? "0 , 0" : $"{pin.Gathering.Address.Latitude} , {pin.Gathering.Address.Longitude}"; awsPinObject.State = pin.Gathering.Address.State; awsPinObject.Zip = pin.Gathering.Address.PostalCode; awsPinObject.GroupStartDate = pin.Gathering.StartDate; awsPinObject.GroupId = pin.Gathering.GroupId; awsPinObject.GroupTypeId = pin.Gathering.GroupTypeId; awsPinObject.GroupDescription = pin.Gathering.GroupDescription; awsPinObject.GroupName = pin.Gathering.GroupName; } AwsCloudsearchDto awsPostPinObject = new AwsCloudsearchDto("add", GenerateAwsPinId(pin), awsPinObject); var pinlist = new List <AwsCloudsearchDto> { awsPostPinObject }; string jsonAwsObject = JsonConvert.SerializeObject(pinlist, new JsonSerializerSettings { NullValueHandling = NullValueHandling.Ignore }); MemoryStream jsonAwsPinDtoStream = new MemoryStream(Encoding.UTF8.GetBytes(jsonAwsObject)); UploadDocumentsRequest upload = new UploadDocumentsRequest() { ContentType = ContentType.ApplicationJson, Documents = jsonAwsPinDtoStream }; return(upload); }