//================================================================================ void Transaq_Connect() { // чтение параметров из формы sLogin = edt_Login.Text; sPassword = edt_Password.Text; ServerIP = edt_IP.Text; ServerPort = edt_Port.Text; // проверка наличия параметров if (sLogin.Length == 0) { ShowStatus("Не указан логин"); return; } if (sPassword.Length == 0) { ShowStatus("Не указан пароль"); return; } if (ServerIP.Length == 0) { ShowStatus("Не указан IP-адрес"); return; } if (ServerPort.Length == 0) { ShowStatus("Не указан порт"); return; } ConnectingReflect(); // очистка таблиц с данными DTS.t_timeframe.Clear(); DTS.t_security.Clear(); DTS.t_candle.Clear(); DTS.t_my_securities.Clear(); DTS.t_my_takingPositions.Clear(); DTS.t_my_ClosingPositions.Clear(); // формирование текста команды string cmd = "<command id=\"connect\">"; cmd = cmd + "<login>" + sLogin + "</login>"; cmd = cmd + "<password>" + sPassword + "</password>"; cmd = cmd + "<host>" + ServerIP + "</host>"; cmd = cmd + "<port>" + ServerPort + "</port>"; cmd = cmd + "<rqdelay>100</rqdelay>"; cmd = cmd + "<session_timeout>" + session_timeout.ToString() + "</session_timeout> "; cmd = cmd + "<request_timeout>" + request_timeout.ToString() + "</request_timeout>"; cmd = cmd + "</command>"; // отправка команды log.WriteLog("SendCommand: <command id=\"connect\"><login>" + sLogin + "</login><password>*</password><host>" + ServerIP + "</host><port>" + ServerPort + "</port><logsdir>" + AppDir + "</logsdir><rqdelay>100</rqdelay></command>"); TXmlConnector.statusDisconnected.Reset(); string res = TXmlConnector.ConnectorSendCommand(cmd); log.WriteLog("ServerReply: " + res); }
public static void sendNewStopOrder2Transaq(NewStopOrder stopOrder) { StringWriter stream = new StringWriter(); XmlWriter writer = XmlWriter.Create(stream, settingsXmlWriter); serializer4newStopOrders.Serialize(writer, stopOrder, emptyNamespaces); string cmd = stream.ToString(); string res = TXmlConnector.ConnectorSendCommand(cmd); }
//================================================================================ // отключение коннектора от сервера Транзак void Transaq_Disconnect() { DisconnectingReflect(); string cmd = "<command id=\"disconnect\"/>"; log.WriteLog("SendCommand: " + cmd); TXmlConnector.statusDisconnected.Reset(); string res = TXmlConnector.ConnectorSendCommand(cmd); log.WriteLog("ServerReply: " + res); }
private void btnPassChange_Click(object sender, EventArgs e) { // Проверяем пароль // Правило: только латинские буквы и цифры, минимум 4, максимум 19 string passPattern = @"^[a-zA-Z0-9]{4,20}$"; string oldPass = txtOldPass.Text; string newPass = txtNewPass.Text; string result; Match m = Regex.Match(newPass, passPattern); if (!bConnected) { ShowStatus("Для смены пароля подключитесь к серверу"); } else if (txtNewPass.Text.Length == 0) { ShowStatus("Введите новый пароль"); } else if (m.Success) { string cmd = String.Format("<command id=\"change_pass\" oldpass=\"{0}\" newpass=\"{1}\" />", oldPass, newPass); log.WriteLog("SendCommand: <command id=\"change_pass\" oldpass=\"*\" newpass=\"*\" />"); result = TXmlConnector.ConnectorSendCommand(cmd); log.WriteLog("ServerReply: " + result); ShowStatus(result); XDocument aXmlDoc = XDocument.Load(new System.IO.StringReader(result)); if (aXmlDoc.Root.Name == "result") { if (aXmlDoc.Root.Attribute("success").Value == "true") { ShowStatus("Пароль изменен"); log.WriteLog("Password was changed"); txtOldPass.Text = ""; txtNewPass.Text = ""; } else if (aXmlDoc.Root.Attribute("success").Value == "false") { ShowStatus(aXmlDoc.Root.Value); } } else { ShowStatus("Произошла ошибка"); } } else { ShowStatus("Введите верный новый пароль"); } }
//================================================================================ void Transaq_Disconnect() { // отключение коннектора от сервера Транзак DisconnectingReflect(); string cmd = "<command id=\"disconnect\"/>"; log.WriteLog("SendCommand: " + cmd); TXmlConnector.statusDisconnected.Reset(); string res = TXmlConnector.ConnectorSendCommand(cmd); log.WriteLog("ServerReply: " + res); }
public static void sendOrder2Transaq(Position position) { string cmd = position.getTakingPositionCommandXML(); string res = TXmlConnector.ConnectorSendCommand(cmd); XmlReader xr = XmlReader.Create(new System.IO.StringReader(res), xs); result result = (result)serializer4results.Deserialize(xr); if (result.success == true) { position.transactionid = result.transactionid; monitoredPositions.Add(position); } }
//================================================================================ // запрос исторических данных для инструмента void Get_Transaq_History(int SecurityID, int TimeframeID, int HistoryLength, bool ResetFlag) { string cmd = "<command id=\"gethistorydata\" "; cmd = cmd + "secid=\"" + SecurityID.ToString() + "\" "; cmd = cmd + "period=\"" + TimeframeID.ToString() + "\" "; cmd = cmd + "count=\"" + HistoryLength.ToString() + "\" "; string s = "false"; if (ResetFlag) { s = "true"; } cmd = cmd + "reset=\"" + s + "\"/>"; log.WriteLog("SendCommand: " + cmd); string res = TXmlConnector.ConnectorSendCommand(cmd); log.WriteLog("ServerReply: " + res); }
public static void sendCancelAll2Transaq() { foreach (Order order in monitoredOrders) { string cmd = "<command id=\"cancelorder\">"; cmd = cmd + "<transactionid>" + order.transactionid.ToString() + "</transactionid>"; cmd = cmd + "</command>"; string res = TXmlConnector.ConnectorSendCommand(cmd); } foreach (Stoporder stoporder in monitoredStopOrders) { string cmd = "<command id=\"cancelstoporder\">"; cmd = cmd + "<transactionid>" + stoporder.transactionid.ToString() + "</transactionid>"; cmd = cmd + "</command>"; string res = TXmlConnector.ConnectorSendCommand(cmd); } }
private void dataGridViewMyInstruments_CellContentClick(object sender, DataGridViewCellEventArgs e) { DataGridView myObject = (DataGridView)sender; if (myObject.CurrentRow == null) { return; } string seccode = myObject.CurrentRow.Cells[2].Value.ToString(); int decimals = (int)myObject.CurrentRow.Cells[4].Value; int market = (int)myObject.CurrentRow.Cells[5].Value; string board = myObject.CurrentRow.Cells[6].Value.ToString(); OportunityMonitor.monitoredSecurityOnHMI = new Security(seccode, board, decimals, market); OportunityMonitor.addSecurityForMonitoring(new Security(seccode, board, decimals, market)); string cmd = "<command id=\"subscribe\">"; cmd = cmd + " <quotations><security><board>" + board + "</board><seccode>" + seccode + "</seccode></security></quotations>"; cmd = cmd + "</command>"; string res = TXmlConnector.ConnectorSendCommand(cmd); }
void Transaq_Connect() { // чтение параметров из формы switch (chs_Server.Text) { case "АО \"Финам\"": ServerIP = "tr1.finam.ru"; break; case "АО \"Банк Финам\"": ServerIP = "tr1.finambank.ru"; break; case "Демо": ServerIP = "tr1-demo5.finam.ru"; break; } if (chs_Server.Text != "АО \"Финам\"" && chs_Server.Text != "АО \"Банк Финам\"" && chs_Server.Text != "Демо" && chs_Server.Text != "tr1.finam.ru" && chs_Server.Text != "tr1.finambank.ru" && chs_Server.Text != "tr1-demo5.finam.ru") { ServerIP = chs_Server.Text; } sLogin = edt_Login.Text; sPassword = edt_Password.Text; ServerPort = edt_Port.Text; // проверка наличия параметров if (sLogin.Length == 0) { ShowStatus("Не указан логин"); return; } if (sPassword.Length == 0) { ShowStatus("Не указан пароль"); return; } if (ServerIP.Length == 0) { ShowStatus("Не указан IP-адрес"); return; } if (ServerPort.Length == 0) { ShowStatus("Не указан порт"); return; } ConnectingReflect(); // очистка таблиц с данными DTS.t_timeframe.Clear(); DTS.t_security.Clear(); DTS.t_candle.Clear(); // формирование текста команды string cmd = "<command id=\"connect\">"; cmd = cmd + "<login>" + sLogin + "</login>"; cmd = cmd + "<password>" + sPassword + "</password>"; cmd = cmd + "<host>" + ServerIP + "</host>"; cmd = cmd + "<port>" + ServerPort + "</port>"; cmd = cmd + "<rqdelay>100</rqdelay>"; cmd = cmd + "<session_timeout>" + session_timeout.ToString() + "</session_timeout> "; cmd = cmd + "<request_timeout>" + request_timeout.ToString() + "</request_timeout>"; cmd = cmd + "</command>"; // отправка команды log.WriteLog("SendCommand: <command id=\"connect\"><login>" + sLogin + "</login><password>*</password><host>" + ServerIP + "</host><port>" + ServerPort + "</port><logsdir>" + AppDir + "</logsdir><rqdelay>100</rqdelay></command>"); TXmlConnector.statusDisconnected.Reset(); string res = TXmlConnector.ConnectorSendCommand(cmd); log.WriteLog("ServerReply: " + res); }