Correcting bug with rowtype error. converting to resultsetmetadata (#2596)
* Update script.csx * Update script.csx changing resultsetmetadata error * Update script.csx
This commit is contained in:
Родитель
1f895f12fb
Коммит
59d455cb6b
|
@ -30,13 +30,13 @@ public class Script : ScriptBase
|
|||
var contentAsJson = JObject.Parse(contentAsString);
|
||||
|
||||
// check for parameters
|
||||
if (contentAsJson["data"] == null || contentAsJson["rowType"]==null)
|
||||
if (contentAsJson["data"] == null || contentAsJson["resultSetMetadata"]==null)
|
||||
{
|
||||
return createErrorResponse("rowType or data parameter are empty!", HttpStatusCode.BadRequest);
|
||||
return createErrorResponse("resultSetMetadata or data parameter are empty!", HttpStatusCode.BadRequest);
|
||||
}
|
||||
|
||||
// get metadata
|
||||
var cols = JArray.Parse(contentAsJson["rowType"].ToString());
|
||||
var cols = JArray.Parse(contentAsJson["resultSetMetadata"].ToString());
|
||||
var rows = JArray.Parse(contentAsJson["data"].ToString());
|
||||
|
||||
JArray newRows = new JArray();
|
||||
|
@ -54,8 +54,16 @@ public class Script : ScriptBase
|
|||
switch (type)
|
||||
{
|
||||
case "fixed":
|
||||
long myLong = long.Parse(row[i].ToString());
|
||||
newRow.Add(new JProperty(name.ToString(), myLong));
|
||||
long scale = 0;
|
||||
long.TryParse(col["scale"].ToString(), out scale);
|
||||
if (scale == 0)
|
||||
{
|
||||
long myLong = long.Parse(row[i].ToString());
|
||||
newRow.Add(new JProperty(name.ToString(), myLong));
|
||||
} else {
|
||||
double myDouble = double.Parse(row[i].ToString());
|
||||
newRow.Add(new JProperty(name.ToString(), myDouble));
|
||||
}
|
||||
break;
|
||||
case "float":
|
||||
float myFloat = float.Parse(row[i].ToString());
|
||||
|
@ -97,11 +105,11 @@ public class Script : ScriptBase
|
|||
};
|
||||
response = new HttpResponseMessage(HttpStatusCode.OK);
|
||||
response.Content = CreateJsonContent(output.ToString());
|
||||
return response;
|
||||
return response;
|
||||
}
|
||||
catch (JsonReaderException ex)
|
||||
{
|
||||
return createErrorResponse("'rowType' or 'data' are in an invalid format: " + ex, HttpStatusCode.BadRequest);
|
||||
return createErrorResponse("'resultSetMetadata' or 'data' are in an invalid format: " + ex, HttpStatusCode.BadRequest);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
|
@ -120,4 +128,4 @@ public class Script : ScriptBase
|
|||
return response;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
|
Загрузка…
Ссылка в новой задаче