Example #1
0
        /// <summary>
        /// Builds a webform and will retry on failed builds.
        /// </summary>
        /// <param name="item">WebFormItem</param>
        public void BuildWebForm(WebFormItem item)
        {
            try
            {
                bool succeeded = false;
                int  attempts  = 0;
                do
                {
                    browser.GoToUrl(string.Format(iMISConfig.WebFormURL, domain, item.WebFormZKey));
                    browser.Click(iMISConfig.CmsTab);
                    if (!browser.IsChecked(iMISConfig.ConfirmationPageCheckBox))
                    {
                        browser.Click(iMISConfig.ConfirmationPageCheckBox);
                    }
                    browser.Click(iMISConfig.SaveButon);
                    browser.Click(iMISConfig.BuildButton);
                    succeeded = !Parser.Match(browser.GetPageSource(), WEBFORM_ERROR);
                    attempts++;
                } while (!succeeded && attempts < MAX_TRIES);

                if (succeeded)
                {
                    Console.WriteLine("Successfully built webform {0}, took {1} {2}", item.WebFormZNo, attempts, attempts == 1 ? "attempt" : "attempts");
                }
                else
                {
                    Console.WriteLine("Failed to build webform {0}, took to many attempts", item.WebFormZNo);
                }
            }
            catch (Exception e)
            {
                Console.WriteLine("Failed to build webform {0}, Check logs for more information", item.WebFormZNo);
            }
        }
Example #2
0
        public void InsertScript(WebFormItem item)
        {
            try
            {
                if (item.CustomJavascript == CustomJavascript.None)
                {
                    return;
                }
                string file    = string.Format(SCRIPT_FORMAT, domain, item.ConfirmationPage);
                string content = File.ReadAllText(file);
                Console.WriteLine("Inserting script into file: " + file);
                switch (item.CustomJavascript)
                {
                case CustomJavascript.None:
                    break;

                case CustomJavascript.ActionA:
                    content = content.Insert(content.IndexOf(SCRIPT_PLACEMENT), Properties.Resources.ActionA);
                    break;

                case CustomJavascript.ActionC:
                    content = content.Insert(content.IndexOf(SCRIPT_PLACEMENT), Properties.Resources.ActionC);
                    break;

                case CustomJavascript.ActionN:
                    content = content.Insert(content.IndexOf(SCRIPT_PLACEMENT), Properties.Resources.ActionN);
                    break;

                default:
                    break;
                }
                File.WriteAllText(file, content);
            }catch (Exception e)
            {
                Console.WriteLine(e);
            }
        }