Ejemplo n.º 1
0
        /// <summary>
        /// Returns a dilemma that contains the problem and a resolution. The problem contains a set of options and objectives. The resolution
        /// contains a set of optimal options, their analytical characteristics, and by default their representation on a two-dimensional space.
        /// You can optionally request that the service also return a refined set of preferable options that are most likely to appeal to the
        /// greatest number of users
        /// </summary>
        /// <param name="successCallback">The success callback.</param>
        /// <param name="failCallback">The fail callback.</param>
        /// <param name="problem">The decision problem.</param>
        /// <param name="generateVisualization">Indicates whether to calculate the map visualization. If true, the visualization is returned if
        /// the is_objective field is true for at least three columns and at least three options have a status of FRONT in the problem resolution.</param>
        /// <param name="customData">Optional custom data.</param>
        /// <returns></returns>
        public bool GetDilemma(SuccessCallback <DilemmasResponse> successCallback, FailCallback failCallback, Problem problem, Boolean generateVisualization, Dictionary <string, object> customData = null)
        {
            if (successCallback == null)
            {
                throw new ArgumentNullException("successCallback");
            }
            if (failCallback == null)
            {
                throw new ArgumentNullException("failCallback");
            }

            RESTConnector connector = RESTConnector.GetConnector(Credentials, DillemaEndpoint);

            if (connector == null)
            {
                return(false);
            }

            GetDilemmaRequest req = new GetDilemmaRequest();

            req.SuccessCallback = successCallback;
            req.FailCallback    = failCallback;
            req.CustomData      = customData == null ? new Dictionary <string, object>() : customData;
            req.OnResponse      = GetDilemmaResponse;
            req.Parameters["generate_visualization"] = generateVisualization.ToString();

            fsData tempData = null;

            _serializer.TrySerialize <Problem>(problem, out tempData);

            req.Send = Encoding.UTF8.GetBytes(tempData.ToString());
            req.Headers["Content-Type"] = "application/json";

            return(connector.Send(req));
        }
Ejemplo n.º 2
0
        public bool GetDilemma(OnDilemma callback, Problem problem, Boolean generateVisualization)
        {
            if (callback == null)
            {
                throw new ArgumentNullException("callback");
            }

            RESTConnector connector = RESTConnector.GetConnector(SERVICE_ID, FUNCTION_DILEMMA);

            if (connector == null)
            {
                return(false);
            }

            GetDilemmaRequest req = new GetDilemmaRequest();

            req.Callback   = callback;
            req.OnResponse = GetDilemmaResponse;
            req.Parameters["generate_visualization"] = generateVisualization.ToString();

            fsData tempData = null;

            sm_Serializer.TrySerialize <Problem>(problem, out tempData);

            Log.Status("GetDilemma", "JSON: {0}", tempData.ToString());

            req.Send = Encoding.UTF8.GetBytes(tempData.ToString());
            req.Headers["Content-Type"] = "application/json";

            return(connector.Send(req));
        }
Ejemplo n.º 3
0
        public bool GetDilemma(OnDilemma callback, Problem problem, Boolean generateVisualization, string customData = default(string))
        {
            if (callback == null)
            {
                throw new ArgumentNullException("callback");
            }

            RESTConnector connector = RESTConnector.GetConnector(Credentials, DillemaEndpoint);

            if (connector == null)
            {
                return(false);
            }

            GetDilemmaRequest req = new GetDilemmaRequest();

            req.Callback   = callback;
            req.OnResponse = GetDilemmaResponse;
            req.Data       = customData;
            req.Parameters["generate_visualization"] = generateVisualization.ToString();

            fsData tempData = null;

            _serializer.TrySerialize <Problem>(problem, out tempData);

            req.Send = Encoding.UTF8.GetBytes(tempData.ToString());
            req.Headers["Content-Type"] = "application/json";

            return(connector.Send(req));
        }