/// <summary> /// Open a form and closes the Cronus dialog if it is shown. If another dialog is shown this will throw an exception. /// </summary> /// <param name="clientSession">The <see cref="ClientSession"/>.</param> /// <param name="formId">The id of the form to open.</param> /// <returns>The form opened.</returns> /// <exception cref="InvalidOperationException">If a dialog is shown that is not the Cronus dialog.</exception> public static ClientLogicalForm OpenInitialForm(this ClientSession clientSession, string formId) { return clientSession.CatchForm(delegate { ClientLogicalForm dialog = clientSession.CatchDialog( () => clientSession.InvokeInteraction(new OpenFormInteraction { Page = formId })); if (dialog != null) { if (ClientLogicalFormExtensions.IsCronusDemoDialog(dialog)) { clientSession.InvokeInteraction(new CloseFormInteraction(dialog)); } else { string exceptionMessage = "Unexpected dialog shown: " + dialog.Caption; ClientStaticStringControl staticStringControl = dialog.ContainedControls.OfType<ClientStaticStringControl>().FirstOrDefault(); if (staticStringControl != null) { exceptionMessage += " - " + staticStringControl.StringValue; } throw new InvalidOperationException(exceptionMessage); } } }); }
/// <summary> /// Open a form. /// </summary> /// <param name="clientSession">The <see cref="ClientSession"/>.</param> /// <param name="formId">The id of the form to open.</param> /// <returns>The form opened.</returns> public static ClientLogicalForm OpenForm(this ClientSession clientSession, string formId) { return clientSession.CatchForm(() => clientSession.InvokeInteraction(new OpenFormInteraction { Page = formId })); }