void Execute(Uii.Csr.RequestActionEventArgs args)
        {
            /*
             * <Controls>
             *  <JAccControl name="clickme" action="click">
             *      <Path>
             *      <NextName offset = "1">Click Me</NextName>
             *      </Path>
             *  </JAccControl>
             * </Controls>
             */


            string      parameterdata = Utility.GetContextReplacedString(args.Data, CurrentContext, localSession);
            XmlDocument doc           = new XmlDocument();

            doc.LoadXml(parameterdata);

            foreach (XmlNode nodeControl in doc.SelectSingleNode("//Controls").ChildNodes) ///JAccControl or AccControl
            {
                using (IUSDAutomationObject automationObject = automationEngine.GetAutomationObject(nodeControl))
                {
                    try
                    {
                        string controlAction = AutomationControl.GetAttributeValue(nodeControl, "action", "");
                        automationEngine.Execute(automationObject, controlAction);
                    }
                    catch (Exception ex)
                    {
                        LogWriter.Log(ex);
                    }
                }
            }
        }
        void Launch(Uii.Csr.RequestActionEventArgs args)
        {
            List <KeyValuePair <string, string> > parameters = Utility.SplitLines(args.Data, CurrentContext, localSession);
            string path                           = Utility.GetAndRemoveParameter(parameters, "path");            //C:\Program Files\Java\jre1.8.0_51\bin\java
            string arguments                      = Utility.GetAndRemoveParameter(parameters, "arguments");       // -jar SimpleSwing.jar
            string workingfolder                  = Utility.GetAndRemoveParameter(parameters, "workingfolder");   // C:\Users\jaymep\OneDrive\DEVELOPMENT\SimpleSwing
            string mainwindowtitle                = Utility.GetAndRemoveParameter(parameters, "mainwindowtitle"); //Swing Simple Application
            string hostingmoderequested           = Utility.GetAndRemoveParameter(parameters, "hostingmode");     //setparent or dynamicpositioning
            string removeFrameAndCaptionParameter = Utility.GetAndRemoveParameter(parameters, "RemoveFrameAndCaption");
            string removeFromTaskbarParameter     = Utility.GetAndRemoveParameter(parameters, "RemoveFromTaskbar");
            string removeSizingControlsParameter  = Utility.GetAndRemoveParameter(parameters, "RemoveSizingControls");
            string removeSizingMenuParameter      = Utility.GetAndRemoveParameter(parameters, "RemoveSizingMenu");
            string removeSystemMenuParameter      = Utility.GetAndRemoveParameter(parameters, "RemoveSystemMenu");

            automationtechnology = Utility.GetAndRemoveParameter(parameters, "automationtechnology"); //java, windows
            Process appprocess = new Process();

            appprocess.StartInfo.WorkingDirectory = workingfolder;
            appprocess.StartInfo.FileName         = path;
            appprocess.StartInfo.Arguments        = arguments;
            appprocess.Start();
            if (String.IsNullOrEmpty(hostingmoderequested) ||
                hostingmoderequested.Equals("setparent", StringComparison.InvariantCultureIgnoreCase))
            {
                hostingMode = WindowHostingMode.SETPARENT;
            }
            else if (hostingmoderequested.Equals("dp", StringComparison.InvariantCultureIgnoreCase) ||
                     hostingmoderequested.Equals("dynamicpositioning", StringComparison.InvariantCultureIgnoreCase))
            {
                hostingMode = WindowHostingMode.DYNAMICPOSITIONING;
            }
            if (!bool.TryParse(removeFrameAndCaptionParameter, out removeFrameAndCaption))
            {
                removeFrameAndCaption = true;
            }
            if (!bool.TryParse(removeFromTaskbarParameter, out removeFromTaskbar))
            {
                removeFromTaskbar = true;
            }
            if (!bool.TryParse(removeSizingControlsParameter, out removeSizingControls))
            {
                removeSizingControls = true;
            }
            if (!bool.TryParse(removeSizingMenuParameter, out removeSizingMenu))
            {
                removeSizingMenu = true;
            }
            if (!bool.TryParse(removeSystemMenuParameter, out removeSystemMenu))
            {
                removeSystemMenu = true;
            }
            if (String.IsNullOrEmpty(mainwindowtitle))
            {
                ProcessAttachApplicationWindow(appprocess, myhost);
            }
            else
            {
                LookForAndAttachApplicationWindow(mainwindowtitle, myhost);
            }
        }
        void Activate(Uii.Csr.RequestActionEventArgs args)
        {
            if (web == null)
            {
                args.ActionReturnValue = "not loaded";
                return;
            }
            SetForegroundWindow((IntPtr)web.HWND);

            args.ActionReturnValue = "activated";
        }
