Пример #1
0
        public string GenerateBusinessRuleMappingTable(int daId, HttpPostedFileBase path)
        {
            try
            {
                ExcelCommonFunctions excelCommonFunctions = new ExcelCommonFunctions();
                TransactionMatrix    transactionMatrix    = new TransactionMatrix();

                InterfaceMappingViewModel interfaceMappingView = new InterfaceMappingViewModel();
                interfaceMappingView.lstHighLevelTxns = interfaceMappingView.GetTransactionsList(daId).lstTransactions;

                BusinessRuleMappingViewModel buzRulesMappingView = new BusinessRuleMappingViewModel();
                buzRulesMappingView.lstBuzRulesData = buzRulesMappingView.GetBuzRulesList(daId);

                using (ExcelPackage objExcelPackage = new ExcelPackage(path.InputStream))
                {
                    int cnt = 1;

                    foreach (var trans in interfaceMappingView.lstHighLevelTxns)
                    {
                        int            colIndex = 1, rowIndex = 0;
                        int            rowCountRuleofN;
                        ExcelWorksheet ws = excelCommonFunctions.OpenSheet(objExcelPackage, trans.HighLevelTxnDesc);

                        DataTable dtRuleOfN = transactionMatrix.GetRuleOfNDataForAllTables(ws, ref colIndex, ref rowIndex, "Business Rules - " + trans.HighLevelTxnDesc);
                        //get merged cells to find the end row of Rule of N table
                        if (ws.MergedCells.Count == 1)
                        {
                            rowCountRuleofN = dtRuleOfN.Rows.Count;
                        }
                        else
                        {
                            //the header row of Rule of N is fixed as 17
                            var          c        = ws.MergedCells[1];  //Assuming the first merged cell is of one mapping table.
                            ExcelAddress cellAddr = new ExcelAddress(c);
                            int          row      = cellAddr.Start.Row; //to get the row number of the merged cell
                            int          lastRow  = row - 2;            //to get last row of Rule of N table
                            rowCountRuleofN = lastRow - 17;             // to get count of rows of RuleofN table excluding header.
                        }

                        //create datatable for each transaction
                        DataTable dtBuzRules = BusinessRuleMappingViewModel.CreateBuzRulesDataTable(buzRulesMappingView.lstBuzRulesData, trans.TransactionSeq, dtRuleOfN);

                        //Table#2
                        if (dtBuzRules.Rows.Count != 0)
                        {
                            rowIndex = rowIndex + 2;

                            string tblName4 = "Business Rules - " + trans.HighLevelTxnDesc;
                            ws.Cells[rowIndex, 1].Value = tblName4;
                            //  ws.Cells[rowIndex, 1, rowIndex, 3].Merge = true; //Merge columns start and end range
                            ws.Cells[rowIndex, 1, rowIndex, 3].Style.Font.Bold           = true;                          //Font should be bold
                            ws.Cells[rowIndex, 1, rowIndex, 3].Style.Font.Size           = 20;
                            ws.Cells[rowIndex, 1, rowIndex, 3].Style.HorizontalAlignment = ExcelHorizontalAlignment.Left; // Alignment is center
                            ws.Cells[rowIndex, 1, rowIndex, 3].Style.Fill.PatternType    = ExcelFillStyle.Solid;          // Aligmnet is center
                            ws.Cells[rowIndex, 1, rowIndex, 3].Style.Fill.BackgroundColor.SetColor(Color.LightGray);      // Alignment is center
                            colIndex = 1;
                            rowIndex = rowIndex + 2;
                            excelCommonFunctions.CreateTableHeader(dtBuzRules, ws, ref colIndex, ref rowIndex, tblName4);
                            Dictionary <string, string> dictBuzRules = excelCommonFunctions.GetMappingID(dtBuzRules);
                            excelCommonFunctions.AddRowsMapping(dtBuzRules, ws, dictBuzRules, rowCountRuleofN, ref colIndex, ref rowIndex);
                        }

                        ws.View.ShowGridLines = false;
                        ws.View.ZoomScale     = 80;
                        //ws.Cells.AutoFitColumns();
                        //rearranged
                        cnt++;
                    }

                    tbl_DesignAccelerator da        = new tbl_DesignAccelerator();
                    DAManager             daManager = new DAManager();

                    da = daManager.FindDA(daId);

                    string filePath = excelCommonFunctions.SaveFile(objExcelPackage, da.daName, path.FileName, "BR");
                    return(filePath);
                }
            }
            catch (Exception)
            {
                throw;
            }
        }
