当前位置: 首页>>代码示例>>C#>>正文


C# ISession.UsingSafe方法代码示例

本文整理汇总了C#中ISession.UsingSafe方法的典型用法代码示例。如果您正苦于以下问题:C# ISession.UsingSafe方法的具体用法?C# ISession.UsingSafe怎么用?C# ISession.UsingSafe使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在ISession的用法示例。


在下文中一共展示了ISession.UsingSafe方法的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: AddUser

 /// <summary>
 /// 添加一个用户帐户
 /// </summary>
 /// <param name="newUser"></param>
 /// <param name="session"></param>
 /// <param name="addSuccess"></param>
 /// <param name="addFailure"></param>
 public void AddUser(User newUser, ISession session, Action<User> addSuccess, Action<User, string> addFailure)
 {
     session.UsingSafe(s =>
     {
         IsUserAccountExist(newUser.UserAccount, s,
             msg =>
             {
                 s.UsingSafeTransaction((ds, f, su) =>
                 {
                     try
                     {
                         ds.Save(newUser);
                         ds.Save(newUser.SecurityInfo);
                         su();
                         addSuccess(newUser);
                         newUser.UserPassword = "";
                     }
                     catch (Exception eX)
                     {
                         f();
                         addFailure(newUser, eX.Message);
                     }
                 });
             },
             u =>
             {
                 addFailure(newUser, "用户帐户已经存在");
             });
     });
 }
开发者ID:JackFong,项目名称:QuantumCode.Web.Security,代码行数:37,代码来源:UserOperator.cs

示例2: UpdateUserTracks

        /// <summary>
        /// 更新用户活动
        /// </summary>
        /// <param name="useraccount"></param>
        /// <param name="userActivity"></param>
        /// <param name="failure"></param>
        /// <param name="success"></param>
        public void UpdateUserTracks(string useraccount, ISession insession, UserActivities userActivity, Action<string> failure, Action success)
        {
            insession.UsingSafe(session =>
            {
                session.UsingSafeTransaction((s, f, su) =>
                {
                    try
                    {
                        UserTracking ut = new UserTracking()
                        {
                            UserAccount = useraccount,
                            UserActivity = (int)userActivity,
                            LastActivity = DateTime.Now
                        };

                        s.Save(ut);

                        su();

                        success();
                    }
                    catch (Exception eX)
                    {
                        f();
                        failure(eX.Message);
                    }
                });
            });
        }
开发者ID:JackFong,项目名称:QuantumCode.Web.Security,代码行数:36,代码来源:UserTrackingOperator.cs

示例3: AddRole

 /// <summary>
 /// 添加角色
 /// </summary>
 /// <param name="newRole"></param>
 /// <param name="addSuccess"></param>
 /// <param name="addFailure"></param>
 public void AddRole(Role newRole, ISession session, Action<Role> addSuccess, Action<string> addFailure)
 {
     session.UsingSafe(s =>
     {
         IsRoleExist(newRole.RoleCode,
             s,
             r => { addFailure("角色代码已经存在"); },
             () =>
             {
                 s.UsingSafeTransaction((ts, failure, success) =>
                 {
                     try
                     {
                         ts.Save(newRole);
                         success();
                         addSuccess(newRole);
                     }
                     catch (Exception eX)
                     {
                         failure();
                         addFailure(eX.Message);
                     }
                 });
             });
     });
 }
开发者ID:JackFong,项目名称:QuantumCode.Web.Security,代码行数:32,代码来源:RoleOperator.cs

示例4: IsRoleExist

        /// <summary>
        /// 判断角色是否存在
        /// </summary>
        /// <param name="roleCode"></param>
        /// <param name="roleExist"></param>
        /// <param name="roleNotExist"></param>
        public void IsRoleExist(string roleCode, ISession session, Action<Role> roleExist, Action roleNotExist)
        {
            session.UsingSafe(s=>{
                Role r = s.Get<Role>(roleCode);

                if (null == r)
                {
                    roleNotExist();
                }
                else
                {
                    roleExist(r);
                }
            });
        }
开发者ID:JackFong,项目名称:QuantumCode.Web.Security,代码行数:21,代码来源:RoleOperator.cs

示例5: IsUserAccountExist

        public void IsUserAccountExist(string account, ISession session, Action<string> userNotExistAction, Action<User> userExistAction)
        {
            session.UsingSafe(s =>
            {
                User u = s.Get<User>(account);

                if (null == u)
                {
                    userNotExistAction("用户帐户不存在");
                }
                else
                {
                    userExistAction(u);
                }
            });
        }
开发者ID:JackFong,项目名称:QuantumCode.Web.Security,代码行数:16,代码来源:UserOperator.cs

示例6: CheckPasswordErrorTimes

        /// <summary>
        /// 
        /// </summary>
        /// <param name="account"></param>
        /// <param name="insession"></param>
        /// <param name="doFailure"></param>
        /// <param name="doSuccess"></param>
        public void CheckPasswordErrorTimes(string account, ISession insession, Action<string> doFailure, Action<int> doSuccess)
        {
            insession.UsingSafe(session =>
            {
                try
                {
                    IList<UserTracking> tracks = session.CreateCriteria<UserTracking>()
                        .Add(Expression.Eq("UserActivity", 1)).List<UserTracking>();

                    doSuccess(tracks.Count);
                }
                catch (Exception eX)
                {
                    doFailure(eX.Message);
                }
            });
        }
