Ejemplo n.º 1
0
        //[BindProperty]
        //private FullSystemConfig FullSystemConfig { get; set; }


        public SystemConfig_IndexModel(SystemConfigService systemConfigService, TenantInfoService tenantInfoService, FullSystemConfigCache fullSystemConfigCache)
        {
            this._systemConfigService   = systemConfigService;
            this._tenantInfoService     = tenantInfoService;
            this._fullSystemConfigCache = fullSystemConfigCache;

            //FullSystemConfig = _fullSystemConfigCache.Data;
        }
Ejemplo n.º 2
0
        //[BindProperty]
        //private FullSystemConfig FullSystemConfig { get; set; }


        public TenantInfo_IndexModel(IServiceProvider serviceProvider, TenantInfoService tenantInfoService, FullSystemConfigCache fullSystemConfigCache)
        {
            this._serviceProvider       = serviceProvider;
            this._tenantInfoService     = tenantInfoService;
            this._fullSystemConfigCache = fullSystemConfigCache;

            //FullSystemConfig = _fullSystemConfigCache.Data;
        }
        public void AddTenantInfo()
        {
            var tenantInfoService = new TenantInfoService(new AccountDbContext());
            var result            = tenantInfoService.Add(new TenantInfo
            {
                OperatorName  = "7tiny",
                IsActive      = (int)TrueFalse.True,
                Description   = "测试租户",
                RegisterEmail = "*****@*****.**",
                TenantName    = "SevenTiny测试租户"
            });

            Assert.True(result.IsSuccess);
        }
Ejemplo n.º 4
0
        public IndexModel(IServiceProvider serviceProvider, XncfModuleServiceExtension xncfModuleService, AdminUserInfoService accountService,
                          SystemConfigService systemConfigService, SysMenuService sysMenuService, TenantInfoService tenantInfoService, Lazy <IHttpContextAccessor> httpContextAccessor)
        {
            _xncfModuleService        = xncfModuleService;
            _accountInfoService       = accountService;
            _sysMenuService           = sysMenuService;
            _tenantInfoService        = tenantInfoService;
            this._httpContextAccessor = httpContextAccessor;
            _systemConfigService      = systemConfigService;
            _serviceProvider          = serviceProvider;

            MultiTenantEnable = SiteConfig.SenparcCoreSetting.EnableMultiTenant;
            TenantRule        = SiteConfig.SenparcCoreSetting.TenantRule;
        }
Ejemplo n.º 5
0
        public async Task <(bool success, string msg)> InitDatabase(IServiceProvider serviceProvider, TenantInfoService tenantInfoService, HttpContext httpContext)
        {
            var    success = true;
            string msg     = null;

            //SenparcEntities senparcEntities = (SenparcEntities)xncfModuleServiceExtension.BaseData.BaseDB.BaseDataContext;
            using (var scope = serviceProvider.CreateScope())
            {
                //暂时关闭多租户状态
                SiteConfig.SenparcCoreSetting.EnableMultiTenant = false;

                SenparcEntities senparcEntities = scope.ServiceProvider.GetRequiredService <SenparcEntities>();
                //更新数据库
                var pendingMigs = await senparcEntities.Database.GetPendingMigrationsAsync();

                if (pendingMigs.Count() > 0)
                {
                    senparcEntities.ResetMigrate();//重置合并状态

                    try
                    {
                        var script = senparcEntities.Database.GenerateCreateScript();
                        SenparcTrace.SendCustomLog("senparcEntities.Database.GenerateCreateScript", script);

                        senparcEntities.Migrate();//进行合并
                    }
                    catch (Exception ex)
                    {
                        success = false;
                        msg     = ex.Message;

                        var currentDatabaseConfiguration = DatabaseConfigurationFactory.Instance.Current;
                        SenparcTrace.BaseExceptionLog(new NcfDatabaseException(ex.Message, currentDatabaseConfiguration.GetType(), senparcEntities.GetType(), ex));
                    }
                }

                SiteConfig.SenparcCoreSetting.EnableMultiTenant = true;
            }

            return(success : success, msg : msg);
        }