public async Task<ResultDetails<GetResult>> GetAsync(Uri uri) { _traceProvider.Trace(TraceEventType.Verbose, "{2}: Request for search: {0}", typeof(GetResult), "GetAsync"); var resultDetails = new ResultDetails<GetResult> { Status = HttpStatusCode.InternalServerError }; try { _traceProvider.Trace(TraceEventType.Verbose, "{1}: Request HTTP GET uri: {0}", uri.AbsoluteUri, "get an object"); resultDetails.RequestUrl = uri.ToString(); var response = await _client.GetAsync(uri, _cancellationTokenSource.Token).ConfigureAwait(true); resultDetails.Status = response.StatusCode; if (response.StatusCode != HttpStatusCode.OK) { _traceProvider.Trace(TraceEventType.Warning, "{2}: GetAsync response status code: {0}, {1}", response.StatusCode, response.ReasonPhrase, "GetAsync"); if (response.StatusCode == HttpStatusCode.BadRequest) { var errorInfo = await response.Content.ReadAsStringAsync().ConfigureAwait(true); resultDetails.Description = errorInfo; if (errorInfo.Contains("RoutingMissingException")) { throw new ElasticsearchCrudException("HttpStatusCode.BadRequest: RoutingMissingException, adding the parent Id if this is a child item..."); } return resultDetails; } if (response.StatusCode == HttpStatusCode.NotFound) { var errorInfo = await response.Content.ReadAsStringAsync().ConfigureAwait(true); resultDetails.Description = errorInfo; return resultDetails; } } var responseString = await response.Content.ReadAsStringAsync().ConfigureAwait(true); _traceProvider.Trace(TraceEventType.Verbose, "{1}: Get Request response: {0}", responseString, "Search"); var responseObject = JObject.Parse(responseString); var ser = new JsonSerializer(); resultDetails.PayloadResult = responseObject.ToObject<GetResult>(ser); return resultDetails; } catch (OperationCanceledException oex) { _traceProvider.Trace(TraceEventType.Verbose, oex, "{1}: Get Request OperationCanceledException: {0}", oex.Message, "Search"); return resultDetails; } }
public async Task<ResultDetails<string>> Execute(HttpClient client, string baseUrl, ITraceProvider traceProvider, CancellationTokenSource cancellationTokenSource) { var resultDetails = new ResultDetails<string> { Status = HttpStatusCode.InternalServerError }; foreach (var command in Commands) { var content = new StringContent(command.Content + "\n"); traceProvider.Trace(TraceEventType.Verbose, "{1}: sending init mappings request: {0}", command, "InitMappings"); traceProvider.Trace(TraceEventType.Verbose, "{1}: Request HTTP PUT uri: {0}", command.Url, "InitMappings"); traceProvider.Trace(TraceEventType.Verbose, "{1}: Request HTTP PUT content: {0}", command.Content, "InitMappings"); content.Headers.ContentType = new MediaTypeHeaderValue("application/json"); HttpResponseMessage response; if (command.RequestType == "POST") { response = await client.PostAsync(baseUrl + command.Url, content, cancellationTokenSource.Token).ConfigureAwait(true); } else { response = await client.PutAsync(baseUrl + command.Url, content, cancellationTokenSource.Token).ConfigureAwait(true); } if (response.StatusCode == HttpStatusCode.BadRequest ) { var errorInfo = await response.Content.ReadAsStringAsync().ConfigureAwait(true); var responseObject = JObject.Parse(errorInfo); var source = responseObject["error"]; throw new ElasticsearchCrudException("IndexMappings: Execute Request POST BadRequest: " + source); } //resultDetails.Status = response.StatusCode; if (response.StatusCode != HttpStatusCode.OK && response.StatusCode != HttpStatusCode.Created) { traceProvider.Trace(TraceEventType.Warning, "{2}: SaveChangesAsync response status code: {0}, {1}", response.StatusCode, response.ReasonPhrase, "InitMappings"); if (response.StatusCode == HttpStatusCode.BadRequest) { var errorInfo = await response.Content.ReadAsStringAsync().ConfigureAwait(true); resultDetails.Description = errorInfo; return resultDetails; } return resultDetails; } var responseString = await response.Content.ReadAsStringAsync().ConfigureAwait(true); traceProvider.Trace(TraceEventType.Verbose, "{1}: response: {0}", responseString, "InitMappings"); } // no errors resultDetails.Status = HttpStatusCode.OK; return resultDetails; }
public ResultDetail() { InitializeComponent(); prog = new ProgressIndicator(); prog.IsIndeterminate = true; prog.Text = "loading..."; prog.IsVisible = true; SystemTray.SetProgressIndicator(this, prog); data = new ResultDetails(); this.DataContext = data; }
public async Task<ResultDetails<bool>> SendWarmerDeleteCommandAsync(string warmerName, string index) { _traceProvider.Trace(TraceEventType.Verbose, string.Format("ElasticsearchContextWarmer: Deleting Warmer {0}", warmerName)); var resultDetails = new ResultDetails<bool> { Status = HttpStatusCode.InternalServerError }; var elasticsearchUrl = string.Format("{0}/{1}/_warmer/{2}", _connectionString, index, warmerName); var uri = new Uri(elasticsearchUrl); _traceProvider.Trace(TraceEventType.Verbose, "{1}: Request HTTP DELETE uri: {0}", uri.AbsoluteUri, "ElasticsearchContextWarmer"); var response = await _client.DeleteAsync(uri, _cancellationTokenSource.Token).ConfigureAwait(false); if (response.StatusCode == HttpStatusCode.OK) { resultDetails.PayloadResult = true; return resultDetails; } _traceProvider.Trace(TraceEventType.Error, string.Format("ElasticsearchContextWarmer: Cound Not Execute Warmer Delete {0}", warmerName)); throw new ElasticsearchCrudException(string.Format("ElasticsearchContextWarmer: Cound Not Execute Warmer Delete {0}", warmerName)); }
public async Task<ResultDetails<bool>> SendWarmerCommandAsync(Warmer warmer, string index, string type) { _traceProvider.Trace(TraceEventType.Verbose, string.Format("ElasticsearchContextWarmer: Creating Warmer {0}", warmer.Name)); var resultDetails = new ResultDetails<bool> { Status = HttpStatusCode.InternalServerError }; var elasticsearchUrl = CreateWarmerUriParameter(index, type, warmer.Name); var uri = new Uri(elasticsearchUrl); _traceProvider.Trace(TraceEventType.Verbose, "{1}: Request HTTP PUT uri: {0}", uri.AbsoluteUri, "ElasticsearchContextWarmer"); var content = new StringContent(warmer.ToString()); var response = await _client.PutAsync(uri, content, _cancellationTokenSource.Token).ConfigureAwait(false); if (response.StatusCode == HttpStatusCode.OK) { resultDetails.PayloadResult = true; return resultDetails; } _traceProvider.Trace(TraceEventType.Error, string.Format("ElasticsearchContextWarmer: Cound Not Execute Warmer Create {0}", warmer.Name)); throw new ElasticsearchCrudException(string.Format("ElasticsearchContextWarmer: Cound Not Execute Warmer Create {0}", warmer.Name)); }
public async Task<ResultDetails<bool>> SendAliasCommandAsync(string contentJson) { _traceProvider.Trace(TraceEventType.Verbose, string.Format("ElasticsearchContextAlias: Creating Alias {0}", contentJson)); var resultDetails = new ResultDetails<bool> { Status = HttpStatusCode.InternalServerError }; var elasticsearchUrlForClearCache = string.Format("{0}/_aliases", _connectionString); var uri = new Uri(elasticsearchUrlForClearCache); _traceProvider.Trace(TraceEventType.Verbose, "{1}: Request HTTP POST uri: {0}", uri.AbsoluteUri, "ElasticsearchContextAlias"); var content = new StringContent(contentJson); var response = await _client.PostAsync(uri, content, _cancellationTokenSource.Token).ConfigureAwait(false); if (response.StatusCode == HttpStatusCode.OK) { resultDetails.PayloadResult = true; return resultDetails; } _traceProvider.Trace(TraceEventType.Error, string.Format("ElasticsearchContextAlias: Cound Not Execute Alias {0}", contentJson)); throw new ElasticsearchCrudException(string.Format("ElasticsearchContextAlias: Cound Not Execute Alias {0}", contentJson)); }
public async Task<ResultDetails<bool>> ExistsAsync(Uri uri) { _traceProvider.Trace(TraceEventType.Verbose, "ExistsAsync: Request HEAD with url: {0}", uri.ToString()); var resultDetails = new ResultDetails<bool> { Status = HttpStatusCode.InternalServerError }; try { var request = new HttpRequestMessage(HttpMethod.Head, uri); var response = await _client.SendAsync(request, _cancellationTokenSource.Token).ConfigureAwait(false); resultDetails.RequestUrl = uri.OriginalString; resultDetails.Status = response.StatusCode; if (response.StatusCode != HttpStatusCode.OK) { resultDetails.PayloadResult = false; if (response.StatusCode == HttpStatusCode.BadRequest) { var errorInfo = await response.Content.ReadAsStringAsync().ConfigureAwait(false); resultDetails.Description = errorInfo; throw new ElasticsearchCrudException("ExistsAsync: HttpStatusCode.BadRequest: RoutingMissingException, adding the parent Id if this is a child item..."); } _traceProvider.Trace(TraceEventType.Information, "ExistsAsync: response status code: {0}, {1}", response.StatusCode, response.ReasonPhrase); } else { resultDetails.PayloadResult = true; } return resultDetails; } catch (OperationCanceledException oex) { _traceProvider.Trace(TraceEventType.Verbose, oex, "ExistsAsync: Get Request OperationCanceledException: {0}", oex.Message); return resultDetails; } }
public async Task <ResultDetails <GetResult> > GetAsync(Uri uri) { _traceProvider.Trace(TraceEventType.Verbose, "{2}: Request for search: {0}", typeof(GetResult), "GetAsync"); var resultDetails = new ResultDetails <GetResult> { Status = HttpStatusCode.InternalServerError }; try { _traceProvider.Trace(TraceEventType.Verbose, "{1}: Request HTTP GET uri: {0}", uri.AbsoluteUri, "get an object"); resultDetails.RequestUrl = uri.ToString(); var response = await _client.GetAsync(uri, _cancellationTokenSource.Token).ConfigureAwait(true); resultDetails.Status = response.StatusCode; if (response.StatusCode != HttpStatusCode.OK) { _traceProvider.Trace(TraceEventType.Warning, "{2}: GetAsync response status code: {0}, {1}", response.StatusCode, response.ReasonPhrase, "GetAsync"); if (response.StatusCode == HttpStatusCode.BadRequest) { var errorInfo = await response.Content.ReadAsStringAsync().ConfigureAwait(true); resultDetails.Description = errorInfo; if (errorInfo.Contains("RoutingMissingException")) { throw new ElasticException( "HttpStatusCode.BadRequest: RoutingMissingException, adding the parent Id if this is a child item..."); } return(resultDetails); } if (response.StatusCode == HttpStatusCode.NotFound) { var errorInfo = await response.Content.ReadAsStringAsync().ConfigureAwait(true); resultDetails.Description = errorInfo; return(resultDetails); } } var responseString = await response.Content.ReadAsStringAsync().ConfigureAwait(true); _traceProvider.Trace(TraceEventType.Verbose, "{1}: Get Request response: {0}", responseString, "Search"); var responseObject = JObject.Parse(responseString); var ser = new JsonSerializer(); resultDetails.PayloadResult = responseObject.ToObject <GetResult>(ser); return(resultDetails); } catch (OperationCanceledException oex) { _traceProvider.Trace(TraceEventType.Verbose, oex, "{1}: Get Request OperationCanceledException: {0}", oex.Message, "Search"); return(resultDetails); } }
public virtual void Result <TMessage>(IWampFormatter <TMessage> formatter, ResultDetails details, TMessage[] arguments) { }
public void Result <TMessage>(IWampFormatter <TMessage> formatter, ResultDetails details) { throw new NotImplementedException(); }
private async Task <ResultDetails <SearchResult <T> > > PostInteranlSearchAsync <T>(string jsonContent, Uri uri) { _traceProvider.Trace(TraceEventType.Verbose, "{2}: Request for search: {0}, content: {1}", typeof(T), jsonContent, "Search"); var resultDetails = new ResultDetails <SearchResult <T> > { Status = HttpStatusCode.InternalServerError, RequestBody = jsonContent }; try { _traceProvider.Trace(TraceEventType.Verbose, "{1}: Request HTTP GET uri: {0}", uri.AbsoluteUri, "Search"); var content = new StringContent(jsonContent); content.Headers.ContentType = new MediaTypeHeaderValue("application/json"); resultDetails.RequestUrl = uri.ToString(); var response = await _client.PostAsync(uri, content, _cancellationTokenSource.Token) .ConfigureAwait(true); resultDetails.Status = response.StatusCode; if (response.StatusCode != HttpStatusCode.OK) { _traceProvider.Trace(TraceEventType.Warning, "{2}: GetSearchAsync response status code: {0}, {1}", response.StatusCode, response.ReasonPhrase, "Search"); if (response.StatusCode == HttpStatusCode.BadRequest) { var errorInfo = await response.Content.ReadAsStringAsync().ConfigureAwait(true); resultDetails.Description = errorInfo; if (errorInfo.Contains("RoutingMissingException")) { throw new ElasticException( "HttpStatusCode.BadRequest: RoutingMissingException, adding the parent Id if this is a child item..."); } return(resultDetails); } if (response.StatusCode == HttpStatusCode.NotFound) { var errorInfo = await response.Content.ReadAsStringAsync().ConfigureAwait(true); resultDetails.Description = errorInfo; return(resultDetails); } } var responseString = await response.Content.ReadAsStringAsync().ConfigureAwait(true); _traceProvider.Trace(TraceEventType.Verbose, "{1}: Get Request response: {0}", responseString, "Search"); var responseObject = JObject.Parse(responseString); var ser = new JsonSerializer(); ser.Converters.Add(new GeoShapeGeometryCollectionGeometriesConverter()); resultDetails.PayloadResult = responseObject.ToObject <SearchResult <T> >(ser); return(resultDetails); } catch (OperationCanceledException oex) { _traceProvider.Trace(TraceEventType.Verbose, oex, "{1}: Get Request OperationCanceledException: {0}", oex.Message, "Search"); return(resultDetails); } }
public virtual void Result <TMessage>(IWampFormatter <TMessage> formatter, ResultDetails details) { Called = true; }
public WampMessage <object> Result(long requestId, ResultDetails details, object[] arguments) { return(mSerializer.SerializeRequest(mResult3, new object[] { requestId, details, arguments })); }
public override void Result <TMessage>(IWampFormatter <TMessage> formatter, ResultDetails details) { // TODO: throw exception if not nullable. SetResult(default(TResult)); }
public override void Result <TMessage>(IWampFormatter <TMessage> formatter, ResultDetails details, TMessage[] arguments, IDictionary <string, TMessage> argumentsKeywords) { string[] result = arguments.Select(x => formatter.Deserialize <string>(x)) .ToArray(); mTask.SetResult(result); }
protected override void RunTest(PlanSetup plan) { DisplayName = "Couch Values"; ResultDetails = ""; TestExplanation = "Checks that couch values are entered for each field based on department standards"; #region Macomb/Detroit Groups, Central, and Northern // Any couch values entered if (Department == Department.CLA || Department == Department.MAC || Department == Department.MPH || Department == Department.DET || Department == Department.FAR || Department == Department.CEN || Department == Department.NOR) { //Check each field to see if couch values are NaN foreach (Beam field in plan.Beams) { if (field.ControlPoints.First().TableTopLateralPosition.ToString() == "NaN" || field.ControlPoints.First().TableTopLongitudinalPosition.ToString() == "NaN" || field.ControlPoints.First().TableTopVerticalPosition.ToString() == "NaN") { Result = "Warning"; ResultDetails += "No couch values for " + field.Id.ToString() + ": "; DisplayColor = ResultColorChoices.Warn; if (field.ControlPoints.First().TableTopLateralPosition.ToString() == "NaN") { ResultDetails += "lat, "; } if (field.ControlPoints.First().TableTopLongitudinalPosition.ToString() == "NaN") { ResultDetails += "long, "; } if (field.ControlPoints.First().TableTopVerticalPosition.ToString() == "NaN") { ResultDetails += "vert, "; } ResultDetails = ResultDetails.TrimEnd(' '); ResultDetails = ResultDetails.TrimEnd(','); ResultDetails += '\n'; } } ResultDetails = ResultDetails.TrimEnd('\n'); //no issues found if (ResultDetails == "") { Result = ""; ResultDetails = $"Lat: {(ConvertCouchLatToVarianIECScale(plan.Beams.First().ControlPoints.First().TableTopLateralPosition) / 10.0).ToString("0.0")} cm\n" + $"Long: {(plan.Beams.First().ControlPoints.First().TableTopLongitudinalPosition / 10.0).ToString("0.0")} cm\n" + $"Vert: {(ConvertCouchVertToVarianIECScale(plan.Beams.First().ControlPoints.First().TableTopVerticalPosition) / 10.0).ToString("0.0")} cm"; DisplayColor = ResultColorChoices.Pass; } } #endregion #region Flint Group // Vert = 0 // Long = 100 // Lat = 0 else if (Department == Department.LAP || Department == Department.FLT || Department == Department.OWO) { //Check each field to see if couch values are NaN foreach (Beam field in plan.Beams) { if (field.ControlPoints.FirstOrDefault().TableTopLateralPosition != 0 || field.ControlPoints.FirstOrDefault().TableTopLongitudinalPosition != 1000 || field.ControlPoints.FirstOrDefault().TableTopVerticalPosition != 0) { Result = "Warning"; ResultDetails += "Couch value incorrect for " + field.Id.ToString() + ": "; DisplayColor = ResultColorChoices.Warn; if (field.ControlPoints.First().TableTopLateralPosition != 0) { ResultDetails += "lat, "; } if (field.ControlPoints.First().TableTopLongitudinalPosition != 1000) { ResultDetails += "long, "; } if (field.ControlPoints.First().TableTopVerticalPosition != 0) { ResultDetails += "vert, "; } ResultDetails = ResultDetails.TrimEnd(' '); ResultDetails = ResultDetails.TrimEnd(','); ResultDetails += '\n'; } } ResultDetails = ResultDetails.TrimEnd('\n'); //no issues found if (ResultDetails == "") { Result = ""; if (Department == Department.LAP || Department == Department.OWO) { ResultDetails = $"Lat: {(ConvertCouchLatToVarianStandardScale(plan.Beams.First().ControlPoints.First().TableTopLateralPosition) / 10.0).ToString("0.0")} cm\nLong: {(plan.Beams.First().ControlPoints.First().TableTopLongitudinalPosition / 10.0).ToString("0.0")} cm\nVert: {(ConvertCouchVertToVarianStandardScale(plan.Beams.First().ControlPoints.First().TableTopVerticalPosition) / 10.0).ToString("0.0")} cm"; } else { ResultDetails = $"Lat: {(ConvertCouchLatToVarianIECScale(plan.Beams.First().ControlPoints.First().TableTopLateralPosition) / 10.0).ToString("0.0")} cm\n" + $"Long: {(plan.Beams.First().ControlPoints.First().TableTopLongitudinalPosition / 10.0).ToString("0.0")} cm\n" + $"Vert: {(ConvertCouchVertToVarianIECScale(plan.Beams.First().ControlPoints.First().TableTopVerticalPosition) / 10.0).ToString("0.0")} cm"; } DisplayColor = ResultColorChoices.Pass; } } #endregion #region Lansing // Vert <= 50 // Long = 50 // Lat = 0 else if (Department == Department.LAN) { //Check each field to see if couch values are NaN foreach (Beam field in plan.Beams) { if (field.ControlPoints.First().TableTopLateralPosition != 0 || field.ControlPoints.First().TableTopLongitudinalPosition != 500 || field.ControlPoints.First().TableTopVerticalPosition < -500) { Result = "Warning"; ResultDetails += "Couch value incorrect for " + field.Id.ToString() + ": "; DisplayColor = ResultColorChoices.Warn; if (field.ControlPoints.First().TableTopLateralPosition != 0) { ResultDetails += "lat, "; } if (field.ControlPoints.First().TableTopLongitudinalPosition != 500) { ResultDetails += "long, "; } if (field.ControlPoints.First().TableTopVerticalPosition < -500) { ResultDetails += "vert, "; } ResultDetails = ResultDetails.TrimEnd(' '); ResultDetails = ResultDetails.TrimEnd(','); ResultDetails += '\n'; } } ResultDetails = ResultDetails.TrimEnd('\n'); //no issues found if (ResultDetails == "") { ResultDetails = $"Lat: {(ConvertCouchLatToVarianIECScale(plan.Beams.First().ControlPoints.First().TableTopLateralPosition) / 10.0).ToString("0.0")} cm\n" + $"Long: {(plan.Beams.First().ControlPoints.First().TableTopLongitudinalPosition / 10.0).ToString("0.0")} cm\n" + $"Vert: {(ConvertCouchVertToVarianIECScale(plan.Beams.First().ControlPoints.First().TableTopVerticalPosition) / 10.0).ToString("0.0")} cm"; DisplayColor = ResultColorChoices.Pass; } } #endregion else { TestNotImplemented(); } }
public override void Result <TMessage>(IWampFormatter <TMessage> formatter, ResultDetails details, TMessage[] arguments) { int result = formatter.Deserialize <int>(arguments[0]); mTask.SetResult(result); }
public override void Result <TMessage>(IWampFormatter <TMessage> formatter, ResultDetails details, TMessage[] arguments, IDictionary <string, TMessage> argumentsKeywords) { string result = formatter.Deserialize <string>(arguments[0]); mTask.SetResult(result); }
public override void Result <TMessage>(IWampFormatter <TMessage> formatter, ResultDetails details, TMessage[] arguments, IDictionary <string, TMessage> argumentsKeywords) { mTask.SetResult(true); }
public override void Result <TMessage>(IWampFormatter <TMessage> formatter, ResultDetails details, TMessage[] arguments) { mTask.SetResult(true); }
public async Task <ResultDetails <OptimizeResult> > IndexOptimizeAsync(string index, OptimizeParameters optimizeParameters) { if (optimizeParameters == null) { optimizeParameters = new OptimizeParameters(); } var elasticUrlForPostRequest = string.Format("{0}/{1}/_optimize{2}", _connectionString, index, optimizeParameters.GetOptimizeParameters()); var uri = new Uri(elasticUrlForPostRequest); _traceProvider.Trace(TraceEventType.Verbose, "IndexOptimizeAsync Request POST with url: {0}", uri.ToString()); var resultDetails = new ResultDetails <OptimizeResult> { Status = HttpStatusCode.InternalServerError }; try { var request = new HttpRequestMessage(HttpMethod.Post, uri); var response = await _client.SendAsync(request, _cancellationTokenSource.Token).ConfigureAwait(true); resultDetails.RequestUrl = uri.OriginalString; resultDetails.Status = response.StatusCode; if (response.StatusCode != HttpStatusCode.OK) { if (response.StatusCode == HttpStatusCode.BadRequest) { var errorInfo = await response.Content.ReadAsStringAsync().ConfigureAwait(true); resultDetails.Description = errorInfo; throw new ElasticException( "IndexOptimizeAsync: HttpStatusCode.BadRequest: RoutingMissingException, adding the parent Id if this is a child item..."); } if (response.StatusCode == HttpStatusCode.NotFound) { throw new ElasticException("IndexOptimizeAsync: HttpStatusCode.NotFound index does not exist"); } _traceProvider.Trace(TraceEventType.Information, "IndexOptimizeAsync: response status code: {0}, {1}", response.StatusCode, response.ReasonPhrase); } else { var responseString = await response.Content.ReadAsStringAsync().ConfigureAwait(true); var responseObject = JObject.Parse(responseString); resultDetails.PayloadResult = responseObject.ToObject <OptimizeResult>(); } return(resultDetails); } catch (OperationCanceledException oex) { _traceProvider.Trace(TraceEventType.Verbose, oex, "IndexOptimizeAsync: Get Request OperationCanceledException: {0}", oex.Message); return(resultDetails); } }
public async Task <ResultDetails <T> > GetDocumentAsync <T>(object entityId, RoutingDefinition routingDefinition) { _traceProvider.Trace(TraceEventType.Verbose, "{2}: Request for select document with id: {0}, Type: {1}", entityId, typeof(T), "ElasticSearchContextGet"); var resultDetails = new ResultDetails <T> { Status = HttpStatusCode.InternalServerError }; try { var elasticSearchMapping = _elasticSerializerConfiguration.ElasticMappingResolver .GetElasticSearchMapping(typeof(T)); var elasticUrlForEntityGet = string.Format("{0}/{1}/{2}/", _connectionString, elasticSearchMapping.GetIndexForType(typeof(T)), elasticSearchMapping.GetDocumentType(typeof(T))); var uri = new Uri( elasticUrlForEntityGet + entityId + RoutingDefinition.GetRoutingUrl(routingDefinition)); _traceProvider.Trace(TraceEventType.Verbose, "{1}: Request HTTP GET uri: {0}", uri.AbsoluteUri, "ElasticSearchContextGet"); var response = await _client.GetAsync(uri, _cancellationTokenSource.Token).ConfigureAwait(false); resultDetails.RequestUrl = uri.OriginalString; resultDetails.Status = response.StatusCode; if (response.StatusCode != HttpStatusCode.OK) { _traceProvider.Trace(TraceEventType.Warning, "{2}: GetDocumentAsync response status code: {0}, {1}", response.StatusCode, response.ReasonPhrase, "ElasticSearchContextGet"); if (response.StatusCode == HttpStatusCode.BadRequest) { var errorInfo = await response.Content.ReadAsStringAsync().ConfigureAwait(false); resultDetails.Description = errorInfo; if (errorInfo.Contains("RoutingMissingException")) { throw new ElasticException( "HttpStatusCode.BadRequest: RoutingMissingException, adding the parent Id if this is a child item..."); } return(resultDetails); } } var responseString = await response.Content.ReadAsStringAsync().ConfigureAwait(false); _traceProvider.Trace(TraceEventType.Verbose, "{1}: Get Request response: {0}", responseString, "ElasticSearchContextGet"); var responseObject = JObject.Parse(responseString); var source = responseObject["_source"]; if (source != null) { var result = _elasticSerializerConfiguration.ElasticMappingResolver .GetElasticSearchMapping(typeof(T)).ParseEntity(source, typeof(T)); resultDetails.PayloadResult = (T)result; } return(resultDetails); } catch (OperationCanceledException oex) { _traceProvider.Trace(TraceEventType.Verbose, oex, "{1}: Get Request OperationCanceledException: {0}", oex.Message, "ElasticSearchContextGet"); return(resultDetails); } }
public void Result(long requestId, ResultDetails details, object[] arguments) { Send(mResult3, requestId, details, arguments); }
public async Task <ResultDetails <bool> > PostSearchExistsAsync <T>(string jsonContent, SearchUrlParameters searchUrlParameters) { _traceProvider.Trace(TraceEventType.Verbose, "{2}: Request for search exists: {0}, content: {1}", typeof(T), jsonContent, "Search"); var resultDetails = new ResultDetails <bool> { Status = HttpStatusCode.InternalServerError, RequestBody = jsonContent }; var urlParams = ""; if (searchUrlParameters != null) { urlParams = searchUrlParameters.GetUrlParameters(); } try { var elasticSearchMapping = _elasticsearchSerializerConfiguration.ElasticsearchMappingResolver.GetElasticSearchMapping(typeof(T)); var elasticsearchUrlForSearchExists = string.Format("{0}/{1}/{2}/_search/exists{3}", _connectionString, elasticSearchMapping.GetIndexForType(typeof(T)), elasticSearchMapping.GetDocumentType(typeof(T)), urlParams); var content = new StringContent(jsonContent); var uri = new Uri(elasticsearchUrlForSearchExists); _traceProvider.Trace(TraceEventType.Verbose, "{1}: Request HTTP Post uri: {0}", uri.AbsoluteUri, "Search"); content.Headers.ContentType = new MediaTypeHeaderValue("application/json"); resultDetails.RequestUrl = elasticsearchUrlForSearchExists; var response = await _client.PostAsync(uri, content, _cancellationTokenSource.Token).ConfigureAwait(true); resultDetails.Status = response.StatusCode; if (response.StatusCode != HttpStatusCode.OK) { _traceProvider.Trace(TraceEventType.Warning, "{2}: Post seach exists async response status code: {0}, {1}", response.StatusCode, response.ReasonPhrase, "Search"); if (response.StatusCode == HttpStatusCode.BadRequest) { var errorInfo = await response.Content.ReadAsStringAsync().ConfigureAwait(true); resultDetails.Description = errorInfo; return(resultDetails); } if (response.StatusCode == HttpStatusCode.NotFound) { var errorInfo = await response.Content.ReadAsStringAsync().ConfigureAwait(true); resultDetails.Description = errorInfo; return(resultDetails); } } var responseString = await response.Content.ReadAsStringAsync().ConfigureAwait(true); _traceProvider.Trace(TraceEventType.Verbose, "{1}: Get Request response: {0}", responseString, "Search"); var responseObject = JObject.Parse(responseString); var source = responseObject["exists"]; resultDetails.PayloadResult = (bool)source; return(resultDetails); } catch (OperationCanceledException oex) { _traceProvider.Trace(TraceEventType.Verbose, oex, "{1}: Get Request OperationCanceledException: {0}", oex.Message, "Search"); return(resultDetails); } }
public override void Display() { base.Display(); ResultDetails.SetActive(false); }
public WampMessage <object> Result(long requestId, ResultDetails details, object[] arguments, IDictionary <string, object> argumentsKeywords) { return(mSerializer.SerializeRequest(mResult4, new object[] { requestId, details, arguments, argumentsKeywords })); }
public void Result <TMessage>(IWampFormatter <TMessage> formatter, ResultDetails details) { mTask.SetResult(-1); // -1 indicates no final return value }
public void Result(long requestId, ResultDetails details) { Send(mResult2, requestId, details); }
private void OnResult(object sender, ResultDetails <int, bool> value) => lastResult = value.Result;
public void Result(long requestId, ResultDetails details, object[] arguments, IDictionary <string, object> argumentsKeywords) { Send(mResult4, requestId, details, arguments, argumentsKeywords); }
public void Result <TMessage>(IWampFormatter <TMessage> formatter, ResultDetails details, TMessage[] arguments, IDictionary <string, TMessage> argumentsKeywords) { }
public void Result <TMessage>(IWampFormatter <TMessage> formatter, ResultDetails details, TMessage[] arguments, IDictionary <string, TMessage> argumentsKeywords) { throw new NotImplementedException(); }
public void Result(long requestId, ResultDetails details, TMessage[] arguments, IDictionary <string, TMessage> argumentsKeywords) { Caller.Result(requestId, details, arguments, argumentsKeywords); }
public void Result <TMessage>(IWampFormatter <TMessage> formatter, ResultDetails details) { }
public async Task <ResultDetails <string> > SaveChangesAsync(List <EntityContextInfo> entityPendingChanges) { _traceProvider.Trace(TraceEventType.Verbose, "{0}: Save changes to Elasticsearch started", "ElasticsearchContextAddDeleteUpdate"); var resultDetails = new ResultDetails <string> { Status = HttpStatusCode.InternalServerError }; if (entityPendingChanges.Count == 0) { resultDetails = new ResultDetails <string> { Status = HttpStatusCode.OK, Description = "Nothing to save" }; return(resultDetails); } try { string serializedEntities; using (var serializer = new ElasticsearchSerializer(_traceProvider, _elasticsearchSerializerConfiguration, _saveChangesAndInitMappings)) { var result = serializer.Serialize(entityPendingChanges); if (_saveChangesAndInitMappings) { await result.IndexMappings.Execute(_client, _connectionString, _traceProvider, _cancellationTokenSource); } _saveChangesAndInitMappings = false; serializedEntities = result.Content; } var content = new StringContent(serializedEntities); _traceProvider.Trace(TraceEventType.Verbose, "{1}: sending bulk request: {0}", serializedEntities, "ElasticsearchContextAddDeleteUpdate"); _traceProvider.Trace(TraceEventType.Verbose, "{1}: Request HTTP POST uri: {0}", _elasticsearchUrlBatch.AbsoluteUri, "ElasticsearchContextAddDeleteUpdate"); content.Headers.ContentType = new MediaTypeHeaderValue("application/json"); resultDetails.RequestUrl = _elasticsearchUrlBatch.OriginalString; var response = await _client.PostAsync(_elasticsearchUrlBatch, content, _cancellationTokenSource.Token).ConfigureAwait(true); resultDetails.Status = response.StatusCode; if (response.StatusCode != HttpStatusCode.OK) { _traceProvider.Trace(TraceEventType.Warning, "{2}: SaveChangesAsync response status code: {0}, {1}", response.StatusCode, response.ReasonPhrase, "ElasticsearchContextAddDeleteUpdate"); if (response.StatusCode == HttpStatusCode.BadRequest) { var errorInfo = await response.Content.ReadAsStringAsync().ConfigureAwait(false); resultDetails.Description = errorInfo; return(resultDetails); } return(resultDetails); } var responseString = await response.Content.ReadAsStringAsync().ConfigureAwait(false); var responseObject = JObject.Parse(responseString); _traceProvider.Trace(TraceEventType.Verbose, "{1}: response: {0}", responseString, "ElasticsearchContextAddDeleteUpdate"); string errors = String.Empty; var items = responseObject["items"]; if (items != null) { foreach (var item in items) { if (item["delete"] != null && item["delete"]["status"] != null) { if (item["delete"]["status"].ToString() == "404") { resultDetails.Status = HttpStatusCode.NotFound; errors = errors + string.Format("Delete failed for item: {0}, {1}, {2} :", item["delete"]["_index"], item["delete"]["_type"], item["delete"]["_id"]); } } } } resultDetails.Description = responseString; resultDetails.PayloadResult = serializedEntities; if (!String.IsNullOrEmpty(errors)) { _traceProvider.Trace(TraceEventType.Warning, errors); throw new ElasticsearchCrudException(errors); } return(resultDetails); } catch (OperationCanceledException oex) { _traceProvider.Trace(TraceEventType.Warning, oex, "{1}: Get Request OperationCanceledException: {0}", oex.Message, "ElasticsearchContextAddDeleteUpdate"); resultDetails.Description = "OperationCanceledException"; return(resultDetails); } finally { entityPendingChanges.Clear(); } }
public abstract void Result <TMessage>(IWampFormatter <TMessage> formatter, ResultDetails details, TMessage[] arguments);
public async Task <ResultDetails <string> > Execute(HttpClient client, string baseUrl, ITraceProvider traceProvider, CancellationTokenSource cancellationTokenSource) { var resultDetails = new ResultDetails <string> { Status = HttpStatusCode.InternalServerError }; foreach (var command in Commands) { var content = new StringContent(command.Content + "\n"); traceProvider.Trace(TraceEventType.Verbose, "{1}: sending init mappings request: {0}", command, "InitMappings"); traceProvider.Trace(TraceEventType.Verbose, "{1}: Request HTTP PUT uri: {0}", command.Url, "InitMappings"); traceProvider.Trace(TraceEventType.Verbose, "{1}: Request HTTP PUT content: {0}", command.Content, "InitMappings"); content.Headers.ContentType = new MediaTypeHeaderValue("application/json"); HttpResponseMessage response; if (command.RequestType == "POST") { response = await client.PostAsync(baseUrl + command.Url, content, cancellationTokenSource.Token) .ConfigureAwait(true); } else { response = await client.PutAsync(baseUrl + command.Url, content, cancellationTokenSource.Token) .ConfigureAwait(true); } if (response.StatusCode == HttpStatusCode.BadRequest) { var errorInfo = await response.Content.ReadAsStringAsync().ConfigureAwait(true); var responseObject = JObject.Parse(errorInfo); var source = responseObject["error"]; throw new ElasticException("IndexMappings: Execute Request POST BadRequest: " + source); } //resultDetails.Status = response.StatusCode; if (response.StatusCode != HttpStatusCode.OK && response.StatusCode != HttpStatusCode.Created) { traceProvider.Trace(TraceEventType.Warning, "{2}: SaveChangesAsync response status code: {0}, {1}", response.StatusCode, response.ReasonPhrase, "InitMappings"); if (response.StatusCode == HttpStatusCode.BadRequest) { var errorInfo = await response.Content.ReadAsStringAsync().ConfigureAwait(true); resultDetails.Description = errorInfo; return(resultDetails); } return(resultDetails); } var responseString = await response.Content.ReadAsStringAsync().ConfigureAwait(true); traceProvider.Trace(TraceEventType.Verbose, "{1}: response: {0}", responseString, "InitMappings"); } // no errors resultDetails.Status = HttpStatusCode.OK; return(resultDetails); }