Esempio n. 1
0
        //数据持久化
        internal static void  SaveToDb(OpProRoleInfo pOpProRoleInfo, OpProRole pOpProRole, bool pIsNew)
        {
            pOpProRole.OpProRoleId = pOpProRoleInfo.opProRoleId;
            pOpProRole.OperationId = pOpProRoleInfo.operationId;
            pOpProRole.ProcessId   = pOpProRoleInfo.processId;
            pOpProRole.RoleId      = pOpProRoleInfo.roleId;
            pOpProRole.IsNew       = pIsNew;
            string UserName = SubsonicHelper.GetUserName();

            try
            {
                pOpProRole.Save(UserName);
            }
            catch (Exception ex)
            {
                LogManager.getInstance().getLogger(typeof(OpProRoleInfo)).Error(ex);
                if (ex.Message.Contains("插入重复键"))               //违反了唯一键
                {
                    throw new AppException("此对象已经存在");          //此处等待优化可以从唯一约束中直接取出提示来,如果没有的话,默认为原始的出错提示
                }
                throw new AppException("保存失败");
            }
            pOpProRoleInfo.opProRoleId = pOpProRole.OpProRoleId;
            //如果缓存存在,更新缓存
            if (CachedEntityCommander.IsTypeRegistered(typeof(OpProRoleInfo)))
            {
                ResetCache();
            }
        }
Esempio n. 2
0
        /// <summary>
        /// 获得分页列表,无论是否是缓存实体都从数据库直接拿取数据
        /// </summary>
        /// <param name="pPageIndex">页数</param>
        /// <param name="pPageSize">每页列表</param>
        /// <param name="pOrderBy">排序</param>
        /// <param name="pSortExpression">排序字段</param>
        /// <param name="pRecordCount">列表行数</param>
        /// <returns>数据分页</returns>
        public static List <OpProRoleInfo> GetPagedList(int pPageIndex, int pPageSize, SortDirection pOrderBy, string pSortExpression, out int pRecordCount)
        {
            if (pPageIndex <= 1)
            {
                pPageIndex = 1;
            }
            List <OpProRoleInfo> list = new List <OpProRoleInfo>();

            Query q = OpProRole.CreateQuery();

            q.PageIndex = pPageIndex;
            q.PageSize  = pPageSize;
            q.ORDER_BY(pSortExpression, pOrderBy.ToString());
            OpProRoleCollection collection = new  OpProRoleCollection();

            collection.LoadAndCloseReader(q.ExecuteReader());

            foreach (OpProRole opProRole  in collection)
            {
                OpProRoleInfo opProRoleInfo = new OpProRoleInfo();
                LoadFromDAL(opProRoleInfo, opProRole);
                list.Add(opProRoleInfo);
            }
            pRecordCount = q.GetRecordCount();

            return(list);
        }
Esempio n. 3
0
        /// <summary>
        /// 获得数据列表
        /// </summary>
        /// <returns></returns>
        public static List <OpProRoleInfo> GetList()
        {
            string cacheKey = GetCacheKey();

            //本实体已经注册成缓存实体,并且缓存存在的时候,直接从缓存取
            if (CachedEntityCommander.IsTypeRegistered(typeof(OpProRoleInfo)) && CachedEntityCommander.GetCache(cacheKey) != null)
            {
                return(CachedEntityCommander.GetCache(cacheKey) as List <OpProRoleInfo>);
            }
            else
            {
                List <OpProRoleInfo> list       = new List <OpProRoleInfo>();
                OpProRoleCollection  collection = new  OpProRoleCollection();
                Query qry = new Query(OpProRole.Schema);
                collection.LoadAndCloseReader(qry.ExecuteReader());
                foreach (OpProRole opProRole in collection)
                {
                    OpProRoleInfo opProRoleInfo = new OpProRoleInfo();
                    LoadFromDAL(opProRoleInfo, opProRole);
                    list.Add(opProRoleInfo);
                }
                //生成缓存
                if (CachedEntityCommander.IsTypeRegistered(typeof(OpProRoleInfo)))
                {
                    CachedEntityCommander.SetCache(cacheKey, list);
                }
                return(list);
            }
        }
