public MasterForm()
 {
     _image           = null;
     _attributes      = new FormRecognitionAttributes();
     _properties      = FormRecognitionProperties.Empty;
     _processingPages = null;
 }
        /// <summary>
        /// Delete a form for testing purposes. This will only work if the form to be deleted has not been used.
        /// </summary>
        /// <param name="formId">The ID of the form to be deleted.</param>
        public void DeleteForm(int formId)
        {
            Console.WriteLine("WindowHandle at Start: " + _driver.GetHashCode().ToString());

            var mainMenu  = new MainMenu(_driver);
            var formMenu  = new SubMenuForms(_driver);
            var formPages = new FormPages(_driver);

            Console.WriteLine("Attemping to delete form with ID {0}", formId);

            // navigate to Forms > Design Forms and Packets > Edit Forms
            _driver.SwitchToDefaultFrame();
            mainMenu.ClickMainMenuTab();
            mainMenu.ClickForms();
            formMenu.ClickDesignFormsandPackets();
            formMenu.ClickEditForms();
            _test.Log(LogStatus.Pass, "Navigate to Forms > Design Forms and Packets > Edit Forms");

            // select the form in the list
            _driver.SwitchToFrameById("MainContentsIFrame");
            formPages.EditFormsPage.SelectForm(formId);
            _test.Log(LogStatus.Pass, "Select the form in the list");

            // delete the form
            _driver.SwitchToDefaultFrame();
            formMenu.ClickDeleteForms();
            formPages.EditFormsPage.ConfirmDeletion();
            _test.Log(LogStatus.Pass, "Delete and confirm");
        }
        /// <summary>
        /// Create a new, blank, form for testing purposes. To use, assign this function to a string.
        /// </summary>
        /// <returns>The ID of the newly created form.</returns>
        public int CreateForm()
        {
            var formData  = new FormData();
            var mainMenu  = new MainMenu(_driver);
            var formMenu  = new SubMenuForms(_driver);
            var formPages = new FormPages(_driver);

            // navigate to Forms > Design Forms and Packets > Create New Form
            _driver.SwitchToDefaultFrame();
            mainMenu.ClickMainMenuTab();
            mainMenu.ClickForms();
            formMenu.ClickDesignFormsandPackets();
            formMenu.ClickCreateNewForm();
            _test.Log(LogStatus.Pass, "Navigate to Forms > Design Forms and Packets > Create New Form");

            // click 'A blank form'
            _driver.SwitchToFrameById("MainContentsIFrame");
            formPages.CreateNewFormPage.ClickBlankForm();
            _test.Log(LogStatus.Pass, "Click 'A blank form'");

            // enter form info
            _driver.SwitchToFrameById("tabs_Panel");
            formPages.EditAndCreateFormPage.PropertiesTab.ClickStandardFormRadioButton();
            formPages.EditAndCreateFormPage.PropertiesTab.FillOutFormTitle(formData.FormTitle);
            _test.Log(LogStatus.Pass, "Enter form information");

            // save
            _driver.SwitchToDefaultFrame();
            _driver.SwitchToFrameById("MainContentsIFrame");
            formPages.EditAndCreateFormPage.ClickSaveButton();
            _test.Log(LogStatus.Pass, "Save the form");
            return(formPages.EditAndCreateFormPage.GetFormId());
        }
        public void Form_Delete_Unused()
        {
            Console.WriteLine("WindowHandle at Start: " + Driver.GetHashCode().ToString());

            var mainMenu  = new MainMenu(Driver);
            var formMenu  = new SubMenuForms(Driver);
            var formPages = new FormPages(Driver);

            var formWorkflow = new FormWorkflows(Driver, test);

            try  //Contains Contents of Test
            {
                //test.Log(LogStatus.Info, "Starting test at URL: " + BaseUrls["ApplitrackLoginPage"]);

                // create the form and get the id
                var newFormId = formWorkflow.CreateForm();
                test.Log(LogStatus.Pass, "Create the form");

                Console.WriteLine("Attemping to delete form with ID {0}", newFormId);
                // navigate to Forms > Design Forms and Packets > Edit Forms
                Driver.SwitchToDefaultFrame();
                mainMenu.ClickMainMenuTab();
                mainMenu.ClickForms();
                formMenu.ClickDesignFormsandPackets();
                formMenu.ClickEditForms();
                test.Log(LogStatus.Pass, "Navigate to Main Menu > Forms > Design Forms and Packets > Edit Forms");

                // select the form in the list
                Driver.SwitchToFrameById("MainContentsIFrame");
                formPages.EditFormsPage.SelectForm(newFormId);
                test.Log(LogStatus.Pass, "Select the form from the list");

                // delete the form
                Driver.SwitchToDefaultFrame();
                formMenu.ClickDeleteForms();
                test.Log(LogStatus.Pass, "Click Delete Forms");

                formPages.EditFormsPage.ConfirmDeletion();
                test.Log(LogStatus.Pass, "Confirm the deletion");

                // verify that the form was deleted
                Driver.SwitchToDefaultFrame();
                mainMenu.ClickMainMenuTab();
                mainMenu.ClickForms();
                formMenu.ClickDesignFormsandPackets();
                formMenu.ClickEditForms();
                Driver.SwitchToFrameById("MainContentsIFrame");
                Assert.IsFalse(formPages.EditFormsPage.FormExists(newFormId));
                test.Log(LogStatus.Pass, "Form deleted");

                Console.Out.WriteLineAsync("Form Deleted");
            }
            catch (Exception e) //On Error Do
            {
                HandleException(e, Driver);
                throw;
            }
        }
Ejemplo n.º 5
0
 public MasterForm(string name)
 {
     _image           = null;
     _attributes      = new FormRecognitionAttributes();
     _properties      = new FormRecognitionProperties();
     _properties.Name = name;
     _processingPages = null;
     _isDirty         = false;
 }
