Skip to content

Instantly share code, notes, and snippets.

@gbraccialli
Created October 28, 2015 17:50
Show Gist options
  • Save gbraccialli/5f1497a9c220ecd0dd5c to your computer and use it in GitHub Desktop.
Save gbraccialli/5f1497a9c220ecd0dd5c to your computer and use it in GitHub Desktop.
using System;
using System.Net;
using System.Collections.Generic;
using Newtonsoft.Json;
using System.Text;
namespace ConsoleApplication1
{
class PhoenixSample
{
public class FirstFrame
{
public String offset;
public List<List<String>> rows;
}
public class Result
{
public FirstFrame firstFrame;
public int updateCount;
}
public class PhoenixResult
{
public string response { get; set; }
public List<Result> results { get; set; }
}
static void Main(string[] args)
{
try
{
string url = "http://192.168.56.203:8765";
string query = "select * from test";
var syncClient = new WebClient();
syncClient.Headers["request"] = "{\"request\":\"prepareAndExecute\",\"connectionId\":\"b27cbc83-a514-49f0-9bbe-f15d8bfb3532\",\"sql\":\"" + query + "\",\"maxRowCount\":-1}";
syncClient.Headers["Content-Type"] = "application/json";
byte[] responseArray = syncClient.UploadData(url, "POST", Encoding.ASCII.GetBytes(""));
string json = Encoding.ASCII.GetString(responseArray);
System.Diagnostics.Debug.WriteLine("teste");
System.Diagnostics.Debug.WriteLine("json=" + json);
PhoenixResult test = JsonConvert.DeserializeObject<PhoenixResult>(json);
System.Diagnostics.Debug.WriteLine(test.response);
System.Diagnostics.Debug.WriteLine(test.results[0].updateCount);
for (int i = 0; i < test.results[0].firstFrame.rows.Count; i++)
{
for (int j = 0; j < test.results[0].firstFrame.rows[i].Count; j++)
{
System.Diagnostics.Debug.Write("row # " + i + " col # " + j + " = ");
System.Diagnostics.Debug.WriteLine(test.results[0].firstFrame.rows[i][j]);
}
}
}
catch (Exception e)
{
Console.WriteLine(e.Message);
Console.Read();
}
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment