Exemple #1
0
        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 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);
            }
        }
        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();
        }
Exemple #4
0
        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;
            }
        }
Exemple #5
0
 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);
 }