Ejemplo n.º 6
0
 public MasterForm(string name, RasterImage image, FormRecognitionAttributes attr, FormRecognitionEngine engine)
 {
     _image           = image;
     _attributes      = attr;
     attr.Image       = Image;
     _properties      = engine.GetFormProperties(attr);
     _properties.Name = name;
     _processingPages = null;
     _isDirty         = false;
 }
Ejemplo n.º 7
0
 // Update the fields of this master form
 public void WriteFields(FormPages fields)
 {
     if (fields == null)
     {
         throw new ArgumentNullException("fields");
     }
     _processingEngine.Pages.Clear();
     _processingEngine.Pages.AddRange(fields);
     _processingEngine.SaveFields(_path + ".xml");
 }
Ejemplo n.º 8
0
        // Read the fields of this master form
        public FormPages ReadFields()
        {
            if (!File.Exists(_path + ".xml"))
            {
                return(null);
            }
            _processingEngine.LoadFields(_path + ".xml");
            //to create new forms pages
            FormProcessingEngine tempProcessingEngine = new FormProcessingEngine();
            FormPages            formFields           = tempProcessingEngine.Pages;

            formFields.AddRange(_processingEngine.Pages);
            return(formFields);
        }
Ejemplo n.º 9
0
        public void Forms_Category_By_Status_Loads()
        {
            // page objects
            var mainMenu  = new MainMenu(Driver);
            var formsMenu = new SubMenuForms(Driver);
            var formPages = new FormPages(Driver);

            // test data
            const string expectedMenuHeader = "By Status";

            try
            {
                // Navigate to Forms > View Submitted Forms by Category > Applicant Screening > Teacher Candidate
                mainMenu.ClickForms();
                formsMenu.ClickViewSubmittedFormsByCategory();
                formsMenu.ClickCategory("Applicant Screening");
                formsMenu.ClickCategory("Teacher Candidate");
                test.Log(LogStatus.Pass, "Navigate to Forms > View Submitted Forms by Category > Applicant Screening > Teacher Candidate");

                // Click By Status
                formsMenu.ClickCategory("By Status");
                test.Log(LogStatus.Pass, "Click 'By Status' on the menu");

                // Assert that the menu header is correct
                var actualHeaderText = formsMenu.GetByStatusHeaderText();
                Assert.AreEqual(expectedMenuHeader, actualHeaderText, "Expected header text: " + expectedMenuHeader + " Actual header text: " + actualHeaderText);
                test.Log(LogStatus.Pass, "The header text is: " + actualHeaderText);

                // Click a menu item and assert that the page is displayed
                formsMenu.ClickCategory("Older");
                test.Log(LogStatus.Pass, "Click 'Older' on the menu");

                Driver.SwitchToFrameById("MainContentsIFrame");
                Assert.IsTrue(formPages.SearchPage.IsDisplayed());
                test.Log(LogStatus.Pass, "The page is displayed");
            }
            catch (Exception e) //On Error Do
            {
                HandleException(e, Driver);
                throw;
            }
        }
        public void Forms_Send_Inactive_Packet()
        {
            var mainMenu     = new MainMenu(Driver);
            var formMenu     = new SubMenuForms(Driver);
            var formPages    = new FormPages(Driver);
            var activeForm   = "HR-2472 Active";
            var inactiveForm = "HR-2472 Inactive";

            try
            {
                // Click Forms > Send a Form
                mainMenu.ClickForms();
                formMenu.ClickSendForm();

                // Send form packet with 1 active and 1 inactive form
                Driver.SwitchToFrameById("MainContentsIFrame");
                formPages.SendFormPage.SelectPacketToSendById(19);
                formPages.SendFormPage.ClickContinueWithSelectedForms();
                formPages.SendFormPage.SelectFormRecipient("me");
                formPages.SendFormPage.ClickNext();
                formPages.SendFormPage.ClickNext();
                // wait for form window to pop up
                Thread.Sleep(TimeSpan.FromSeconds(5));
                Driver.SwitchToPopup();
                Driver.ClosePopup();

                // Verify that only active form was sent
                Driver.SwitchToDefaultFrame();
                formMenu.ClickMySentForms();
                Driver.SwitchToFrameById("MainContentsIFrame");
                Assert.IsTrue(formPages.MySentFormsPage.FormExists(activeForm));
                Assert.IsFalse(formPages.MySentFormsPage.FormExists(inactiveForm));
            }
            catch (Exception e)
            {
                HandleException(e, Driver);
                throw;
            }
        }
        public IMasterForm AddMasterForm(FormRecognitionAttributes attributes, FormPages fields, Uri url)
        {
            if (attributes == null)
            {
                throw new ArgumentException(string.Format("Master Form attributes should be available"), "attributes");
            }
            // Create the file(s)
            FormRecognitionProperties properties = _recognitionEngine.GetFormProperties(attributes);
            DiskMasterFormExample     masterForm = new DiskMasterFormExample(_repository, properties.Name, System.IO.Path.Combine(_path, properties.Name), this);

            // Create the file
            masterForm.WriteAttributes(attributes);
            if (fields != null)
            {
                masterForm.WriteFields(fields);
            }
            if (url != null)
            {
                masterForm.WriteForm(_repository.RasterCodecsInstance.Load(url, 1, CodecsLoadByteOrder.Bgr, 1, -1));
            }

            _masterForms.AddMasterForm(masterForm);
            return(masterForm);
        }
Ejemplo n.º 12
0
 public async Task Initialise()
 {
     IsBusy = true;
     FormPages.AddRange(await _fileReaderWriter.LoadResource <HomeViewModel>(_resourcePrefix));
     IsBusy = false;
 }
Ejemplo n.º 13
0
        public void Form_SendTo_Applicant_using_Main_Menu()
        {
            // pages
            var mainMenu              = new MainMenu(Driver);
            var formMenu              = new SubMenuForms(Driver);
            var formPages             = new FormPages(Driver);
            var applicantPage         = new ApplicantPages(Driver);
            var applicantMenu         = new ApplicantAdminMenu(Driver);
            var applicantProfilePages = new ApplicantProfilePages(Driver);

            // workflows
            var searchWorkflows = new SearchWorkflows(Driver);
            var formWorkflows   = new FormWorkflows(Driver, test);

            // data
            var          formData = new FormData();
            var          formName = formData.FormTitle;
            const string appNo    = "2593";
            const string appName  = "Kevin Pavao";

            try //Contains Contents of Test
            {
                //test.Log(LogStatus.Info, "Starting test at URL: " + BaseUrls["ApplitrackLoginPage"]);

                // create a new form
                var formId = formWorkflows.CreateForm();
                test.Log(LogStatus.Info, "Created new form: " + formId + ": " + formName);

                // navigate back to the main menu
                Driver.SwitchToDefaultFrame();
                mainMenu.ClickMainMenuTab();

                // Navigate to Forms > Send a Form
                mainMenu.ClickForms();
                formMenu.ClickSendForm();
                test.Log(LogStatus.Pass, "Navigate to Forms > Send a Form");

                // Select "Approval and Deny Form for testing"
                Driver.SwitchToFrameById("MainContentsIFrame");
                formPages.SendFormPage.SelectFormToSendById(formId);
                test.Log(LogStatus.Pass, "Select form: " + formId);

                formPages.SendFormPage.ClickContinueWithSelectedForms();
                test.Log(LogStatus.Pass, "Click 'Continue with Selected Forms'");

                formPages.SendFormPage.ClickNext();
                test.Log(LogStatus.Pass, "Click 'Next'");

                // Assign the form to appno1
                formPages.SendFormPage.SelectAssociatedApplicant(appNo);
                test.Log(LogStatus.Pass, "Select Applicant Number: " + appNo);

                formPages.SendFormPage.ClickNext();
                test.Log(LogStatus.Pass, "Click 'Next'");

                // Send the form
                formPages.SendFormPage.ClickFinishAndDeliver();
                test.Log(LogStatus.Pass, "Click 'Finish and Deliver'");

                // Open the applicant page
                searchWorkflows.OpenApplicantUsingSearch(appNo, appName);
                test.Log(LogStatus.Pass, "Opened applicant page for: " + appNo + " " + appName);

                // Login as applicant
                Driver.SwitchToFrameById("App" + appNo);
                applicantProfilePages.Toolbar.LoginAsApplicant();
                test.Log(LogStatus.Pass, "Log in as applicant");

                // Click on the forms tab and select the "Approval and Deny Form for testing"
                applicantPage.ClickFormsTab();
                test.Log(LogStatus.Pass, "Clicking the 'Forms' tab");
                Driver.SwitchToFrameById("FormsDataPage");

                var formGuid = applicantPage.GetFormGuid(formName);
                // switch back to the main window
                Driver.ClosePopup();

                // Navigate to 'List All Forms'
                Driver.SwitchToFrameById("App" + appNo);
                applicantMenu.ClickListAllForms();
                Driver.SwitchToFrameById("MainContentsIFrame");
                test.Log(LogStatus.Pass, "Navigate to 'List All Forms' from the applicant menu");

                // Verify the form was sent
                Assert.IsTrue(applicantProfilePages.ListAllForms.FormWasSent(formGuid), "The form was not sent.");
                test.Log(LogStatus.Pass, "Check the list to verify that the form was sent");

                // Cleanup - delete the form
                test.Log(LogStatus.Info, "Beginning cleanup");
                formWorkflows.DeleteSentForm(formGuid);
                test.Log(LogStatus.Pass, "Delete sent form");

                Driver.SwitchToDefaultFrame();
                mainMenu.ClickMainMenuTab();
                formWorkflows.DeleteForm(formId);
                test.Log(LogStatus.Pass, "Delete created form");
            }
            catch (Exception e) //On Error Do
            {
                HandleException(e, Driver);
                throw;
            }
        }
        public void Form_Create_New_Blank()
        {
            Console.WriteLine("WindowHandle at Start: " + Driver.GetHashCode().ToString());

            var formData  = new FormData();
            var mainMenu  = new MainMenu(Driver);
            var formMenu  = new SubMenuForms(Driver);
            var formPages = new FormPages(Driver);

            var formWorkflow = new FormWorkflows(Driver, test);

            try  //Contains Contents of Test
            {
                //test.Log(LogStatus.Info, "Starting test at URL: " + BaseUrls["ApplitrackLoginPage"]);

                // navigate to Forms > Design Forms and Packets > Create New Form
                mainMenu.ClickForms();
                formMenu.ClickDesignFormsandPackets();
                formMenu.ClickCreateNewForm();
                test.Log(LogStatus.Pass, "Navigate to Forms > Design Forms and Packets > Create New Form");

                // click 'A blank form'
                Driver.SwitchToFrameById("MainContentsIFrame");
                formPages.CreateNewFormPage.ClickBlankForm();
                test.Log(LogStatus.Pass, "Click 'A blank form'");

                // enter form info
                Driver.SwitchToFrameById("tabs_Panel");
                formPages.EditAndCreateFormPage.PropertiesTab.ClickStandardFormRadioButton();
                test.Log(LogStatus.Pass, "Select the 'Standard Form' radio button");

                formPages.EditAndCreateFormPage.PropertiesTab.FillOutFormTitle(formData.FormTitle);
                test.Log(LogStatus.Pass, "Fill out the form title");

                // save
                Driver.SwitchToDefaultFrame();
                Driver.SwitchToFrameById("MainContentsIFrame");
                formPages.EditAndCreateFormPage.ClickSaveButton();
                test.Log(LogStatus.Pass, "Click the save button");
                var formId = formPages.EditAndCreateFormPage.GetFormId();
                Console.WriteLine("Form ID: {0}", formId);

                // verify that the form was created
                Driver.SwitchToDefaultFrame();
                mainMenu.ClickMainMenuTab();
                mainMenu.ClickForms();
                formMenu.ClickDesignFormsandPackets();
                formMenu.ClickEditForms();
                Driver.SwitchToFrameById("MainContentsIFrame");
                Assert.IsTrue(formPages.EditFormsPage.FormExists(formId));
                test.Log(LogStatus.Pass, "Verify the form exists");

                // delete the form
                formWorkflow.DeleteForm(formId);
                test.Log(LogStatus.Pass, "Delete the form");
            }
            catch (Exception e) //On Error Do
            {
                HandleException(e, Driver);
                throw;
            }
        }
        public void Form_SendTo_Applicant_Approve()
        {
            Console.WriteLine("WindowHandle at Start: " + Driver.GetHashCode().ToString());

            var mainMenu              = new MainMenu(Driver);
            var formMenu              = new SubMenuForms(Driver);
            var formPages             = new FormPages(Driver);
            var applicantProfilePages = new ApplicantProfilePages(Driver);
            var applicantPage         = new ApplicantPages(Driver);
            var applicantMenu         = new ApplicantAdminMenu(Driver);

            var searchWorkflows = new SearchWorkflows(Driver);
            var formWorkflows   = new FormWorkflows(Driver, test);

            try //Contains Contents of Test
            {
                const int    formId     = 895;
                const string formName   = "Approve Form Automated Testing";
                const string appNo      = "435";
                const string appName    = "Raj email";
                const string employeeNo = "484";

                //test.Log(LogStatus.Info, "Starting test at URL: " + BaseUrls["ApplitrackLoginPage"]);

                // Navigate to Forms > Send a Form
                mainMenu.ClickForms();
                formMenu.ClickSendForm();
                test.Log(LogStatus.Pass, "Navigate to Forms > Send a Form");

                // Select "Approval and Deny Form for testing"
                Driver.SwitchToFrameById("MainContentsIFrame");
                formPages.SendFormPage.SelectFormToSendById(formId);
                test.Log(LogStatus.Pass, "Select form: " + formId);
                formPages.SendFormPage.ClickContinueWithSelectedForms();
                test.Log(LogStatus.Pass, "Click 'Continue with Selected Forms'");

                // Assign the form to appno1
                formPages.SendFormPage.SelectAssociatedApplicant(appNo);
                test.Log(LogStatus.Pass, "Select Applicant Number: " + appNo);

                // Assign the form to an employee
                formPages.SendFormPage.SelectAssociatedEmployee(employeeNo);
                test.Log(LogStatus.Pass, "Select Employee Number: " + employeeNo);

                formPages.SendFormPage.ClickNext();
                test.Log(LogStatus.Pass, "Click 'Next'");

                // Send the form
                formPages.SendFormPage.ClickFinishAndDeliver();
                test.Log(LogStatus.Pass, "Click 'Finish and Deliver'");

                // Open the applicant page
                searchWorkflows.OpenApplicantUsingSearch(appNo, appName);
                test.Log(LogStatus.Pass, "Opened applicant page for: " + appNo + " " + appName);

                // Login as applicant
                Driver.SwitchToFrameById("App" + appNo);
                applicantProfilePages.Toolbar.LoginAsApplicant();
                test.Log(LogStatus.Pass, "Log in as applicant");

                // Click on the forms tab and select the "Approval and Deny Form for testing"
                applicantPage.ClickFormsTab();
                test.Log(LogStatus.Pass, "Clicking the 'Forms' tab");
                Driver.SwitchToFrameById("FormsDataPage");
                // TODO: refactor SelectForm() in order to use GetFormKey() instead
                var formGuid = applicantPage.SelectForm(formName);
                test.Log(LogStatus.Pass, "Selecting " + formName);

                // Fill out an answer and click Next
                Driver.SwitchToDefaultFrame();
                applicantPage.ClickNextPage();
                test.Log(LogStatus.Pass, "Click Next Page");
                // the Next Page button must be clicked twice in order to go to the next page
                // TODO work with developers to fix
                applicantPage.ClickNextPage();
                test.Log(LogStatus.Pass, "Click Next Page again");

                // The IFrames are nested so we need to switch to both
                Driver.SwitchToFrameById("FormsDataPage");
                Driver.SwitchToFrameById("IFrameFormSent");

                // Verify the 'Approve' button exists
                Assert.IsTrue(applicantPage.ApproveButtonExists(), "The 'Approve' button does not appear on the screen");
                test.Log(LogStatus.Pass, "The 'Approve' button exists");

                // Digitally sign and approve the form
                applicantPage.EnterDigitalSignature(appName);
                test.Log(LogStatus.Pass, "Digitally sign the form");

                applicantPage.ClickApprove();
                test.Log(LogStatus.Pass, "Approve the form");

                // switch back to the main window
                Driver.ClosePopup();

                // Navigate to 'List All Forms'
                Driver.SwitchToFrameById("App" + appNo);
                applicantMenu.ClickListAllForms();
                Driver.SwitchToFrameById("MainContentsIFrame");
                test.Log(LogStatus.Pass, "Navigate to 'List All Forms' from the applicant menu");

                // Verify form has been approved
                Assert.IsTrue(applicantProfilePages.ListAllForms.FormIsApproved(formGuid), "The form was not approved");
                test.Log(LogStatus.Pass, "Form was approved");

                // Cleanup - delete the form
                test.Log(LogStatus.Info, "Beginning cleanup");
                formWorkflows.DeleteSentForm(formGuid);
                test.Log(LogStatus.Pass, "Delete sent form");
            }
            catch (Exception e) //On Error Do
            {
                HandleException(e, Driver);
                throw;
            }
        }
