예제 #1
0
        public List <AscmUserInfo> GetList(YnPage ynPage, string sortName, string sortOrder, string queryWord, string whereOther, bool isSetDepartmentPosition = true, bool isLogisticsClassName = true)
        {
            List <AscmUserInfo> list = null;

            try
            {
                string sort = " order by userId ";
                if (!string.IsNullOrEmpty(sortName))
                {
                    sort = " order by " + sortName.Trim() + " ";
                    if (!string.IsNullOrEmpty(sortOrder))
                    {
                        sort += sortOrder.Trim();
                    }
                }
                string sql = "from AscmUserInfo a";
                string where = "", whereQueryWord = "", whereOrganization = " (organizationId=0 or organizationId is null) ";
                if (!string.IsNullOrEmpty(queryWord))
                {
                    whereQueryWord = " (userId like '%" + queryWord.Trim() + "%' or userName like '%" + queryWord.Trim() + "%' or description like '%" + queryWord.Trim() + "%')";
                }
                //if (!string.IsNullOrEmpty(organizationId))
                //    whereOrganization = " a.organizationId=" + organizationId;
                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))
                {
                    sql += " where " + where;
                }
                IList <AscmUserInfo> ilist = null;
                if (ynPage != null)
                {
                    ilist = YnDaoHelper.GetInstance().nHibernateHelper.Find <AscmUserInfo>(sql + sort, sql, ynPage);
                }
                else
                {
                    ilist = YnDaoHelper.GetInstance().nHibernateHelper.Find <AscmUserInfo>(sql + sort);
                }
                if (ilist != null)
                {
                    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);
        }
예제 #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);
        }