Beispiel #1
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();
                }
            });
        }
        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();
                }
            });
        }
Beispiel #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>();


                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();
                }
            });
        }