Ejemplo n.º 16
0
        [Ignore] // TODO figure out why this is flaky
        public void Form_SendTo_Applicant_using_New_Form()
        {
            // pages
            var mainMenu              = new MainMenu(Driver);
            var formPages             = new FormPages(Driver);
            var applicantProfilePage  = new ApplicantProfilePages(Driver);
            var applicantPage         = new ApplicantPages(Driver);
            var applicantMenu         = new ApplicantAdminMenu(Driver);
            var applicantProfilePages = new ApplicantProfilePages(Driver);

            // workflows
            var searchWorkflows = new SearchWorkflows(Driver);
            var formWorkflows   = new FormWorkflows(Driver, test);

            // data
            var          formData = new FormData();
            var          formName = formData.FormTitle;
            const string appNo    = "2593";
            const string appName  = "Kevin Pavao";

            try //Contains Contents of Test
            {
                // create a new form
                var formId = formWorkflows.CreateForm();
                test.Log(LogStatus.Info, "Created new form: " + formId + ": " + formName);

                // Open the applicant page
                searchWorkflows.OpenApplicantUsingSearch(appNo, appName);
                test.Log(LogStatus.Pass, "Opened applicant page for: " + appNo + " " + appName);

                // Click the 'New Form' button and switch to the new window
                Driver.SwitchToFrameById("App" + appNo);
                applicantProfilePage.Toolbar.ClickNewFormButton();
                Driver.SwitchToPopup();

                formPages.SendFormPage.SelectFormToSendById(formId);
                test.Log(LogStatus.Pass, "Select form: " + formId);

                formPages.SendFormPage.ClickContinueWithSelectedForms();
                test.Log(LogStatus.Pass, "Click 'Continue with Selected Forms'");

                // TODO create method(s) to select other radio buttons
                // This page should automatically select the 'Applicant' radio button
                // Therefore we can just click next...
                formPages.SendFormPage.ClickNext();
                test.Log(LogStatus.Pass, "Click 'Next Page'");

                // Send the form
                formPages.SendFormPage.ClickFinishAndDeliver();
                test.Log(LogStatus.Pass, "Click 'Finish and Deliver'");

                // Close the window and switch back to the main window
                Driver.ClosePopup();

                // Login as applicant
                Driver.SwitchToFrameById("App" + appNo);
                applicantProfilePage.Toolbar.LoginAsApplicant();
                test.Log(LogStatus.Pass, "Log in as applicant");

                // Click on the forms tab and select the "Approval and Deny Form for testing"
                applicantPage.ClickFormsTab();
                test.Log(LogStatus.Pass, "Clicking the 'Forms' tab");
                Driver.SwitchToFrameById("FormsDataPage");

                var formGuid = applicantPage.GetFormGuid(formName);

                // switch back to the main window
                Driver.ClosePopup();

                // Navigate to 'List All Forms'
                Driver.SwitchToFrameById("App" + appNo);
                applicantMenu.ClickListAllForms();
                Driver.SwitchToFrameById("MainContentsIFrame");
                test.Log(LogStatus.Pass, "Navigate to 'List All Forms' from the applicant menu");

                // Verify the form was sent
                Assert.IsTrue(applicantProfilePages.ListAllForms.FormWasSent(formGuid), "The form was not sent.");
                test.Log(LogStatus.Pass, "Check the list to verify that the form was sent");

                // Cleanup - delete the form
                test.Log(LogStatus.Info, "Beginning cleanup");
                formWorkflows.DeleteSentForm(formGuid);
                test.Log(LogStatus.Pass, "Delete sent form");

                Driver.SwitchToDefaultFrame();
                mainMenu.ClickMainMenuTab();
                formWorkflows.DeleteForm(formId);
                test.Log(LogStatus.Pass, "Delete created form");
            }
            catch (Exception e) //On Error Do
            {
                HandleException(e, Driver);
                throw;
            }
        }
