Example #1
0
        /// <summary>
        /// 分页获取数据字典
        /// </summary>
        /// <param name="page"></param>
        /// <param name="rowCount"></param>
        /// <param name="roleName"></param>
        /// <param name="createDate"></param>
        /// <param name="totalCount"></param>
        /// <returns></returns>
        public IList <D_Dictionary_Model> GetAllByPage(int startCount, int rowCount, DicTypeEnum?dicType, string dicName, string createDate, out int totalCount)
        {
            ICriteria ic = NhSession.CreateCriteria(typeof(D_Dictionary_Model));

            if (!string.IsNullOrEmpty(dicName))
            {
                ic.Add(Restrictions.Like("DicName", dicName, MatchMode.Anywhere));
            }

            if (!string.IsNullOrEmpty(createDate))
            {
                ic.Add(Restrictions.Le("CreateDateTime", createDate));
            }
            if (dicType.HasValue)
            {
                ic.Add(Restrictions.Eq("DicType", dicType));
            }

            ic.Add(Restrictions.Eq("DataStatus", false));

            ICriteria pageCrit = CriteriaTransformer.Clone(ic);

            totalCount = Convert.ToInt32(pageCrit.SetProjection(Projections.RowCount()).UniqueResult());

            ic.AddOrder(new Order("Ord", false));

            IList <D_Dictionary_Model> list = ic.SetFirstResult(startCount).SetMaxResults(rowCount).List <D_Dictionary_Model>();

            return(list);
        }
Example #2
0
        /// <summary>
        /// 获取所有用户角色信息
        /// </summary>
        /// <returns></returns>
        public IList <D_Role_Model> GetAll()
        {
            ICriteria            ic   = NhSession.CreateCriteria(typeof(D_Role_Model));
            IList <D_Role_Model> list = ic.List <D_Role_Model>() ?? new List <D_Role_Model>();

            return(list);
        }
Example #3
0
        public IList <D_User_Model> GetUserByUserLoginName(List <string> UserLoginName)
        {
            ICriteria ic = NhSession.CreateCriteria(typeof(D_User_Model));

            ic.Add(Restrictions.In("UserLoginName", UserLoginName));
            return(ic.List <D_User_Model>());
        }
Example #4
0
        public IList <D_Board_User_Role_Model> GetModelListByUser(D_User_Model userModel)
        {
            ICriteria ic = NhSession.CreateCriteria(typeof(D_Board_User_Role_Model));;

            ic.Add(Restrictions.Eq("UserGuid", userModel));
            //IList<D_Board_User_Role_Model> list = ic.List<D_Board_User_Role_Model>();
            return(ic.List <D_Board_User_Role_Model>());
        }
Example #5
0
        /// <summary>
        /// 获取所有用户角色权限
        /// </summary>
        /// <returns></returns>
        public IList <D_Role_Permissions_Model> GetRole_Permissions_ByRole(D_Role_Model role)
        {
            ICriteria ic = NhSession.CreateCriteria(typeof(D_Role_Permissions_Model));

            ic.Add(Restrictions.Eq("RoleGuid", role));
            ic.Add(Restrictions.Eq("DataStatus", false));
            IList <D_Role_Permissions_Model> list = ic.List <D_Role_Permissions_Model>() ?? new List <D_Role_Permissions_Model>();

            return(list);
        }
Example #6
0
        public D_User_Model GetUserByUserLoginName(string userLoginName)
        {
            ICriteria ic = NhSession.CreateCriteria(typeof(D_User_Model));

            ic.Add(Restrictions.Eq("UserLoginName", userLoginName));
            ic.Add(Restrictions.Eq("DataStatus", false));
            D_User_Model model = ic.UniqueResult <D_User_Model>();

            return(model);
        }
Example #7
0
        public D_Board_User_Role_Model GetOne(D_Board_Model boardModel, D_User_Model userModel, D_Role_Model roleModel)
        {
            ICriteria ic = NhSession.CreateCriteria(typeof(D_Board_User_Role_Model));

            ic.Add(Restrictions.Eq("BoardGuid", boardModel));
            ic.Add(Restrictions.Eq("UserGuid", userModel));
            ic.Add(Restrictions.Eq("RoleGuid", roleModel));
            return(ic.List <D_Board_User_Role_Model>().SingleOrDefault());
            //IList<D_Board_User_Role_Model> list = ic.List<D_Board_User_Role_Model>();
            //return list.FirstOrDefault<D_Board_User_Role_Model>();
        }
