コード例 #1
0
        private void displayData(GuiComponent c)
        {
            string type = c.GetDetailType();

            Type t = SAPAutomationHelper.Current.GetSAPTypeInfo(type);
            //Type detailType = null; GuiShell shellObj = null;
            //if (c.Type.ToLower().Contains("shell"))
            //{
            //    shellObj = c as GuiShell;
            //    if (shellObj != null)
            //    {
            //        foreach (Type t in SAPAutomationHelper.Current.SAPGuiApiAssembly.GetTypes().Where(tp => tp.IsInterface))
            //        {
            //            if (t.Name.Contains("Gui" + shellObj.SubType))
            //            {
            //                detailType = t;
            //                break;
            //            }
            //        }
            //    }
            //}

            //string typeName = detailType == null ? c.Type : detailType.Name;

            //var props = SAPAutomationHelper.Current.GetSAPTypeInfoes<PropertyInfo>(typeName, t => t.GetProperties().Where(p => p.IsSpecialName == false));

            List <SAPElementProperty> pps = new List <SAPElementProperty>();

            foreach (var p in t.GetProperties().Where(p => p.IsSpecialName == false))
            {
                SAPElementProperty prop = new SAPElementProperty();
                prop.Name       = p.Name;
                prop.IsReadOnly = !p.CanWrite;
                try
                {
                    prop.Value = p.GetValue(c).ToString();
                }
                catch
                {
                    prop.Value = "";
                }
                pps.Add(prop);
            }
            List <string> mds = getMethods(t);

            lv_Props.Dispatcher.BeginInvoke(new Action(() =>
            {
                lv_Props.DataContext   = pps;
                lv_Methods.DataContext = mds;
            }));
        }
コード例 #2
0
        private static CodeExpression getFindByIdCode(GuiComponent Component)
        {
            if (Component == null)
            {
                return(null);
            }
            CodeMethodInvokeExpression expression = new CodeMethodInvokeExpression(
                new CodeMethodReferenceExpression(
                    new CodeVariableReferenceExpression("SAPTestHelper.Current.SAPGuiSession")
                    , "FindById"
                    , new CodeTypeReference(Component.GetDetailType()))
                , new CodePrimitiveExpression(formatId(Component.Id)));

            return(expression);
        }
コード例 #3
0
        private static CodeExpression getFindByNameDetailCode(GuiComponent Component)
        {
            if (Component == null)
            {
                return(null);
            }
            try
            {
                Stack <SapCompInfo> comps = new Stack <SapCompInfo>();
                do
                {
                    SapCompInfo ci = new SapCompInfo();
                    ci.Id   = Component.Id;
                    ci.Name = Component.Name;
                    ci.Type = Component.GetDetailType();
                    comps.Push(ci);
                    Component = Component.Parent;
                }while ((Component is GuiSession) == false);

                SapCompInfo top = comps.Pop();
                CodeMethodInvokeExpression expression = new CodeMethodInvokeExpression(
                    new CodeMethodReferenceExpression(
                        new CodeVariableReferenceExpression("SAPTestHelper.Current.SAPGuiSession")
                        , "FindById"
                        , new CodeTypeReference(top.Type))
                    , new CodePrimitiveExpression(top.Name));


                while (comps.Count > 0)
                {
                    SapCompInfo temp = comps.Pop();
                    expression = new CodeMethodInvokeExpression(
                        new CodeMethodReferenceExpression(
                            expression
                            , "FindByName"
                            , new CodeTypeReference(temp.Type))
                        , new CodePrimitiveExpression(temp.Name));
                }
                return(expression);
            }
            catch
            {
                return(null);
            }
        }
コード例 #4
0
        private static CodeExpression getFindByNameCode(GuiComponent Component)
        {
            if (Component == null)
            {
                return(null);
            }
            try
            {
                string name = Component.Name;
                string type = Component.GetDetailType();

                while (!(Component.Parent is GuiSession))
                {
                    Component = Component.Parent;
                }

                string basicMethod = "SAPTestHelper.Current.";
                if (Component is GuiModalWindow)
                {
                    basicMethod += "PopupWindow";
                }
                else
                {
                    basicMethod += "MainWindow";
                }


                CodeMethodInvokeExpression expression = new CodeMethodInvokeExpression(
                    new CodeMethodReferenceExpression(
                        new CodeVariableReferenceExpression(basicMethod)
                        , "FindByName"
                        , new CodeTypeReference(type))
                    , new CodePrimitiveExpression(name));


                return(expression);
            }
            catch
            {
                return(null);
            }
        }