Ejemplo n.º 17
0
        public void Form_Blank_Form_Deletion()
        {
            Console.WriteLine("WindowHandle at Start: " + Driver.GetHashCode().ToString());

            var mainMenu              = new MainMenu(Driver);
            var formPages             = new FormPages(Driver);
            var applicantProfilePages = new ApplicantProfilePages(Driver);
            var applicantPage         = new ApplicantPages(Driver);
            var applicantMenu         = new ApplicantAdminMenu(Driver);

            var searchWorkflows = new SearchWorkflows(Driver);
            var formWorkflows   = new FormWorkflows(Driver, test);

            var formData = new FormData();
            var formName = formData.FormTitle;

            var windowHelpers = new WindowHelpers(Driver);

            try //Contains Contents of Test
            {
                const string appNo   = "1";
                const string appName = "Sample Applicant";

                //test.Log(LogStatus.Info, "Starting test at URL: " + BaseUrls["ApplitrackLoginPage"]);

                // create a new form
                var formId = formWorkflows.CreateForm();
                test.Log(LogStatus.Info, "Created new form: " + formId + ": " + formName);

                // Open the applicant page
                searchWorkflows.OpenApplicantUsingSearch(appNo, appName);
                test.Log(LogStatus.Pass, "Opened applicant page for: " + appNo + " " + appName);

                // Click the 'New Form' button and switch to the new window
                Driver.SwitchToFrameById("App" + appNo);
                applicantProfilePages.Toolbar.ClickNewFormButton();
                Driver.SwitchToPopup();

                formPages.SendFormPage.SelectFormToSendById(formId);
                test.Log(LogStatus.Pass, "Select form: " + formId);

                formPages.SendFormPage.ClickContinueWithSelectedForms();
                test.Log(LogStatus.Pass, "Click 'Continue with Selected Forms'");

                // TODO create method(s) to select other radio buttons
                // This page should automatically select the 'Applicant' radio button
                // Therefore we can just click next...
                formPages.SendFormPage.ClickNext();
                test.Log(LogStatus.Pass, "Click 'Next Page'");

                // Send the form
                formPages.SendFormPage.ClickFinishAndDeliver();
                test.Log(LogStatus.Pass, "Click 'Finish and Deliver'");

                // Close the window and switch back to the main window
                //formPages.ClickCloseWindow();
                Driver.ClosePopup();

                // Login as applicant
                Driver.SwitchToFrameById("App" + appNo);
                applicantProfilePages.Toolbar.LoginAsApplicant();
                test.Log(LogStatus.Pass, "Log in as applicant");

                // Click on the forms tab and select the "Approval and Deny Form for testing"
                applicantPage.ClickFormsTab();
                test.Log(LogStatus.Pass, "Clicking the 'Forms' tab");
                Driver.SwitchToFrameById("FormsDataPage");

                var formGuid = applicantPage.GetFormGuid(formName);

                // switch back to the main window
                Driver.ClosePopup();

                // Navigate to 'List All Forms'
                Driver.SwitchToFrameById("App" + appNo);
                applicantMenu.ClickListAllForms();
                Driver.SwitchToFrameById("MainContentsIFrame");

                // Verify the form was sent
                Assert.IsTrue(applicantProfilePages.ListAllForms.FormWasSent(formGuid), "The form was not sent.");

                // click 'Edit Form'
                applicantProfilePages.ListAllForms.EditForm(formGuid);
                Driver.SwitchToPopup();
                //formPages.ClickSaveAsDraft();
                Driver.ClosePopup();

                BrowseTo(BaseUrls["ApplitrackLoginPage"] + "/onlineapp/admin/maintenance/deleteunansweredformssent.aspx", Driver);

                /*
                 * // Cleanup - delete the form
                 * Driver.SwitchToDefaultFrame();
                 * Driver.SwitchToFrameById("App"+appNo);
                 * Driver.SwitchToFrameById("MainContentsIFrame");
                 * applicantAdminPages.DeleteForm(formGuid);
                 * AlertAccept(Driver);
                 * AlertAccept(Driver);
                 * test.Log(LogStatus.Pass, "Form was deleted");
                 */
            }
            catch (Exception e) //On Error Do
            {
                HandleException(e, Driver);
                throw;
            }
        }
