public override void Execute(object iObject) { try { SetFileAppenderPath("ThisStepFileAppender"); OnStepStarted(new StepEventArgs(iObject)); string regressionStartDate = System.DateTime.Now.ToString("dd-MMM-yyyy_HH_mm"); //:change: regression date should come from the calling class string backupFolderPath = Path.Combine(Properties.Regression.Default.TestResultsBackup, regressionStartDate); log.Info("Backup Folder: " + backupFolderPath); Properties.Internal.Default.BackupResultsPath = Path.GetFullPath(backupFolderPath); string resultSourcePath = Properties.Regression.Default.PartsFolder; string resultDsntPath = Path.Combine(backupFolderPath, "testresults"); //COPY ALL XML, DFMR AND DFMRESULTS FILES log.Info("COPY RESULT FILES"); var files = Directory.EnumerateFiles(resultSourcePath, "*.*", SearchOption.AllDirectories).Where(s => s.ToLower().EndsWith(".xml") || s.ToLower().EndsWith(".dfmr") || s.ToLower().EndsWith(".dfmresult")); foreach (string thisFile in files) { string destinationFile = thisFile.Replace(resultSourcePath, resultDsntPath); Directory.CreateDirectory(Path.GetDirectoryName(destinationFile)); log.Info("Copy " + thisFile + "to " + destinationFile); File.Copy(thisFile, destinationFile, true); } //COPY LOG FOLDER string logSourcePath = Properties.Regression.Default.LogFolderPath; string logDstnPath = Path.Combine(backupFolderPath, "log"); Helper.ProcessHelper procHelper = new Helper.ProcessHelper(); procHelper.dataReceivedHandler += DataReceivedHandler; procHelper.errorReceivedHandler += ErrorReceivedHander; log.Info("COPY LOG FILES"); procHelper.Execute("robocopy.exe", logSourcePath + " " + logDstnPath); //COPY REPORTS FOLDER string reportSourcePath = Properties.Regression.Default.ReportPath; string reportDstnPath = Path.Combine(backupFolderPath, "reports"); log.Info("COPY REPORT FILES"); procHelper.Execute("robocopy.exe", reportSourcePath + " " + reportDstnPath); OnStepCompleted(new StepEventArgs(iObject)); } catch (Exception ex) { OnStepFailed(new StepFailedEventArgs(iObject, ex)); } }
public override void Execute(object iArgument) { try { SetFileAppenderPath("ThisStepFileAppender"); OnStepStarted(new StepEventArgs(iArgument)); string processName = @"C:\Program Files\SlikSvn\bin\svn"; string foldersToUpdate = Path.GetFullPath(Properties.Regression.Default.BaselineFolder + "\\..\\.."); string svnrevertArgument = "revert --recursive " + foldersToUpdate; log.Info("Process: " + processName); log.Info("Arguments: " + svnrevertArgument); Helper.ProcessHelper procHelper = new Helper.ProcessHelper(); procHelper.dataReceivedHandler += proc_OutputDataReceived; procHelper.errorReceivedHandler += proc_ErrorDataReceived; int exitCode = procHelper.Execute(processName, svnrevertArgument); if (exitCode != 0) { string errorString = processName + " exited with error code: " + exitCode.ToString(); OnStepFailed(new StepFailedEventArgs(iArgument, errorString)); } else { string svnupdateArgument = "up " + foldersToUpdate; log.Info("Process: " + processName); log.Info("Arguments: " + svnupdateArgument); int upExitCode = procHelper.Execute(processName, svnupdateArgument); if (upExitCode != 0) { string errorString = processName + " exited with error code: " + upExitCode.ToString(); OnStepFailed(new StepFailedEventArgs(iArgument, errorString)); } else { OnStepCompleted(new StepEventArgs(iArgument)); } } } catch (Exception ex) { OnStepFailed(new StepFailedEventArgs(iArgument, ex)); } }
//Returns Zero if the files are same private int CompareFiles(string iRequestFileName) { string absolutePartsFolder = Path.GetFullPath(Properties.Location.Default.PartsFolder); string absoluteBaselineFolder = Path.GetFullPath(Properties.Location.Default.BaselineFolder); string baselineFile = iRequestFileName.Replace(absolutePartsFolder, absoluteBaselineFolder); //using fc.exe utility from command prompt so as to avoid any bugs while implementing our own utility //arguments /w => Commpress white space (this is, tabs and spaces) during the comparision. //https://ss64.com/nt/fc.html // string processName = "fc.exe"; string arguments = "/w " + iRequestFileName + " " + baselineFile; testLog.Info("Process: " + processName); testLog.Info("Arguments: " + arguments); Helper.ProcessHelper procHelper = new Helper.ProcessHelper(); procHelper.dataReceivedHandler = dataReceivedHandle; procHelper.errorReceivedHandler = errorReceivedHandle; int exitCode = procHelper.Execute(processName, arguments); if (!(exitCode == 0 || exitCode == 1)) { testLog.Error(processName + " exited with error code: " + exitCode); throw new Exception(); } return(exitCode); }
public override void Execute(object iArgument) { try { SetFileAppenderPath("ThisStepFileAppender"); OnStepStarted(new StepEventArgs(iArgument)); string processName = @"C:\cygwin64\bin\bash.exe"; string diffScriptPath = Properties.Regression.Default.ScriptsFolder + "\\" + "generate_diff_report.sh"; string arguments = diffScriptPath + " " + leftFolder + " " + rightFolder; Helper.ProcessHelper procHelper = new Helper.ProcessHelper(); procHelper.EnviornmentPath = @"C:\cygwin64\bin"; procHelper.dataReceivedHandler += DataReceivedHandler; procHelper.errorReceivedHandler += ErrorRecivedHandler; log.Info("Process: " + processName); log.Info("Arguments: " + arguments); int exitCode = procHelper.Execute(processName, arguments); if (exitCode == 0) { OnStepCompleted(new StepEventArgs(iArgument)); } else { string errorString = processName + "failed with error code + " + exitCode.ToString(); OnStepFailed(new StepFailedEventArgs(iArgument, errorString)); } } catch (Exception ex) { OnStepFailed(new StepFailedEventArgs(iArgument, ex)); } }
public override void Execute(object iObject) { try { SetFileAppenderPath("ThisStepFileAppender"); OnStepStarted(new StepEventArgs(iObject)); string processName = "JarvisTestExecuter.exe"; string dfmTestAppPath = Path.Combine(Properties.Regression.Default.DFMInstallLocation, @"dfmpro", Properties.Regression.Default.DFMTestAppName); string arguments = "\"" + Path.GetFullPath(Properties.Regression.Default.RegressionInputFile) + "\" \"" + dfmTestAppPath + "\""; log.Info("Process Name: " + processName); log.Info("Arguments: " + arguments); Helper.ProcessHelper procHelper = new Helper.ProcessHelper(); int exitCode = procHelper.Execute(processName, arguments); if (exitCode == 0) { OnStepCompleted(new StepEventArgs(iObject)); } else { string errorString = processName + " exited with error code : " + exitCode.ToString(); OnStepFailed(new StepFailedEventArgs(iObject, errorString)); } } catch (Exception ex) { OnStepFailed(new StepFailedEventArgs(iObject, ex)); } }
public override void Execute(object iArgument) { try { SetFileAppenderPath("ThisStepFileAppender"); OnStepStarted(new StepEventArgs(iArgument)); string processName = "regedit.exe"; string arguments = "/s " + Properties.Regression.Default.RegFilePath + @"\DFMProInterfaceOpenRegEntry.reg"; //RegistryKey key = Registry.CurrentUser.OpenSubKey(@"Software\Geometric\DPT_PRODUCT\DFMPro\ProE\Add-in"); //key.SetValue("bIsDFMProInterfaceOpen", "1"); Helper.ProcessHelper procHelper = new Helper.ProcessHelper(); int exitCode = procHelper.Execute(processName, arguments); if (exitCode != 0) { string errorString = processName + " exited with error code: " + exitCode.ToString(); OnStepFailed(new StepFailedEventArgs(iArgument, errorString)); } else { OnStepCompleted(new StepEventArgs(iArgument)); } } catch (Exception ex) { OnStepFailed(new StepFailedEventArgs(iArgument, ex)); } }
public override void Execute(object iArgument) { try { SetFileAppenderPath("ThisStepFileAppender"); //todo: this should be changed to interface since this error prone to maintainance OnStepStarted(new StepEventArgs(iArgument)); string argumentString = CreateArgumentString(); string processName = @"C:\Program Files\7-Zip\7z.exe"; Helper.ProcessHelper procHelper = new Helper.ProcessHelper(); procHelper.dataReceivedHandler += proc_OutputDataReceived; procHelper.errorReceivedHandler += proc_ErrorDataReceived; procHelper.EnviornmentPath = @"C:\Program Files\7-Zip"; //change log.Info("Process Name: " + processName); log.Info("Arguments: " + argumentString); int exitCode = procHelper.Execute(processName, argumentString); if (exitCode > 0) { string errorString = processName + " exited with error code: " + exitCode.ToString(); OnStepFailed(new StepFailedEventArgs(iArgument, errorString)); } else { OnStepCompleted(new StepEventArgs(iArgument)); } } catch (Exception ex) { OnStepFailed(new StepFailedEventArgs(iArgument, ex)); } }
private void EditRegistry() { string processName = "regedit.exe"; string arguments = "/s " + Path.GetFullPath(@"..\..\..\..\reg\DFMProInterfaceOpenRegEntry.reg"); testLog.Info(processName); testLog.Info(arguments); Helper.ProcessHelper procHelper = new Helper.ProcessHelper(); int exitCode = procHelper.Execute(processName, arguments); }
public override void Execute(object iArgument) { try { //SetFileAppenderPath("ThisStepFileAppender"); //:think: OnStepStarted(new StepEventArgs(iArgument)); if (!File.Exists(MSIPath)) { log.Error("File Not Found: " + MSIPath); //:think: throw new FileNotFoundException(); } string processName = "msiexec.exe"; //i = Installs or configures a product //qn = No UI //Lv = Verbose output //For detail options of msiexec.exe use following command on the command prompt "msiexec /?" MSIPath = Path.GetFullPath(MSIPath); string arguments; if (InstallDir != null) { arguments = "/i " + MSIPath + " INSTALLDIR=\"" + InstallDir + "\" /qn /Lv " + LogPath; } else { arguments = "/i " + MSIPath + " /qn /Lv " + LogPath; } Helper.ProcessHelper procHelper = new Helper.ProcessHelper(); log.Info("Process: " + processName); log.Info("Arguments: " + arguments); int exitCode = procHelper.Execute(processName, arguments); if (exitCode != 0) { string errorString = processName + " exited with error code: " + exitCode.ToString(); OnStepFailed(new StepFailedEventArgs(iArgument, errorString)); } else { OnStepCompleted(new StepEventArgs(iArgument)); } } catch (FileNotFoundException ex) { OnStepFailed(new StepFailedEventArgs(iArgument, ex)); } catch (Exception ex) { OnStepFailed(new StepFailedEventArgs(iArgument, ex)); } }
private void RegisterBinaries() { Helper.ProcessHelper procHelper = new Helper.ProcessHelper(); procHelper.dataReceivedHandler = dataReceivedHandle; procHelper.errorReceivedHandler = errorReceivedHandle; //register costguiaddon string costguiaddonPath = Path.Combine(GetBinariesRootPath(), "costmodule", "costguiaddon.dll"); string argument1 = "\"" + costguiaddonPath + "\" /codebase"; testLog.Info("Register costguiaddon.dll"); testLog.Info(costguiaddonPath + " " + argument1); procHelper.Execute(Constants.AppPath.RegAsm64, argument1); //register mti dlls string mtfeaturenetPath = Path.Combine(GetBinariesRootPath(), "costmodule", "MTFeatureNet.Interop.dll"); string argumnet2 = "\"" + mtfeaturenetPath + "\" /codebase"; testLog.Info("Register MTFeatureNet.Interop.dll"); testLog.Info(mtfeaturenetPath + " " + argumnet2); procHelper.Execute(Constants.AppPath.RegAsm64, argumnet2); string mtspreadnetPath = Path.Combine(GetBinariesRootPath(), "costmodule", "MTSpreadNet.Interop.dll"); string argument3 = "\"" + mtspreadnetPath + "\" /codebase"; testLog.Info("Register MTSpreadNet.Interop.dll"); testLog.Info(mtspreadnetPath + " " + argument3); procHelper.Execute(Constants.AppPath.RegAsm64, argument3); //register dfmproserver string dfmproserverPath = Path.Combine(GetBinariesRootPath(), "dfmpro", "DFMProServerProEu.exe"); //string argument4 = "\"" + dfmproserverPath + "\" /RegServer"; dfmproserverPath = "\"" + dfmproserverPath + "\""; string argument4 = "/RegServer"; testLog.Info("Register DFMProServerProEu.exe"); testLog.Info(dfmproserverPath + " " + argument4); procHelper.Execute(dfmproserverPath, argument4); }
/////////////////////////////////////////////////////////////////////////////// #region DEFINING EVENTS AND ITS HANDLERS //public DataReceivedEventHandler errorReceivedEventHandler; //msg: future use //public DataReceivedEventHandler dataReceivedEventHandler; //msg: future use #endregion /////////////////////////////////////////////////////////////////////////////// #region MAIN FUNCTION OF EXECUTE public override void Execute(object iArgument) { try { SetFileAppenderPath("ThisStepFileAppender"); //todo: this should be changed to interface since this error prone to maintainance OnStepStarted(new StepEventArgs(iArgument)); //check if the source exits if (!File.Exists(copyFrom + "\\" + fileToCopy)) { log.Error("File Not Found: " + copyFrom + "\\" + fileToCopy); //should this logging moved into OnStepFailed? //:think: throw new System.IO.FileNotFoundException(); } //check if the log path exits if (!Directory.Exists(copyTo)) { Directory.CreateDirectory(copyTo); } string processName = "robocopy.exe"; //no need to check if destination exits since robocopy creates destination if not present. string arguments = "\"" + copyFrom + "\" \"" + copyTo + "\" \"" + fileToCopy + "\""; Helper.ProcessHelper procHelper = new Helper.ProcessHelper(); procHelper.dataReceivedHandler += proc_OutputDataReceived; procHelper.errorReceivedHandler += proc_ErrorDataReceived; int exitCode = procHelper.Execute(processName, arguments); if (exitCode < 8) //check this link for exit codes of robocopy https://ss64.com/nt/robocopy-exit.html { OnStepCompleted(new StepEventArgs(iArgument)); } else { string errorString = processName + " exited with error code: " + exitCode.ToString(); OnStepFailed(new StepFailedEventArgs(iArgument, errorString)); } } catch (FileNotFoundException ex) { OnStepFailed(new StepFailedEventArgs(iArgument, ex)); } catch (Exception ex) { OnStepFailed(new StepFailedEventArgs(iArgument, ex)); } }
public override void Execute(object iArgument) { try { //SetFileAppenderPath("ThisStepFileAppender"); OnStepStarted(new StepEventArgs(iArgument)); //ADD A CHECK TO SEE IF THE PRODUCT IS INSTALLED. //:imp: if (IsProductInstalled(ProductName)) { if (!File.Exists(MSIPath)) { log.Error("File Not Found: " + MSIPath); //:think: throw new FileNotFoundException(); } string processName = "msiexec.exe"; //i = Installs or configures a product //qn = No UI //Lv = Verbose output //For detail options of msiexec.exe use following command on the command prompt "msiexec /?" MSIPath = Path.GetFullPath(MSIPath); string arguments = "/x " + MSIPath + " /qn /Lv " + LogPath; log.Info("Process: " + processName); log.Info("Arguments: " + arguments); Helper.ProcessHelper procHelper = new Helper.ProcessHelper(); int exitCode = procHelper.Execute(processName, arguments); if (exitCode != 0) { string errorString = processName + " exited with error code: " + exitCode.ToString(); log.Error(errorString); OnStepFailed(new StepFailedEventArgs(iArgument, errorString)); } else { OnStepCompleted(new StepEventArgs(iArgument)); } } else { log.Info("Cannot Uninstall since " + ProductName + " not installed"); OnStepCompleted(new StepEventArgs(iArgument)); } } catch (Exception ex) { OnStepFailed(new StepFailedEventArgs(iArgument, ex)); } }
public override void Execute(object iObject) { try { SetFileAppenderPath("ThisStepFileAppender"); OnStepStarted(new StepEventArgs(iObject)); if (DoesServiceExists(Properties.Regression.Default.LicenseServiceName) == false) { string processName = Properties.Regression.Default.LicenseServerPath + @"\installs.exe"; if (!File.Exists(processName)) { throw new FileNotFoundException(); } string serverLogPath = Path.Combine(Properties.Regression.Default.LicenseServerPath, "LicenseServer.log"); string arguments = "-c \"" + Properties.Regression.Default.DFMProLicenseFile + "\" -e \"" + Properties.Regression.Default.LicenseServerPath + "\\lmgrd.exe\" -n \"" + Properties.Regression.Default.LicenseServiceName + "\" -l \"" + serverLogPath + "\""; log.Info("Process: " + processName); log.Info("Arguments: " + arguments); Helper.ProcessHelper procHelper = new Helper.ProcessHelper(); procHelper.dataReceivedHandler += dataReceivedHandler; procHelper.errorReceivedHandler += errorReceivedHandler; int exitCode = procHelper.Execute(processName, arguments); //:think: check logging - its not proper. if (exitCode != 0) { string errorString = processName + " exited with error code " + exitCode.ToString(); OnStepFailed(new StepFailedEventArgs(iObject, errorString)); } } ServiceController sc = new ServiceController(Properties.Regression.Default.LicenseServiceName); if (sc.Status != ServiceControllerStatus.Running) { log.Info("Attempting to start the service"); sc.Start(); } //:todo: //check if the service is startes sc.Refresh(); if (sc.Status == ServiceControllerStatus.Running) { log.Info("Service Started"); Environment.SetEnvironmentVariable("DFMPRO_LICENSE_FILE", Properties.Regression.Default.LicenseServer, EnvironmentVariableTarget.Process); OnStepCompleted(new StepEventArgs(iObject)); } else { string errorString = "Not able to start the service"; OnStepFailed(new StepFailedEventArgs(iObject, errorString)); } //check if the license exists. } catch (Exception ex) { if (ex is FileNotFoundException) { FileNotFoundException fex = ex as FileNotFoundException; log.Error("File Not Found: " + fex.FileName); } OnStepFailed(new StepFailedEventArgs(iObject, ex)); } }
void bwThread_DoWork(object sender, DoWorkEventArgs e) { //copy the sc_vs_creocost report from template to working dir CopyComparisionTemplate(); //register dlls in the local bin path - only for Local Regression if (!IsRegressionSystem) { RegisterBinaries(); EditRegistry(); } //for each of the test case execute DFMProTestApplication. foreach (DataGridViewRow thisRow in testCase_DataGridView.Rows) { try { if ((bool)thisRow.Cells[Constants.DGVColumnName.SelectParts].Value == true) { PauseExecute(!waitHandle.WaitOne(0), thisRow); this.Invoke((MethodInvoker) delegate { thisRow.Cells[Constants.DGVColumnName.Status].Value = eStatus.EXECUTING.ToString(); }); AutoScrollDataGridView(thisRow); string partNumber = thisRow.Cells[Constants.ExcelColumnNames.PartNumber].Value.ToString(); //Using "Part No" can break the code. string relativeLocation = thisRow.Cells[Constants.ExcelColumnNames.RelativeLocation].Value.ToString(); string partPath = Path.GetFullPath(Path.Combine(Properties.Location.Default.PartsFolder, relativeLocation, partNumber)); string dfmMaterial = thisRow.Cells[Constants.ExcelColumnNames.DFMMaterial].Value.ToString(); string processType = thisRow.Cells[Constants.ExcelColumnNames.Process].Value.ToString(); string timeCSVPath = null; if (processType == Constants.ProcessType.Mill) { timeCSVPath = Path.GetFullPath(Path.Combine(Properties.Location.Default.PartsFolder, "mill.csv")); } else if (processType == Constants.ProcessType.SM) { timeCSVPath = Path.GetFullPath(Path.Combine(Properties.Location.Default.PartsFolder, "sm.csv")); } else { timeCSVPath = Path.GetFullPath(Path.Combine(Properties.Location.Default.PartsFolder, "im.csv")); } string ruleFilePath = Path.GetFullPath(Path.Combine(Properties.Location.Default.RuleFilePath, "AllRules.dfm")); string processName = "\"" + testapp_TextBox.Text + "\""; string arguments = ruleFilePath + " " + processType + " \"" + dfmMaterial + "\" " + partPath + " " + timeCSVPath; this.BeginInvoke((MethodInvoker) delegate { toolStripStatusLabel1.Text = string.Format("Processing part: {0}", partNumber); }); testLog.Info("Process: " + processName); testLog.Info("Arguments: " + arguments); Stopwatch sw = new Stopwatch(); sw.Start(); Helper.ProcessHelper procHelper = new Helper.ProcessHelper(); procHelper.dataReceivedHandler = dataReceivedHandle; procHelper.errorReceivedHandler = errorReceivedHandle; procHelper.EnviornmentPath = Path.Combine(GetBinariesRootPath(), "costmodule"); //@"C:\Program Files\Geometric\DFMPro for Creo Parametric(x64)\costmodule"; procHelper.Execute(processName, arguments); sw.Stop(); string approxRunTime = sw.Elapsed.ToString(@"hh\:mm\:ss"); testLog.Info("ApproxRunTime: " + approxRunTime); this.Invoke((MethodInvoker) delegate { thisRow.Cells[Constants.DGVColumnName.AppoxRunTime].Value = approxRunTime; }); string requestFileName = Path.Combine(Path.GetDirectoryName(partPath), Path.GetFileName(partPath) + "-Request.xml"); string responseFileName = Path.Combine(Path.GetDirectoryName(partPath), Path.GetFileName(partPath) + "-Response.xml"); //POST PROCESS RESPONSE XML TO GENERATE ACCURACY EXCEL string isShouldCostPresent = thisRow.Cells[Constants.ExcelColumnNames.ShouldCostAvailable].Value.ToString(); if (isShouldCostPresent.ToLower() == "yes" && File.Exists(responseFileName)) { //::refactor:: the below code is not extensible, should be closed for modifications string shouldCostReport = Path.Combine(Properties.Location.Default.ReportPath, "SC_vs_CreoCost_Comparision_Report.xlsx"); if (processType != Constants.ProcessType.IM) { ResponseData responseData = new ResponseData(); ResponseXMLReader xmlReader = new ResponseXMLReader(responseData); xmlReader.Read(responseFileName); responseData.PartNumber = Path.GetFileName(partPath); //this should not be done. this is done because, the part number in the response xml file has NT id appended. ShouldCostReportPopulator reportPopulator = new ShouldCostReportPopulator(responseData); reportPopulator.Populate(Path.GetFullPath(shouldCostReport)); } else { IMResponseData responseData = new IMResponseData(); IMResponseReader xmlReader = new IMResponseReader(responseData); xmlReader.Read(responseFileName); responseData.PartNumber = Path.GetFileName(partPath); //::refactor:: this should not be done. this is done because, the part number in the response xml file has NT id appended. IMShouldCostReportPopulator reportPopulator = new IMShouldCostReportPopulator(responseData); reportPopulator.Populate(Path.GetFullPath(shouldCostReport)); } } //CHECK IF THE REQUEST AND RESPONSE FILE IS CREATED. if (File.Exists(requestFileName)) { this.Invoke((MethodInvoker) delegate { thisRow.Cells[Constants.DGVColumnName.CostRequestFile].Value = requestFileName; }); } if (File.Exists(responseFileName)) { this.Invoke((MethodInvoker) delegate { thisRow.Cells[Constants.DGVColumnName.CostResponseFile].Value = responseFileName; }); } //COMPARE WITH BASELINE AND SEE IF THERE ARE ANY DIFF int isRequestFileDiff = CompareFiles(requestFileName); int isResponseFileDiff = CompareFiles(responseFileName); this.Invoke((MethodInvoker) delegate { thisRow.Cells[Constants.DGVColumnName.IsRequestFileDiff].Value = isRequestFileDiff; thisRow.Cells[Constants.DGVColumnName.IsResponseFileDiff].Value = isResponseFileDiff; thisRow.Cells[Constants.DGVColumnName.Status].Value = eStatus.COMPLETED.ToString(); }); } } catch (Exception ex) { testLog.Error("Exception", ex); thisRow.Cells[Constants.DGVColumnName.Status].Value = eStatus.FAILED.ToString(); } } }