Example #1
0
        protected override void Execute(CodeActivityContext context)
        {
            this.table = new DataTable();
            bool          roleMatched    = false;
            List <string> unusedHdrNames = new List <string>();

            string[] userHeaderNames = UserHeaderNames.Get(context);

            UiElement _table = Element.Get <UiElement>(context);

            if (_table == null)
            {
                throw new ArgumentException("Element can not be null, please check input Element value");
            }

            foreach (string role in roles)
            {
                if (roleMatched) //이미 데이터를 추출했다면 다음 role에 대해서 검사하지 않도록
                {
                    break;
                }
                UiElement[] rows = _table.FindAll(FindScope.FIND_CHILDREN, new UiPath.Core.Selector(GetSelectorType("head", role)));
                if (rows == null)
                {
                    System.Console.Out.WriteLine(" Find Children with <ctrl name='{0}' role='{1}' /> was failed, no child element exist", "head", role);
                    continue;
                }
                roleMatched = true;
                //우선 테이블 헤더부분을 만들어 내고
                if (userHeaderNames is null)
                {
                    BuildTableHeaderFromUiElement(this.table, rows, unusedHdrNames);
                }
                else
                {
                    BuildTableHeaderFromUserInput(this.table, userHeaderNames);
                    string[] excNames = ExcludeHeaderNames.Get(context);
                    if (!(excNames is null))
                    {
                        foreach (string name in excNames)
                        {
                            unusedHdrNames.Add(name);
                        }
                    }
                }
                //테이블 본문을 만들어 낸나.
                rows = _table.FindAll(FindScope.FIND_CHILDREN, new UiPath.Core.Selector(GetSelectorType("body", role)));
                BuildTableBodyFromUiElement(this.table, rows, unusedHdrNames);
            }
            // 최종 결과 table 할당
            Table.Set(context, this.table);
        }
        public override void DoExecute()
        {
            AutomationElement     a = UiElement.AutomationElement;
            ExpandCollapsePattern expandCollapsePattern = a.GetCurrentPattern(ExpandCollapsePattern.Pattern) as ExpandCollapsePattern;

            expandCollapsePattern.Expand();
            var cbxEditItems = UiElement.FindAll(TreeScope.Subtree, new System.Windows.Automation.PropertyCondition(AutomationElement.ClassNameProperty, "ComboBoxEditItem"));

            switch (PlaybackObject.action)
            {
            case "SetText":
                try
                {
                    var Editor = a.FindFirst(TreeScope.Subtree, new PropertyCondition(AutomationElement.AutomationIdProperty, "PART_Editor"));
                    ((ValuePattern)Editor.GetCurrentPattern(ValuePattern.Pattern)).SetValue(PlaybackObject.text);
                    expandCollapsePattern.Collapse();
                    Result = true;
                }
                catch (Exception)
                {
                    Result = false;
                    //throw;
                }
                break;

            case "Select":
                try
                {
                    if (cbxEditItems[PlaybackObject.itemIndex].AutomationElement.FindFirst(TreeScope.Subtree, new PropertyCondition(AutomationElement.ClassNameProperty, "CheckEdit")) != null)
                    {
                        var checkBox = cbxEditItems[PlaybackObject.itemIndex].FindFirst(TreeScope.Subtree, new PropertyCondition(AutomationElement.ClassNameProperty, "CheckEdit"));
                        checkBox.AsCheckBox().Click();
                        SendKeys.SendWait("{ENTER}");
                    }
                    else
                    {
                        cbxEditItems[PlaybackObject.itemIndex].AutomationElement.SelectionItemPattern().Select();
                        expandCollapsePattern.Collapse();
                    }
                    Result = true;
                }
                catch (Exception)
                {
                    Result = false;
                    //throw;
                }
                break;

            default:
                Result = false;
                break;
            }

            //expandCollapsePattern.Collapse();
        }