public async Task _01_HandlePackageUpdates_NonBeta() { try { this.LaunchPackageUpdaterTestsAppWithArgs(out FileInfo appFile, Apps.PackageNames.PackageUpdaterTestAppV1, SharedTestHelpers.GetMethodName(), waitForExit: false); Window updateNowMsgBox = await WindowHelpers.WaitForWindowAsync(x => x.Equals("PackageTriggerUpdaterTestApp update download"), TimeSpan.FromMinutes(2)).ConfigureAwait(false); updateNowMsgBox.Get <Button>(SearchCriteria.ByText("Yes")).Click(); Window executed = await WindowHelpers.WaitForWindowAsync(x => x.Equals("Updater executed"), TimeSpan.FromMinutes(1)).ConfigureAwait(false); executed.Get <Button>(SearchCriteria.ByText("OK")).Click(); Window doneMsg = await WindowHelpers.WaitForWindowAsync(x => x.Equals("Updater finished"), TimeSpan.FromMinutes(1)).ConfigureAwait(false); string text = this.GetTextFromMsgBox(doneMsg); Assert.AreEqual("Killed other processes: True", text); //do not check if app was updated, because we only care whether the updater was actually launched } catch (Exception ex) { throw this.CleanupAndRethrow(ex); } }
/// <summary> /// 医院名称为空,点击查询按钮,加载所有医院 /// </summary> public static bool Search_HospitalNameNull(Window appWin, out string msg) { try { var startTime = DateTime.Now; //医院名称为空 TextBox txtSearchHospital = appWin.Get <TextBox>(SearchCriteria.ByAutomationId("txtSearchHospital")); txtSearchHospital.Text = ""; //点击查询按钮 Button btnSearch = appWin.Get <Button>(SearchCriteria.ByAutomationId("btnSearch")); btnSearch.Click(); var endTime = DateTime.Now; try { //捕捉报错信息,如果能捕捉到,则测试未通过 string error_info = appWin.Get <Label>(SearchCriteria.ByText("查询医院列表异常!")).ToString(); msg = "测试【医院名称为空,点击查询按钮,加载所有医院】--未通过," + error_info + "用时:" + (endTime - startTime).TotalSeconds; return(false); } catch { msg = "测试【医院名称为空,点击查询按钮,加载所有医院】--通过,用时:" + (endTime - startTime).TotalSeconds; return(true); } } catch (Exception e) { msg = "测试【医院名称为空,点击查询按钮,加载所有医院】--失败,原因:" + e.ToString(); return(false); } }
private void Add(string value1, string value2) { InputValue(value1); _mainWindow.Get <Button>(SearchCriteria.ByText("+")).Click(); InputValue(value2); _mainWindow.Get <Button>(SearchCriteria.ByText("=")).Click(); }
/// <summary> /// 点击角色管理菜单,加载所有角色 /// </summary> public static bool Load_RoleList(Window appWin, out string msg) { try { var startTime = DateTime.Now; //在菜单页选择角色管理 Button tlRoleManagement = appWin.Get <Button>(SearchCriteria.ByAutomationId("tlRoleManagement")); tlRoleManagement.Click(); var endTime = DateTime.Now; try { //捕捉报错信息,如果能捕捉到,则测试未通过 string error_info = appWin.Get <Label>(SearchCriteria.ByText("查询角色列表异常!")).ToString(); msg = "测试【点击角色管理菜单,加载所有角色】--未通过," + error_info + "用时:" + (endTime - startTime).TotalSeconds; return(false); } catch { msg = "测试【点击角色管理菜单,加载所有角色】--通过,用时:" + (endTime - startTime).TotalSeconds; return(true); } } catch (Exception e) { msg = "测试【点击角色管理菜单,加载所有角色】--失败,原因:" + e.ToString(); return(false); } }
public void LeaveNetwork() { Button CloseNetwork = MainWindow.Get <Button>(SearchCriteria.ByText("X")); Assert.IsNotNull(CloseNetwork); CloseNetwork.Click(); }
public async Task <VersionTuple> GetVersionFromMsgBox(Window msgBox) { string text = msgBox.Get <Label>(SearchCriteria.Indexed(0)).Text; string[] versions = text.Split(new char[] { '\r', '\n' }, StringSplitOptions.RemoveEmptyEntries); try { msgBox.Get <Button>(SearchCriteria.ByText("OK")).Click(); await Task.Delay(500).ConfigureAwait(false); } catch (Exception ex) { if (!string.IsNullOrEmpty(text)) { if (ex.Message.Contains("Window didn't respond") && ex.InnerException != null && ex.InnerException.Message.Contains("Process with an Id of")) { //that's weird but the message box got closed by something else } else { throw; } } } return(new VersionTuple() { AssemblyVersion = versions[0].Trim().Replace("AssemblyVersion: ", ""), FileVersion = versions[1].Trim().Replace("FileVersion: ", "") }); }
public void ApplicationLaunch() { SearchCriteria searchCriteria = SearchCriteria.ByText(TestDataInfrastructure.GetTestInputData("SelectEmployeeLabelText")).AndControlType(typeof(Label)); Label selectEmployeeLabel = Window.Get <Label>(searchCriteria); Assert.IsNotNull(selectEmployeeLabel); ListView list = Window.Get <ListView>(TestDataInfrastructure.GetControlId("EmployeesList")); Assert.IsNotNull(list, TestDataInfrastructure.GetTestInputData("EmployeeListNotFound")); Assert.AreEqual(2, list.Rows.Count, TestDataInfrastructure.GetTestInputData("EmployeeListIncorrectRowCount")); Assert.AreEqual(2, list.Header.Columns.Count, TestDataInfrastructure.GetTestInputData("EmployeeListIncorrectColumnCount")); /* Buttons have been removed * searchCriteria = SearchCriteria.ByAutomationId(TestDataInfrastructure.GetControlId("SendEmailButton")).AndControlType(typeof(Button)); * Button sendEmailButton = window.Get<Button>(searchCriteria); * Assert.IsNotNull(sendEmailButton, TestDataInfrastructure.GetTestInputData("SendMailButtonNotFound")); * * searchCriteria = SearchCriteria.ByAutomationId(TestDataInfrastructure.GetControlId("CallButton")).AndControlType(typeof(Button)); * Button callButton = window.Get<Button>(searchCriteria); * Assert.IsNotNull(callButton, TestDataInfrastructure.GetTestInputData("CallButtonNotFound")); * * searchCriteria = SearchCriteria.ByAutomationId(TestDataInfrastructure.GetControlId("PastProjectsButton")).AndControlType(typeof(Button)); * Button pastProjectsButton = window.Get<Button>(searchCriteria); * Assert.IsNotNull(callButton, TestDataInfrastructure.GetTestInputData("PastProjectsButtonNotfound")); */ }
public void setDateInCheckedPicker(Window window, DateTimePicker picker, int years) { clickDatePickerCheckBox(window, picker); window.Keyboard.PressSpecialKey(KeyboardInput.SpecialKeys.F4); int numberOfMonths = findNumberOfMonthsFromNumberOfYears(years); int directionMarker = -1; Panel cc = window.Get <Panel>(SearchCriteria.ByText("Calendar Control")); if (numberOfMonths == 0) { cc.Items[2].Click(); return; } if (numberOfMonths < 0) { directionMarker = 1; numberOfMonths *= -1; } else { directionMarker = 0; } for (var i = 0; i <= numberOfMonths; i++) { cc.Items[directionMarker].Click(); } picker.Click(); }
public void ClickOnNewProjectCrashTest() { Application app = Application.Launch(designer_executable); Assert.IsNotNull(app); Core.UIItems.WindowItems.Window window = app.GetWindow("Designer"); //Create new schema IUIItem new_project_button = window.Get(SearchCriteria.ByText("New Project")); Assert.IsNotNull(new_project_button); System.Drawing.Point pt = new System.Drawing.Point(System.Convert.ToInt32(new_project_button.Location.X) + 5, System.Convert.ToInt32(new_project_button.Location.Y) + 5); //Do click several times window.Mouse.Click(pt); System.Threading.Thread.Sleep(1000); window.Mouse.Click(pt); System.Threading.Thread.Sleep(1000); window.Mouse.Click(pt); window.Close(); Assert.IsTrue(window.IsClosed); Assert.IsTrue(app.HasExited); }
/// <summary> /// 订单ID为空,点击查询按钮,加载所有订单 /// </summary> public static bool Search_OrderIDNull(Window appWin, out string msg) { try { var startTime = DateTime.Now; //订单ID为空 TextBox txtOrderSn = appWin.Get <TextBox>(SearchCriteria.ByAutomationId("txtOrderSn")); txtOrderSn.Text = ""; //点击查询按钮 Button btnSearchOrderList = appWin.Get <Button>(SearchCriteria.ByAutomationId("btnSearchOrderList")); btnSearchOrderList.Click(); var endTime = DateTime.Now; try { //捕捉报错信息,如果能捕捉到,则测试未通过 string error_info = appWin.Get <Label>(SearchCriteria.ByText("查询订单列表异常!")).ToString(); msg = "测试【订单ID为空,点击查询按钮,加载所有订单】--未通过," + error_info + "用时:" + (endTime - startTime).TotalSeconds; return(false); } catch { msg = "测试【订单ID为空,点击查询按钮,加载所有订单】--通过,用时:" + (endTime - startTime).TotalSeconds; return(true); } } catch (Exception e) { msg = "测试【订单ID为空,点击查询按钮,加载所有订单】--失败,原因:" + e.ToString(); return(false); } }
public void FindMultiLevelMenuItemTest() { var menuBar = MainWindow.MenuBar; var menu = menuBar.MenuItem("Multi-Level Menu"); Assert.That(menu.SubMenu(SearchCriteria.ByText("Level 1")).SubMenu("Level 2").SubMenu("Level 3"), Is.Not.Null); }
public void CalculatorTests() { //strat process for the above exe file location var psi = new ProcessStartInfo(ExeSourceFile); // launch the process through white application using (var application = Application.AttachOrLaunch(psi)) using (var mainWindow = application.GetWindow(SearchCriteria.ByText("Calculator"), InitializeOption.NoCache)) { mainWindow.Keyboard.HoldKey(KeyboardInput.SpecialKeys.CONTROL); mainWindow.Keyboard.Enter("E"); mainWindow.Keyboard.LeaveKey(KeyboardInput.SpecialKeys.CONTROL); //On Date window find the difference between dates. //Set value into combobox mainWindow.Get <ComboBox>(SearchCriteria.ByAutomationId("4003")).Select("Calculate the difference between two dates"); //Click on Calculate button mainWindow.Get <Button>(SearchCriteria.ByAutomationId("4009")).Click(); mainWindow.Keyboard.HoldKey(KeyboardInput.SpecialKeys.CONTROL); mainWindow.Keyboard.PressSpecialKey(KeyboardInput.SpecialKeys.F4); mainWindow.Keyboard.LeaveKey(KeyboardInput.SpecialKeys.CONTROL); var menuView = mainWindow.Get <Menu>(SearchCriteria.ByText("View")); menuView.Click(); var menuViewBasic = mainWindow.Get <Menu>(SearchCriteria.ByText("Basic")); menuViewBasic.Click(); PerformSummationOnCalculator(mainWindow); } }
public void OpenSentItemsSection() { AutomationElement sentItemsAE = outlookWindow.GetElement(SearchCriteria.ByText("Sent Items")); UIItem sentItems = new UIItem(sentItemsAE, new NullActionListener()); sentItems.Click(); }
public void EnterReplyMessage(string replyText) { Button replyBtn = outlookWindow.Get <Button>(SearchCriteria.ByText("Reply")); replyBtn.Click(); outlookWindow.Keyboard.Enter(replyText); }
//This method select when multiple Button Found for same AutomationID/Name/Class public static bool ClickOnSpecificItemByName(pscWindow window, string id) { try { TestStack.White.UIItems.IUIItem[] item = window.GetMultiple(SearchCriteria.ByText(id)); int iter = 0; while (iter <= item.Length) { try { item[iter].Click(); return(true); } catch { iter++; continue; } } return(false); } catch (Exception) { Console.WriteLine("Not able to find item"); return(false); } }
public void Setup() { var applicationDirectory = TestContext.CurrentContext.TestDirectory; string projectName = "Oef13_3_Clear"; var applicationPath = Directory.GetCurrentDirectory() + Path.DirectorySeparatorChar + "bin" + Path.DirectorySeparatorChar + "Debug"; applicationPath = Path.Combine(applicationPath, projectName + ".exe"); TestContext.Progress.WriteLine("Using EXE: " + applicationPath); application = Application.Launch(applicationPath); Window window = application.GetWindow("Oef 13.3 Clear"); //This needs to be the title of the window, not the name of the class random = new Random(); try { //Get all the UI items here seriesListBox = window.Get <ListBox>("seriesListBox"); addButton = window.Get <Button>(SearchCriteria.ByText("Voeg toe")); itemTextBox = window.Get <TextBox>("itemTextBox"); deleteButton = window.Get <Button>(SearchCriteria.ByText("Verwijder")); clearButton = window.Get <Button>(SearchCriteria.ByText("Wis lijst")); } catch (Exception) { //The reason we are ignoring errors while finding ui items is because //we don't want every test to fail when an item isn't found. //Ignoring the exceptions still runs the tests. This makes it easier to pin down //which ui element was not found. } }
public void AddFundToCustomer() { WPFComboBox customer; WPFComboBox fund; Button addButton; Label activityLabel; //Get the handle of the Customer combo box and select Customer1 customer = Window.Get <WPFComboBox>(TestDataInfrastructure.GetControlId("CustomerCombobox")); customer.Select(TestDataInfrastructure.GetTestInputData("DefaultCustomer").ToString()); //Get the handle of the Fund combo box and select FundA fund = Window.Get <WPFComboBox>(TestDataInfrastructure.GetControlId("FundCombobox")); fund.Select(TestDataInfrastructure.GetTestInputData("DefaultFund")); //Get the handle of the Add button and click on it addButton = Window.Get <Button>(TestDataInfrastructure.GetControlId("AddButton")); addButton.Click(); //Get the handle of the Activity Label activityLabel = Window.Get <Label>(TestDataInfrastructure.GetControlId("ActivityLabel")); //Check if the selected fund is added to the Activity View of the selected customer. Assert.AreEqual(activityLabel.Text, TestDataInfrastructure.GetTestInputData("Customer1ActivityLabelText")); Assert.IsNotNull((Label)Window.Get(SearchCriteria.ByText(TestDataInfrastructure.GetTestInputData("DefaultFund")) .AndControlType(typeof(Label)))); }
/// <summary> /// Get the Button based on the input Window and Button Text /// </summary> /// <param name="wVStoreWin">Window</param> /// <param name="sText">Unique Text Identifier of the Button</param> /// <returns>Button</returns> public Button GetButtonUsingText(Window wVStoreWin, string sText) { wVStoreWin.WaitWhileBusy(); Button Button = wVStoreWin.Get <Button>(SearchCriteria.ByText(sText)); return(Button); }
public string GetTextFromMsgBox(Window msgBox) { string text = msgBox.Get <Label>(SearchCriteria.Indexed(0)).Text; try { msgBox.Get <Button>(SearchCriteria.ByText("OK")).Click(); } catch (Exception ex) { if (!string.IsNullOrEmpty(text)) { if (ex.Message.Contains("Window didn't respond") && ex.InnerException != null && ex.InnerException.Message.Contains("Process with an Id of")) { //that's weird but the message box got closed by something else } else { throw; } } } return(text); }
public void GetModalWindowBasedOnSearchCriteria() { LaunchModalWindow(); Window modalWindow = Window.ModalWindow(SearchCriteria.ByText("ModalForm")); Assert.AreNotEqual(null, modalWindow); }
public void GeneralEmployeetv(GeneralEmployees filter, string filterValue) { switch (filter) { case GeneralEmployees.OfficeRegion: advanceSearch.Get <Button>(SearchCriteria.ByAutomationId("btnOfficeRegion")).Click(); Tree offcRgn = advanceSearch.Get <Tree>(SearchCriteria.ByAutomationId("tvHierarchy")); Treev.TreeHiearchy.ExpandTree(offcRgn); TreeNode Offc = offcRgn.Get <TreeNode>(SearchCriteria.ByText(filterValue)); Offc.Click(); advanceSearch.Keyboard.PressSpecialKey(KeyboardInput.SpecialKeys.SPACE); advanceSearch.Get <Button>(SearchCriteria.ByAutomationId("btnSave")).Click(); break; case GeneralEmployees.LevelDeptt: advanceSearch.Get <Button>(SearchCriteria.ByAutomationId("btnLevelDepartment")).Click(); Tree lvlDpt = advanceSearch.Get <Tree>(SearchCriteria.ByAutomationId("tvLevelDepartment")); Treev.TreeHiearchy.ExpandTree(lvlDpt); TreeNode lvdp = lvlDpt.Get <TreeNode>(SearchCriteria.ByText(filterValue)); lvdp.Click(); advanceSearch.Keyboard.PressSpecialKey(KeyboardInput.SpecialKeys.SPACE); advanceSearch.Get <Button>(SearchCriteria.ByAutomationId("btnOK")).Click(); break; } }
/// <summary> /// Get node from the treeNodes /// </summary> /// <param name="treeNodes"></param> /// <param name="path"></param> /// <returns></returns> private TreeNode GetNodeFromTreeNodes(TreeNodes treeNodes, string path) { foreach (var subNode in treeNodes) { if (subNode.HelpText != string.Empty && IgnoreItems.Contains(subNode.HelpText) == false) { if (subNode.HelpText.Contains(path)) { return(subNode); } } else if (subNode.Text != string.Empty && IgnoreItems.Contains(subNode.Text) == false) { if (subNode.Text.Contains(path)) { return(subNode); } } else { var lblnode = QALabel.Get(SearchCriteria.ByText(path), string.Empty, subNode, 500); if (lblnode != null && lblnode.UIItemExists && lblnode.IsVisible) { return(subNode); } } } return(null); }
/// <summary> /// 输入角色名称,点击查询按钮,加载该角色 /// </summary> public static bool Search_RoleName(Window appWin, out string msg) { try { var startTime = DateTime.Now; //输入角色名称 TextBox txtSearchRole = appWin.Get <TextBox>(SearchCriteria.ByAutomationId("txtSearchRole")); txtSearchRole.BulkText = "超级管理员"; //点击查询按钮 Button btnSearch = appWin.Get <Button>(SearchCriteria.ByAutomationId("btnSearch")); btnSearch.Click(); var endTime = DateTime.Now; try { //捕捉报错信息,如果能捕捉到,则测试未通过 string error_info = appWin.Get <Label>(SearchCriteria.ByText("查询角色列表异常!")).ToString(); msg = "测试【输入角色名称,点击查询按钮,加载该角色】--未通过," + error_info + "用时:" + (endTime - startTime).TotalSeconds; return(false); } catch { msg = "测试【输入角色名称,点击查询按钮,加载该角色】--通过,用时:" + (endTime - startTime).TotalSeconds; return(true); } } catch (Exception e) { msg = "测试【输入角色名称,点击查询按钮,加载该角色】--失败,原因:" + e.ToString(); return(false); } }
public void treevLocation(string offcName) { advanceSearch.Get <Button>(SearchCriteria.ByAutomationId("btnManagingOfficeRegion")).Click(); Tree managingOfficeRegion = advanceSearch.Get <Tree>(SearchCriteria.ByAutomationId("tvHierarchy")); DateTime beginWait = DateTime.Now; while (!Console.KeyAvailable && DateTime.Now.Subtract(beginWait).TotalSeconds < 5) { Thread.Sleep(250); } Treev.TreeHiearchy.ExpandTree(managingOfficeRegion); TreeNode na = managingOfficeRegion.Get <TreeNode>(SearchCriteria.ByText(offcName)); na.Click(); while (!Console.KeyAvailable && DateTime.Now.Subtract(beginWait).TotalSeconds < 5) { Thread.Sleep(250); } advanceSearch.Keyboard.PressSpecialKey(KeyboardInput.SpecialKeys.SPACE); advanceSearch.Get <Button>(SearchCriteria.ByAutomationId("btnSave")).Click(); }
/// <summary> /// 新增医院,点击取消按钮,关闭新增医院窗口 /// </summary> /// <param name="appWin"></param> /// <param name="msg"></param> /// <returns></returns> public static bool AddHospital_ClickCancle(Window appWin, out string msg) { try { var startTime = DateTime.Now; //点击新增按钮 Button btnAddHospital = appWin.Get <Button>(SearchCriteria.ByAutomationId("btnAddHospital")); btnAddHospital.Click(); //点击取消按钮 Button btnCancleAddHospital = appWin.Get <Button>(SearchCriteria.ByAutomationId("btnCancleAddHospital")); btnCancleAddHospital.Click(); var endTime = DateTime.Now; try { //捕捉新增角色窗口,如果不能捕捉到,则测试通过 string add_win = appWin.Get <Label>(SearchCriteria.ByText("新增医院")).ToString(); msg = "测试【新增医院,点击取消按钮,关闭新增医院窗口】--未通过,未关闭新增窗口。用时:" + (endTime - startTime).TotalSeconds; return(false); } catch { msg = "测试【新增医院,点击取消按钮,关闭新增医院窗口】--通过,用时:" + (endTime - startTime).TotalSeconds; return(true); } } catch (Exception e) { msg = "测试【新增医院,点击取消按钮,关闭新增医院窗口】--失败,原因:" + e.ToString(); return(false); } }
//This method Type the value which passed to this method public static bool Type(TestStack.White.UIItems.WindowItems.Window window, string elementid, string value) { try { TextBox textbox = window.Get <TextBox>(SearchCriteria.ByAutomationId(elementid)); textbox.Text = value; return(true); } catch (Exception) { try { TextBox textbox = window.Get <TextBox>(SearchCriteria.ByText(elementid)); textbox.Text = value; return(true); } catch (Exception) { try { TextBox textbox = window.Get <TextBox>(SearchCriteria.ByClassName(elementid)); textbox.Text = value; return(true); } catch (Exception) { Console.WriteLine("Not able to find the element"); return(false); } } } }
public void ClickButtonOnMessageBox() { window.Get <Button>("buttonLaunchesMessageBox").Click(); Window messageBox = window.MessageBox("Close Me"); messageBox.Get <Button>(SearchCriteria.ByText("OK")).Click(); }
//This method Type the value which passed to this method public static bool SelectRadioButton(TestStack.White.UIItems.WindowItems.Window window, string elementid) { try { Radio radio = window.Get <Radio>(SearchCriteria.ByAutomationId(elementid)); radio.Click(); return(true); } catch (Exception) { try { Radio radio = window.Get <Radio>(SearchCriteria.ByText(elementid)); radio.Click(); return(true); } catch (Exception) { try { Radio radio = window.Get <Radio>(SearchCriteria.ByClassName(elementid)); radio.Click(); return(true); } catch (Exception) { Console.WriteLine("Not able to find the element"); return(false); } } } }
public void ЕслиОтнимаюИз(string value2, string value1) { InputValue(value1); _mainWindow.Get <Button>(SearchCriteria.ByText("-")).Click(); InputValue(value2); _mainWindow.Get <Button>(SearchCriteria.ByText("=")).Click(); }
public async Task _05_CheckAndInstallUpdates_Beta() { try { VersionTuple initialVersions = this.GetVersionsFromExtractedAppFile(Apps.PackageNames.AutomaticTestsClientAppV1, SharedTestHelpers.GetMethodName(), out FileInfo appFile); this.LaunchTestsAppAndGetResult <UpdateCheckResult>(appFile, Actions.HandleUpdatesWithBeta, Apps.Keys.AutomaticTestsClient, waitForExit: false); Window updateNowMsgBox = await WindowHelpers.WaitForWindowAsync(x => x.Equals("AutomaticTestsClient update installation"), TimeSpan.FromMinutes(1)).ConfigureAwait(false); updateNowMsgBox.Get <Button>(SearchCriteria.ByText("Yes")).Click(); Window updater = await WindowHelpers.WaitForWindowAsync(x => x.Contains("AutomaticTestsClient Updater"), TimeSpan.FromMinutes(1)).ConfigureAwait(false); updater.Get <Button>(SearchCriteria.ByText("Install now!")).Click(); Window doneMsg = await WindowHelpers.WaitForMessageBoxAsync(updater, "Update complete", TimeSpan.FromMinutes(1)).ConfigureAwait(false); doneMsg.Get <Button>(SearchCriteria.ByText("No")).Click(); VersionTuple newVersions = this.GetVersionsFromFile(appFile); await this.AssertVersionAreCorrect(newVersions, initialVersions, appFile, "3.").ConfigureAwait(false); //now just assert that the update check result is empty next time UpdateCheckResult result = this.LaunchTestsAppAndGetResult <UpdateCheckResult>(appFile, Actions.CheckAndInstallUpdates, Apps.Keys.AutomaticTestsClient, waitForExit: true); this.AssertNoNonBetaUpdatesToInstall(result, false); } catch (Exception ex) { throw this.CleanupAndRethrow(ex); } }