private void GetDilemmaResponse(RESTConnector.Request req, RESTConnector.Response resp) { DilemmasResponse response = new DilemmasResponse(); if (resp.Success) { try { fsData data = null; fsResult r = fsJsonParser.Parse(Encoding.UTF8.GetString(resp.Data), out data); if (!r.Succeeded) { throw new WatsonException(r.FormattedMessages); } object obj = response; r = sm_Serializer.TryDeserialize(data, obj.GetType(), ref obj); if (!r.Succeeded) { throw new WatsonException(r.FormattedMessages); } } catch (Exception e) { Log.Error("TradeoffAnalytics", "GetDilemmaResponse Exception: {0}", e.ToString()); resp.Success = false; } } if (((GetDilemmaRequest)req).Callback != null) { ((GetDilemmaRequest)req).Callback(resp.Success ? response : null); } }
private void OnGetDilemma(DilemmasResponse resp) { if (m_Callback != null && resp != null) { m_Callback(SERVICE_ID, true); } else { OnFailure("DillemaResponse is null"); } }
private void GetDilemmaResponse(RESTConnector.Request req, RESTConnector.Response resp) { DilemmasResponse result = new DilemmasResponse(); fsData data = null; Dictionary <string, object> customData = ((GetDilemmaRequest)req).CustomData; if (resp.Success) { try { fsResult r = fsJsonParser.Parse(Encoding.UTF8.GetString(resp.Data), out data); if (!r.Succeeded) { throw new WatsonException(r.FormattedMessages); } object obj = result; r = _serializer.TryDeserialize(data, obj.GetType(), ref obj); if (!r.Succeeded) { throw new WatsonException(r.FormattedMessages); } customData.Add("json", data); } catch (Exception e) { Log.Error("TradeoffAnalytics.GetDilemmaResponse()", "GetDilemmaResponse Exception: {0}", e.ToString()); resp.Success = false; } } if (resp.Success) { if (((GetDilemmaRequest)req).SuccessCallback != null) { ((GetDilemmaRequest)req).SuccessCallback(result, customData); } } else { if (((GetDilemmaRequest)req).FailCallback != null) { ((GetDilemmaRequest)req).FailCallback(resp.Error, customData); } } }