public override void RegisterModule()
        {
            ExecuteFaultHandledOperation(() =>
            {
                systemCoreData.ISolutionRepository solutionRepository = _DataRepositoryFactory.GetDataRepository <systemCoreData.ISolutionRepository>();
                systemCoreData.IModuleRepository moduleRepository     = _DataRepositoryFactory.GetDataRepository <systemCoreData.IModuleRepository>();
                systemCoreData.IMenuRepository menuRepository         = _DataRepositoryFactory.GetDataRepository <systemCoreData.IMenuRepository>();
                systemCoreData.IRoleRepository roleRepository         = _DataRepositoryFactory.GetDataRepository <systemCoreData.IRoleRepository>();
                systemCoreData.IMenuRoleRepository menuRoleRepository = _DataRepositoryFactory.GetDataRepository <systemCoreData.IMenuRoleRepository>();


                using (TransactionScope ts = new TransactionScope())
                {
                    //check if module has been installed
                    systemCoreEntities.Module module = moduleRepository.Get().Where(c => c.Name == MODULE_NAME).FirstOrDefault();
                    if (module == null)
                    {
                        //check if module category exit
                        systemCoreEntities.Solution solution = solutionRepository.Get().Where(c => c.Name == SOLUTION_NAME).FirstOrDefault();
                        if (solution == null)
                        {
                            //register solution
                            solution = new systemCoreEntities.Solution()
                            {
                                Name      = SOLUTION_NAME,
                                Alias     = SOLUTION_ALIAS,
                                Active    = true,
                                Deleted   = false,
                                CreatedBy = "Auto",
                                CreatedOn = DateTime.Now,
                                UpdatedBy = "Auto",
                                UpdatedOn = DateTime.Now
                            };

                            solution = solutionRepository.Add(solution);
                        }

                        //register module
                        module = new systemCoreEntities.Module()
                        {
                            Name       = MODULE_NAME,
                            Alias      = MODULE_ALIAS,
                            SolutionId = solution.EntityId,
                            Active     = true,
                            Deleted    = false,
                            CreatedBy  = "Auto",
                            CreatedOn  = DateTime.Now,
                            UpdatedBy  = "Auto",
                            UpdatedOn  = DateTime.Now
                        };

                        module = moduleRepository.Add(module);


                        int menuIndex = 0;
                        var root      = menuRepository.Get().Where(c => c.Alias == "IFRS Processed Data").FirstOrDefault();
                        //Role
                        var adminRole = roleRepository.Get().Where(c => c.Name == GROUP_ADMINISTRATOR && c.SolutionId == solution.SolutionId).FirstOrDefault();
                        var userRole  = roleRepository.Get().Where(c => c.Name == GROUP_USER && c.SolutionId == solution.SolutionId).FirstOrDefault();


                        //register menu
                        var actionMenu = new systemCoreEntities.Menu()
                        {
                            Name      = "IFRS_BOND_PERIODIC_SCHEDULE",
                            Alias     = "Bond Periodic Data",
                            Action    = "IFRS_BOND_PERIODIC_SCHEDULE",
                            ActionUrl = "ifrs-bondperiodicschedule-list",
                            Image     = null,
                            ImageUrl  = "action_image",
                            ModuleId  = module.EntityId,
                            ParentId  = root.EntityId,
                            Position  = menuIndex += 1,
                            Active    = true,
                            Deleted   = false,
                            CreatedBy = "Auto",
                            CreatedOn = DateTime.Now,
                            UpdatedBy = "Auto",
                            UpdatedOn = DateTime.Now
                        };

                        menuRepository.Add(actionMenu);

                        menuRoleRepository.Add(new systemCoreEntities.MenuRole()
                        {
                            MenuId    = actionMenu.EntityId,
                            RoleId    = adminRole.EntityId,
                            Active    = true,
                            Deleted   = false,
                            CreatedBy = "Auto",
                            CreatedOn = DateTime.Now,
                            UpdatedBy = "Auto",
                            UpdatedOn = DateTime.Now
                        });
                        actionMenu = new systemCoreEntities.Menu()
                        {
                            Name      = "DAILY_BOND_AMORTIZATION",
                            Alias     = "Daily Bond Amortization",
                            Action    = "DAILY_BOND_AMORTIZATION",
                            ActionUrl = "ifrs-bondamortization-list",
                            Image     = null,
                            ImageUrl  = "action_image",
                            ModuleId  = module.EntityId,
                            ParentId  = root.EntityId,
                            Position  = menuIndex += 1,
                            Active    = true,
                            Deleted   = false,
                            CreatedBy = "Auto",
                            CreatedOn = DateTime.Now,
                            UpdatedBy = "Auto",
                            UpdatedOn = DateTime.Now
                        };

                        menuRepository.Add(actionMenu);

                        menuRoleRepository.Add(new systemCoreEntities.MenuRole()
                        {
                            MenuId    = actionMenu.EntityId,
                            RoleId    = adminRole.EntityId,
                            Active    = true,
                            Deleted   = false,
                            CreatedBy = "Auto",
                            CreatedOn = DateTime.Now,
                            UpdatedBy = "Auto",
                            UpdatedOn = DateTime.Now
                        });
                        actionMenu = new systemCoreEntities.Menu()
                        {
                            Name      = "ZERO_COUPON_BOND",
                            Alias     = "Zero Coupon Bond",
                            Action    = "ZERO_COUPON_BOND",
                            ActionUrl = "ifrs-zerocouponbond-list",
                            Image     = null,
                            ImageUrl  = "action_image",
                            ModuleId  = module.EntityId,
                            ParentId  = root.EntityId,
                            Position  = menuIndex += 1,
                            Active    = true,
                            Deleted   = false,
                            CreatedBy = "Auto",
                            CreatedOn = DateTime.Now,
                            UpdatedBy = "Auto",
                            UpdatedOn = DateTime.Now
                        };

                        menuRepository.Add(actionMenu);

                        menuRoleRepository.Add(new systemCoreEntities.MenuRole()
                        {
                            MenuId    = actionMenu.EntityId,
                            RoleId    = adminRole.EntityId,
                            Active    = true,
                            Deleted   = false,
                            CreatedBy = "Auto",
                            CreatedOn = DateTime.Now,
                            UpdatedBy = "Auto",
                            UpdatedOn = DateTime.Now
                        });

                        actionMenu = new systemCoreEntities.Menu()
                        {
                            Name      = "LOAN_PERIODIC_SCHEDULE",
                            Alias     = "Loan Periodic Schedule",
                            Action    = "LOAN_PERIODIC_SCHEDULE",
                            ActionUrl = "ifrs-loanperiodicschedule-list",
                            Image     = null,
                            ImageUrl  = "action_image",
                            ModuleId  = module.EntityId,
                            ParentId  = root.EntityId,
                            Position  = menuIndex += 1,
                            Active    = true,
                            Deleted   = false,
                            CreatedBy = "Auto",
                            CreatedOn = DateTime.Now,
                            UpdatedBy = "Auto",
                            UpdatedOn = DateTime.Now
                        };

                        menuRepository.Add(actionMenu);

                        menuRoleRepository.Add(new systemCoreEntities.MenuRole()
                        {
                            MenuId    = actionMenu.EntityId,
                            RoleId    = adminRole.EntityId,
                            Active    = true,
                            Deleted   = false,
                            CreatedBy = "Auto",
                            CreatedOn = DateTime.Now,
                            UpdatedBy = "Auto",
                            UpdatedOn = DateTime.Now
                        });

                        actionMenu = new systemCoreEntities.Menu()
                        {
                            Name      = "LOAN_DAILY_SCHEDULE",
                            Alias     = "Loan Daily Schedule",
                            Action    = "LOAN_DAILY_SCHEDULE",
                            ActionUrl = "ifrs-loandailyschedule-list",
                            Image     = null,
                            ImageUrl  = "action_image",
                            ModuleId  = module.EntityId,
                            ParentId  = root.EntityId,
                            Position  = menuIndex += 1,
                            Active    = true,
                            Deleted   = false,
                            CreatedBy = "Auto",
                            CreatedOn = DateTime.Now,
                            UpdatedBy = "Auto",
                            UpdatedOn = DateTime.Now
                        };

                        menuRepository.Add(actionMenu);

                        menuRoleRepository.Add(new systemCoreEntities.MenuRole()
                        {
                            MenuId    = actionMenu.EntityId,
                            RoleId    = adminRole.EntityId,
                            Active    = true,
                            Deleted   = false,
                            CreatedBy = "Auto",
                            CreatedOn = DateTime.Now,
                            UpdatedBy = "Auto",
                            UpdatedOn = DateTime.Now
                        });

                        actionMenu = new systemCoreEntities.Menu()
                        {
                            Name      = "LOAN_IMAPIRMENT_RESULT",
                            Alias     = "Loan Impairment Result",
                            Action    = "LOAN_IMAPIRMENT_RESULT",
                            ActionUrl = "ifrs-loanimpairmentresult-list",
                            Image     = null,
                            ImageUrl  = "action_image",
                            ModuleId  = module.EntityId,
                            ParentId  = root.EntityId,
                            Position  = menuIndex += 1,
                            Active    = true,
                            Deleted   = false,
                            CreatedBy = "Auto",
                            CreatedOn = DateTime.Now,
                            UpdatedBy = "Auto",
                            UpdatedOn = DateTime.Now
                        };

                        menuRepository.Add(actionMenu);

                        menuRoleRepository.Add(new systemCoreEntities.MenuRole()
                        {
                            MenuId    = actionMenu.EntityId,
                            RoleId    = adminRole.EntityId,
                            Active    = true,
                            Deleted   = false,
                            CreatedBy = "Auto",
                            CreatedOn = DateTime.Now,
                            UpdatedBy = "Auto",
                            UpdatedOn = DateTime.Now
                        });

                        actionMenu = new systemCoreEntities.Menu()
                        {
                            Name      = "TREASURY_BILL_COMPUTATION",
                            Alias     = "Treasury Bills",
                            Action    = "TREASURY_BILL_COMPUTATION",
                            ActionUrl = "ifrs-treasurybillscomputation-list",
                            Image     = null,
                            ImageUrl  = "action_image",
                            ModuleId  = module.EntityId,
                            ParentId  = root.EntityId,
                            Position  = menuIndex += 1,
                            Active    = true,
                            Deleted   = false,
                            CreatedBy = "Auto",
                            CreatedOn = DateTime.Now,
                            UpdatedBy = "Auto",
                            UpdatedOn = DateTime.Now
                        };

                        menuRepository.Add(actionMenu);

                        menuRoleRepository.Add(new systemCoreEntities.MenuRole()
                        {
                            MenuId    = actionMenu.EntityId,
                            RoleId    = adminRole.EntityId,
                            Active    = true,
                            Deleted   = false,
                            CreatedBy = "Auto",
                            CreatedOn = DateTime.Now,
                            UpdatedBy = "Auto",
                            UpdatedOn = DateTime.Now
                        });

                        actionMenu = new systemCoreEntities.Menu()
                        {
                            Name      = "EQUITY_STOCK_COMPUTATION",
                            Alias     = "Equity Stock",
                            Action    = "EQUITY_STOCK_COMPUTATION",
                            ActionUrl = "ifrs-equitystock-list",
                            Image     = null,
                            ImageUrl  = "action_image",
                            ModuleId  = module.EntityId,
                            ParentId  = root.EntityId,
                            Position  = menuIndex += 1,
                            Active    = true,
                            Deleted   = false,
                            CreatedBy = "Auto",
                            CreatedOn = DateTime.Now,
                            UpdatedBy = "Auto",
                            UpdatedOn = DateTime.Now
                        };

                        menuRepository.Add(actionMenu);

                        menuRoleRepository.Add(new systemCoreEntities.MenuRole()
                        {
                            MenuId    = actionMenu.EntityId,
                            RoleId    = adminRole.EntityId,
                            Active    = true,
                            Deleted   = false,
                            CreatedBy = "Auto",
                            CreatedOn = DateTime.Now,
                            UpdatedBy = "Auto",
                            UpdatedOn = DateTime.Now
                        });
                    }

                    ts.Complete();
                }
            });
        }
