Beispiel #1
0
        public static ReturnCode ReturnCode(string json) // The logic is this: if the message text is empty, then the result = Success, otherwise = depending on the code //
        {
            ReturnCode code = ReturnCodeFactory.Error(ExtractTextMessage(json));

            code.NumericValue = CxConvert.ToInt32(ExtractNumericCode(json), ReturnCodeFactory.NcError);
            if (code.StringValue == string.Empty)
            {
                code.NumericValue = ReturnCodeFactory.NcSuccess;
            }
            return(code);
        }
Beispiel #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);
        }
        public ReceivedValueColor FromString(string value)
        {
            Color color;

            try
            {
                color = CxConvert.JsonToObject <Color>(value);
            }
            catch
            {
                return(ReceivedValueColor.Error(ReturnCodeFactory.NcError));
            }
            return(ReceivedValueColor.Success(color));
        }
Beispiel #4
0
        public ReceivedValueFont FromString(string value)
        {
            Font font;

            try
            {
                font = CxConvert.JsonToObject <Font>(value);
            }
            catch
            {
                return(ReceivedValueFont.Error(ReturnCodeFactory.NcError));
            }
            return(ReceivedValueFont.Success(font));
        }
Beispiel #5
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);
        }
 public void SetRowHeight(int height) => Grid.TableElement.RowHeight = CxConvert.ValueInRange(height, 20, 50);
 public static int ZzGetIntegerValueByFieldName(this RadGridView grid, string FieldName, int DefaultValue) => CxConvert.ToInt32(ZzGetStringValue(grid, Standard.GetGridColumnName(FieldName)), DefaultValue);
Beispiel #8
0
 public static string GetDateOfFile(string FileName) => CxConvert.ToString(File.GetLastWriteTime(FileName));
Beispiel #9
0
 public static string GetDateOfPdbFile() => CxConvert.ToString(File.GetLastWriteTime($"{System.Reflection.Assembly.GetExecutingAssembly().GetName().Name}.pdb"));
 public string ToString(Color value)
 {
     return(CxConvert.ObjectToJson(value));
 }