Esempio n. 4
0
 /// <summary>
 /// 复制一个对象,采用硬编码的方式,避免反射的低效
 /// </summary>
 /// <param name="pIndustryTypeInfoFrom"></param>
 /// <param name="pIndustryTypeInfoTo"></param>
 public static void Copy(OpProRoleInfo pOpProRoleInfoFrom, OpProRoleInfo pOpProRoleInfoTo)
 {
     pOpProRoleInfoTo.OpProRoleId = pOpProRoleInfoFrom.opProRoleId;
     pOpProRoleInfoTo.OperationId = pOpProRoleInfoFrom.operationId;
     pOpProRoleInfoTo.ProcessId   = pOpProRoleInfoFrom.processId;
     pOpProRoleInfoTo.RoleId      = pOpProRoleInfoFrom.roleId;
     pOpProRoleInfoTo.Loaded      = pOpProRoleInfoFrom.Loaded;
 }
Esempio n. 5
0
 //从后台获取数据
 internal static void  LoadFromDAL(OpProRoleInfo pOpProRoleInfo, OpProRole pOpProRole)
 {
     pOpProRoleInfo.opProRoleId = pOpProRole.OpProRoleId;
     pOpProRoleInfo.operationId = pOpProRole.OperationId;
     pOpProRoleInfo.processId   = pOpProRole.ProcessId;
     pOpProRoleInfo.roleId      = pOpProRole.RoleId;
     pOpProRoleInfo.Loaded      = true;
 }
Esempio n. 6
0
 /// <summary>
 /// 批量装载
 /// </summary>
 internal static void LoadFromDALPatch(List <OpProRoleInfo> pList, OpProRoleCollection pCollection)
 {
     foreach (OpProRole opProRole in pCollection)
     {
         OpProRoleInfo opProRoleInfo = new OpProRoleInfo();
         LoadFromDAL(opProRoleInfo, opProRole);
         pList.Add(opProRoleInfo);
     }
 }
Esempio n. 7
0
        public OpProRoleInfo GetOpProRoleInfoById(int OpProRoleId)
        {
            OpProRoleInfo opProRoleInfo = null;             //

            try
            {
                opProRoleInfo = new OpProRoleInfo(OpProRoleId);
            }
            catch (AppException)
            {
                return(null);
            }

            return(opProRoleInfo);
        }
Esempio n. 8
0
        public OpProRoleInfo GetOpProRoleInfoById(int OpProRoleId)
        {
            OpProRoleInfo opProRoleInfo  = null;//
            try
            {
                 opProRoleInfo = new OpProRoleInfo(OpProRoleId);

            }
            catch (AppException)
            {
                return null;
            }

            return  opProRoleInfo;
        }
Esempio n. 9
0
        protected void AddOperationRole(int roleid,int processid, CheckBoxList ckl)
        {
            for (int i = 0; i < ckl.Items.Count; i++)
            {
                if (ckl.Items[i].Selected && !RoleInfo.IsOperationRole(roleid,processid,Convert.ToInt32(ckl.Items[i].Value)))
                {

                        OpProRoleInfo opr = new OpProRoleInfo();
                        opr.OperationId = Convert.ToInt32(ckl.Items[i].Value);
                        opr.RoleId = roleid;
                        opr.ProcessId = processid;
                        opr.Save();
                }
                else if (!ckl.Items[i].Selected && RoleInfo.IsOperationRole(roleid, processid, Convert.ToInt32(ckl.Items[i].Value)))
                {
                    RoleInfo.DelOperation(processid, roleid, Convert.ToInt32(ckl.Items[i].Value));
                }
            }
        }
Esempio n. 10
0
 private void LoadFromId(int opProRoleId)
 {
     if (CachedEntityCommander.IsTypeRegistered(typeof(OpProRoleInfo)))
     {
         OpProRoleInfo opProRoleInfo = Find(GetList(), opProRoleId);
         if (opProRoleInfo == null)
         {
             throw new AppException("未能在缓存中找到相应的键值对象");
         }
         Copy(opProRoleInfo, this);
     }
     else
     {
         OpProRole opProRole = new OpProRole(opProRoleId);
         if (opProRole.IsNew)
         {
             throw new AppException("尚未初始化");
         }
         LoadFromDAL(this, opProRole);
     }
 }
