private void RestoreInf_Click(object sender, EventArgs e) { if (this.CheckCookie()) { GeneralConfigInfo __configinfo = AdminConfigs.GetConfig(); GeneralConfigs.Serialiaze(__configinfo, Server.MapPath("../../config/general.config")); AdminVistLogs.InsertLog(this.userid, this.username, this.usergroupid, this.grouptitle, this.ip, "恢复论坛初始化设置", ""); base.RegisterStartupScript("PAGE", "window.location.href='global_restoresetupinf.aspx';"); } }
public void Build <TModel>(AdminConfig <TModel> adminConfig, bool hasConfiguration = false) where TModel : class { var modelType = typeof(TModel); switch (AdminType) { //TODO: Validate adminConfig for entity type case AdminType.Entity when AdminConfigs.ContainsKey(modelType): throw new InvalidOperationException($"The ModelType {modelType} has already been registered for this admin site, duplicate site registrations are not allowed"); case AdminType.Entity when Mapper == null: throw new InvalidOperationException($"AutoMapper configuration is required when creating admin site using AdminType: {AdminType}"); case AdminType.Entity: { if (_typeMaps == null) { _typeMaps = Mapper.ConfigurationProvider.GetAllTypeMaps().ToList(); } var entityClrType = GetEntityClrTypeFor(modelType); if (entityClrType == null) { throw new InvalidOperationException($"The entity type for the ModelType: {modelType} cannot be found in MapperConfiguration, please AutoMapper configuration for ModelType and ModelType"); } var entityType = _dbContext.Model.FindEntityType(entityClrType); if (entityType == null) { throw new InvalidOperationException($"The entity type for the ModelType: {modelType} cannot be found on this context {_dbContext}"); } adminConfig.EntityConfig = new EntityConfig(_dbContextType, entityType); BuildMainFormAndCustomForm(adminConfig, hasConfiguration, modelType); if (adminConfig.ChildConfigs != null && adminConfig.ChildConfigs.Count > 0) { foreach (var childConfig in adminConfig.ChildConfigs) { var childModelType = childConfig.Field.FieldClrType; var childEntityClrType = GetEntityClrTypeFor(childModelType); if (childEntityClrType == null) { throw new InvalidOperationException($"The entity type for the ModelType: {childModelType} cannot be found in MapperConfiguration, please check MapperConfiguration"); } var childEntityType = _dbContext.Model.FindEntityType(entityClrType); if (childEntityType == null) { throw new InvalidOperationException($"The entity type for the ModelType: {modelType} cannot be found on this context {_dbContext}"); } childConfig.EntityConfig = new EntityConfig(_dbContextType, childEntityType); BuildForm(childConfig, hasConfiguration, childModelType); } } break; } case AdminType.Custom when adminConfig.AdminServiceType == null: throw new InvalidOperationException($"AdminService is required when creating admin site with AdminType: {AdminType}"); case AdminType.Custom when(adminConfig.ModelConfig.KeyField.FieldExpression == null && adminConfig.AdminConfigType == AdminConfigType.GridAndForm): throw new InvalidOperationException($"KeyField is required when creating admin site with AdminType: {AdminType}"); case AdminType.Custom: { //TODO: Validate adminConfig for custom type BuildMainFormAndCustomForm(adminConfig, hasConfiguration, modelType); if (adminConfig.ChildConfigs != null && adminConfig.ChildConfigs.Count > 0) { foreach (var childConfig in adminConfig.ChildConfigs) { var childModelType = childConfig.Field.FieldClrType; BuildForm(childConfig, hasConfiguration, childModelType); } } break; } } LoadMasterData(adminConfig); AdminConfigs.Add(modelType, adminConfig); }