Exemple #4
0
        protected override void DoAction(Uii.Csr.RequestActionEventArgs args)
        {
            if (args.Action.Equals("ShowImages", StringComparison.InvariantCultureIgnoreCase))
            {
                string imagelist = Utility.GetContextReplacedString(args.Data, CurrentContext, localSession);
                images        = imagelist.Replace("\r\n", "\n").Replace('\r', '\n').Split('\n');
                imagePosition = -1;
                ShowNextImage();
                return;
            }

            base.DoAction(args);
        }
        void Navigate(Uii.Csr.RequestActionEventArgs args)
        {
            List <KeyValuePair <string, string> > parameters = Utility.SplitLines(args.Data, CurrentContext, localSession);
            string url       = Utility.GetAndRemoveParameter(parameters, "url");
            string remainder = Utility.RemainderParameter(parameters);

            if (String.IsNullOrEmpty(url))
            {
                url = remainder;
            }
            Navigate(url);
            return;
        }
Exemple #6
0
        protected override void DoAction(Uii.Csr.RequestActionEventArgs args)
        {
            string action = args.Action.ToLower();

            lock (registeredActions)
            {
                if (registeredActions.ContainsKey(action))
                {
                    registeredActions[action].Invoke(args);
                    return;
                }
            }

            base.DoAction(args);
        }
        void DynamicPositionWindow(Uii.Csr.RequestActionEventArgs args)
        {
            List <KeyValuePair <string, string> > parameters = Utility.SplitLines(args.Data, CurrentContext, localSession);
            string windowhandle = Utility.GetAndRemoveParameter(parameters, "windowhandle");
            string removeFrameAndCaptionParameter = Utility.GetAndRemoveParameter(parameters, "RemoveFrameAndCaption");
            string removeFromTaskbarParameter     = Utility.GetAndRemoveParameter(parameters, "RemoveFromTaskbar");
            string removeSizingControlsParameter  = Utility.GetAndRemoveParameter(parameters, "RemoveSizingControls");
            string removeSizingMenuParameter      = Utility.GetAndRemoveParameter(parameters, "RemoveSizingMenu");
            string removeSystemMenuParameter      = Utility.GetAndRemoveParameter(parameters, "RemoveSystemMenu");

            automationtechnology = Utility.GetAndRemoveParameter(parameters, "automationtechnology"); //java
            if (!String.IsNullOrEmpty(windowhandle))
            {
                IntPtr winPtr;
                long   temp;
                if (long.TryParse(windowhandle, out temp))
                {
                    winPtr = new IntPtr(temp);
                }
                else
                {
                    winPtr = new IntPtr(Convert.ToInt64(windowhandle, 16));
                }
                StartAutomationtechnology(winPtr);
                hostingMode = WindowHostingMode.DYNAMICPOSITIONING;
                if (!bool.TryParse(removeFrameAndCaptionParameter, out removeFrameAndCaption))
                {
                    removeFrameAndCaption = true;
                }
                if (!bool.TryParse(removeFromTaskbarParameter, out removeFromTaskbar))
                {
                    removeFromTaskbar = true;
                }
                if (!bool.TryParse(removeSizingControlsParameter, out removeSizingControls))
                {
                    removeSizingControls = true;
                }
                if (!bool.TryParse(removeSizingMenuParameter, out removeSizingMenu))
                {
                    removeSizingMenu = true;
                }
                if (!bool.TryParse(removeSystemMenuParameter, out removeSystemMenu))
                {
                    removeSystemMenu = true;
                }
                WindowAttachApplicationWindow(winPtr, myhost);
            }
        }
