Beispiel #1
0
 private static void printOutcomeEvent(OSOutcomeEvent outcomeEvent)
 {
     Debug.WriteLine(outcomeEvent.session.ToString() + "\n" +
                     string.Join(", ", outcomeEvent.notificationIds) + "\n" +
                     outcomeEvent.name + "\n" +
                     outcomeEvent.timestamp + "\n" +
                     outcomeEvent.weight);
 }
 private void printOutcomeEvent(OSOutcomeEvent outcomeEvent)
 {
     Console.WriteLine(outcomeEvent.session + "\n" +
                       string.Join(", ", outcomeEvent.notificationIds) + "\n" +
                       outcomeEvent.name + "\n" +
                       outcomeEvent.timestamp + "\n" +
                       outcomeEvent.weight);
 }
    // Called from the native SDK - Called After calling SendOutcome(...), SendUniqueOutcome(...), SendOutcomeWithValue(...)
    private void onSendOutcomeSuccess(string jsonString)
    {
        if (string.IsNullOrEmpty(jsonString))
        {
            return;
        }

        // Break part the jsonString which might contain a 'delegate_id' and a 'response'
        var jsonObject = Json.Deserialize(jsonString) as Dictionary <string, object>;

        // Check if the delegate should be processed
        if (!isValidDelegate(jsonObject))
        {
            return;
        }

        var delegateId = jsonObject["delegate_id"] as string;
        var response   = jsonObject["response"] as string;

        OSOutcomeEvent outcomeEvent;

        if (string.IsNullOrEmpty(response))
        {
            outcomeEvent = new OSOutcomeEvent();
        }
        else
        {
            // Parse outcome json string and return it through the callback
            var outcomeObject = Json.Deserialize(response) as Dictionary <string, object>;
            outcomeEvent = new OSOutcomeEvent(outcomeObject);
        }

        if (delegates.ContainsKey(delegateId) && delegates[delegateId] != null)
        {
            var sendOutcomeSuccess = (OnSendOutcomeSuccess)delegates[delegateId];
            delegates.Remove(delegateId);
            sendOutcomeSuccess(outcomeEvent);
        }
    }