public ReceivedValueColor FromString(string value)
        {
            Color color;

            try
            {
                color = CxConvert.JsonToObject <Color>(value);
            }
            catch
            {
                return(ReceivedValueColor.Error(ReturnCodeFactory.NcError));
            }
            return(ReceivedValueColor.Success(color));
        }
Exemple #2
0
        public static async Task <ReturnCode> FromHttpResponse(HttpResponseMessage response, bool KeepReturnCodeGivenByStoredProcedure)
        {
            ReturnCode code;

            if (KeepReturnCodeGivenByStoredProcedure)
            {/* In this version, the method will return exactly the [ReturnCode] value that the server Stored Procedure returned */
                string json = await response.Content.ReadAsStringAsync();   code = CxConvert.JsonToObject <ReturnCode>(json);
            }
            else
            { /* In this variant, the method replaces the contents of the ReturnCode that the server Stored Procedure returned, returning its own ReturnCode value based on the HttpResponse Code */
                code = response.IsSuccessStatusCode ? Success() : Error(response.ReasonPhrase, response.StatusCode.ToString());
            }
            return(code);
        }
Exemple #3
0
        public ReceivedValueFont FromString(string value)
        {
            Font font;

            try
            {
                font = CxConvert.JsonToObject <Font>(value);
            }
            catch
            {
                return(ReceivedValueFont.Error(ReturnCodeFactory.NcError));
            }
            return(ReceivedValueFont.Success(font));
        }
Exemple #4
0
        public static async Task <ReturnCode> FromHttpResponse(HttpResponseMessage response)
        {/* In this version, the method will return exactly the [ReturnCode] value that the server Stored Procedure returned */
         //if (response.StatusCode == ServerCode.CodeErrorTimeout)  return Error("The server did not respond to your request.");
         //if (response.StatusCode == ServerCode.CodeError) return Error("An error occurred while executing the request!");

            ReturnCode code;

            try
            {
                string json = await response.Content.ReadAsStringAsync();

                code = CxConvert.JsonToObject <ReturnCode>(json);
            }
            catch (Exception ex)
            {
                code = Error("Error trying to get response from server! " + ex.Message + " " + ex.StackTrace, ex.Source);
            }

            return(code);
        }