Ejemplo n.º 18
0
        private void AddMasterFormPages(RasterImage imagesToAdd, DiskMasterForm currentform, string folderName)
        {
            try
            {
                DiskMasterForm            currentMasterForm = currentform;
                FormRecognitionAttributes attributes        = currentMasterForm.ReadAttributes();
                FormPages   formPages = currentMasterForm.ReadFields();
                RasterImage formImage = currentMasterForm.ReadForm();

                for (int i = 0; i < imagesToAdd.PageCount; i++)
                {
                    //Add each new page to the masterform by creating attributes for each page
                    imagesToAdd.Page = i + 1;
                    AddPageToMasterForm(imagesToAdd.Clone(), attributes, -1, null);
                }

                //Add image
                if (formImage != null)
                {
                    formImage.AddPages(imagesToAdd.CloneAll(), 1, imagesToAdd.PageCount);
                }
                else
                {
                    formImage = imagesToAdd.CloneAll();
                }

                //Only add processing pages for the new pages
                if (formPages != null)
                {
                    for (int i = 0; i < imagesToAdd.PageCount; i++)
                    {
                        formPages.Add(new FormPage(formPages.Count + 1, imagesToAdd.XResolution, imagesToAdd.YResolution));
                    }
                }
                else
                {
                    //No processing pages exist so we must create them
                    FormRecognitionEngine recognitionEngine    = SetupRecognitionEngine();
                    FormProcessingEngine  tempProcessingEngine = new FormProcessingEngine();
                    tempProcessingEngine.OcrEngine = OcrEngineManager.CreateEngine(OcrEngineType.LEAD, false);
                    //tempProcessingEngine.BarcodeEngine = barcodeEngine;

                    for (int i = 0; i < recognitionEngine.GetFormProperties(attributes).Pages; i++)
                    {
                        tempProcessingEngine.Pages.Add(new FormPage(i + 1, imagesToAdd.XResolution, imagesToAdd.YResolution));
                    }

                    formPages = tempProcessingEngine.Pages;
                }

                //FormField newField = null;
                //AnnHiliteObject newObject = new AnnHiliteObject();
                //newField = new TextFormField();
                //newField.Name = "test";
                //newField.Bounds = new LogicalRectangle(50, 50, 50, 50, LogicalUnit.Pixel);

                //FormField newField1 = null;
                //AnnHiliteObject newObject1 = new AnnHiliteObject();
                //newField1 = new OmrFormField();
                //newField1.Name = "test1";
                //newField1.Bounds = new LogicalRectangle(50, 50, 50, 50, LogicalUnit.Pixel);

                //newObject.Tag = newField;
                //newObject1.Tag = newField1;
                //FormField currentField = newObject.Tag as FormField;
                //FormField currentField1 = newObject1.Tag as FormField;

                //formPages[0].Add(currentField);
                //formPages[0].Add(currentField1);

                currentMasterForm.WriteForm(formImage);
                currentMasterForm.WriteAttributes(attributes);
                currentMasterForm.WriteFields(formPages);
                DBHelper.UpdateTifPageCount(formImage.PageCount.ToString(), folderName);
            }
            catch (Exception ex)
            {
                throw;
            }
        }
