Example #1
0
        /// <summary>
        /// This method performs the auto sign-on by populating the given credentials
        /// in their corresponding credential fields and submitting the page.
        /// </summary>
        /// <param name="application">
        /// The credentials of the user to be populating in the credential fields identified.
        /// </param>
        public void DoLogin(object application)
        {
            HostedWebApplication app = (HostedWebApplication)application;

            webBrowser = (System.Windows.Forms.WebBrowser)app.TopLevelWindow;
            System.Windows.Forms.HtmlDocument axDoc = webBrowser.Document;

            if (null == app.LoginFields || app.LoginFields.Count == 0 || axDoc == null)
            {
                return;
            }

            int setFieldCount = 0;

            // For each credential field, perform the required operation.
            foreach (LoginFieldRecord field in app.LoginFields)
            {
                HtmlElement element;

                int sequence = (null != field.ControlSequence && string.Empty != field.ControlSequence ? int.Parse(field.ControlSequence) : -1);

                // Get the reference to the element corresonding to the credential field.
                //element = GetElement(axDoc, field.AttributeIdentity, field.AttributeValue, sequence);
                // TODO Update GetElement function to work with new WebBrowser
                // for first pass go with ID
                element = webBrowser.Document.GetElementById(field.AttributeValue);

                // If element is not found, then auto sign-on is failed, stop the auto sign-on
                if (null == element)
                {
                    throw new LoginFieldNotFoundException(field.LabelName);
                }

                switch (field.Operation)
                {
                // Populate the credentials in the value attribute of the element.
                case SET_OPERATION:
                {
                    Set(element, app.AgentCreds[setFieldCount]);
                    setFieldCount++;
                    break;
                }

                // Perform click operation on the element.
                case CLICK_OPERATION:
                {
                    Click(element);
                    break;
                }
                }
            }
        }
Example #2
0
 /// <summary>
 /// Moves the browser's display forward to the page that hda been displayed before going back.
 /// </summary>
 /// <param name="sender">Object Sender</param>
 /// <param name="e">System.EventArgs e</param>
 private void Forward_Click(object sender, EventArgs e)
 {
     try
     {
         // Perform the "Forward" operation on the web page
         HostedWebApplication webApp = app as HostedWebApplication;
         if (webApp != null)
         {
             WebBrowserExtended browser = webApp.TopLevelWindow as WebBrowserExtended;
             browser.GoForward();
         }
     }
     catch (Exception exp)
     {
         Logging.Trace(exp.Message + "\n\n" + exp.StackTrace);
     }
 }
Example #3
0
 public BrowserActionData(HostedWebApplication.WebAction action, string data)
 {
     Action = action;
     Data = data;
 }
Example #4
0
        /// <summary>
        /// Action Handler for Uii
        /// </summary>
        /// <param name="action">Action Object with Url and query data</param>
        /// <param name="data">Data passed into the action</param>
        public override bool DoAction(HostedWebApplication.WebAction action, ref string data)
        {
            Trace.WriteLine(string.Format(CultureInfo.CurrentUICulture, "{0}>>>>> RECEIVED (WebAction) Action : {1} ", this.Name, action.Name));

            // Check to see if the browser is working on something before allowing the system to do 'normal' behavior.
            if (Browser.WebBrowser.ReadyState != tagREADYSTATE.READYSTATE_COMPLETE)
            {
                // Browser is not in a state to process this request,  Queue it for when the browser is ready to handle it. 
                Trace.WriteLine(string.Format(CultureInfo.CurrentUICulture, "{0}>>>>> Browser Busy,({2}) Queuing Action : {1} ", this.Name, action.Name, Browser.WebBrowser.ReadyState.ToString()));
                qReqActionList.Enqueue(new BrowserActionData(action, data));
                return false;
            }

            Trace.WriteLine(string.Format(CultureInfo.CurrentUICulture, "{0}>>>>>>>>>>> Action:Name={1} Action:Url={2} Action:Query={3} Action:Init={4}", this.Name, action.Name, action.Url, action.QueryString, action.Initialization));
            return base.DoAction(action, ref data);
        }