Exemple #1
0
 public ShouldCostReportPopulator(ResponseData iData)
 {
     Data = iData;
 }
Exemple #2
0
 public ResponseXMLReader(ResponseData data)
 {
     Data = data;
 }
        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();
                }
            }
        }