Esempio n. 11
0
        /// <summary>
        /// 获得分页列表,无论是否是缓存实体都从数据库直接拿取数据
        /// </summary>
        /// <param name="pPageIndex">页数</param>
        /// <param name="pPageSize">每页列表</param>
        /// <param name="pOrderBy">排序</param>
        /// <param name="pSortExpression">排序字段</param>
        /// <param name="pRecordCount">列表行数</param>
        /// <returns>数据分页</returns>
        public static List<OpProRoleInfo> GetPagedList(int pPageIndex,int pPageSize,SortDirection pOrderBy,string pSortExpression,out int pRecordCount)
        {
            if(pPageIndex<=1)
            pPageIndex=1;
            List< OpProRoleInfo> list = new List< OpProRoleInfo>();

            Query q = OpProRole .CreateQuery();
            q.PageIndex = pPageIndex;
            q.PageSize = pPageSize;
            q.ORDER_BY(pSortExpression,pOrderBy.ToString());
            OpProRoleCollection  collection=new  OpProRoleCollection();
             	collection.LoadAndCloseReader(q.ExecuteReader());

            foreach (OpProRole  opProRole  in collection)
            {
                OpProRoleInfo opProRoleInfo = new OpProRoleInfo();
                LoadFromDAL(opProRoleInfo,   opProRole);
                list.Add(opProRoleInfo);
            }
            pRecordCount=q.GetRecordCount();

            return list;
        }
Esempio n. 12
0
        public void DeleteById(OpProRoleInfo pOpProRoleInfo)
        {
            OpProRoleInfo opProRoleInfo = new OpProRoleInfo(pOpProRoleInfo.OpProRoleId);

            opProRoleInfo.Delete();
        }
Esempio n. 13
0
 public object SaveOpProRoleInfo(OpProRoleInfo opProRoleInfo)
 {
     opProRoleInfo.Save();
     return opProRoleInfo . OpProRoleId;
 }
Esempio n. 14
0
 public List <OpProRoleInfo> GetPagedList(int pPageIndex, int pPageSize, SortDirection pOrderBy, string pSortExpression, out int pRecordCount)
 {
     return(OpProRoleInfo.GetPagedList(pPageIndex, pPageSize, pOrderBy, pSortExpression, out pRecordCount));
 }
Esempio n. 15
0
 public List <OpProRoleInfo> GetOpProRoleInfoList()
 {
     return(OpProRoleInfo.GetList());
 }
Esempio n. 16
0
 //数据持久化
 internal static void SaveToDb(OpProRoleInfo pOpProRoleInfo, OpProRole  pOpProRole,bool pIsNew)
 {
     pOpProRole.OpProRoleId = pOpProRoleInfo.opProRoleId;
      		pOpProRole.OperationId = pOpProRoleInfo.operationId;
      		pOpProRole.ProcessId = pOpProRoleInfo.processId;
      		pOpProRole.RoleId = pOpProRoleInfo.roleId;
     pOpProRole.IsNew=pIsNew;
     string UserName = SubsonicHelper.GetUserName();
     try
     {
         pOpProRole.Save(UserName);
     }
     catch(Exception ex)
     {
         LogManager.getInstance().getLogger(typeof(OpProRoleInfo)).Error(ex);
         if(ex.Message.Contains("插入重复键"))//违反了唯一键
         {
             throw new AppException("此对象已经存在");//此处等待优化可以从唯一约束中直接取出提示来,如果没有的话,默认为原始的出错提示
         }
         throw new AppException("保存失败");
     }
     pOpProRoleInfo.opProRoleId = pOpProRole.OpProRoleId;
     //如果缓存存在,更新缓存
     if (CachedEntityCommander.IsTypeRegistered(typeof(OpProRoleInfo)))
     {
         ResetCache();
     }
 }
Esempio n. 17
0
 public object  SaveOpProRoleInfo(OpProRoleInfo opProRoleInfo)
 {
     opProRoleInfo.Save();
     return(opProRoleInfo.OpProRoleId);
 }