コード例 #5
0
        void _sapGuiSession_Change(GuiSession Session, GuiComponent Component, object CommandArray)
        {
            if (_stepAction == null)
            {
                return;
            }
            SapCompInfo cpInfo = new SapCompInfo();

            cpInfo.Id   = Component.Id;
            cpInfo.Name = Component.Name;
            cpInfo.Type = Component.GetDetailType();

            if (Component is GuiVComponent)
            {
                var vc = Component as GuiVComponent;
                try
                {
                    cpInfo.Tip = vc.DefaultTooltip == "" ? vc.Tooltip : vc.DefaultTooltip;
                }
                catch
                {
                }
            }


            if (_isFindById)
            {
                cpInfo.FindMethod = Component.FindByIdCode();
            }
            else
            {
                cpInfo.FindMethod = Component.FindByNameCode();
            }

            RecordStep step = new RecordStep();

            step.CompInfo = cpInfo;

            object[] objs = CommandArray as object[];

            objs = objs[0] as object[];
            switch (objs[0].ToString().ToLower())
            {
            case "m":
                step.Action = BindingFlags.InvokeMethod;
                break;

            case "sp":
                step.Action = BindingFlags.SetProperty;
                break;
            }

            var action = objs[1].ToString();

            upperFirstChar(ref action);

            step.ActionName = action;

            var count = objs.Count();

            if (count > 2)
            {
                step.ActionParams = new List <SAPDataParameter>();

                if (step.Action == BindingFlags.InvokeMethod)
                {
                    MethodInfo method = GetSAPTypeInfo(step.CompInfo.Type).GetMethod(step.ActionName);
                    //MethodInfo method = SAPAutomationHelper.Current.GetSAPTypeInfo<MethodInfo>(step.CompInfo.Type, t => t.GetMethod(step.ActionName));
                    int index = 2;
                    foreach (var pInfo in method.GetParameters())
                    {
                        var para = new SAPDataParameter();
                        para.Type    = pInfo.ParameterType;
                        para.Comment = pInfo.Name;
                        para.Value   = objs[index];
                        para.Name    = pInfo.Name;
                        step.ActionParams.Add(para);
                        index++;
                    }
                }
                else
                {
                    for (int i = 2; i < count; i++)
                    {
                        var para = new SAPDataParameter();
                        para.Type    = objs[i].GetType();
                        para.Value   = objs[i];
                        para.Comment = step.CompInfo.Tip;

                        step.ActionParams.Add(para);
                    }
                }
            }

            _stepAction(step);
        }
コード例 #6
0
        private static CodeExpression getFindByNameCode(GuiComponent Component)
        {
            if (Component == null)
                return null;
            try
            {
                Stack<SapCompInfo> comps = new Stack<SapCompInfo>();
                do
                {
                    SapCompInfo ci = new SapCompInfo();
                    ci.Id = Component.Id;
                    ci.Name = Component.Name;
                    ci.Type = Component.GetDetailType();
                    comps.Push(ci);
                    Component = Component.Parent;
                }
                while ((Component is GuiSession) == false);

                SapCompInfo top = comps.Pop();
                CodeMethodInvokeExpression expression = new CodeMethodInvokeExpression(
                    new CodeMethodReferenceExpression(
                        new CodeVariableReferenceExpression("SAPTestHelper.Current.SAPGuiSession")
                        , "FindById"
                        , new CodeTypeReference(top.Type))
                        , new CodePrimitiveExpression(top.Name));

                while (comps.Count > 0)
                {
                    SapCompInfo temp = comps.Pop();
                    expression = new CodeMethodInvokeExpression(
                    new CodeMethodReferenceExpression(
                          expression
                          , "FindByName"
                          , new CodeTypeReference(temp.Type))
                          , new CodePrimitiveExpression(temp.Name));

                }
                return expression;
            }
            catch
            {
                return null;
            }
        }
コード例 #7
0
 private static CodeExpression getFindByIdCode(GuiComponent Component)
 {
     if (Component == null)
         return null;
     CodeMethodInvokeExpression expression = new CodeMethodInvokeExpression(
            new CodeMethodReferenceExpression(
                new CodeVariableReferenceExpression("SAPTestHelper.Current.SAPGuiSession")
                , "FindById"
                , new CodeTypeReference(Component.GetDetailType()))
                , new CodePrimitiveExpression(formatId(Component.Id)));
     return expression;
 }