Ejemplo n.º 19
0
        private void UpdateData()
        {
            var recognitionEngineVersion = FormRecognitionEngine.Version;

#if FOR_DOTNET4
            var originalFullTextSearchManager = recognitionEngine.FullTextSearchManager;
#endif

            try
            {
                if (!Directory.Exists(_txtSrcFolder.Text))
                {
                    Invoke((MethodInvoker) delegate { Messager.Show(this, "Please select valid folder", MessageBoxIcon.Error, MessageBoxButtons.OK); });
                    return;
                }

                // Set the data version to latest, we want to update the data to use the latest
                FormRecognitionEngine.Version = FormRecognitionEngine.LatestVersion;

                // Set the full text search engine
                DiskMasterFormsRepository workingRepository = new DiskMasterFormsRepository(_codecs, _txtSrcFolder.Text);

#if FOR_DOTNET4
                if (_cbUseFullTextSearch.Checked)
                {
                    DiskFullTextSearchManager fullTextSearchManager = new DiskFullTextSearchManager();
                    fullTextSearchManager.IndexDirectory    = Path.Combine(workingRepository.Path, "index");
                    recognitionEngine.FullTextSearchManager = fullTextSearchManager;
                }
#endif
                IMasterFormsCategory parentCategory = workingRepository.RootCategory;
                Invoke((MethodInvoker) delegate { _prgbar.Maximum = parentCategory.MasterForms.Count; });

                for (int i = 0; i < _prgbar.Maximum; i++)
                {
                    if (!_isRunning)
                    {
                        return;
                    }

                    Invoke((MethodInvoker) delegate { _prgbar.Value++; });

                    //Get the Original Attributes
                    DiskMasterForm            originalMasterForm = parentCategory.MasterForms[i] as DiskMasterForm;
                    FormRecognitionAttributes originalAttributes = originalMasterForm.ReadAttributes();
                    recognitionEngine.OpenMasterForm(originalAttributes);
                    recognitionEngine.CloseMasterForm(originalAttributes);

                    FormRecognitionOptions    options    = new FormRecognitionOptions();
                    FormRecognitionAttributes attributes = recognitionEngine.CreateMasterForm(parentCategory.MasterForms[i].Name, new Guid(), options);
                    recognitionEngine.CloseMasterForm(attributes);

                    IMasterForm newForm = parentCategory.AddMasterForm(attributes, null, (RasterImage)null);

                    DiskMasterForm currentMasterForm = parentCategory.MasterForms[i] as DiskMasterForm;
                    attributes = currentMasterForm.ReadAttributes();
                    FormPages   formPages = currentMasterForm.ReadFields();
                    RasterImage formImage = currentMasterForm.ReadForm();

                    for (int j = 0; j < formImage.PageCount; j++)
                    {
                        //Get the Page Recognition Options for the original Attributes
                        PageRecognitionOptions pageOptions = GetPageOptions(j, originalAttributes);

                        //Add each new page to the masterform by creating attributes for each page
                        formImage.Page = j + 1;
                        recognitionEngine.OpenMasterForm(attributes);
                        recognitionEngine.DeleteMasterFormPage(attributes, j + 1);
                        recognitionEngine.InsertMasterFormPage(j + 1, attributes, formImage.Clone(), pageOptions, null);
#if FOR_DOTNET4
                        if (_cbUseFullTextSearch.Checked)
                        {
                            recognitionEngine.UpsertMasterFormToFullTextSearch(attributes, "index", null, null, null, null);
                        }
#endif

                        recognitionEngine.CloseMasterForm(attributes);
                    }

                    FormProcessingEngine tempProcessingEngine = new FormProcessingEngine();
                    tempProcessingEngine.OcrEngine     = ocrEngine;
                    tempProcessingEngine.BarcodeEngine = barcodeEngine;

                    for (int j = 0; j < recognitionEngine.GetFormProperties(attributes).Pages; j++)
                    {
                        tempProcessingEngine.Pages.Add(new FormPage(j + 1, formImage.XResolution, formImage.YResolution));
                    }

                    formPages = tempProcessingEngine.Pages;
                    currentMasterForm.WriteAttributes(attributes);

                    currentMasterForm.WriteFields(parentCategory.MasterForms[i].ReadFields());
                }
#if FOR_DOTNET4
                if (recognitionEngine.FullTextSearchManager != null)
                {
                    recognitionEngine.FullTextSearchManager.Index();
                }
#endif
                System.Diagnostics.Process.Start(_txtSrcFolder.Text);
            }
            catch (Exception ex)
            {
                Invoke((MethodInvoker) delegate { Messager.Show(this, ex, MessageBoxIcon.Error); });
            }
            finally
            {
                // Restore the original version
                FormRecognitionEngine.Version = recognitionEngineVersion;
#if FOR_DOTNET4
                recognitionEngine.FullTextSearchManager = originalFullTextSearchManager;
#endif
                _isRunning = false;
                Invoke((MethodInvoker) delegate
                {
                    _prgbar.Value = 0;
                    UpdateControls();
                });
            }
        }
Ejemplo n.º 20
0
        public HttpResponseMessage DeletePage(FormDataCollection Form)
        {
            HttpResponseMessage httpResponseMessage = Request.CreateResponse(HttpStatusCode.OK, "Some problem in delete master form page.");

            if (Form != null)
            {
                string PageNumber = Form["PageNumber"]?.ToString().Trim() ?? "";
                string FolderName = Form["FolderName"]?.ToString().Trim() ?? "";
                string result     = DBHelper.GetFileFriendlyName(FolderName);

                string workingDirectory = HttpContext.Current.Server.MapPath("~/" + RootFolderName + "/" + result);
                if (Directory.Exists(workingDirectory))
                {
                    using (RasterCodecs _codecs = new RasterCodecs())
                    {
                        RasterDefaults.DitheringMethod = RasterDitheringMethod.None;
                        ServiceHelper.SetLicense();

                        workingRepository = new DiskMasterFormsRepository(_codecs, workingDirectory);
                        var masterForm = workingRepository?.RootCategory?.MasterForms?.FirstOrDefault();
                        if (masterForm != null)
                        {
                            DiskMasterForm            currentMasterForm = (DiskMasterForm)masterForm;
                            FormRecognitionAttributes attributes        = currentMasterForm.ReadAttributes();

                            int currentPageIdx = Convert.ToInt32(PageNumber);

                            FormPages   formPages = currentMasterForm.ReadFields();
                            RasterImage formImage = currentMasterForm.ReadForm();

                            //Delete page from master form attaributes
                            DeletePageFromMasterForm(currentPageIdx + 1, attributes); //page number here is 1 based
                                                                                      //Delete fields page
                            formPages.RemoveAt(currentPageIdx);
                            //Delete the page from the image
                            if (formImage.PageCount == 1)
                            {
                                formImage = null; //You cannot remove the only page from a rasterimage, an exception will occur
                            }
                            else
                            {
                                formImage.RemovePageAt(currentPageIdx + 1);
                            }

                            //We need to recreate the FormPages to ensure the page numbers are updated correctly
                            for (int i = 0; i < formPages.Count; i++)
                            {
                                FormPage currentPage = formPages[i];
                                FormPage newPage     = new FormPage(i + 1, currentPage.DpiX, currentPage.DpiY);
                                newPage.AddRange(currentPage.GetRange(0, currentPage.Count));
                                formPages[i] = newPage;
                            }
                            //Write the updated masterform to disk. Delete it first just in case the entire image was deleted
                            DiskMasterFormsCategory parentCategory = (workingRepository.RootCategory) as DiskMasterFormsCategory;
                            parentCategory.DeleteMasterForm(currentMasterForm);
                            parentCategory.AddMasterForm(attributes, formPages, formImage);
                            httpResponseMessage = Request.CreateResponse(HttpStatusCode.OK, "Page deleted from master set sucessfully.");
                            DBHelper.UpdateTifPageCount(formPages.Count.ToString(), FolderName);
                        }
                    }
                }
            }
            return(httpResponseMessage);
        }
