public IUnitOfWorkCompleteHandle Begin(UnitOfWorkOptions options) { options.FillDefaultsForNonProvidedOptions(this._defaultOptions); if (options.Scope == TransactionScopeOption.Required && this._currentUnitOfWorkProvider.Current != null) { return(new InnerUnitOfWorkCompleteHandle()); } var uow = this._iocResolver.Resolve <IUnitOfWork>(); uow.Completed += (sender, args) => { this._currentUnitOfWorkProvider.Current = null; }; uow.Failed += (sender, args) => { this._currentUnitOfWorkProvider.Current = null; }; uow.Disposed += (sender, args) => { this._iocResolver.Release(uow); }; uow.Begin(options); this._currentUnitOfWorkProvider.Current = uow; return(uow); }
public virtual async Task <ActionResult> ResetPassword(ResetPasswordFormViewModel model) { this.CheckModelState(); IActiveUnitOfWork current = this._unitOfWorkManager.Current; current.DisableFilter(new string[] { "MayHaveTenant" }); long num = Convert.ToInt64(SimpleStringCipher.Decrypt(model.UserId, "gsKnGZ041HLL4IM8")); FuelWerx.Authorization.Users.User userByIdAsync = await this._userManager.GetUserByIdAsync(num); if (userByIdAsync == null || userByIdAsync.PasswordResetCode.IsNullOrEmpty() || userByIdAsync.PasswordResetCode != model.ResetCode) { throw new UserFriendlyException(this.L("InvalidPasswordResetCode"), this.L("InvalidPasswordResetCode_Detail")); } userByIdAsync.Password = (new PasswordHasher()).HashPassword(model.Password); userByIdAsync.PasswordResetCode = null; userByIdAsync.IsEmailConfirmed = true; userByIdAsync.ShouldChangePasswordOnNextLogin = false; await this._userManager.UpdateAsync(userByIdAsync); if (userByIdAsync.IsActive) { await this.SignInAsync(userByIdAsync, null, false); } return(this.RedirectToAction("Index", "Application")); }
public async Task <PagedResultOutput <NameValueDto> > FindUsers(FindUsersInput input) { if (this.AbpSession.MultiTenancySide == MultiTenancySides.Host && input.TenantId.HasValue) { IActiveUnitOfWork currentUnitOfWork = this.CurrentUnitOfWork; int?tenantId = input.TenantId; currentUnitOfWork.SetFilterParameter("MayHaveTenant", "tenantId", tenantId.Value); } IQueryable <User> users = this.UserManager.Users; IQueryable <User> users1 = users.WhereIf <User>(!input.Filter.IsNullOrWhiteSpace(), (User u) => u.Name.Contains(input.Filter) || u.Surname.Contains(input.Filter) || u.UserName.Contains(input.Filter) || u.EmailAddress.Contains(input.Filter)); int num = await users1.CountAsync <User>(); IQueryable <User> users2 = users1; IOrderedQueryable <User> name = from u in users2 orderby u.Name select u; List <User> listAsync = await name.ThenBy <User, string>((User u) => u.Surname).PageBy <User>(input).ToListAsync <User>(); List <User> users3 = listAsync; int num1 = num; List <User> users4 = users3; PagedResultOutput <NameValueDto> pagedResultOutput = new PagedResultOutput <NameValueDto>(num1, ( from u in users4 select new NameValueDto(string.Concat(new string[] { u.Name, " ", u.Surname, " (", u.EmailAddress, ")" }), u.Id.ToString())).ToList <NameValueDto>()); return(pagedResultOutput); }
public virtual async Task <ActionResult> ResetPassword(ResetPasswordViewModel model) { Guid guid; Guid guid1; this.CheckModelState(); IActiveUnitOfWork current = this._unitOfWorkManager.Current; current.DisableFilter(new string[] { "MayHaveTenant" }); long num = Convert.ToInt64(SimpleStringCipher.Decrypt(model.UserId, "gsKnGZ041HLL4IM8")); FuelWerx.Authorization.Users.User userByIdAsync = await this._userManager.GetUserByIdAsync(num); if (userByIdAsync == null || userByIdAsync.PasswordResetCode.IsNullOrEmpty() || userByIdAsync.PasswordResetCode != model.ResetCode) { throw new UserFriendlyException(this.L("InvalidPasswordResetCode"), this.L("InvalidPasswordResetCode_Detail")); } TenantLogosEditDto tenantLogosEditDto = Abp.Threading.AsyncHelper.RunSync <TenantLogosEditDto>(() => this.GetCurrentTenantLogos()); dynamic viewBag = this.ViewBag; guid = (tenantLogosEditDto.HeaderImageId.HasValue ? tenantLogosEditDto.HeaderImageId.Value : Guid.Empty); viewBag.TenantCompanyHeaderImageId = guid; dynamic obj = this.ViewBag; guid1 = (tenantLogosEditDto.HeaderMobileImageId.HasValue ? tenantLogosEditDto.HeaderMobileImageId.Value : Guid.Empty); obj.TenantCompanyHeaderMobileImageId = guid1; return(this.View(model)); }
public virtual async Task <ActionResult> EmailConfirmation(EmailConfirmationViewModel model) { string tenancyName; this.CheckModelState(); IActiveUnitOfWork current = this._unitOfWorkManager.Current; current.DisableFilter(new string[] { "MayHaveTenant" }); long num = Convert.ToInt64(SimpleStringCipher.Decrypt(model.UserId, "gsKnGZ041HLL4IM8")); FuelWerx.Authorization.Users.User userByIdAsync = await this._userManager.GetUserByIdAsync(num); if (userByIdAsync == null || userByIdAsync.EmailConfirmationCode.IsNullOrEmpty() || userByIdAsync.EmailConfirmationCode != model.ConfirmationCode) { throw new UserFriendlyException(this.L("InvalidEmailConfirmationCode"), this.L("InvalidEmailConfirmationCode_Detail")); } userByIdAsync.IsEmailConfirmed = true; userByIdAsync.EmailConfirmationCode = null; await this._userManager.UpdateAsync(userByIdAsync); if (!userByIdAsync.TenantId.HasValue) { tenancyName = ""; } else { TenantManager tenantManager = this._tenantManager; int? tenantId = userByIdAsync.TenantId; tenancyName = (await tenantManager.GetByIdAsync(tenantId.Value)).TenancyName; } string str = tenancyName; ActionResult action = this.RedirectToAction("Login", new { successMessage = this.L("YourEmailIsConfirmedMessage"), tenancyName = str, userNameOrEmailAddress = userByIdAsync.UserName }); return(action); }
/// <summary> /// 切换 DbContextProviderName /// </summary> /// <param name="unitOfWork"></param> /// <param name="name">provider name</param> /// <returns></returns> public static IDisposable SetDbContextProvider(this IActiveUnitOfWork unitOfWork, string name) { Check.NotNull(unitOfWork, nameof(unitOfWork)); Check.NotNullOrWhiteSpace(name, nameof(name)); return((unitOfWork as EfCoreUnitOfWork).SetDbContextProvider(name)); }
public static TDbContext GetDbContext <TDbContext>(this IActiveUnitOfWork unitOfWork) where TDbContext : DbContext { //if(unitOfWork is IDirectUnitOfWork) //{ // return ((dynamic)unitOfWork).GetOrCreateDbContext<TDbContext>(); //} return((unitOfWork as EfUnitOfWork).GetOrCreateDbContext <TDbContext>()); }
/// <summary> /// 确保事件触发。如果在事务过程中,确保在事务完成后触发事件 /// </summary> /// <typeparam name="TEventData"></typeparam> /// <param name="eventBus"></param> /// <param name="currentActiveUnitOfWork"></param> /// <param name="eventData"></param> /// <param name="triggerInUow"></param> public static void EnsureTrigger <TEventData>(this IEventBus eventBus, IActiveUnitOfWork currentActiveUnitOfWork, TEventData eventData, bool triggerInUow = false) where TEventData : EventData { if (currentActiveUnitOfWork == null || triggerInUow) { eventBus.Trigger(eventData); return; } currentActiveUnitOfWork.Completed += (sender, args) => eventBus.Trigger(eventData); }
public static IDataProvider GetDataProvider(this IActiveUnitOfWork unitOfWork, string dataSettingName) { Check.NotNull(unitOfWork, nameof(unitOfWork)); if (!(unitOfWork is MapleUnitOfWork)) { throw new ArgumentException("unitOfWork is not type of " + typeof(MapleUnitOfWork).FullName, nameof(MapleUnitOfWork)); } return((unitOfWork as MapleUnitOfWork).GetOrCreateDataProvider(dataSettingName)); }
public void BeginTransaction() { _call++; if (ActiveUnitOfWork == null) { var connection = GetConnection(); ActiveUnitOfWork = new ActiveUnitOfWork(connection); } Console.WriteLine("Transaction started, hash: {0}", GetHashCode()); }
public void Rollback() { if (ActiveUnitOfWork == null) { throw new InvalidOperationException("No transaction started."); } ActiveUnitOfWork.Rollback(); ActiveUnitOfWork = null; _call = 0; Console.WriteLine("Transaction rollbacked, hash: {0}", GetHashCode()); }
public static TDbContext GetDbContext <TDbContext>(this IActiveUnitOfWork unitOfWork, string name = null) where TDbContext : DbContext { if (unitOfWork == null) { throw new ArgumentNullException("unitOfWork"); } if (!(unitOfWork is EfCoreUnitOfWork)) { throw new ArgumentException("unitOfWork is not type of " + typeof(EfCoreUnitOfWork).FullName, "unitOfWork"); } return((unitOfWork as EfCoreUnitOfWork).GetOrCreateDbContext <TDbContext>(name)); }
/// <summary> /// 获取DbContext /// </summary> /// <param name="unitOfWork">工作单元对象</param> /// <param name="dbContextType">DbContext类型</param> /// <param name="name"></param> /// <returns>DbContext</returns> public static DbContext GetDbContext(this IActiveUnitOfWork unitOfWork) { Check.NotNull(unitOfWork, nameof(unitOfWork)); if (!(unitOfWork is EfCoreUnitOfWork efCoreUnitOfWork)) { throw new ArgumentException("unitOfWork is not type of " + typeof(EfCoreUnitOfWork).FullName, "unitOfWork"); } return(efCoreUnitOfWork.GetOrCreateDbContext()); }
/// <summary> /// Gets a DbContext as a part of active unit of work. /// This method can be called when current unit of work is an <see cref="EfCoreUnitOfWork"/>. /// </summary> /// <typeparam name="TDbContext">Type of the DbContext</typeparam> /// <param name="unitOfWork">Current (active) unit of work</param> public static TDbContext GetDbContext <TDbContext>(this IActiveUnitOfWork unitOfWork) where TDbContext : DbContext { Check.NotNull(unitOfWork, nameof(unitOfWork)); if (unitOfWork is EfCoreUnitOfWork efCoreUnitOfWork) { return(efCoreUnitOfWork.GetOrCreateDbContext <TDbContext>()); } throw new ArgumentException("unitOfWork is not type of " + typeof(EfCoreUnitOfWork).FullName, nameof(unitOfWork)); }
/// <summary> /// Gets a DbContext as a part of active unit of work. /// This method can be called when current unit of work is an <see cref="EfCoreUnitOfWork"/>. /// </summary> /// <typeparam name="TDbContext">Type of the DbContext</typeparam> /// <param name="unitOfWork">Current (active) unit of work</param> public static TDbContext GetDbContext <TDbContext>(this IActiveUnitOfWork unitOfWork) where TDbContext : DbContext { Throw.IfArgumentNull(unitOfWork, nameof(unitOfWork)); if (!(unitOfWork is EfCoreUnitOfWork)) { throw new ArgumentException("unitOfWork is not type of " + typeof(EfCoreUnitOfWork).FullName, "unitOfWork"); } return(((EfCoreUnitOfWork)unitOfWork).GetOrCreateDbContext <TDbContext>()); }
public virtual async Task <JsonResult> SendEmailActivationLink(SendEmailActivationLinkViewModel model) { IActiveUnitOfWork current = this._unitOfWorkManager.Current; current.DisableFilter(new string[] { "MayHaveTenant" }); FuelWerx.Authorization.Users.User userByChecking = await this.GetUserByChecking(model.EmailAddress, model.TenancyName); FuelWerx.Authorization.Users.User user = userByChecking; user.SetNewEmailConfirmationCode(); await this._userEmailer.SendEmailActivationLinkAsync(user, null); return(this.Json(new MvcAjaxResponse())); }
public static TDbContext GetDbContext <TDbContext>(this IActiveUnitOfWork unitOfWork, MultiTenancySides?multiTenancySide) where TDbContext : DbContext { if (unitOfWork == null) { throw new ArgumentNullException(nameof(unitOfWork)); } if (!(unitOfWork is EfUnitOfWork)) { throw new ArgumentException("unitOfWork is not type of " + typeof(EfUnitOfWork).FullName, nameof(unitOfWork)); } return((unitOfWork as EfUnitOfWork).GetOrCreateDbContext <TDbContext>(multiTenancySide)); }
public static ISession GetSession <TSessionContext>(this IActiveUnitOfWork unitOfWork) where TSessionContext : ISessionContext { if (unitOfWork == null) { throw new ArgumentNullException(nameof(unitOfWork)); } if (!(unitOfWork is NhUnitOfWork)) { throw new ArgumentException("unitOfWork is not type of " + typeof(NhUnitOfWork).FullName, nameof(unitOfWork)); } return(((NhUnitOfWork)unitOfWork).GetOrCreateSession <TSessionContext>()); }
public static Transaction GetTransaction(this IActiveUnitOfWork unitOfWork) { if (unitOfWork == null) { throw new ArgumentNullException(nameof(unitOfWork)); } if (!(unitOfWork is DbReezeUnitOfWork)) { throw new ArgumentException("unitOfWork is not type of " + typeof(DbReezeUnitOfWork).FullName, nameof(unitOfWork)); } return(((DbReezeUnitOfWork)unitOfWork).Transaction); }
private static NhUnitOfWork GetNhUnitOfWork(IActiveUnitOfWork unitOfWork) { if (unitOfWork == null) { throw new ArgumentNullException(nameof(unitOfWork)); } if (!(unitOfWork is NhUnitOfWork)) { throw new ArgumentException("unitOfWork is not type of " + typeof(NhUnitOfWork).FullName, "unitOfWork"); } return(unitOfWork as NhUnitOfWork); }
public static ISession GetSession(this IActiveUnitOfWork unitOfWork) { if (unitOfWork == null) { throw new ArgumentNullException(nameof(unitOfWork)); } if (!(unitOfWork is NhUnitOfWork)) { throw new ArgumentException("unitOfWork is not type of " + typeof(NhUnitOfWork).FullName, nameof(unitOfWork)); } return((unitOfWork as NhUnitOfWork).Session); }
public static IBucketContext GetSession(this IActiveUnitOfWork unitOfWork) { if (unitOfWork == null) { throw new ArgumentNullException(nameof(unitOfWork)); } if (!(unitOfWork is CouchbaseUnitOfWork)) { throw new ArgumentException("unitOfWork is not type of " + typeof(CouchbaseUnitOfWork).FullName, nameof(unitOfWork)); } return(((CouchbaseUnitOfWork)unitOfWork).Session); }
/// <summary> /// Gets a DbContext as a part of active unit of work. /// This method can be called when current unit of work is an <see cref="EfCoreUnitOfWork"/>. /// </summary> /// <typeparam name="TDbContext">Type of the DbContext</typeparam> /// <param name="unitOfWork">Current (active) unit of work</param> /// <param name="multiTenancySide">Multitenancy side</param> /// <param name="name"> /// A custom name for the dbcontext to get a named dbcontext. /// If there is no dbcontext in this unit of work with given name, then a new one is created. /// </param> public static Task <TDbContext> GetDbContextAsync <TDbContext>(this IActiveUnitOfWork unitOfWork, MultiTenancySides?multiTenancySide = null, string name = null) where TDbContext : DbContext { if (unitOfWork == null) { throw new ArgumentNullException("unitOfWork"); } if (!(unitOfWork is EfCoreUnitOfWork)) { throw new ArgumentException("unitOfWork is not type of " + typeof(EfCoreUnitOfWork).FullName, "unitOfWork"); } return((unitOfWork as EfCoreUnitOfWork).GetOrCreateDbContextAsync <TDbContext>(multiTenancySide, name)); }
public void Commit() { if (ActiveUnitOfWork == null) { throw new InvalidOperationException("No transaction started."); } if (_call == 1) { ActiveUnitOfWork.Commit(); ActiveUnitOfWork = null; } _call--; Console.WriteLine("Transaction commited, hash: {0}", GetHashCode()); }
public static ISession GetSession <TTenantId, TUserId>(this IActiveUnitOfWork unitOfWork) where TTenantId : struct where TUserId : struct { if (unitOfWork == null) { throw new ArgumentNullException("unitOfWork"); } if (!(unitOfWork is NhUnitOfWork <TTenantId, TUserId>)) { throw new ArgumentException("unitOfWork is not type of " + typeof(NhUnitOfWork <,>).FullName, "unitOfWork"); } return((unitOfWork as NhUnitOfWork <TTenantId, TUserId>).Session); }
/// <summary> /// Gets a DbContext as a part of active unit of work. /// This method can be called when current unit of work is an <see cref="EfUnitOfWork"/>. /// </summary> /// <typeparam name="TDbContext">Type of the DbContext</typeparam> /// <typeparam name="TTenantId"></typeparam> /// <typeparam name="TUserId"></typeparam> /// <param name="unitOfWork">Current (active) unit of work</param> public static TDbContext GetDbContext <TDbContext, TTenantId, TUserId>(this IActiveUnitOfWork unitOfWork) where TDbContext : DbContext where TTenantId : struct where TUserId : struct { if (unitOfWork == null) { throw new ArgumentNullException("unitOfWork"); } if (!(unitOfWork is EfUnitOfWork <TTenantId, TUserId>)) { throw new ArgumentException("unitOfWork is not type of " + typeof(EfUnitOfWork <TTenantId, TUserId>).FullName, "unitOfWork"); } return((unitOfWork as EfUnitOfWork <TTenantId, TUserId>).GetOrCreateDbContext <TDbContext>()); }
public static void DoWithoutFlush(this IActiveUnitOfWork uow, Action action) { if (!(uow is NhUnitOfWork nhUow)) { return; } var session = nhUow.GetSession(); var previousFlushMode = session.FlushMode; // We do NOT want this to flush pending changes as checking for a duplicate should // only compare the object against data that's already in the database session.FlushMode = FlushMode.Manual; action.Invoke(); session.FlushMode = previousFlushMode; }
public virtual async Task <ActionResult> Register(RegisterViewModel model) { ActionResult actionResult; AbpUserManager <Tenant, Role, FuelWerx.Authorization.Users.User> .AbpLoginResult loginResultAsync; Guid guid; Guid guid1; bool flag; AbpUserManager <Tenant, Role, FuelWerx.Authorization.Users.User> .AbpLoginResult abpLoginResult; TenantLogosEditDto tenantLogosEditDto = Abp.Threading.AsyncHelper.RunSync <TenantLogosEditDto>(() => this.GetCurrentTenantLogos()); dynamic viewBag = this.ViewBag; guid = (tenantLogosEditDto.HeaderImageId.HasValue ? tenantLogosEditDto.HeaderImageId.Value : Guid.Empty); viewBag.TenantCompanyHeaderImageId = guid; dynamic obj = this.ViewBag; guid1 = (tenantLogosEditDto.HeaderMobileImageId.HasValue ? tenantLogosEditDto.HeaderMobileImageId.Value : Guid.Empty); obj.TenantCompanyHeaderMobileImageId = guid1; try { this.CheckSelfRegistrationIsEnabled(); this.CheckModelState(); if (!model.IsExternalLogin && this.UseCaptchaOnRegistration()) { RecaptchaVerificationHelper recaptchaVerificationHelper = this.GetRecaptchaVerificationHelper(); if (recaptchaVerificationHelper.Response.IsNullOrEmpty()) { throw new UserFriendlyException(this.L("CaptchaCanNotBeEmpty")); } if (recaptchaVerificationHelper.VerifyRecaptchaResponse() != RecaptchaVerificationResult.Success) { throw new UserFriendlyException(this.L("IncorrectCaptchaAnswer")); } } if (!this._multiTenancyConfig.IsEnabled) { model.TenancyName = "Default"; } else if (model.TenancyName.IsNullOrEmpty()) { throw new UserFriendlyException(this.L("TenantNameCanNotBeEmpty")); } Tenant activeTenantAsync = await this.GetActiveTenantAsync(model.TenancyName); bool settingValueForTenantAsync = await SettingManagerExtensions.GetSettingValueForTenantAsync <bool>(this.SettingManager, "App.UserManagement.AllowSelfRegistration", activeTenantAsync.Id); if (!settingValueForTenantAsync) { throw new UserFriendlyException(this.L("SelfUserRegistrationIsDisabledMessage_Detail")); } settingValueForTenantAsync = await SettingManagerExtensions.GetSettingValueForTenantAsync <bool>(this.SettingManager, "App.UserManagement.IsNewRegisteredUserActiveByDefault", activeTenantAsync.Id); bool flag1 = settingValueForTenantAsync; settingValueForTenantAsync = await SettingManagerExtensions.GetSettingValueForTenantAsync <bool>(this.SettingManager, "Abp.Zero.UserManagement.IsEmailConfirmationRequiredForLogin", activeTenantAsync.Id); bool flag2 = settingValueForTenantAsync; FuelWerx.Authorization.Users.User user = new FuelWerx.Authorization.Users.User() { TenantId = new int?(activeTenantAsync.Id), Name = model.Name, Surname = model.Surname, EmailAddress = model.EmailAddress, IsActive = flag1 }; FuelWerx.Authorization.Users.User userName = user; ExternalLoginInfo externalLoginInfoAsync = null; if (model.IsExternalLogin) { externalLoginInfoAsync = await AuthenticationManagerExtensions.GetExternalLoginInfoAsync(this.AuthenticationManager); if (externalLoginInfoAsync == null) { throw new ApplicationException("Can not external login!"); } FuelWerx.Authorization.Users.User user1 = userName; List <UserLogin> userLogins = new List <UserLogin>(); UserLogin userLogin = new UserLogin() { LoginProvider = externalLoginInfoAsync.Login.LoginProvider, ProviderKey = externalLoginInfoAsync.Login.ProviderKey }; userLogins.Add(userLogin); user1.Logins = userLogins; model.UserName = model.EmailAddress; model.Password = FuelWerx.Authorization.Users.User.CreateRandomPassword(); if (string.Equals(externalLoginInfoAsync.Email, model.EmailAddress, StringComparison.InvariantCultureIgnoreCase)) { userName.IsEmailConfirmed = true; } } else if (model.UserName.IsNullOrEmpty() || model.Password.IsNullOrEmpty()) { throw new UserFriendlyException(this.L("FormIsNotValidMessage")); } userName.UserName = model.UserName; userName.Password = (new PasswordHasher()).HashPassword(model.Password); IActiveUnitOfWork current = this._unitOfWorkManager.Current; current.EnableFilter(new string[] { "MayHaveTenant" }); this._unitOfWorkManager.Current.SetFilterParameter("MayHaveTenant", "tenantId", activeTenantAsync.Id); userName.Roles = new List <UserRole>(); IQueryable <Role> roles = this._roleManager.Roles; List <Role> listAsync = await( from r in roles where r.IsDefault select r).ToListAsync <Role>(); foreach (Role role in listAsync) { ICollection <UserRole> userRoles = userName.Roles; userRoles.Add(new UserRole() { RoleId = role.Id }); } this.CheckErrors(await this._userManager.CreateAsync(userName)); await this._unitOfWorkManager.Current.SaveChangesAsync(); if (!userName.IsEmailConfirmed) { userName.SetNewEmailConfirmationCode(); await this._userEmailer.SendEmailActivationLinkAsync(userName, null); } if (userName.IsActive && (userName.IsEmailConfirmed || !flag2)) { if (externalLoginInfoAsync == null) { loginResultAsync = await this.GetLoginResultAsync(userName.UserName, model.Password, activeTenantAsync.TenancyName); abpLoginResult = loginResultAsync; } else { loginResultAsync = await this._userManager.LoginAsync(externalLoginInfoAsync.Login, activeTenantAsync.TenancyName); abpLoginResult = loginResultAsync; } if (abpLoginResult.Result != AbpLoginResultType.Success) { this.Logger.Warn(string.Concat("New registered user could not be login. This should not be normally. login result: ", abpLoginResult.Result)); abpLoginResult = null; } else { await this.SignInAsync(abpLoginResult.User, abpLoginResult.Identity, false); actionResult = this.Redirect(this.Url.Action("Index", "Application")); return(actionResult); } } AccountController accountController = this; RegisterResultViewModel registerResultViewModel = new RegisterResultViewModel() { TenancyName = activeTenantAsync.TenancyName, NameAndSurname = string.Concat(userName.Name, " ", userName.Surname), UserName = userName.UserName, EmailAddress = userName.EmailAddress, IsActive = userName.IsActive, IsEmailConfirmationRequired = flag2 }; actionResult = accountController.View("RegisterResult", registerResultViewModel); } catch (UserFriendlyException userFriendlyException1) { UserFriendlyException userFriendlyException = userFriendlyException1; ((dynamic)this.ViewBag).IsMultiTenancyEnabled = this._multiTenancyConfig.IsEnabled; dynamic viewBag1 = this.ViewBag; flag = (model.IsExternalLogin ? false : this.UseCaptchaOnRegistration()); viewBag1.UseCaptcha = flag; ((dynamic)this.ViewBag).ErrorMessage = userFriendlyException.Message; actionResult = this.View("Register", model); } return(actionResult); }
/// <summary> /// Gets a DbContext as a part of active unit of work.This method can be called when current unit of work is an <see cref="EfUnitOfWork"/>. /// 获取一个数据库上下文作为工作单元的一部分,如果当前工作单元是<see cref="EfUnitOfWork"/>,则当前方法可以被调用。 /// </summary> /// <typeparam name="TDbContext">Type of the DbContext / 数据库上下文的类型</typeparam> /// <param name="unitOfWork">Current (active) unit of work / 当前的(激活的)工作单元</param> public static TDbContext GetDbContext <TDbContext>(this IActiveUnitOfWork unitOfWork) where TDbContext : DbContext { return(GetDbContext <TDbContext>(unitOfWork, null)); }
/// <summary> /// Add an action that should be executed after successful completion of the current transaction /// </summary> public static void DoAfterTransaction(this IActiveUnitOfWork unitOfWork, Action action) { var nhUow = GetNhUnitOfWork(unitOfWork); nhUow.GetSession().DoAfterTransaction(action); }