protected override void OnStart(string[] args) { try { RobotCollection.Initialize(); } catch (Exception ex) { Logger.Error("Ошибка инициализации коллекции роботов", ex); throw; } QuoteStorage.Instance.LoadQuotes(string.Format("{0}\\lastquote.txt", ExecutablePath.ExecPath)); try { quoteReceiver = new TcpQuoteReceiver(); } catch (Exception ex) { Logger.Error("Ошибка получения котировок", ex); throw; } Logger.InfoFormat("Старт сервиса - загрузка настроек"); BL.RobotFarm.Instance.LoadSettings(); quoteReceiver.OnQuotesReceived += BL.RobotFarm.Instance.OnQuotesReceived; StartWebServer(); }
public void ReadRobotsSettings(string xmlPath) { if (!File.Exists(xmlPath)) { return; } gridRobot.rows.Clear(); try { var doc = new XmlDocument(); doc.Load(xmlPath); var node = doc.SelectSingleNode("RobotsPortfolio"); var nodes = node.SelectNodes("robot"); var robots = new List <RobotGridItem>(); foreach (XmlElement item in nodes) { var inodes = item.SelectNodes("Robot.TypeName"); var inode = (XmlElement)inodes[0]; var title = inode.Attributes["value"].Value; var robot = RobotCollection.MakeRobot(title); PropertyXMLTagAttribute.InitObjectProperties(robot, item, false); robots.Add(new RobotGridItem(robot, true)); } gridRobot.DataBind(robots); } catch (Exception ex) { Logger.Error("Ошибка чтения файла настроек портфеля роботов: ", ex); } }
public static List <BaseRobot> LoadRobots() { var listRobots = new List <BaseRobot>(); var fileName = string.Format("{0}\\{1}", ExecutablePath.ExecPath, RobotFileName); if (!File.Exists(fileName)) { return(listRobots); } try { var doc = new XmlDocument(); doc.Load(fileName); var node = doc.SelectSingleNode("RobotsPortfolio"); var nodes = node.SelectNodes("robot"); foreach (XmlElement item in nodes) { var inodes = item.SelectNodes("Robot.TypeName"); var inode = (XmlElement)inodes[0]; var title = inode.Attributes["value"].Value; var robot = RobotCollection.MakeRobot(title); PropertyXMLTagAttribute.InitObjectProperties(robot, item); listRobots.Add(robot); } } catch (Exception ex) { Logger.ErrorFormat("Ошибка чтения файла \"{0}\": {1}", fileName, ex); } return(listRobots); }
public void TestRobotCount() { RobotCollection robots = new RobotCollection(); robots.Add(new Robot(0, null, null, null, null)); Assert.AreEqual(1, robots.Count); }
public void ListenReportedPosition() { RobotCollection robots = new RobotCollection(); robots.ReportedPosition += (id, position, heading) => Assert.Pass(); robots.Add(new Robot(0, new Position(1, 1), new HeadingEast(), new List<char>() { 'M' }, new Plateau(5, 5))); robots.StartExplore(); }
private void AddRobotInPortfolio(string robotName) { var robot = RobotCollection.MakeRobot(robotName); robot.Magic = gridRobot.rows.Count + 1; var allRobots = grid.GetBoundValues().ToList(); var robotInitialized = !LivePortfolioMode; allRobots.Add(new RobotGridItem(robot, robotInitialized)); gridRobot.DataBind(allRobots); gridRobot.Invalidate(); }
public MainForm() { InitializeComponent(); workerQuote.WorkerSupportsCancellation = true; workerQuote.WorkerReportsProgress = true; workerQuote.DoWork += WorkerQuoteOnDoWork; workerQuote.ProgressChanged += (sender, args) => { lblWorkerProgress.Text = "прогресс: " + args.ProgressPercentage; }; workerQuote.RunWorkerCompleted += WorkerQuoteOnRunWorkerCompleted; RobotCollection.Initialize(); }
public MainForm() { InitializeComponent(); SetupDaysOff(); workerQuote.WorkerSupportsCancellation = true; workerQuote.WorkerReportsProgress = true; workerQuote.DoWork += WorkerQuoteOnDoWork; workerQuote.ProgressChanged += (sender, args) => { lblWorkerProgress.Text = "прогресс: " + args.ProgressPercentage; }; workerQuote.RunWorkerCompleted += WorkerQuoteOnRunWorkerCompleted; receiver = new TcpQuoteReceiver(); receiver.OnQuotesReceived += (names, quotes) => { LiveQuotes.Instance.UpdateQuotes(names, quotes); }; RobotCollection.Initialize(); }
private static List <BaseRobot> MakeRobots(XmlElement accountNode) { var robots = new List <BaseRobot>(); try { foreach (XmlElement robotNode in accountNode.GetElementsByTagName("robot")) { var inodes = robotNode.SelectNodes("Robot.TypeName"); var inode = (XmlElement)inodes[0]; var title = inode.Attributes["value"].Value; var robot = RobotCollection.MakeRobot(title); PropertyXMLTagAttribute.InitObjectProperties(robot, robotNode, false); robots.Add(robot); } return(robots); } catch (Exception ex) { Logger.Error("Error in MakeRobots()", ex); throw; } }
public int LoadRobots(XmlElement node) { robots.Clear(); try { var nodes = node.SelectNodes("robot"); // ReSharper disable PossibleNullReferenceException foreach (XmlElement item in nodes) { var inodes = item.SelectNodes("Robot.TypeName"); var inode = (XmlElement)inodes[0]; // ReSharper restore PossibleNullReferenceException var title = inode.Attributes["value"].Value; var robot = RobotCollection.MakeRobot(title); PropertyXMLTagAttribute.InitObjectProperties(robot, item, false); robots.Add(robot); } } catch (Exception ex) { Logger.Error("Ошибка чтения файла настроек портфеля роботов: ", ex); } return(robots.Count); }
public void NotListenReportedPosition() { RobotCollection robots = new RobotCollection(); robots.Add(new Robot(0, new Position(1, 1), new HeadingEast(), new List<char>() { 'M' }, new Plateau(5, 5))); robots.StartExplore(); }
public Engine() { citiPopulation = new CitizenCollection(); robotCollection = new RobotCollection(); }