Exemple #2
0
        public override void RegisterModule()
        {
            ExecuteFaultHandledOperation(() =>
            {
                systemCoreData.ISolutionRepository solutionRepository = _DataRepositoryFactory.GetDataRepository <systemCoreData.ISolutionRepository>();
                systemCoreData.IModuleRepository moduleRepository     = _DataRepositoryFactory.GetDataRepository <systemCoreData.IModuleRepository>();
                systemCoreData.IMenuRepository menuRepository         = _DataRepositoryFactory.GetDataRepository <systemCoreData.IMenuRepository>();
                systemCoreData.IRoleRepository roleRepository         = _DataRepositoryFactory.GetDataRepository <systemCoreData.IRoleRepository>();
                systemCoreData.IMenuRoleRepository menuRoleRepository = _DataRepositoryFactory.GetDataRepository <systemCoreData.IMenuRoleRepository>();


                using (TransactionScope ts = new TransactionScope())
                {
                    //check if module has been installed
                    systemCoreEntities.Module module = moduleRepository.Get().Where(c => c.Name == MODULE_NAME).FirstOrDefault();
                    if (module == null)
                    {
                        //check if module category exit
                        systemCoreEntities.Solution solution = solutionRepository.Get().Where(c => c.Name == SOLUTION_NAME).FirstOrDefault();
                        if (solution == null)
                        {
                            //register solution
                            solution = new systemCoreEntities.Solution()
                            {
                                Name      = SOLUTION_NAME,
                                Alias     = SOLUTION_ALIAS,
                                Active    = true,
                                Deleted   = false,
                                CreatedBy = "Auto",
                                CreatedOn = DateTime.Now,
                                UpdatedBy = "Auto",
                                UpdatedOn = DateTime.Now
                            };

                            solution = solutionRepository.Add(solution);
                        }

                        //register module
                        module = new systemCoreEntities.Module()
                        {
                            Name       = MODULE_NAME,
                            Alias      = MODULE_ALIAS,
                            SolutionId = solution.EntityId,
                            Active     = true,
                            Deleted    = false,
                            CreatedBy  = "Auto",
                            CreatedOn  = DateTime.Now,
                            UpdatedBy  = "Auto",
                            UpdatedOn  = DateTime.Now
                        };

                        module = moduleRepository.Add(module);


                        int menuIndex = 0;
                        var root      = menuRepository.Get().Where(c => c.Alias == "Financial Instrument").FirstOrDefault();
                        //Role
                        var adminRole = roleRepository.Get().Where(c => c.Name == GROUP_ADMINISTRATOR && c.SolutionId == solution.SolutionId).FirstOrDefault();
                        var userRole  = roleRepository.Get().Where(c => c.Name == GROUP_USER && c.SolutionId == solution.SolutionId).FirstOrDefault();


                        //register menu
                        var actionMenu = new systemCoreEntities.Menu()
                        {
                            Name      = "IFRS_MARKET_YIELD",
                            Alias     = "Market Yield/Price",
                            Action    = "IFRS_MARKET_YIELD",
                            ActionUrl = "ifrsfi-marketyield-list",
                            Image     = null,
                            ImageUrl  = "action_image",
                            ModuleId  = module.EntityId,
                            ParentId  = root.EntityId,
                            Position  = menuIndex += 1,
                            Active    = true,
                            Deleted   = false,
                            CreatedBy = "Auto",
                            CreatedOn = DateTime.Now,
                            UpdatedBy = "Auto",
                            UpdatedOn = DateTime.Now
                        };

                        menuRepository.Add(actionMenu);

                        menuRoleRepository.Add(new systemCoreEntities.MenuRole()
                        {
                            MenuId    = actionMenu.EntityId,
                            RoleId    = adminRole.EntityId,
                            Active    = true,
                            Deleted   = false,
                            CreatedBy = "Auto",
                            CreatedOn = DateTime.Now,
                            UpdatedBy = "Auto",
                            UpdatedOn = DateTime.Now
                        });
                        actionMenu = new systemCoreEntities.Menu()
                        {
                            Name      = "FAIR_VALUE_BASIS_MAP",
                            Alias     = "Fair Value Basis Map",
                            Action    = "FAIR_VALUE_BASIS_MAP",
                            ActionUrl = "ifrsfi-fairvaluebasismap-list",
                            Image     = null,
                            ImageUrl  = "action_image",
                            ModuleId  = module.EntityId,
                            ParentId  = root.EntityId,
                            Position  = menuIndex += 1,
                            Active    = true,
                            Deleted   = false,
                            CreatedBy = "Auto",
                            CreatedOn = DateTime.Now,
                            UpdatedBy = "Auto",
                            UpdatedOn = DateTime.Now
                        };

                        menuRepository.Add(actionMenu);

                        menuRoleRepository.Add(new systemCoreEntities.MenuRole()
                        {
                            MenuId    = actionMenu.EntityId,
                            RoleId    = adminRole.EntityId,
                            Active    = true,
                            Deleted   = false,
                            CreatedBy = "Auto",
                            CreatedOn = DateTime.Now,
                            UpdatedBy = "Auto",
                            UpdatedOn = DateTime.Now
                        });
                        actionMenu = new systemCoreEntities.Menu()
                        {
                            Name      = "FAIR_VALUE_BASIS_EXEMPTION",
                            Alias     = "Fair Value Basis Exemption",
                            Action    = "FAIR_VALUE_BASIS_EXEMPTION",
                            ActionUrl = "ifrsfi-fairvaluebasisexemption-list",
                            Image     = null,
                            ImageUrl  = "action_image",
                            ModuleId  = module.EntityId,
                            ParentId  = root.EntityId,
                            Position  = menuIndex += 1,
                            Active    = true,
                            Deleted   = false,
                            CreatedBy = "Auto",
                            CreatedOn = DateTime.Now,
                            UpdatedBy = "Auto",
                            UpdatedOn = DateTime.Now
                        };

                        menuRepository.Add(actionMenu);

                        menuRoleRepository.Add(new systemCoreEntities.MenuRole()
                        {
                            MenuId    = actionMenu.EntityId,
                            RoleId    = adminRole.EntityId,
                            Active    = true,
                            Deleted   = false,
                            CreatedBy = "Auto",
                            CreatedOn = DateTime.Now,
                            UpdatedBy = "Auto",
                            UpdatedOn = DateTime.Now
                        });
                    }

                    ts.Complete();
                }
            });
        }