Ejemplo n.º 21
0
        private bool AddField(DiskMasterForm currentform, List <XmlModel> model)
        {
            try
            {
                DiskMasterForm            currentMasterForm = currentform;
                FormRecognitionAttributes attributes        = currentMasterForm.ReadAttributes();
                FormPages   formPages = currentMasterForm.ReadFields();
                RasterImage formImage = currentMasterForm.ReadForm();
                foreach (XmlModel xmlModel in model)
                {
                    int i = formPages[xmlModel.PageNumber - 1].Count;
                    formPages[xmlModel.PageNumber - 1].RemoveRange(0, i);
                    foreach (XmlDetail xmlDetail in xmlModel.Detail)
                    {
                        FormField newField = null;

                        if (xmlDetail.FieldInfo.ObjectId == -51) // For textfield => -51 //for OmrField => -50
                        {
                            newField = new TextFormField();
                            (newField as TextFormField).EnableIcr = xmlDetail.FieldInfo.OcrFieldInfo.EnableICR;
                            (newField as TextFormField).EnableOcr = xmlDetail.FieldInfo.OcrFieldInfo.EnableOCR;
                            (newField as TextFormField).Type      = (xmlDetail.FieldInfo.OcrFieldInfo.Character == true ? TextFieldType.Character : (xmlDetail.FieldInfo.OcrFieldInfo.Numeric == true ? TextFieldType.Numerical : TextFieldType.Data));
                            if (xmlDetail.FieldInfo.OcrFieldInfo.CellBoarders)
                            {
                                newField.Dropout |= DropoutFlag.CellsDropout;
                            }
                            else
                            {
                                newField.Dropout &= ~DropoutFlag.CellsDropout;
                            }

                            if (xmlDetail.FieldInfo.OcrFieldInfo.Words)
                            {
                                newField.Dropout |= DropoutFlag.WordsDropout;
                            }
                            else
                            {
                                newField.Dropout &= ~DropoutFlag.WordsDropout;
                            }
                        }
                        else
                        {
                            newField = new OmrFormField();
                            if (xmlDetail.FieldInfo.OmrFieldInfo.WithFrame)
                            {
                                (newField as OmrFormField).FrameMethod = OcrOmrFrameDetectionMethod.WithFrame;
                            }
                            else if (xmlDetail.FieldInfo.OmrFieldInfo.WithoutFrame)
                            {
                                (newField as OmrFormField).FrameMethod = OcrOmrFrameDetectionMethod.WithoutFrame;
                            }
                            else if (xmlDetail.FieldInfo.OmrFieldInfo.Auto)
                            {
                                (newField as OmrFormField).FrameMethod = OcrOmrFrameDetectionMethod.Auto;
                            }

                            if (xmlDetail.FieldInfo.OmrFieldInfo.Lowest)
                            {
                                (newField as OmrFormField).Sensitivity = OcrOmrSensitivity.Lowest;
                            }
                            else if (xmlDetail.FieldInfo.OmrFieldInfo.Low)
                            {
                                (newField as OmrFormField).Sensitivity = OcrOmrSensitivity.Low;
                            }
                            else if (xmlDetail.FieldInfo.OmrFieldInfo.High)
                            {
                                (newField as OmrFormField).Sensitivity = OcrOmrSensitivity.High;
                            }
                            else if (xmlDetail.FieldInfo.OmrFieldInfo.Highest)
                            {
                                (newField as OmrFormField).Sensitivity = OcrOmrSensitivity.Highest;
                            }
                        }
                        newField.Name   = xmlDetail.FieldInfo.Name;
                        newField.Bounds = new LeadRect(Convert.ToInt32(Annotations.Engine.AnnUnitConverter.ConvertToPixels(xmlDetail.Cordinates.X, Leadtools.Annotations.Engine.AnnUnit.Unit, 96)), Convert.ToInt32(Annotations.Engine.AnnUnitConverter.ConvertToPixels(xmlDetail.Cordinates.Y, Annotations.Engine.AnnUnit.Unit, 96)), Convert.ToInt32(Annotations.Engine.AnnUnitConverter.ConvertToPixels(xmlDetail.Cordinates.Width, Annotations.Engine.AnnUnit.Unit, 96)), Convert.ToInt32(Annotations.Engine.AnnUnitConverter.ConvertToPixels(xmlDetail.Cordinates.Height, Annotations.Engine.AnnUnit.Unit, 96)));
                        // newField.Bounds= new LogicalRectangle(AnnUnitConverter.ConvertToPixels(xmlDetail.Cordinates.X, AnnUnit.Unit, 96), AnnUnitConverter.ConvertToPixels(xmlDetail.Cordinates.Y, AnnUnit.Unit, 96), AnnUnitConverter.ConvertToPixels(xmlDetail.Cordinates.Width, AnnUnit.Unit, 96), AnnUnitConverter.ConvertToPixels(xmlDetail.Cordinates.Height, AnnUnit.Unit, 96), LogicalUnit.Pixel);

                        Annotations.Engine.AnnHiliteObject newObject = new Annotations.Engine.AnnHiliteObject();
                        newObject.Tag = newField;
                        FormField currentField = newObject.Tag as FormField;
                        formPages[xmlModel.PageNumber - 1].Add(currentField);
                    }
                }
                currentMasterForm.WriteForm(formImage);
                currentMasterForm.WriteAttributes(attributes);
                currentMasterForm.WriteFields(formPages);
                return(true);
            }
            catch (Exception ex)
            {
                return(false);

                throw;
            }
        }