Пример #1
0
        public PagedResponse <ListProduct> GetProducts(PredicateObject predicateObject)
        {
            try
            {
                //NOTE: I will send a stringified json object to handle this
                //and a factory to build the predicate set and sql query
                //both in C# and in Angular 2, this will create a dynamic query
                //from those params based on object property types from the object itself
                //	It is very straightforward using reflection to ensure
                //	conditional values are types expected
                //	and wheres and orderbys point to properties of the object
                //	and no issues arise from Little Bobby Tables (string checks ;drop tables)
                //	-This will be the first public version of that API,
                //   previous had 0 vulnerabilities in penetration testing

                //Will use RowNumber Based SQL selects
                //Handled by Entity: Insert<T>(Object), Update<T>(Object), Delete<T>(ObjectId)
                //Accepts the Predicate Object: Get[Object](), Get[Object]s(), and Get[Object]Count()
                //This only handles very simple joins

                //Predicate object property creation needs filters and cleans
                //This is the simplest case, will have to extend the where for each filter type
                //Still leaning towards a SQL dynamic command using RowNumber
                //and intelligent Safe scripts

                //NOTE: On this rebuild also add a front end string [] for each property
                //I want returned from the full list (can clean up partial class selection)

                //Working on matching breeze api again but for RxJs

                /*
                 * Breeze client side code:
                 * return breeze.EntityQuery.from('TodoLists')
                 *        .select('name','id','propertyA', ...)
                 *        .where('Title', 'startsWith', 'T')
                 *        .take(3).orderBy('title')
                 *        .using(manager).execute()
                 *        .then(success).catch(failure)
                 */

                return(new PagedResponse <ListProduct>()
                {
                    Data = viewModel.GetProducts(predicateObject),
                    Total = viewModel.GetProductCount(predicateObject)
                });
            }
            catch (Exception ex)
            {
                var that = ex;
                //TODO UIService for error handling and logging
                return(new PagedResponse <ListProduct>()
                {
                    Data = new List <ListProduct>().AsQueryable(),
                    Total = 0,
                    Error = ex.Message + Environment.NewLine + Environment.NewLine + ex.StackTrace
                });
            }
        }
Пример #2
0
        public ActionResult Index(int?id)
        {
            try
            {
                ProductsViewModel prodviewmodel = new ProductsViewModel();
                if (id == null)
                {
                    id = (int)TempData["daId"];
                }
                prodviewmodel = prodviewmodel.GetProducts(id);
                prodviewmodel.GetScreenAccessRights("Products");

                ViewData["prodviewmodel1"] = (IEnumerable <ProductsViewModel>) from u in prodviewmodel.lstProd
                                             join b in prodviewmodel.lstLOB on u.LobID equals b.LobID
                                             join bp in prodviewmodel.lstBuzProd on u.BuzProdID equals bp.BuzProdID
                                             select new ProductsViewModel {
                    ProductID = u.ProductID, ReqReference = u.ReqReference, BuzProdID = u.BuzProdID, BuzProdDesc = bp.BuzProdDesc, LobID = b.LobID, LobDesc = b.LobDesc
                };

                CommonFunctions comfuns = new CommonFunctions();

                var da = comfuns.FindDA((int)id);
                prodviewmodel.daid     = (int)id;
                prodviewmodel.ModuleId = da.ModuleId;
                prodviewmodel.daName   = da.DAName;
                TempData["daId"]       = prodviewmodel.daid;

                int    projectId;
                int    clientId;
                string projectName;
                string appName;

                int    applicationId;
                string modName;

                //CommonFunctions comfuns = new CommonFunctions();

                comfuns.GetModuleName(da.ModuleId, out applicationId, out modName);
                prodviewmodel.ApplicationID = applicationId;
                prodviewmodel.ModuleName    = modName;

                comfuns.GetApplicationName(applicationId, out projectId, out appName);
                prodviewmodel.ProjectID       = projectId;
                prodviewmodel.ApplicationName = appName;

                comfuns.GetProjectName(projectId, out clientId, out projectName);
                prodviewmodel.ClientID    = clientId;
                prodviewmodel.ProjectName = projectName;

                prodviewmodel.ClientName = comfuns.GetClientName(clientId);

                if (Convert.ToString(TempData["ErrorMsg"]) != "")
                {
                    ModelState.AddModelError("ReqReference", "Requirement Reference Required");
                    TempData["ErrorMsg"] = "";
                }

                return(View(prodviewmodel));
            }
            catch (Exception ex)
            {
                errorlogviewmodel = new ErrorLogViewModel();
                errorlogviewmodel.LogError(ex);
                return(View("Error"));
            }
        }