Esempio n. 18
0
 /// <summary>
 /// 批量装载
 /// </summary>
 internal static void LoadFromDALPatch(List< OpProRoleInfo> pList, OpProRoleCollection pCollection)
 {
     foreach (OpProRole opProRole in pCollection)
     {
         OpProRoleInfo opProRoleInfo = new OpProRoleInfo();
         LoadFromDAL(opProRoleInfo, opProRole );
         pList.Add(opProRoleInfo);
     }
 }
Esempio n. 19
0
 //从后台获取数据
 internal static void LoadFromDAL(OpProRoleInfo pOpProRoleInfo, OpProRole  pOpProRole)
 {
     pOpProRoleInfo.opProRoleId = pOpProRole.OpProRoleId;
      		pOpProRoleInfo.operationId = pOpProRole.OperationId;
      		pOpProRoleInfo.processId = pOpProRole.ProcessId;
      		pOpProRoleInfo.roleId = pOpProRole.RoleId;
     pOpProRoleInfo.Loaded=true;
 }
Esempio n. 20
0
 /// <summary>
 /// 复制一个对象,采用硬编码的方式,避免反射的低效
 /// </summary>
 /// <param name="pIndustryTypeInfoFrom"></param>
 /// <param name="pIndustryTypeInfoTo"></param>
 public static void Copy(OpProRoleInfo pOpProRoleInfoFrom, OpProRoleInfo pOpProRoleInfoTo)
 {
     pOpProRoleInfoTo.OpProRoleId = pOpProRoleInfoFrom.opProRoleId;
      		pOpProRoleInfoTo.OperationId = pOpProRoleInfoFrom.operationId;
      		pOpProRoleInfoTo.ProcessId = pOpProRoleInfoFrom.processId;
      		pOpProRoleInfoTo.RoleId = pOpProRoleInfoFrom.roleId;
     pOpProRoleInfoTo.Loaded=pOpProRoleInfoFrom.Loaded;
 }
Esempio n. 21
0
 /// <summary>
 /// 复制为另一个对象
 /// </summary>
 /// <param name="pIndustryTypeInfoTo"></param>
 public void CopyTo(OpProRoleInfo pOpProRoleInfoTo)
 {
     Copy(this, pOpProRoleInfoTo);
 }
Esempio n. 22
0
 /// <summary>
 /// 获得数据列表
 /// </summary>
 /// <returns></returns>
 public static List<OpProRoleInfo> GetList()
 {
     string cacheKey = GetCacheKey();
     //本实体已经注册成缓存实体,并且缓存存在的时候,直接从缓存取
     if (CachedEntityCommander.IsTypeRegistered(typeof(OpProRoleInfo)) && CachedEntityCommander.GetCache(cacheKey) != null)
     {
         return CachedEntityCommander.GetCache(cacheKey) as List< OpProRoleInfo>;
     }
     else
     {
         List< OpProRoleInfo>  list =new List< OpProRoleInfo>();
         OpProRoleCollection  collection=new  OpProRoleCollection();
         Query qry = new Query(OpProRole.Schema);
         collection.LoadAndCloseReader(qry.ExecuteReader());
         foreach(OpProRole opProRole in collection)
         {
             OpProRoleInfo opProRoleInfo= new OpProRoleInfo();
             LoadFromDAL(opProRoleInfo,opProRole);
             list.Add(opProRoleInfo);
         }
       	//生成缓存
         if (CachedEntityCommander.IsTypeRegistered(typeof(OpProRoleInfo)))
         {
             CachedEntityCommander.SetCache(cacheKey, list);
         }
         return list;
     }
 }
Esempio n. 23
0
 /// <summary>
 /// 复制为另一个对象
 /// </summary>
 /// <param name="pIndustryTypeInfoTo"></param>
 public void CopyTo(OpProRoleInfo pOpProRoleInfoTo)
 {
     Copy(this,  pOpProRoleInfoTo);
 }
Esempio n. 24
0
 public void DeleteById(OpProRoleInfo pOpProRoleInfo)
 {
     OpProRoleInfo opProRoleInfo = new OpProRoleInfo(pOpProRoleInfo.OpProRoleId);
     opProRoleInfo.Delete();
 }