Пример #2
0
        // GET: TestDesign
        public async Task <string> GenerateTestDesign(int daId, HttpPostedFileBase txmPath, HttpPostedFileBase ScbPath)
        {
            try
            {
                Dictionary <string, List <TestScenarioMembers> > testScenarios = new Dictionary <string, List <TestScenarioMembers> >();

                IList <tbl_Attribute> lstAttributes = new List <tbl_Attribute>();

                TransactionMatrix transactionMatrix = new TransactionMatrix();

                testDesignVM.lstHighLevelTransactions = testDesignVM.GetTransactionsList(daId).lstTransactions;

                ModuleViewModel moduleViewModel = new ModuleViewModel();

                int colIndex = 1, rowIndex = 0;

                //Create new workbook for Test Design
                using (var package = new ExcelPackage())
                {
                    ExcelWorksheet ws2 = package.Workbook.Worksheets.Add("Design Document");

                    CreateHeadersForTD(ws2, out dtTD);

                    //Read data from Test Scenario
                    using (var objExcelPackage = new ExcelPackage(ScbPath.InputStream))
                    {
                        //string scenarioId = "";
                        //string testConditionId = "";

                        ExcelWorksheet ws = excelCommonFunctions.OpenSheet(objExcelPackage, "Test Scenarios");

                        testScenarios = GetDataTableFromExcel(ScbPath);
                    }

                    //Read data from RuleOfNData
                    DataSet transactionMatrixSheets = new DataSet();

                    //list of the rule reference datatables will come into this list
                    List <DataTable> dtRuleOfNforTestDesignRuleReference = new List <DataTable>();

                    //Dictionary to add the fetched last tables from tm into dtRuleOFNForTestDesignRuleReference and pass as a parameter to addTestDesign method.
                    Dictionary <string, List <DataTable> > ruleReferences = new Dictionary <string, List <DataTable> >();

                    using (var objExcelPackage = new ExcelPackage(txmPath.InputStream))
                    {
                        foreach (var trans in testDesignVM.lstHighLevelTransactions)
                        {
                            int            colIdex = 1, rowIdex = 0;
                            ExcelWorksheet ws = excelCommonFunctions.OpenSheet(objExcelPackage, trans.HighLevelTxnDesc);

                            //For Test design last tables
                            dtRuleOfNforTestDesignRuleReference = transactionMatrix.GetRuleOfNDataForTestDesignRuleReferene(ws, ref colIdex, ref rowIdex);

                            //Adding all the fetched tables into the dictionary from list
                            foreach (var item in dtRuleOfNforTestDesignRuleReference)
                            {
                                if (ruleReferences.ContainsKey(ws.ToString()))
                                {
                                    ruleReferences[ws.ToString()].Add(item);
                                }
                                else
                                {
                                    ruleReferences.Add(ws.ToString(), new List <DataTable> {
                                        item
                                    });
                                }
                            }

                            DataTable dtRuleOfN = transactionMatrix.GetRuleOfNData(ws, ref colIdex, ref rowIdex);
                            dtRuleOfN.TableName = trans.HighLevelTxnDesc;
                            transactionMatrixSheets.Tables.Add(dtRuleOfN);
                        }
                    }

                    tbl_DesignAccelerator da        = new tbl_DesignAccelerator();
                    DAManager             daManager = new DAManager();

                    da = daManager.FindDA(daId);

                    var modId = da.ModuleId;

                    tbl_Module    daModule   = new tbl_Module();
                    ModuleManager modManager = new ModuleManager();
                    daModule = modManager.FindModuleNameForRunPlan(modId);
                    var moduleName = daModule.ModuleName;

                    string tblName4 = moduleName + " - Test Design Document";
                    ws2.Cells[2, 1].Value = tblName4;

                    //// Format Excel Sheet
                    ws2.Cells[2, 1, 2, 5].Merge                     = true;                          //Merge columns start and end range
                    ws2.Cells[2, 1, 2, 5].Style.Font.Bold           = true;                          //Font should be bold
                    ws2.Cells[2, 1, 2, 5].Style.Font.Size           = 14;
                    ws2.Cells[2, 1, 2, 5].Style.HorizontalAlignment = ExcelHorizontalAlignment.Left; // Alignment is Left
                    ws2.Cells[2, 1, 2, 5].Style.Fill.PatternType    = ExcelFillStyle.Solid;          // Border
                    ws2.Cells[2, 1, 2, 5].Style.Fill.BackgroundColor.SetColor(Color.LightGray);      // Background Color

                    excelCommonFunctions.CreateTableHeader(dtTD, ws2, ref colIndex, ref rowIndex, "tbl4");
                    ws2.Cells["A4:N4"].Style.HorizontalAlignment = ExcelHorizontalAlignment.Center;
                    AddTestDesign(testScenarios, transactionMatrixSheets, ws2, colIndex, rowIndex, dtTD, testDesignVM.lstHighLevelTransactions, ruleReferences);

                    //Format Excel Sheet
                    ws2.View.ShowGridLines = false;
                    ws2.View.ZoomScale     = 80;
                    ws2.Cells.AutoFitColumns();
                    ws2.Column(4).Width  = 50;
                    ws2.Column(12).Width = 75;
                    ws2.Column(13).Width = 75;
                    ws2.Column(14).Width = 75;

                    string filePath = excelCommonFunctions.SaveFile(package, da.daName, "", "TD");

                    return(filePath);
                }
            }
            catch (Exception)
            {
                throw;
            }
        }
