예제 #1
0
        //数据持久化
        internal static void  SaveToDb(RoleMasterInfo pRoleMasterInfo, RoleMaster pRoleMaster, bool pIsNew)
        {
            pRoleMaster.RoleMasterId = pRoleMasterInfo.roleMasterId;
            pRoleMaster.RoleId       = pRoleMasterInfo.roleId;
            pRoleMaster.MasterId     = pRoleMasterInfo.masterId;
            pRoleMaster.IsPass       = pRoleMasterInfo.isPass;
            pRoleMaster.IsNew        = pIsNew;
            string UserName = SubsonicHelper.GetUserName();

            try
            {
                pRoleMaster.Save(UserName);
            }
            catch (Exception ex)
            {
                LogManager.getInstance().getLogger(typeof(RoleMasterInfo)).Error(ex);
                if (ex.Message.Contains("插入重复键"))               //违反了唯一键
                {
                    throw new AppException("此对象已经存在");          //此处等待优化可以从唯一约束中直接取出提示来,如果没有的话,默认为原始的出错提示
                }
                throw new AppException("保存失败");
            }
            pRoleMasterInfo.roleMasterId = pRoleMaster.RoleMasterId;
            //如果缓存存在,更新缓存
            if (CachedEntityCommander.IsTypeRegistered(typeof(RoleMasterInfo)))
            {
                ResetCache();
            }
        }
예제 #2
0
 //数据持久化
 internal static void SaveToDb(RoleMasterInfo pRoleMasterInfo, RoleMaster  pRoleMaster,bool pIsNew)
 {
     pRoleMaster.RoleMasterId = pRoleMasterInfo.roleMasterId;
      		pRoleMaster.RoleId = pRoleMasterInfo.roleId;
      		pRoleMaster.MasterId = pRoleMasterInfo.masterId;
      		pRoleMaster.IsPass = pRoleMasterInfo.isPass;
     pRoleMaster.IsNew=pIsNew;
     string UserName = SubsonicHelper.GetUserName();
     try
     {
         pRoleMaster.Save(UserName);
     }
     catch(Exception ex)
     {
         LogManager.getInstance().getLogger(typeof(RoleMasterInfo)).Error(ex);
         if(ex.Message.Contains("插入重复键"))//违反了唯一键
         {
             throw new AppException("此对象已经存在");//此处等待优化可以从唯一约束中直接取出提示来,如果没有的话,默认为原始的出错提示
         }
         throw new AppException("保存失败");
     }
     pRoleMasterInfo.roleMasterId = pRoleMaster.RoleMasterId;
     //如果缓存存在,更新缓存
     if (CachedEntityCommander.IsTypeRegistered(typeof(RoleMasterInfo)))
     {
         ResetCache();
     }
 }