public ActionResult Policy(int defaultAction = -1) { try { APIUtil.Authenticate(this.Request); var client = DecisionServiceClientFactory.AddOrGetExisting(ModelSuccessNotifier); var context = APIUtil.ReadBody(this.Request); var eventId = APIUtil.CreateEventId(); var action = defaultAction != -1 ? client.ChooseAction(eventId, context, defaultAction) : client.ChooseAction(eventId, context); return(Json(new { EventId = eventId, Action = action, ModelTime = ModelUpdateTime })); } catch (UnauthorizedAccessException ex) { return(new HttpStatusCodeResult(HttpStatusCode.Unauthorized, ex.Message)); } catch (Exception ex) { new TelemetryClient().TrackException(ex); return(new HttpStatusCodeResult(HttpStatusCode.InternalServerError, ex.ToString())); } }
public ActionResult Ranker(string defaultActions) { try { APIUtil.Authenticate(this.Request); int[] defaultActionArray = Array.ConvertAll(defaultActions.Split(new char[] { ',' }, StringSplitOptions.RemoveEmptyEntries), Convert.ToInt32); var client = DecisionServiceClientFactory.AddOrGetExisting(ModelSuccessNotifier); var context = APIUtil.ReadBody(this.Request); var eventId = APIUtil.CreateEventId(); var actions = defaultActionArray != null && defaultActionArray.Length > 0 ? client.ChooseRanking(eventId, context, defaultActionArray) : client.ChooseRanking(eventId, context); return(Json(new { EventId = eventId, Actions = actions, ModelTime = ModelUpdateTime })); } catch (UnauthorizedAccessException ex) { return(new HttpStatusCodeResult(HttpStatusCode.Unauthorized, ex.Message)); } catch (Exception ex) { new TelemetryClient().TrackException(ex); return(new HttpStatusCodeResult(HttpStatusCode.InternalServerError, ex.ToString())); } }
public async Task <ActionResult> Ranker(string defaultActions, string eventId) { try { APIUtil.Authenticate(this.Request); var client = DecisionServiceClientFactory.AddOrGetExisting(ModelSuccessNotifier); var context = APIUtil.ReadBody(this.Request); if (string.IsNullOrEmpty(eventId)) { eventId = APIUtil.CreateEventId(); } int[] actions; if (string.IsNullOrWhiteSpace(defaultActions)) { actions = await client.ChooseRankingAsync(eventId, context); } else { int[] defaultActionArray = Array.ConvertAll(defaultActions.Split(new char[] { ',' }, StringSplitOptions.RemoveEmptyEntries), Convert.ToInt32); actions = await client.ChooseRankingAsync(eventId, context, defaultActionArray); } return(Json(new { EventId = eventId, Actions = actions, ModelTime = ModelUpdateTime })); } catch (UnauthorizedAccessException ex) { return(new HttpStatusCodeResult(HttpStatusCode.Unauthorized, ex.Message)); } catch (Exception ex) { new TelemetryClient().TrackException(ex); return(new HttpStatusCodeResult(HttpStatusCode.InternalServerError, ex.ToString())); } }