示例#1
0
        //查询某角色所属部门用户@2014/5/5
        public List <AscmUserInfo> GetList(YnPage ynPage, string sortName, string sortOrder, string queryWord, string whereOther)
        {
            List <AscmUserInfo> list = null;

            try
            {
                string hql = "select u.* from YnDepartmentPositionUserLink l, YnPosition p, YnUser u";

                string sort = " order by u.userId ";
                if (!string.IsNullOrEmpty(sortName))
                {
                    sort = " order by " + sortName.Trim() + " ";
                    if (!string.IsNullOrEmpty(sortOrder))
                    {
                        sort += sortOrder.Trim();
                    }
                }

                string where = "", whereQueryWord = "", whereOrganization = " (u.organizationId=0 or u.organizationId is null) ";

                whereQueryWord = "p.id = l.positionId";
                where          = YnBaseClass2.Helper.StringHelper.SqlWhereAndAdd(where, whereQueryWord);

                whereQueryWord = "u.userId = l.userId";
                where          = YnBaseClass2.Helper.StringHelper.SqlWhereAndAdd(where, whereQueryWord);

                if (!string.IsNullOrEmpty(queryWord))
                {
                    whereQueryWord = "u.userId like '" + queryWord + "%' or u.userName like '" + queryWord + "%'";
                    where          = YnBaseClass2.Helper.StringHelper.SqlWhereAndAdd(where, whereQueryWord);
                }
                where = YnBaseClass2.Helper.StringHelper.SqlWhereAndAdd(where, whereOther);
                where = YnBaseClass2.Helper.StringHelper.SqlWhereAndAdd(where, whereOrganization);

                if (!string.IsNullOrEmpty(where))
                {
                    hql += " where " + where;
                }

                NHibernate.ISQLQuery query = YnDaoHelper.GetInstance().nHibernateHelper.FindBySQLQuery(hql);
                IList <AscmUserInfo> ilist = query.AddEntity("u", typeof(AscmUserInfo)).List <AscmUserInfo>();
                if (ilist != null && ilist.Count > 0)
                {
                    list = YnBaseClass2.Helper.ConvertHelper.ConvertIListToList <AscmUserInfo>(ilist);
                    List <YnFrame.Dal.Entities.YnUser> list1 = new List <YnFrame.Dal.Entities.YnUser>();
                    foreach (AscmUserInfo ascmUserInfo in list)
                    {
                        list1.Add((YnFrame.Dal.Entities.YnUser)ascmUserInfo);
                    }
                }
            }
            catch (Exception ex)
            {
                YnBaseClass2.Helper.LogHelper.GetLog().Error("查询失败(Find YnUser)", ex);
                throw ex;
            }

            return(list);
        }
示例#2
0
        //查询所属部门用户@2014/4/25
        public List <AscmUserInfo> GetList(YnPage ynPage, string sortName, string sortOrder, string queryWord, string whereOther, string departName, bool isSetDepartmentPosition = true, bool isLogisticsClassName = true)
        {
            List <AscmUserInfo> list = null;

            try
            {
                string hql = "select u.* from YnUser u, YnDepartmentPositionUserLink l, YnDepartment d";

                string sort = " order by u.userId ";
                if (!string.IsNullOrEmpty(sortName))
                {
                    sort = " order by " + sortName.Trim() + " ";
                    if (!string.IsNullOrEmpty(sortOrder))
                    {
                        sort += sortOrder.Trim();
                    }
                }

                string where = "", whereQueryWord = "", whereOrganization = " (u.organizationId=0 or u.organizationId is null) ";

                whereQueryWord = "l.departmentId = d.id";
                where          = YnBaseClass2.Helper.StringHelper.SqlWhereAndAdd(where, whereQueryWord);

                whereQueryWord = "l.userId = u.userId";
                where          = YnBaseClass2.Helper.StringHelper.SqlWhereAndAdd(where, whereQueryWord);

                if (!string.IsNullOrEmpty(departName))
                {
                    whereQueryWord = "d.name = '" + departName + "'";
                    where          = YnBaseClass2.Helper.StringHelper.SqlWhereAndAdd(where, whereQueryWord);
                }

                if (!string.IsNullOrEmpty(queryWord))
                {
                    whereQueryWord = " (u.userId like '%" + queryWord.Trim() + "%' or u.userName like '%" + queryWord.Trim() + "%' or u.description like '%" + queryWord.Trim() + "%')";
                    where          = YnBaseClass2.Helper.StringHelper.SqlWhereAndAdd(where, whereQueryWord);
                }

                where = YnBaseClass2.Helper.StringHelper.SqlWhereAndAdd(where, whereOther);
                where = YnBaseClass2.Helper.StringHelper.SqlWhereAndAdd(where, whereOrganization);

                if (!string.IsNullOrEmpty(where))
                {
                    hql += " where " + where;
                }
                //string hql_Param = hql.Replace("u.*", "count(u.userId)");
                //object obj = YnFrame.Dal.YnDaoHelper.GetInstance().nHibernateHelper.GetObjectBySQL(hql_Param);
                //int count = 0;
                //int.TryParse(obj.ToString(), out count);

                //IList<AscmUserInfo> ilist = YnDaoHelper.GetInstance().nHibernateHelper.Find<AscmUserInfo>(hql, count, ynPage);
                NHibernate.ISQLQuery query = YnDaoHelper.GetInstance().nHibernateHelper.FindBySQLQuery(hql);
                IList <AscmUserInfo> ilist = query.AddEntity("u", typeof(AscmUserInfo)).List <AscmUserInfo>();
                if (ilist != null && ilist.Count > 0)
                {
                    list = YnBaseClass2.Helper.ConvertHelper.ConvertIListToList <AscmUserInfo>(ilist);
                    List <YnFrame.Dal.Entities.YnUser> list1 = new List <YnFrame.Dal.Entities.YnUser>();
                    foreach (AscmUserInfo ascmUserInfo in list)
                    {
                        list1.Add((YnFrame.Dal.Entities.YnUser)ascmUserInfo);
                    }
                    //YnFrame.Services.YnUserService.GetInstance().SetRole(list1);
                    if (isSetDepartmentPosition)
                    {
                        YnFrame.Services.YnUserService.GetInstance().SetDepartmentPosition(list1);
                    }

                    if (isLogisticsClassName)
                    {
                        AscmUserInfoService.GetInstance().SetUserLogisticsClass(list);
                    }
                }
            }
            catch (Exception ex)
            {
                YnBaseClass2.Helper.LogHelper.GetLog().Error("查询失败(Find YnUser)", ex);
                throw ex;
            }

            return(list);
        }