Exemple #8
0
        protected override void DoAction(Uii.Csr.RequestActionEventArgs args)
        {
            // EXAMPLE ACTION
            //if (args.Action.Equals("Test1", StringComparison.InvariantCultureIgnoreCase))
            //{
            //    string param = "<DdaParameters><ControlName>UIA:3</ControlName><ControlValue></ControlValue><Data></Data></DdaParameters>";
            //    RequestActionEventArgs raArgs = new RequestActionEventArgs(args.SessionId, this.ApplicationName, AutomationAdapter.DdaActionFindControl, param);
            //    bool ret = _AutomationAdapter.DoAction(actions[AutomationAdapter.DdaActionFindControl], raArgs);
            //    Trace.WriteLine("RET=" + raArgs.ActionReturnValue);
            //    ret = _AutomationAdapter.DoAction(actions[AutomationAdapter.DdaActionExecuteControlAction], raArgs);
            //    Trace.WriteLine("RET=" + raArgs.ActionReturnValue);
            //    //System.Threading.Thread run = new System.Threading.Thread(new System.Threading.ParameterizedThreadStart(RunCalcCallback));
            //    //run.Start("45/98*324-78+541");

            //    //RunCalc("45/98*324-78+541");
            //}

            base.DoAction(args);
        }
        void AttachByTitle(Uii.Csr.RequestActionEventArgs args)
        {
            List <KeyValuePair <string, string> > parameters = Utility.SplitLines(args.Data, CurrentContext, localSession);
            string mainwindowtitle                = Utility.GetAndRemoveParameter(parameters, "mainwindowtitle");
            string hostingmoderequested           = Utility.GetAndRemoveParameter(parameters, "hostingmode"); //setparent or dynamicpositioning
            string removeFrameAndCaptionParameter = Utility.GetAndRemoveParameter(parameters, "RemoveFrameAndCaption");
            string removeFromTaskbarParameter     = Utility.GetAndRemoveParameter(parameters, "RemoveFromTaskbar");
            string removeSizingControlsParameter  = Utility.GetAndRemoveParameter(parameters, "RemoveSizingControls");
            string removeSizingMenuParameter      = Utility.GetAndRemoveParameter(parameters, "RemoveSizingMenu");
            string removeSystemMenuParameter      = Utility.GetAndRemoveParameter(parameters, "RemoveSystemMenu");

            if (String.IsNullOrEmpty(hostingmoderequested) ||
                hostingmoderequested.Equals("setparent", StringComparison.InvariantCultureIgnoreCase))
            {
                hostingMode = WindowHostingMode.SETPARENT;
            }
            else if (hostingmoderequested.Equals("dp", StringComparison.InvariantCultureIgnoreCase) ||
                     hostingmoderequested.Equals("dynamicpositioning", StringComparison.InvariantCultureIgnoreCase))
            {
                hostingMode = WindowHostingMode.DYNAMICPOSITIONING;
            }
            if (!bool.TryParse(removeFrameAndCaptionParameter, out removeFrameAndCaption))
            {
                removeFrameAndCaption = true;
            }
            if (!bool.TryParse(removeFromTaskbarParameter, out removeFromTaskbar))
            {
                removeFromTaskbar = true;
            }
            if (!bool.TryParse(removeSizingControlsParameter, out removeSizingControls))
            {
                removeSizingControls = true;
            }
            if (!bool.TryParse(removeSizingMenuParameter, out removeSizingMenu))
            {
                removeSizingMenu = true;
            }
            if (!bool.TryParse(removeSystemMenuParameter, out removeSystemMenu))
            {
                removeSystemMenu = true;
            }
            LookForAndAttachApplicationWindow(mainwindowtitle, myhost);
        }
        void ListWindows(Uii.Csr.RequestActionEventArgs args)
        {
            List <KeyValuePair <string, string> > parameters = Utility.SplitLines(args.Data, CurrentContext, localSession);
            string windowRegex = Utility.GetAndRemoveParameter(parameters, "regex");

            if (windowRegex == null)
            {
                windowRegex = String.Empty;
            }
            List <WindowMetadata> windowMeta = GetWindowMetaData(windowRegex);
            StringBuilder         sb         = new StringBuilder();

            sb.AppendLine("ListWindows Found: ");
            foreach (WindowMetadata wm in windowMeta)
            {
                sb.AppendLine("\tWindow Handle:[" + wm.handle.ToString() + "] Name:[" + wm.name + "] ");
            }
            LogWriter.Log(sb.ToString(), TraceEventType.Verbose);
        }
        void SetValue(Uii.Csr.RequestActionEventArgs args)
        {
            string      parameterdata = Utility.GetContextReplacedString(args.Data, CurrentContext, localSession);
            XmlDocument doc           = new XmlDocument();

            doc.LoadXml(parameterdata);
            foreach (XmlNode nodeControl in doc.SelectSingleNode("//Controls").ChildNodes) ///JAccControl or AccControl
            {
                using (IUSDAutomationObject automationObject = automationEngine.GetAutomationObject(nodeControl))
                {
                    try
                    {
                        string controlValue = AutomationControl.GetAttributeValue(nodeControl, "value", "");
                        automationEngine.SetValue(automationObject, controlValue);
                    }
                    catch (Exception ex)
                    {
                        LogWriter.Log(ex);
                    }
                }
            }
        }
        void DisplayVisualTree(Uii.Csr.RequestActionEventArgs args)
        {
            List <KeyValuePair <string, string> > parameters = Utility.SplitLines(args.Data, CurrentContext, localSession);
            string windowhandle = Utility.GetAndRemoveParameter(parameters, "windowhandle");

            automationtechnology = Utility.GetAndRemoveParameter(parameters, "automationtechnology"); //java, windows
            if (!String.IsNullOrEmpty(windowhandle))
            {
                IntPtr winPtr;
                long   temp;
                if (long.TryParse(windowhandle, out temp))
                {
                    winPtr = new IntPtr(temp);
                }
                else
                {
                    winPtr = new IntPtr(Convert.ToInt64(windowhandle, 16));
                }
                StartAutomationtechnology(winPtr);
                automationEngine.DisplayVisualTree();
            }
        }
        void GetValue(Uii.Csr.RequestActionEventArgs args)
        {
            string      parameterdata = Utility.GetContextReplacedString(args.Data, CurrentContext, localSession);
            XmlDocument doc           = new XmlDocument();

            doc.LoadXml(parameterdata);
            List <LookupRequestItem> lritems = new List <LookupRequestItem>();

            foreach (XmlNode nodeControl in doc.SelectSingleNode("//Controls").ChildNodes) ///JAccControl or AccControl
            {
                using (IUSDAutomationObject automationObject = automationEngine.GetAutomationObject(nodeControl))
                {
                    try
                    {
                        lritems.Add(automationEngine.GetValue(automationObject));
                    }
                    catch (Exception ex)
                    {
                        LogWriter.Log(ex);
                    }
                }
            }
            ((DynamicsCustomerRecord)localSession.Customer.DesktopCustomer).MergeReplacementParameter(this.ApplicationName, lritems, false);
        }
 void CloseWindow(Uii.Csr.RequestActionEventArgs args)
 {
     base.CloseWindow();
     StopAutomationtechnology();
 }
Exemple #15
0
 void ExitApplication(Uii.Csr.RequestActionEventArgs args)
 {
     System.Windows.Application.Current.Shutdown();
 }
        private void SaveLayout(Uii.Csr.RequestActionEventArgs args)
        {
            var currentPanelLayout = mainLayout.Save().Root.ToString();

            UpsertUserSetting("C1PanelLayout", currentPanelLayout);
        }
 void DetachWindow(Uii.Csr.RequestActionEventArgs args)
 {
     base.DetachWindow();
     StopAutomationtechnology();
 }