开发者ID:JackFong,项目名称:QuantumCode.Web.Security,代码行数:24,代码来源:UserTrackingOperator.cs

示例7: SaveOrUpdateSessionUser

 /// <summary>
 /// 保存或更新SessionUser
 /// </summary>
 /// <param name="target"></param>
 /// <param name="failure"></param>
 /// <param name="success"></param>
 public void SaveOrUpdateSessionUser(SessionUser target, ISession session, Action<string> failure, Action<SessionUser> success)
 {
     session.UsingSafe(session1 =>
     {
         session1.UsingSafeTransaction((s, f, su) =>
         {
             try
             {
                 s.SaveOrUpdate(target);
                 su();
                 success(target);
             }
             catch (Exception eX)
             {
                 f();
                 failure(eX.Message);
             }
         });
     });
 }
开发者ID:JackFong,项目名称:QuantumCode.Web.Security,代码行数:26,代码来源:SessionUserOperator.cs

示例8: ClearUserPasswordInputError

        /// <summary>
        /// 清除密码输入错误记录
        /// </summary>
        /// <param name="useraccount"></param>
        /// <param name="failure"></param>
        /// <param name="success"></param>
        /// <param name="insession"></param>
        public void ClearUserPasswordInputError(string useraccount, ISession insession, Action<string> failure, Action success)
        {
            insession.UsingSafe(session =>
            {
                session.UsingSafeTransaction((s, f, su) =>
                {
                    try
                    {
                        s.Delete("from UserTracking where UserActivity = " +
                            ((int)UserActivities.SignInFailse).ToString() +
                            " and UserAccount = '" +
                            useraccount + "'");

                        su();
                        success();
                    }
                    catch (Exception eX)
                    {
                        f();
                        failure(eX.Message);
                    }
                });
            });
        }
开发者ID:JackFong,项目名称:QuantumCode.Web.Security,代码行数:31,代码来源:UserTrackingOperator.cs

示例9: CheckUserAccount

        /// <summary>
        /// 检查用户帐户状态
        /// </summary>
        /// <param name="account"></param>
        /// <param name="session"></param>
        /// <returns></returns>
        public AccountStatus CheckUserAccount(string account, ISession session)
        {
            AccountStatus retValue = AccountStatus.None;

            session.UsingSafe(s =>
            {
                LockedUser u = s.Get<LockedUser>(account);

                if (null == u)
                    retValue = AccountStatus.Normal;
                else
                    retValue = AccountStatus.Locked;
            });

            return retValue;
        }
开发者ID:JackFong,项目名称:QuantumCode.Web.Security,代码行数:22,代码来源:UserOperator.cs

示例10: UnlockUser

 /// <summary>
 /// 解锁用户账户
 /// </summary>
 /// <param name="useraccount"></param>
 /// <param name="failure"></param>
 /// <param name="success"></param>
 public void UnlockUser(string useraccount, ISession insession, Action<string> failure, Action success)
 {
     insession.UsingSafe(session =>
     {
         session.UsingSafeTransaction((s, f, su) =>
         {
             try
             {
                 _UTOper.ClearUserPasswordInputError(useraccount, s, msg =>
                 {
                     f();
                     failure(msg);
                 },
                 () =>
                 {
                     s.Delete("from LockedUser where UserAccount = '" + useraccount + "'");
                     su();
                     success();
                 });
             }
             catch (Exception eX)
             {
                 f();
                 failure(eX.Message);
             }
         });
     });
 }
开发者ID:JackFong,项目名称:QuantumCode.Web.Security,代码行数:34,代码来源:UserOperator.cs

示例11: LockUser

        /// <summary>
        /// 锁定用户
        /// </summary>
        /// <param name="useraccount"></param>
        /// <param name="lockedType"></param>
        /// <param name="failure"></param>
        /// <param name="success"></param>
        public void LockUser(string useraccount, ISession insession, UserActivities lockedType, Action<string> failure, Action success)
        {
            insession.UsingSafe(session =>
            {
                session.UsingSafeTransaction((s, f, su) =>
                {
                    try
                    {
                        LockedUser lu = new LockedUser()
                        {
                            UserAccount = useraccount,
                            LockedDateTime = DateTime.Now,
                            LockedTypeValue = (int)lockedType
                        };

                        s.Save(lu);
                        su();
                        success();
                    }
                    catch (Exception eX)
                    {
                        f();
                        failure(eX.Message);
                    }
                });
            });
        }
开发者ID:JackFong,项目名称:QuantumCode.Web.Security,代码行数:34,代码来源:UserOperator.cs

示例12: GetUserSecurityInfo

        /// <summary>
        /// 获取账户的安全信息
        /// </summary>
        /// <param name="useraccount"></param>
        /// <param name="success"></param>
        /// <param name="failure"></param>
        public void GetUserSecurityInfo(string useraccount, ISession session, Action<UserSecurityInfo> success, Action<string> failure)
        {
            UserSecurityInfo usi = null;

            session.UsingSafe(s =>
            {
                usi = s.Get<UserSecurityInfo>(useraccount);

                if (null == usi)
                {
                    failure("找不到指定账户的安全信息");
                }
                else
                {
                    success(usi);
                }
            });
        }
开发者ID:JackFong,项目名称:QuantumCode.Web.Security,代码行数:24,代码来源:UserOperator.cs


注:本文中的ISession.UsingSafe方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。