예제 #1
0
파일: Form1.cs 프로젝트: amavr/datascraper
 private void ShowNodeData(ActionTreeNode treeNode)
 {
     if (treeNode == null)
     {
         props.SelectedObject = null;
         tboxSour.Text = String.Empty;
         tboxDest.Text = String.Empty;
         tboxBack.Text = String.Empty;
     }
     else
     {
         props.SelectedObject = treeNode.Action;
         tboxSour.Text = treeNode.InputData;
         tboxDest.Text = treeNode.OutputData;
         tboxBack.Text = treeNode.BackData;
     }
 }
예제 #2
0
파일: Form1.cs 프로젝트: amavr/datascraper
        private void Run(ActionTreeNode Node, bool Deep)
        {
            DateTime dt = DateTime.Now;

            if (Node == null) return;

            try
            {
                Cursor = Cursors.WaitCursor;
                RunActions(Node, Deep);
                ShowNodeData(treeScript.SelectedNode as ActionTreeNode);
            }
            catch (Exception)
            {
                // Nothing to do
                // MessageBox.Show(e.Message);
            }
            finally
            {
                TimeSpan ts = DateTime.Now.Subtract(dt);
                slabTime.Text = String.Format("Time: {0} min {1} sec", ts.Minutes, ts.Seconds);
                Cursor = Cursors.Default;
            }

            BringTop();
        }
예제 #3
0
파일: Form1.cs 프로젝트: amavr/datascraper
        private void RunActions(ActionTreeNode Node, bool Deep)
        {
            // Строим дерево акций для исполнения
            ScriptAction action = Node.BuildActionTree(Deep);

            // Инициализируем входные данные корневого элемента
            action.InputFlow = Node.InputData;

            // Запускаем исполнение корневой акции
            // Важно! Параметра вложенного исполнения - Deep нет!
            // т.к. выпоняем всю созданную иерархию
            action.Execute();

            // Данные из акций переносим в узлы для отображения на экране
            Node.ApplyResults(Deep);
            ShowNodeData(treeScript.SelectedNode as ActionTreeNode);
        }
예제 #4
0
        public static ActionTreeNode ParseXmlElement(XmlElement Element)
        {
            ScriptAction action = null;
            switch (Element.GetAttribute(ScriptConsts.ATTR_TYPE))
            {
                case ScriptConsts.TYPE_TEXT:
                    action = new ScriptTextAction();
                    break;

                case ScriptConsts.TYPE_COOK:
                    action = new ScriptCookieAction();
                    break;

                case ScriptConsts.TYPE_DATE:
                    action = new ScriptDateAction();
                    break;

                case ScriptConsts.TYPE_LOAD:
                    action = new ScriptLoadAction();
                    break;

                case ScriptConsts.TYPE_DOWNLOAD:
                    action = new ScriptDownloadAction();
                    break;

                case ScriptConsts.TYPE_SAVE:
                    action = new ScriptSaveAction();
                    break;

                case ScriptConsts.TYPE_FIND:
                    action = new ScriptFindAction();
                    break;

                case ScriptConsts.TYPE_REPL:
                    action = new ScriptReplaceAction();
                    break;

                case ScriptConsts.TYPE_SET_VAR:
                    action = new ScriptSetVarAction();
                    break;

                case ScriptConsts.TYPE_GET_VAR:
                    action = new ScriptGetVarAction();
                    break;

                case ScriptConsts.TYPE_NEXT_PAGE:
                    action = new ScriptNextURLAction();
                    break;

                case ScriptConsts.TYPE_INC:
                    action = new ScriptIncAction();
                    break;

            }
            action.Load(Element);

            action.OnLogMessage += new ActionCallback(LogAction);

            ActionTreeNode node = new ActionTreeNode(action);

            foreach (XmlNode child in Element.SelectNodes(ScriptConsts.TAG_NAME))
                node.Nodes.Add(ParseXmlElement(child as XmlElement));

            return node;
        }