/// <summary> /// The run. /// </summary> /// <param name="filePath"> /// The file path. /// </param> /// <param name="fileName"> /// The file name. /// </param> /// <returns> /// The <see cref="bool"/>. /// </returns> public bool Run(string filePath, string fileName) { // instantiate all necessary modules var connectionStatus = new Functions.StatusArea.Statusbar.Statusbar_Functions(); var execFunction = new Functions.Helpers.InterfaceHelpers.DTMFunctions(); var devScreen = new Functions.ApplicationArea.Page_DeviceScreen.Page_DeviceScreen_Functions(); string fileLocation; string basePath; // set all necessary parameters devScreen.IsRestoreRequest = false; // check if device is online if (connectionStatus.IsDeviceConnected()) { Log.Info(LogInfo.Namespace(MethodBase.GetCurrentMethod()), "Device is connected. Saving device data..."); // click button "program functions" devScreen.OpenProgramFunctionsMenu(); // check if menu is open if (devScreen.IsDTMFunctionMenuShown()) { // select "save device data" devScreen.RunDTMFunction(); // wait until process is finished if (connectionStatus.IsActionFinished()) { // get event message text string msg = connectionStatus.GetStatusMessage(); // check if saving was successful if (msg.Contains("set has been saved")) { // get file path and extract basepath fileLocation = connectionStatus.GetFileLocationFromStatusMessage(msg); basePath = connectionStatus.GetBasePath(fileLocation); // construct the destination path string finalizedPath = filePath + "\\" + fileName + ".dcdtm"; // rename the file execFunction.MoveFile(fileLocation, finalizedPath); // check if renaming was successful if (File.Exists(finalizedPath)) { Log.Info(LogInfo.Namespace(MethodBase.GetCurrentMethod()), "The file was successfully created. File location: " + finalizedPath); return(true); } } } } } return(false); }
/// <summary> /// The run. /// </summary> /// <param name="filePath"> /// The file path. /// </param> /// <param name="fileName"> /// The file name. /// </param> /// <returns> /// The <see cref="bool"/>. /// </returns> public bool Run(string filePath, string fileName) { // instantiate all necessary modules var execFunction = new Functions.Helpers.InterfaceHelpers.DTMFunctions(); var connectionStatus = new Functions.StatusArea.Statusbar.Statusbar_Functions(); var devScreen = new Functions.ApplicationArea.Page_DeviceScreen.Page_DeviceScreen_Functions(); var dialog = new Functions.Helpers.DialogFunctions(); // set all necessary parameters devScreen.IsRestoreRequest = true; Log.Info(LogInfo.Namespace(MethodBase.GetCurrentMethod()), "Current task: Restore device data"); if (connectionStatus.IsDeviceConnected()) { Log.Info(LogInfo.Namespace(MethodBase.GetCurrentMethod()), "Device is connected. Restoring device data..."); // click button "program functions" devScreen.OpenProgramFunctionsMenu(); // check if menu is open if (devScreen.IsDTMFunctionMenuShown()) { // select "restore device data" and then "browse" devScreen.RunDTMFunction(); // check if browse dialog is open if (dialog.IsBrowseDialogOpen()) { // construct the destination path string finalizedPath = filePath + "\\" + fileName + ".dcdtm"; // set filepath in the browse dialog dialog.SetFilePath(finalizedPath); // check if path is set if (dialog.IsFilePathSet(finalizedPath)) { // select "go" and then "ok" dialog.AckDialog(); // check if pop up dialog is open if (dialog.IsPopupOpen()) { // select yes in the pop up dialog dialog.AckPopup(); // wait for completion and check status area message for success/failure if (devScreen.IsRestoreFinished()) { Log.Info(LogInfo.Namespace(MethodBase.GetCurrentMethod()), "Restoring DTM data was successful"); return(true); } } } } } } return(false); }