Esempio n. 1
0
 public override void Execute(InitModuleJobsArgs args)
 {
     //如果账套还没有模块,则初始化模块
     if (!ModuleInfoManager.GetAll().Any(o => o.TenantId == args.TenantId))
     {
         MESTenantManager.InitModule(new int[] { args.TenantId }).GetAwaiter().GetResult();
     }
     MESTenantManager.InitAdminRole(new int[] { args.TenantId }).GetAwaiter().GetResult();
 }
Esempio n. 2
0
        public virtual async Task SetActive(int tenantId, bool isActive)
        {
            var tenant = await Repository.GetAsync(tenantId);

            tenant.IsActive = isActive;
            //如果账套还没有模块,则初始化模块
            if (!await ModuleInfoManager.GetAll().AnyAsync(o => o.TenantId == tenantId))
            {
                await InitModule(new int[] { tenant.Id });
            }
            await CurrentUnitOfWork.SaveChangesAsync();
        }
Esempio n. 3
0
        /// <summary>
        /// 模块初始化
        /// </summary>
        /// <param name="ids"></param>
        /// <param name="addOn">若为true,则保留原有数据更新,否则删除原模块数据</param>
        /// <returns></returns>
        public virtual async Task InitModule(IEnumerable <int> ids, bool addOn = true)
        {
            foreach (var tenantId in ids)
            {
                var modules = await ModuleInfoManager.GetAll().Where(o => o.TenantId == tenantId).ToListAsync();

                if (!addOn)
                {
                    //删除原模块数据
                    await ModuleInfoManager.Repository.HardDeleteAsync(o => modules.Select(m => m.Id).Contains(o.Id));
                }
                await CurrentUnitOfWork.SaveChangesAsync();

                var context = Repository.GetDbContext() as MasterDbContext;
                new TenantDefaultModuleBuilder(context, tenantId).Create();
            }
        }