Пример #1
0
        public static void GetLsTradeSail(int id)
        {
            if (!TimeSpanExtensions.IsTimeWork())
            {
                return;
            }

            while (busyLsTradeAgent)
            {
                Color.WriteLineColor("LsTradeAgent занят...", ConsoleColor.Red);
                Thread.Sleep(1000);
            }

            //Color.WriteLineColor("busyLsTradeAgent = true", ConsoleColor.Cyan);
            busyLsTradeAgent = true;

            while (!Server.clients.ContainsValue("LsTradeAgent"))
            {
                Color.WriteLineColor("Внимание не запущен LsTradeAgent ..Ожидаю подключение...", ConsoleColor.Red);
                Thread.Sleep(5000);
            }

            string   bar;
            int      price;
            DateTime date;

            Color.WriteLineColor("Запрос в LsTrade информации по списаниям...", ConsoleColor.Cyan);

            try
            {
                using (MySqlConnection conn = new MySqlConnection(Connector.BarrierStringConnecting))
                {
                    conn.Open();

                    MySqlCommand cmd = new MySqlCommand(@"SELECT `bar`,`turn_price`,`date` FROM `priority` WHERE `id` = " + id, conn);

                    cmd.CommandTimeout = 0;

                    using (MySqlDataReader dr = cmd.ExecuteReader())
                    {
                        while (dr.Read())
                        {
                            bar   = dr.GetString(0);
                            price = dr.GetInt32(1);
                            date  = dr.GetDateTime(2);

                            Msg.SendUser("LsTradeAgent", "DR", 0, id + ";" + bar + ";" + price + ";" + date.ToString("yyyy-MM-dd,HH:mm:ss"));
                        }
                    }
                }
            }
            catch (System.Exception ex)
            {
                Color.WriteLineColor("[GetLsTradeSail] " + ex.Message, ConsoleColor.Red);
                Log.ExcWrite("[GetLsTradeSail] " + ex.Message);
            }

            finally
            {
                Color.WriteLineColor("Запрос отправлен.", ConsoleColor.Gray);
                Thread.Sleep(2000);
                //Color.WriteLineColor("busyLsTradeAgent = false", ConsoleColor.Cyan);
                busyLsTradeAgent = false;
            }
        }
Пример #2
0
        private static void CheckSendUkmPrice()
        {
            if (!TimeSpanExtensions.IsTimeWork())
            {
                return;
            }

            while (CheckThisBar.busyLsTradeAgent)
            {
                Color.WriteLineColor("LsTradeAgent занят...", ConsoleColor.Red);
                Thread.Sleep(1000);
            }

            //Color.WriteLineColor("busyLsTradeAgent = true", ConsoleColor.Cyan);
            CheckThisBar.busyLsTradeAgent = true;

            while (!Server.clients.ContainsValue("LsTradeAgent"))
            {
                Color.WriteLineColor("Внимание не запущен LsTradeAgent .\nДля продолжения работы нужно запустить LsTradeAgent", ConsoleColor.Red);
                Thread.Sleep(5000);
            }

            try
            {
                using (MySqlConnection conn = new MySqlConnection(Connector.BarrierStringConnecting))
                {
                    conn.Open();

                    MySqlCommand cmd = new MySqlCommand("SELECT t.tasks_id,p.id,p.bar,p.date FROM tasks t,priority p WHERE  p.id = t.priority_id", conn);
                    cmd.CommandTimeout = 0;

                    using (MySqlDataReader dr = cmd.ExecuteReader())
                    {
                        while (dr.Read())
                        {
                            if (!dr.IsDBNull(0))
                            {
                                int    tasks_id    = dr.GetInt32(0);
                                int    priority_id = dr.GetInt32(1);
                                string bar         = dr.GetString(2);
                                string datetime    = dr.GetDateTime(3).ToString("yyyy-MM-dd,HH:mm:ss");

                                //send lstradeagent priority_id;bar;datetime
                                Msg.SendUser("LsTradeAgent", "DR", 1, priority_id + ";" + bar + ";" + datetime);
                                Thread.Sleep(1000);
                            }
                        }

                        Color.WriteLineColor("Данные для проверки задач отправлены в LsTradeAgent.", ConsoleColor.Cyan);

                        Msg.SendUser("LsTradeAgent", "DR", 2, "Данные для проверки задач отправлены.");
                    }
                }
            }
            catch (Exception ex)
            {
                Color.WriteLineColor("[CheckSendUkmPrice]" + ex.Message, ConsoleColor.Red);
                Log.ExcWrite("[CheckSendUkmPrice]" + ex.Message);
            }
            finally
            {
                Thread.Sleep(2000);
                //Color.WriteLineColor("busyLsTradeAgent = false", ConsoleColor.Cyan);
                CheckThisBar.busyLsTradeAgent = false;
            }
        }