// Requests a HISTORY TICK or HISTORY OHLC record by building up the appropriate // XML string and sending it to the QT Server
private void buttonRequestHistory_Click(object sender, System.EventArgs e)
{
try
{
FormGetHistory FormGetHistory = new FormGetHistory();
if (FormGetHistory.ShowDialog(this) == DialogResult.OK)
{
if (FormGetHistory.radioButtonTick.Checked == true)
mReqType = "TICK";
else
mReqType = "OHLC";
DateTime From = DateTime.Parse(FormGetHistory.dateTimePickerFrom.Text);
DateTime To = DateTime.Parse(FormGetHistory.dateTimePickerTo.Text);
string data = "<GetHistory><ReqType>" + mReqType + "</ReqType>";
data += "<Symbol>" + FormGetHistory.textBoxSymbol.Text + "</Symbol>";
data += "<FROM>" + From.ToString("yyyy/MM/dd HH:mm:ss") + "</FROM><TO>" + To.ToString("yyyy/MM/dd HH:mm:ss") + "</TO></GetHistory>";
byte[] byteData = Encoding.ASCII.GetBytes(data + "\0");
byteData[byteData.Length-1] = 255;
mClient.Send(byteData, 0, byteData.Length, SocketFlags.None);
StateObject state = new StateObject();
mClient.BeginReceive( state.buffer, 0, StateObject.BufferSize, 0,
new AsyncCallback(ReceiveCallback), state);
RichTextBoxAppendText(richTextBoxMessageToServer, data + Environment.NewLine);
}
}
catch(Exception ex)
{
MessageBox.Show(ex.Message);
}
}