Exemple #3
0
        public override void RegisterModule()
        {
            ExecuteFaultHandledOperation(() =>
            {
                systemCoreData.ISolutionRepository solutionRepository = _DataRepositoryFactory.GetDataRepository <systemCoreData.ISolutionRepository>();
                systemCoreData.IModuleRepository moduleRepository     = _DataRepositoryFactory.GetDataRepository <systemCoreData.IModuleRepository>();
                systemCoreData.IMenuRepository menuRepository         = _DataRepositoryFactory.GetDataRepository <systemCoreData.IMenuRepository>();
                systemCoreData.IRoleRepository roleRepository         = _DataRepositoryFactory.GetDataRepository <systemCoreData.IRoleRepository>();
                systemCoreData.IMenuRoleRepository menuRoleRepository = _DataRepositoryFactory.GetDataRepository <systemCoreData.IMenuRoleRepository>();
                IGLTypeRepository glTypeRepository = _DataRepositoryFactory.GetDataRepository <IGLTypeRepository>();

                using (TransactionScope ts = new TransactionScope())
                {
                    //check if module has been installed
                    systemCoreEntities.Module module = moduleRepository.Get().Where(c => c.Name == MODULE_NAME).FirstOrDefault();
                    if (module == null)
                    {
                        //check if module category exit
                        systemCoreEntities.Solution solution = solutionRepository.Get().Where(c => c.Name == SOLUTION_NAME).FirstOrDefault();
                        if (solution == null)
                        {
                            //register solution
                            solution = new systemCoreEntities.Solution()
                            {
                                Name      = SOLUTION_NAME,
                                Alias     = SOLUTION_ALIAS,
                                Active    = true,
                                Deleted   = false,
                                CreatedBy = "Auto",
                                CreatedOn = DateTime.Now,
                                UpdatedBy = "Auto",
                                UpdatedOn = DateTime.Now
                            };

                            solution = solutionRepository.Add(solution);
                        }

                        //register module
                        module = new systemCoreEntities.Module()
                        {
                            Name       = MODULE_NAME,
                            Alias      = MODULE_ALIAS,
                            SolutionId = solution.EntityId,
                            Active     = true,
                            Deleted    = false,
                            CreatedBy  = "Auto",
                            CreatedOn  = DateTime.Now,
                            UpdatedBy  = "Auto",
                            UpdatedOn  = DateTime.Now
                        };

                        module = moduleRepository.Add(module);

                        //Role
                        var adminRole = new systemCoreEntities.Role()
                        {
                            SolutionId  = solution.SolutionId,
                            Name        = GROUP_ADMINISTRATOR,
                            Description = "For IFRS solution unlimited users",
                            Type        = systemCoreFramework.RoleType.Application,
                            Active      = true,
                            Deleted     = false,
                            CreatedBy   = "Auto",
                            CreatedOn   = DateTime.Now,
                            UpdatedBy   = "Auto",
                            UpdatedOn   = DateTime.Now
                        };

                        roleRepository.Add(adminRole);

                        var userRole = new systemCoreEntities.Role()
                        {
                            SolutionId  = solution.SolutionId,
                            Name        = GROUP_USER,
                            Description = "For IFRS solution limited users",
                            Type        = systemCoreFramework.RoleType.Application,
                            Active      = true,
                            Deleted     = false,
                            CreatedBy   = "Auto",
                            CreatedOn   = DateTime.Now,
                            UpdatedBy   = "Auto",
                            UpdatedOn   = DateTime.Now
                        };

                        roleRepository.Add(userRole);

                        int menuIndex = 0;

                        //register menu
                        var root = new systemCoreEntities.Menu()
                        {
                            Name      = "IFRS",
                            Alias     = "IFRS",
                            Action    = "",
                            ActionUrl = "",
                            Image     = null,
                            ImageUrl  = "ifrs_image",
                            ModuleId  = module.EntityId,
                            ParentId  = null,
                            Position  = menuIndex += 1,
                            Active    = true,
                            Deleted   = false,
                            CreatedBy = "Auto",
                            CreatedOn = DateTime.Now,
                            UpdatedBy = "Auto",
                            UpdatedOn = DateTime.Now
                        };

                        root = menuRepository.Add(root);

                        menuRoleRepository.Add(new systemCoreEntities.MenuRole()
                        {
                            MenuId    = root.EntityId,
                            RoleId    = adminRole.EntityId,
                            Active    = true,
                            Deleted   = false,
                            CreatedBy = "Auto",
                            CreatedOn = DateTime.Now,
                            UpdatedBy = "Auto",
                            UpdatedOn = DateTime.Now
                        });

                        menuRoleRepository.Add(new systemCoreEntities.MenuRole()
                        {
                            MenuId    = root.EntityId,
                            RoleId    = userRole.EntityId,
                            Active    = true,
                            Deleted   = false,
                            CreatedBy = "Auto",
                            CreatedOn = DateTime.Now,
                            UpdatedBy = "Auto",
                            UpdatedOn = DateTime.Now
                        });

                        var loan = new systemCoreEntities.Menu()
                        {
                            Name      = "IFRS_LOAN",
                            Alias     = "Loans",
                            Action    = "IFRS_LOAN",
                            ActionUrl = "",
                            Image     = null,
                            ImageUrl  = "ifrs_loan_image",
                            ModuleId  = module.EntityId,
                            ParentId  = root.EntityId,
                            Position  = menuIndex += 1,
                            Active    = true,
                            Deleted   = false,
                            CreatedBy = "Auto",
                            CreatedOn = DateTime.Now,
                            UpdatedBy = "Auto",
                            UpdatedOn = DateTime.Now
                        };

                        menuRepository.Add(loan);

                        menuRoleRepository.Add(new systemCoreEntities.MenuRole()
                        {
                            MenuId    = loan.EntityId,
                            RoleId    = adminRole.EntityId,
                            Active    = true,
                            Deleted   = false,
                            CreatedBy = "Auto",
                            CreatedOn = DateTime.Now,
                            UpdatedBy = "Auto",
                            UpdatedOn = DateTime.Now
                        });

                        menuRoleRepository.Add(new systemCoreEntities.MenuRole()
                        {
                            MenuId    = loan.EntityId,
                            RoleId    = userRole.EntityId,
                            Active    = true,
                            Deleted   = false,
                            CreatedBy = "Auto",
                            CreatedOn = DateTime.Now,
                            UpdatedBy = "Auto",
                            UpdatedOn = DateTime.Now
                        });


                        var finInstrument = new systemCoreEntities.Menu()
                        {
                            Name      = "IFRS_FINANCIAL_INSTRUMENT",
                            Alias     = "Financial Instrument",
                            Action    = "IFRS_FINANCIAL_INSTRUMENT",
                            ActionUrl = "",
                            Image     = null,
                            ImageUrl  = "ifrs_financialinstrument_image",
                            ModuleId  = module.EntityId,
                            ParentId  = root.EntityId,
                            Position  = menuIndex += 1,
                            Active    = true,
                            Deleted   = false,
                            CreatedBy = "Auto",
                            CreatedOn = DateTime.Now,
                            UpdatedBy = "Auto",
                            UpdatedOn = DateTime.Now
                        };

                        menuRepository.Add(finInstrument);

                        menuRoleRepository.Add(new systemCoreEntities.MenuRole()
                        {
                            MenuId    = finInstrument.EntityId,
                            RoleId    = adminRole.EntityId,
                            Active    = true,
                            Deleted   = false,
                            CreatedBy = "Auto",
                            CreatedOn = DateTime.Now,
                            UpdatedBy = "Auto",
                            UpdatedOn = DateTime.Now
                        });

                        menuRoleRepository.Add(new systemCoreEntities.MenuRole()
                        {
                            MenuId    = finInstrument.EntityId,
                            RoleId    = userRole.EntityId,
                            Active    = true,
                            Deleted   = false,
                            CreatedBy = "Auto",
                            CreatedOn = DateTime.Now,
                            UpdatedBy = "Auto",
                            UpdatedOn = DateTime.Now
                        });

                        var dataview = new systemCoreEntities.Menu()
                        {
                            Name      = "IFRS_DATA_VIEW",
                            Alias     = "IFRS Processed Data",
                            Action    = "IFRS_DATA_VIEW",
                            ActionUrl = "",
                            Image     = null,
                            ImageUrl  = "ifrs_dataview_image",
                            ModuleId  = module.EntityId,
                            ParentId  = root.EntityId,
                            Position  = menuIndex += 1,
                            Active    = true,
                            Deleted   = false,
                            CreatedBy = "Auto",
                            CreatedOn = DateTime.Now,
                            UpdatedBy = "Auto",
                            UpdatedOn = DateTime.Now
                        };

                        menuRepository.Add(dataview);

                        menuRoleRepository.Add(new systemCoreEntities.MenuRole()
                        {
                            MenuId    = dataview.EntityId,
                            RoleId    = adminRole.EntityId,
                            Active    = true,
                            Deleted   = false,
                            CreatedBy = "Auto",
                            CreatedOn = DateTime.Now,
                            UpdatedBy = "Auto",
                            UpdatedOn = DateTime.Now
                        });

                        menuRoleRepository.Add(new systemCoreEntities.MenuRole()
                        {
                            MenuId    = dataview.EntityId,
                            RoleId    = userRole.EntityId,
                            Active    = true,
                            Deleted   = false,
                            CreatedBy = "Auto",
                            CreatedOn = DateTime.Now,
                            UpdatedBy = "Auto",
                            UpdatedOn = DateTime.Now
                        });


                        var finstat = new systemCoreEntities.Menu()
                        {
                            Name      = "FINSTAT",
                            Alias     = "Finstat",
                            Action    = "FINSTAT",
                            ActionUrl = "",
                            Image     = null,
                            ImageUrl  = "finstat_image",
                            ModuleId  = module.EntityId,
                            ParentId  = root.EntityId,
                            Position  = menuIndex += 1,
                            Active    = true,
                            Deleted   = false,
                            CreatedBy = "Auto",
                            CreatedOn = DateTime.Now,
                            UpdatedBy = "Auto",
                            UpdatedOn = DateTime.Now
                        };

                        menuRepository.Add(finstat);

                        menuRoleRepository.Add(new systemCoreEntities.MenuRole()
                        {
                            MenuId    = finstat.EntityId,
                            RoleId    = adminRole.EntityId,
                            Active    = true,
                            Deleted   = false,
                            CreatedBy = "Auto",
                            CreatedOn = DateTime.Now,
                            UpdatedBy = "Auto",
                            UpdatedOn = DateTime.Now
                        });

                        menuRoleRepository.Add(new systemCoreEntities.MenuRole()
                        {
                            MenuId    = finstat.EntityId,
                            RoleId    = userRole.EntityId,
                            Active    = true,
                            Deleted   = false,
                            CreatedBy = "Auto",
                            CreatedOn = DateTime.Now,
                            UpdatedBy = "Auto",
                            UpdatedOn = DateTime.Now
                        });

                        var actionMenu = new systemCoreEntities.Menu()
                        {
                            Name      = "IFRS_REGISTRY",
                            Alias     = "Registries",
                            Action    = "IFRS_REGISTRY",
                            ActionUrl = "finstat-registry-list",
                            Image     = null,
                            ImageUrl  = "action_image",
                            ModuleId  = module.EntityId,
                            ParentId  = finstat.EntityId,
                            Position  = menuIndex += 1,
                            Active    = true,
                            Deleted   = false,
                            CreatedBy = "Auto",
                            CreatedOn = DateTime.Now,
                            UpdatedBy = "Auto",
                            UpdatedOn = DateTime.Now
                        };

                        menuRepository.Add(actionMenu);

                        menuRoleRepository.Add(new systemCoreEntities.MenuRole()
                        {
                            MenuId    = actionMenu.EntityId,
                            RoleId    = adminRole.EntityId,
                            Active    = true,
                            Deleted   = false,
                            CreatedBy = "Auto",
                            CreatedOn = DateTime.Now,
                            UpdatedBy = "Auto",
                            UpdatedOn = DateTime.Now
                        });

                        actionMenu = new systemCoreEntities.Menu()
                        {
                            Name      = "DERIVED_CAPTIONS",
                            Alias     = "Derived Captions",
                            Action    = "DERIVED_CAPTIONS",
                            ActionUrl = "finstat-derivedcaption-list",
                            Image     = null,
                            ImageUrl  = "action_image",
                            ModuleId  = module.EntityId,
                            ParentId  = finstat.EntityId,
                            Position  = menuIndex += 1,
                            Active    = true,
                            Deleted   = false,
                            CreatedBy = "Auto",
                            CreatedOn = DateTime.Now,
                            UpdatedBy = "Auto",
                            UpdatedOn = DateTime.Now
                        };

                        menuRepository.Add(actionMenu);

                        menuRoleRepository.Add(new systemCoreEntities.MenuRole()
                        {
                            MenuId    = actionMenu.EntityId,
                            RoleId    = adminRole.EntityId,
                            Active    = true,
                            Deleted   = false,
                            CreatedBy = "Auto",
                            CreatedOn = DateTime.Now,
                            UpdatedBy = "Auto",
                            UpdatedOn = DateTime.Now
                        });
                    }

                    ts.Complete();
                }
            });
        }