Example #8
0
        /// <summary>
        /// 获取字典值通过数据字典枚举
        /// </summary>
        /// <returns></returns>
        public IList <D_Dictionary_Model> GetDictionaryByDicType(DicTypeEnum dicType)
        {
            ICriteria ic = NhSession.CreateCriteria(typeof(D_Dictionary_Model));

            ic.Add(Restrictions.Eq("DicType", dicType));

            ic.Add(Restrictions.Eq("DataStatus", false));

            IList <D_Dictionary_Model> list = ic.List <D_Dictionary_Model>() ?? new List <D_Dictionary_Model>();

            return(list);
        }
Example #9
0
        public IList <D_WorkFlowLog_Model> GetAllByPage(int startCount, int rowCount, D_Report_Model reportModel, out int totalCount)
        {
            ICriteria ic = NhSession.CreateCriteria(typeof(D_WorkFlowLog_Model));

            ic.Add(Restrictions.Eq("ReportGuid", reportModel));

            ICriteria pageCrit = CriteriaTransformer.Clone(ic);

            totalCount = Convert.ToInt32(pageCrit.SetProjection(Projections.RowCount()).UniqueResult());

            IList <D_WorkFlowLog_Model> list = ic.SetFirstResult(startCount).SetMaxResults(rowCount).List <D_WorkFlowLog_Model>();

            return(list);
        }
Example #10
0
        /// <summary>
        /// 分页获取板块
        /// </summary>
        /// <param name="page"></param>
        /// <param name="rowCount"></param>
        /// <param name="roleName"></param>
        /// <param name="createDate"></param>
        /// <param name="totalCount"></param>
        /// <returns></returns>
        public IList <D_Board_User_Role_Model> GetAllByPage(int startCount, int rowCount, Model.D_Board_Model boardModel, out int totalCount)
        {
            ICriteria ic = NhSession.CreateCriteria(typeof(D_Board_User_Role_Model));

            ic.Add(Restrictions.Eq("BoardGuid", boardModel));

            //if (!string.IsNullOrEmpty(createDate))
            //    ic.Add(Restrictions.Le("CreateDateTime", createDate));

            ICriteria pageCrit = CriteriaTransformer.Clone(ic);

            totalCount = Convert.ToInt32(pageCrit.SetProjection(Projections.RowCount()).UniqueResult());

            ic.AddOrder(Order.Desc("CreateDateTime"));

            IList <D_Board_User_Role_Model> list = ic.SetFirstResult(startCount).SetMaxResults(rowCount).List <D_Board_User_Role_Model>();

            return(list);
        }
Example #11
0
        /// <summary>
        /// 分页获取报表列表
        /// </summary>
        /// <param name="page"></param>
        /// <param name="rowCount"></param>
        /// <param name="roleName"></param>
        /// <param name="createDate"></param>
        /// <param name="totalCount"></param>
        /// <returns></returns>
        public IList <D_Report_Model> GetAllByPage(int startCount, int rowCount, List <Model.D_Board_Model> boardModel, string reportNo, string createDate, out int totalCount)
        {
            ICriteria ic = NhSession.CreateCriteria(typeof(D_Report_Model));

            if (boardModel != null)
            {
                if (boardModel.Count > 0)
                {
                    ic.Add(Restrictions.In("ReportBoardGuid", boardModel));
                }
                else
                {
                    ic.Add(Restrictions.IsNull("ReportBoardGuid"));
                }
            }
            else
            {
                ic.Add(Restrictions.IsNull("ReportBoardGuid"));
            }

            if (!string.IsNullOrEmpty(reportNo))
            {
                ic.Add(Restrictions.Like("ReportNo", reportNo, MatchMode.Anywhere));
            }

            if (!string.IsNullOrEmpty(createDate))
            {
                ic.Add(Restrictions.Le("CreateDateTime", createDate));
            }

            ic.Add(Restrictions.Eq("DataStatus", false));

            ICriteria pageCrit = CriteriaTransformer.Clone(ic);

            totalCount = Convert.ToInt32(pageCrit.SetProjection(Projections.RowCount()).UniqueResult());

            ic.AddOrder(Order.Desc("ModifyDateTime"));
            IList <D_Report_Model> list = ic.SetFirstResult(startCount).SetMaxResults(rowCount).List <D_Report_Model>();

            return(list);
        }