Пример #3
0
        public async Task <ActionResult> Matrix(ProcessCategory processCategory)//
        {
            try
            {
                string result = string.Empty;
                int    daId   = (int)TempData["daId"];
                TempData["daId"] = daId;
                string             filePath = string.Empty;
                HttpPostedFileBase tmFile;
                HttpPostedFileBase tmFile1;
                //HttpPostedFileBase tmFile3;

                switch (processCategory.sProcess)
                {
                case "Rule of 1 - Txn Matrix":
                    break;

                case "Rule of N - Txn Matrix":
                    TransactionMatrix transactionMatrix = new TransactionMatrix();

                    Task <string> fipath1 = transactionMatrix.GenerateTransactionMatrix(daId);
                    await Task.WhenAll(fipath1);     //

                    fipath1.Wait();
                    if (fipath1.Status == TaskStatus.RanToCompletion)
                    {
                        filePath = fipath1.Result;
                    }
                    else if (fipath1.Status == TaskStatus.Running)
                    {
                        fipath1.Wait();
                        filePath = fipath1.Result;
                    }
                    break;

                case "Business Rule":
                    tmFile = processCategory.file.ElementAt(0);
                    GenerateBusinessRules generateBusinessRules = new GenerateBusinessRules();
                    filePath = generateBusinessRules.GenerateBusinessRuleMappingTable(daId, tmFile);
                    break;

                case "Interface":
                    tmFile = processCategory.file.ElementAt(0);
                    GenerateInterfaces generateInterfaces = new GenerateInterfaces();
                    filePath = generateInterfaces.GenerateInterfaceMappingTable(daId, tmFile);
                    break;

                case "Channels&Alerts":
                    tmFile = processCategory.file.ElementAt(0);
                    GenerateChannelsAlerts generateChannelsAlerts = new GenerateChannelsAlerts();
                    filePath = generateChannelsAlerts.GenerateChannelsAlertsMappingTable(daId, tmFile);
                    break;

                case "Reports":
                    tmFile = processCategory.file.ElementAt(0);
                    GenerateReports generateReports = new GenerateReports();
                    filePath = generateReports.GenerateReportsMappingTable(daId, tmFile);
                    break;

                //To generate scenario builder Template file
                case "Scenario Builder Template":
                    ScenarioBuilder scenarioBuilderTemplate = new ScenarioBuilder();
                    filePath = scenarioBuilderTemplate.CreateSBTemplateFile(daId);
                    break;

                case "Scenario Stitching":
                    tmFile  = processCategory.file.ElementAt(0);
                    tmFile1 = processCategory.file.ElementAt(1);
                    ScenarioBuilder scenarioBuilder = new ScenarioBuilder();
                    //filePath = scenarioBuilder.GenerateScenarioBuilder(daId, tmFile, tmFile1); //
                    Task <string> fipath = scenarioBuilder.GenerateScenarioBuilder(daId, tmFile, tmFile1);
                    await Task.WhenAll(fipath);     //

                    fipath.Wait();
                    if (fipath.Status == TaskStatus.RanToCompletion)
                    {
                        filePath = fipath.Result;
                    }
                    else if (fipath.Status == TaskStatus.Running)
                    {
                        fipath.Wait();
                        filePath = fipath.Result;
                    }
                    break;

                case "Test Design":
                    tmFile  = processCategory.file.ElementAt(0);
                    tmFile1 = processCategory.file.ElementAt(1);
                    TestDesignController testDesign = new TestDesignController();
                    // filePath = testDesign.GenerateTestDesign(daId, tmFile,tmFile1); //
                    Task <string> fpath = testDesign.GenerateTestDesign(daId, tmFile, tmFile1);
                    await Task.WhenAll(fpath);     //

                    fpath.Wait();
                    if (fpath.Status == TaskStatus.RanToCompletion)
                    {
                        filePath = fpath.Result;
                    }
                    else if (fpath.Status == TaskStatus.Running)
                    {
                        fpath.Wait();
                        filePath = fpath.Result;
                    }
                    break;

                case "Traceability Matrix":
                    tmFile  = processCategory.file.ElementAt(0);
                    tmFile1 = processCategory.file.ElementAt(1);
                    TraceabilityMatrix traceabilityMatrix = new TraceabilityMatrix();
                    filePath = traceabilityMatrix.GenerateTraceabilityMatrix(daId, tmFile, tmFile1);     //
                    break;

                case "Run Plan":
                    tmFile = processCategory.file.ElementAt(2);
                    RunPlan runPlan = new RunPlan();
                    filePath = runPlan.CreateRunPlanFile(daId, tmFile);     //
                    break;

                case "Export DA":
                    ExportDesignAcceleratorController exportDA = new ExportDesignAcceleratorController();
                    filePath = exportDA.ExportDAFile(daId);
                    break;
                }


                var errorMessage = "you can return the errors in here!";

                //return the Excel file name
                return(Json(new { fileName = filePath, errorMessage = "" }));
            }
            catch (Exception ex)
            {
                errorlogviewmodel = new ErrorLogViewModel();
                errorlogviewmodel.LogError(ex);
                return(View("Error"));
            }
        }