Пример #3
0
 public void Execute(object parameter)
 {
     _viewModel.GetProducts();
 }
        public string ExportDAFile(int id)
        {
            try
            {
                ExportDesignAcceleratorViewModel ExportDAViewModel = new ExportDesignAcceleratorViewModel();

                ProductsViewModel prodviewmodel = new ProductsViewModel();
                //if (id == null)
                //    id = (int)TempData["daId"];
                var lstprods = prodviewmodel.GetProducts(id);

                var lstExportProducts = ExportDAViewModel.GetProducts(id);

                var lstExportTransactions = ExportDAViewModel.GetTransactions(id);

                IList <tbl_Attribute> lstExportAttributes = ExportDAViewModel.GetAttributes(id);


                List <string> lstSheetNames = new List <string>();
                lstSheetNames.Add("Products");
                lstSheetNames.Add("Transactions");
                lstSheetNames.Add("Transaction Attributes");
                lstSheetNames.Add("Business Rules");
                lstSheetNames.Add("Interfaces");
                lstSheetNames.Add("Channels");
                lstSheetNames.Add("Reports");

                int    i   = 1;
                string tbl = "";

                using (ExcelPackage objExcelPackage = new ExcelPackage())
                {
                    foreach (var sheet in lstSheetNames)
                    {
                        DataTable dt = new DataTable();

                        switch (sheet)
                        {
                        case "Products":
                            dt = CreateProductTable();
                            break;

                        case "Transactions":
                            dt = CreateTransactionsTable();
                            break;

                        case "Transaction Attributes":
                            dt = CreateAttributesTable(lstExportAttributes, id);
                            break;

                        case "Business Rules":
                            dt = CreateBusinessRulesTable(id, tbl);
                            break;

                        case "Interfaces":
                            dt = CreateInterfaceTable(id);
                            break;

                        case "Channels":
                            dt = CreateChannelsAlertsTable(id);
                            break;

                        case "Reports":
                            dt = CreateReportsTable(id);
                            break;

                        default:
                            break;
                        }

                        ExcelWorksheet ws = CreateSheet(objExcelPackage, sheet, dt, i);


                        if (sheet == "Transaction Attributes" || sheet == "Interfaces" || sheet == "Channels" || sheet == "Reports" || sheet == "Business Rules")
                        {
                            ws.Cells[2, 1].Value                           = sheet;
                            ws.Cells[2, 1, 2, 3].Merge                     = true;                          //Merge columns start and end range
                            ws.Cells[2, 1, 2, 3].Style.Font.Bold           = true;                          //Font should be bold
                            ws.Cells[2, 1, 2, 3].Style.Font.Size           = 20;
                            ws.Cells[2, 1, 2, 3].Style.HorizontalAlignment = ExcelHorizontalAlignment.Left; // Alignment is center
                            ws.Cells[2, 1, 2, 3].Style.Fill.PatternType    = ExcelFillStyle.Solid;          // Alignment is center
                            ws.Cells[2, 1, 2, 3].Style.Fill.BackgroundColor.SetColor(Color.LightGray);      // Alignment is center

                            var border = ws.Cells[2, 1, 2, 3].Style.Border;
                            border.Bottom.Style = ExcelBorderStyle.Medium;
                            border.Top.Style    = ExcelBorderStyle.Thin;
                            border.Left.Style   = ExcelBorderStyle.None;
                            border.Right.Style  = ExcelBorderStyle.None;

                            int colIndex, rowIndex;
                            if (sheet == "Business Rules")
                            {
                                CreateTableHeaderForBR(dt, ws, out colIndex, out rowIndex, "brtbl", count);
                            }
                            else if (sheet == "Reports")
                            {
                                CreateTableHeaderForReports(dt, ws, out colIndex, out rowIndex, "Reports", count);
                            }
                            else if (sheet == "Transaction Attributes")
                            {
                                CreateTableHeaderForBR(dt, ws, out colIndex, out rowIndex, "txnAttr", count);
                            }
                            else if (sheet == "Interfaces")
                            {
                                CreateTableHeaderForBR(dt, ws, out colIndex, out rowIndex, "Interfaces", count);
                            }
                            else if (sheet == "Channels")
                            {
                                CreateTableHeaderForBR(dt, ws, out colIndex, out rowIndex, "Channels", count);
                            }

                            else
                            {
                                CreateTableHeaderForBR(dt, ws, out colIndex, out rowIndex, "", count);
                            }

                            AddRowsHLT(dt, ws, ref colIndex, ref rowIndex, count, id);



                            ws.View.ShowGridLines = false;
                            ws.View.ZoomScale     = 80;
                            ws.Cells.AutoFitColumns();
                            int j;

                            if (sheet == "Business Rules")
                            {
                                for (j = 5; j <= count + 4; j++)
                                {
                                    ws.Column(j).Width = 3.57;
                                }
                            }
                            else if (sheet == "Reports")
                            {
                                for (j = 6; j <= count + 5; j++)
                                {
                                    ws.Column(j).Width = 3.57;
                                }
                            }
                            else if (sheet == "Transaction Attributes")
                            {
                                for (j = 4; j <= count + 3; j++)
                                {
                                    ws.Column(j).Width = 3.57;
                                }
                            }
                            else if (sheet == "Interfaces")
                            {
                                for (j = 8; j <= count + 7; j++)
                                {
                                    ws.Column(j).Width = 3.57;
                                }
                            }
                            else if (sheet == "Channels")
                            {
                                for (j = 5; j <= count + 4; j++)
                                {
                                    ws.Column(j).Width = 3.57;
                                }
                            }

                            if (sheet == "Business Rules")
                            {
                                ws.DeleteColumn(3);
                            }
                            else if (sheet == "Interfaces")
                            {
                                ws.DeleteColumn(4);
                            }
                            else if (sheet == "Channels")
                            {
                                var cnt = ws.Dimension.End.Column;
                                ws.DeleteColumn(cnt);
                            }
                            else if (sheet == "Transaction Attributes")
                            {
                                ws.DeleteColumn(count + 6);
                            }
                            else if (sheet == "Reports")
                            {
                                ws.DeleteColumn(4);
                                var cnt = ws.Dimension.End.Column;
                                ws.DeleteColumn(cnt);
                            }


                            i++;
                        }

                        else
                        {
                            ws.Cells[2, 1].Value                           = sheet;
                            ws.Cells[2, 1, 2, 3].Merge                     = true;                          //Merge columns start and end range
                            ws.Cells[2, 1, 2, 3].Style.Font.Bold           = true;                          //Font should be bold
                            ws.Cells[2, 1, 2, 3].Style.Font.Size           = 20;
                            ws.Cells[2, 1, 2, 3].Style.HorizontalAlignment = ExcelHorizontalAlignment.Left; // Alignment is center
                            ws.Cells[2, 1, 2, 3].Style.Fill.PatternType    = ExcelFillStyle.Solid;          // Alignment is center
                            ws.Cells[2, 1, 2, 3].Style.Fill.BackgroundColor.SetColor(Color.LightGray);      // Alignment is center

                            var border = ws.Cells[2, 1, 2, 3].Style.Border;
                            border.Bottom.Style = ExcelBorderStyle.Medium;
                            border.Top.Style    = ExcelBorderStyle.Thin;
                            border.Left.Style   = ExcelBorderStyle.None;
                            border.Right.Style  = ExcelBorderStyle.None;

                            int colIndex, rowIndex;

                            CreateTableHeader(dt, ws, out colIndex, out rowIndex, tbl);
                            AddRows(dt, ws, ref colIndex, ref rowIndex);


                            ws.View.ShowGridLines = false;
                            ws.View.ZoomScale     = 80;
                            ws.Cells.AutoFitColumns();

                            i++;
                        }
                    }
                    tbl_DesignAccelerator da        = new tbl_DesignAccelerator();
                    DAManager             daManager = new DAManager();

                    da = daManager.FindDA(id);
                    ExcelCommonFunctions excelCommonfunctions = new ExcelCommonFunctions();
                    string filePath = excelCommonfunctions.SaveFile(objExcelPackage, da.daName, "", "ExportDA");

                    return(filePath);
                }
            }
            catch (Exception)
            {
                throw;
            }
        }