Example #12
0
        public IList <D_User_Model> GetAllByPage(int page, int rowCount, string userName, string userCode, string departmentName,
                                                 string userLoginName, string createDate, out int totalCount)
        {
            ICriteria ic = NhSession.CreateCriteria(typeof(D_User_Model));

            if (!string.IsNullOrEmpty(userName))
            {
                ic.Add(Restrictions.Like("UserName", userName, MatchMode.Anywhere));
            }

            if (!string.IsNullOrEmpty(userCode))
            {
                ic.Add(Restrictions.Like("UserCode", userCode, MatchMode.Anywhere));
            }

            if (!string.IsNullOrEmpty(userLoginName))
            {
                ic.Add(Restrictions.Like("UserLoginName", userLoginName, MatchMode.Anywhere));
            }

            if (!string.IsNullOrEmpty(departmentName))
            {
                ic.Add(Restrictions.Like("DepartmentName", departmentName, MatchMode.Anywhere));
            }

            if (!string.IsNullOrEmpty(createDate))
            {
                ic.Add(Restrictions.Le("CreateDateTime", createDate));
            }

            ic.Add(Restrictions.Eq("DataStatus", false));

            ICriteria pageCrit = CriteriaTransformer.Clone(ic);

            totalCount = Convert.ToInt32(pageCrit.SetProjection(Projections.RowCount()).UniqueResult());

            IList <D_User_Model> list = ic.SetFirstResult(page * rowCount).SetMaxResults(rowCount).List <D_User_Model>();

            return(list);
        }
Example #13
0
 public virtual IEnumerable <TEntidade> Lista()
 {
     return(NhSession.CreateCriteria <TEntidade>().List <TEntidade>());
 }
Example #14
0
        public ActionResult Role_Permission_Edit()
        {
            bool   success     = false;
            string roleGuid    = Request.Form["RoleGuid"];
            string permissions = Request.Form[2].ToString();

            string[] permission = permissions.Split(',');
            using (NHibernate.ITransaction tran = NhSession.BeginTransaction())
            {
                try
                {
                    Guid RoleGuid           = new Guid(roleGuid);
                    Model.D_Role_Model role = NhSession.Get <Model.D_Role_Model>(RoleGuid);
                    ICriteria          ic   = NhSession.CreateCriteria(typeof(Model.D_Role_Permissions_Model));
                    ic.Add(Restrictions.Eq("RoleGuid", role));
                    IList <Model.D_Role_Permissions_Model> rolePermissionList = ic.List <Model.D_Role_Permissions_Model>();

                    foreach (var item in rolePermissionList)
                    {
                        item.DataStatus     = true;
                        item.ModifyDateTime = DateTime.Now;
                        item.ModifyUserGuid = UserView.UserGuid;
                        item.ModifyUserName = UserView.UserName;
                        NhSession.Update(item);
                    }

                    foreach (var item in permission)
                    {
                        Model.D_Role_Permissions_Model rolePermission = rolePermissionList.SingleOrDefault(m => m.Permissions == item);
                        if (rolePermission == null)
                        {
                            rolePermission = new Model.D_Role_Permissions_Model();
                            rolePermission.CreateDateTime = DateTime.Now;
                            rolePermission.CreateUserGuid = UserView.UserGuid;
                            rolePermission.CreateUserName = UserView.UserName;
                            rolePermission.RoleGuid       = role;
                            rolePermission.Permissions    = item;
                        }

                        rolePermission.DataStatus     = false;
                        rolePermission.ModifyDateTime = DateTime.Now;
                        rolePermission.ModifyUserGuid = UserView.UserGuid;
                        rolePermission.ModifyUserName = UserView.UserName;

                        NhSession.SaveOrUpdate(rolePermission);
                    }
                    tran.Commit();
                    return(Json(new { success = success, message = "成功" }, JsonRequestBehavior.AllowGet));
                }
                catch (Exception ex)
                {
                    return(Json(new { success = success, message = ex.Message }));
                }
                finally
                {
                    if (!tran.WasCommitted && !tran.WasRolledBack)
                    {
                        tran.Rollback();
                    }
                }
            }
        }