Exemple #4
0
        public override void RegisterModule()
        {
            ExecuteFaultHandledOperation(() =>
            {
                systemCoreData.ISolutionRepository solutionRepository = _DataRepositoryFactory.GetDataRepository <systemCoreData.ISolutionRepository>();
                systemCoreData.IModuleRepository moduleRepository     = _DataRepositoryFactory.GetDataRepository <systemCoreData.IModuleRepository>();
                systemCoreData.IMenuRepository menuRepository         = _DataRepositoryFactory.GetDataRepository <systemCoreData.IMenuRepository>();
                systemCoreData.IRoleRepository roleRepository         = _DataRepositoryFactory.GetDataRepository <systemCoreData.IRoleRepository>();
                systemCoreData.IMenuRoleRepository menuRoleRepository = _DataRepositoryFactory.GetDataRepository <systemCoreData.IMenuRoleRepository>();


                using (TransactionScope ts = new TransactionScope())
                {
                    //check if module has been installed
                    systemCoreEntities.Module module = moduleRepository.Get().Where(c => c.Name == FinancialInstrumentModuleDefinition.MODULE_NAME).FirstOrDefault();

                    var register = false;
                    if (module == null)
                    {
                        register = true;
                    }
                    else
                    {
                        register = module.CanUpdate;
                    }
                    if (register)
                    {
                        //check if module category exit
                        Solution solution = solutionRepository.Get().Where(c => c.Name == FinancialInstrumentModuleDefinition.SOLUTION_NAME).FirstOrDefault();
                        if (solution == null)
                        {
                            //register solution
                            solution = new Solution()
                            {
                                Name      = FinancialInstrumentModuleDefinition.SOLUTION_NAME,
                                Alias     = FinancialInstrumentModuleDefinition.SOLUTION_ALIAS,
                                Active    = true,
                                Deleted   = false,
                                CreatedBy = "Auto",
                                CreatedOn = DateTime.Now,
                                UpdatedBy = "Auto",
                                UpdatedOn = DateTime.Now
                            };

                            solution = solutionRepository.Add(solution);
                        }

                        //register module
                        if (module == null)
                        {
                            module = new Module()
                            {
                                Name       = FinancialInstrumentModuleDefinition.MODULE_NAME,
                                Alias      = FinancialInstrumentModuleDefinition.MODULE_ALIAS,
                                SolutionId = solution.EntityId,
                                Active     = true,
                                Deleted    = false,
                                CreatedBy  = "Auto",
                                CreatedOn  = DateTime.Now,
                                UpdatedBy  = "Auto",
                                UpdatedOn  = DateTime.Now
                            };

                            module = moduleRepository.Add(module);
                        }

                        //Roles
                        var existingRoles = roleRepository.Get().Where(c => c.SolutionId == solution.SolutionId && c.Type == RoleType.Application).ToList();
                        var updatedRoles  = new List <Role>();

                        foreach (var role in FinancialInstrumentModuleDefinition.GetRoles())
                        {
                            var localRole = existingRoles.Where(c => c.Name == role.Name).FirstOrDefault();

                            if (localRole == null)
                            {
                                localRole = new Role()
                                {
                                    Name = role.Name, Description = role.Description, SolutionId = solution.SolutionId, Type = RoleType.Application, Active = true, Deleted = false, CreatedBy = "Auto", CreatedOn = DateTime.Now, UpdatedBy = "Auto", UpdatedOn = DateTime.Now
                                };

                                localRole = roleRepository.Add(localRole);
                            }
                            else
                            {
                                localRole.Description = role.Description;
                                localRole.UpdatedOn   = DateTime.Now;
                                localRole             = roleRepository.Update(localRole);
                            }

                            updatedRoles.Add(localRole);
                        }

                        //Menus
                        var existingMenus = menuRepository.Get().Where(c => c.ModuleId == module.ModuleId).ToList();
                        var updatedMenus  = new List <Menu>();

                        var menuIndex = 0;

                        foreach (var menu in FinancialInstrumentModuleDefinition.GetMenus())
                        {
                            menuIndex      += 1;
                            Menu parentMenu = null;

                            int?parentId = null;
                            if (!string.IsNullOrEmpty(menu.Parent))
                            {
                                if (string.IsNullOrEmpty(menu.ParentModule))
                                {
                                    parentMenu = existingMenus.Where(c => c.Name == menu.Parent).FirstOrDefault();

                                    if (parentMenu == null)
                                    {
                                        parentMenu = menuRepository.Get().Where(c => c.ModuleId == module.ModuleId && c.Name == menu.Parent).FirstOrDefault();
                                    }
                                }
                                else
                                {
                                    var parentModule = moduleRepository.Get().Where(c => c.Name == menu.ParentModule).FirstOrDefault();

                                    if (parentModule != null)
                                    {
                                        parentMenu = menuRepository.Get().Where(c => c.ModuleId == parentModule.ModuleId && c.Name == menu.Parent).FirstOrDefault();
                                    }
                                }

                                if (parentMenu != null)
                                {
                                    parentId = parentMenu.MenuId;
                                }
                            }

                            var localMenu = existingMenus.Where(c => c.Name == menu.Name).FirstOrDefault();

                            if (localMenu == null)
                            {
                                localMenu = new Menu()
                                {
                                    Name = menu.Name, Alias = menu.Alias, Action = menu.Action, ActionUrl = menu.ActionUrl, ImageUrl = menu.ImageUrl, ModuleId = module.ModuleId, Position = menuIndex, ParentId = parentId, Active = true, Deleted = false, CreatedBy = "Auto", CreatedOn = DateTime.Now, UpdatedBy = "Auto", UpdatedOn = DateTime.Now
                                };

                                localMenu = menuRepository.Add(localMenu);
                            }
                            else
                            {
                                localMenu.Alias     = menu.Alias;
                                localMenu.Action    = menu.Action;
                                localMenu.ActionUrl = menu.ActionUrl;
                                localMenu.ImageUrl  = menu.ImageUrl;
                                localMenu.ModuleId  = module.ModuleId;
                                localMenu.Position  = menuIndex;
                                localMenu.ParentId  = parentId;
                                localMenu.UpdatedOn = DateTime.Now;

                                localMenu = menuRepository.Update(localMenu);
                            }

                            updatedMenus.Add(localMenu);
                        }

                        //MenuRoles
                        var menuIds           = updatedMenus.Select(c => c.MenuId).Distinct().ToArray();
                        var existingMenuRoles = menuRoleRepository.Get().Where(c => menuIds.Contains(c.MenuId)).ToList();

                        foreach (var menuRole in FinancialInstrumentModuleDefinition.GetMenuRoles())
                        {
                            var myMenu = updatedMenus.Where(c => c.Name == menuRole.MenuName).FirstOrDefault();
                            var myRole = updatedRoles.Where(c => c.Name == menuRole.RoleName).FirstOrDefault();

                            var localMenuRole = existingMenuRoles.Where(c => c.MenuId == myMenu.MenuId && c.RoleId == myRole.RoleId).FirstOrDefault();

                            if (localMenuRole == null)
                            {
                                localMenuRole = new MenuRole()
                                {
                                    MenuId = myMenu.MenuId, RoleId = myRole.RoleId, Active = true, Deleted = false, CreatedBy = "Auto", CreatedOn = DateTime.Now, UpdatedBy = "Auto", UpdatedOn = DateTime.Now
                                };

                                menuRoleRepository.Add(localMenuRole);
                            }
                            else
                            {
                                localMenuRole.MenuId    = myMenu.MenuId;
                                localMenuRole.RoleId    = myRole.RoleId;
                                localMenuRole.UpdatedOn = DateTime.Now;

                                menuRoleRepository.Update(localMenuRole);
                            }
                        }
                    }
                    ts.Complete();
                }
            });
        }