Ejemplo n.º 1
0
        public IEnumerable<User> SearchUserUnPaged(UserSearchJsonPatch json)
        {
            if (json == null)
                throw new ArgumentNullException(" json is null ");

            IList<Core.Business.User> userlist = new List<Core.Business.User>();
            SqlServerUtility sql = new SqlServerUtility();
            if (!string.IsNullOrEmpty(json.RealName))
            {
                sql.AddParameter("@realname", SqlDbType.NVarChar, json.RealName);
            }

            if (!string.IsNullOrEmpty(json.Name))
            {
                sql.AddParameter("@name", SqlDbType.NVarChar, json.Name);
            }

            if (json.Gender != null)
            {
                if (json.Gender.Value == 1)
                {
                    sql.AddParameter("@gender", SqlDbType.NVarChar, "��");
                }
                else
                {
                    sql.AddParameter("@gender", SqlDbType.NVarChar, "Ů");
                }
            }

            if (json.PostRank != null && json.PostRank.Value != Guid.Empty)
            {
                sql.AddParameter("@postrank", SqlDbType.UniqueIdentifier, json.PostRank.Value);
            }
            if (json.Education != null && json.Education.Value != Guid.Empty)
            {
                sql.AddParameter("@educaion", SqlDbType.UniqueIdentifier, json.Education);
            }
            if (json.StartAge != null)
            {
                sql.AddParameter("@startage", SqlDbType.Int, json.StartAge.Value);
            }
            if (json.EndAge != null)
            {
                sql.AddParameter("@endage", SqlDbType.Int, json.EndAge.Value);
            }
            if (json.IsPhone != null)
            {
                sql.AddParameter("@isphone", SqlDbType.Bit, json.IsPhone);
            }
            if (!string.IsNullOrEmpty(json.Phone))
            {
                sql.AddParameter("@phone", SqlDbType.NVarChar, json.Phone);
            }
            if (json.IsMobile != null)
            {
                sql.AddParameter("@ismobile", SqlDbType.Bit, json.IsMobile.Value);
            }
            if (!string.IsNullOrEmpty(json.Mobile))
            {
                sql.AddParameter("@name", SqlDbType.NVarChar, json.Mobile);
            }

            if (json.IsEmail != null)
            {
                sql.AddParameter("@isemail", SqlDbType.Bit, json.IsEmail.Value);
            }
            if (!string.IsNullOrEmpty(json.Email))
            {
                sql.AddParameter("@email", SqlDbType.NVarChar, json.Email);
            }

            if (json.UserType != null)
            {
                sql.AddParameter("@name", SqlDbType.Int, json.UserType.Value);
            }

            if (json.Unit != null)
            {
                sql.AddParameter("@unit", SqlDbType.UniqueIdentifier, json.Unit.Value);
            }

            if (json.StartRegisterTime != null && json.StartRegisterTime.Value > DateTime.MinValue)
            {
                sql.AddParameter("@startregistertime", SqlDbType.DateTime, json.StartRegisterTime.Value);
            }
            if (json.EndRegisterTime != null && json.EndRegisterTime.Value > DateTime.MinValue && json.EndRegisterTime.Value >= json.StartRegisterTime.Value)
            {
                sql.AddParameter("@endregistertime", SqlDbType.DateTime, json.EndRegisterTime.Value);
            }

            if (!string.IsNullOrEmpty(json.Department))
            {
                sql.AddParameter("@department", SqlDbType.NVarChar, json.Department);
            }
            if (json.Status != null)
            {
                sql.AddParameter("@status", SqlDbType.Int, json.Status.Value);
            }

            SqlDataReader reader = sql.ExecuteSPReader("usp_SelectUserUnPaged");

            if (reader != null)
            {
                while (reader.Read() && !reader.IsClosed)
                {
                    Core.Business.User user = new Core.Business.User();

                    if (!reader.IsDBNull(0)) user.Id = reader.GetGuid(0);
                    if (!reader.IsDBNull(1)) user.UserID = reader.GetString(1);
                    if (!reader.IsDBNull(2)) user.PostRankID = reader.GetGuid(2);
                    if (!reader.IsDBNull(3)) user.EducationID = reader.GetGuid(3);
                    if (!reader.IsDBNull(4)) user.PicURL = reader.GetString(4);
                    if (!reader.IsDBNull(5)) user.Name = reader.GetString(5);
                    if (!reader.IsDBNull(6)) user.Password = reader.GetString(6);
                    if (!reader.IsDBNull(7)) user.Gender = reader.GetString(7);
                    if (!reader.IsDBNull(8)) user.BirthDate = reader.GetDateTime(8);
                    if (!reader.IsDBNull(9)) user.Address = reader.GetString(9);
                    if (!reader.IsDBNull(10)) user.Mailcode = reader.GetString(10);
                    if (!reader.IsDBNull(11)) user.Fax = reader.GetString(11);
                    if (!reader.IsDBNull(12)) user.Phone = reader.GetString(12);
                    if (!reader.IsDBNull(13)) user.MobilePhone = reader.GetString(13);
                    if (!reader.IsDBNull(14)) user.Email = reader.GetString(14);
                    if (!reader.IsDBNull(15)) user.Specialty = reader.GetString(15);
                    if (!reader.IsDBNull(16)) user.Resume = reader.GetString(16);
                    if (!reader.IsDBNull(17)) user.Remark = reader.GetString(17);
                    if (!reader.IsDBNull(18)) user.UnitID = reader.GetGuid(18);
                    if (!reader.IsDBNull(19)) user.UserType = reader.GetInt32(19);
                    if (!reader.IsDBNull(20)) user.Discourse = reader.GetString(20);
                    if (!reader.IsDBNull(21)) user.Acquire = reader.GetString(21);
                    if (!reader.IsDBNull(22)) user.RegDate = reader.GetDateTime(22);
                    if (!reader.IsDBNull(23)) user.LastActiveTime = reader.GetDateTime(23);
                    if (!reader.IsDBNull(24)) user.Status = reader.GetInt32(24);
                    if (!reader.IsDBNull(25)) user.Unit = reader.GetString(25);
                    if (!reader.IsDBNull(26)) user.Duty = reader.GetString(26);
                    if (!reader.IsDBNull(27)) user.FeildID = reader.GetGuid(27);

                    user.MarkOld();
                    userlist.Add(user);
                }
                reader.Close();
            }
            return userlist;
        }
Ejemplo n.º 2
0
        public int GetTotalCount(UserSearchJsonPatch json)
        {
            if (json == null)
                throw new ArgumentNullException(" json  is null ");

            SqlServerUtility sql = new SqlServerUtility();

            if (!string.IsNullOrEmpty(json.RealName))
            {
                sql.AddParameter("@realname", SqlDbType.NVarChar, json.RealName);
            }

            if (!string.IsNullOrEmpty(json.Name))
            {
                sql.AddParameter("@name", SqlDbType.NVarChar, json.Name);
            }

            if (json.Gender != null)
            {
                if (json.Gender.Value == 1)
                {
                    sql.AddParameter("@gender", SqlDbType.NVarChar, "��");
                }
                else
                {
                    sql.AddParameter("@gender", SqlDbType.NVarChar, "Ů");
                }
            }

            if (json.PostRank != null && json.PostRank.Value != Guid.Empty)
            {
                sql.AddParameter("@postrank", SqlDbType.UniqueIdentifier, json.PostRank.Value);
            }
            if (json.Education != null && json.Education.Value != Guid.Empty)
            {
                sql.AddParameter("@educaion", SqlDbType.UniqueIdentifier, json.Education);
            }
            if (json.StartAge != null)
            {
                sql.AddParameter("@startage", SqlDbType.Int, json.StartAge.Value);
            }
            if (json.EndAge != null)
            {
                sql.AddParameter("@endage", SqlDbType.Int, json.EndAge.Value);
            }
            if (json.IsPhone != null)
            {
                sql.AddParameter("@isphone", SqlDbType.Bit, json.IsPhone);
            }
            if (!string.IsNullOrEmpty(json.Phone))
            {
                sql.AddParameter("@phone", SqlDbType.NVarChar, json.Phone);
            }
            if (json.IsMobile != null)
            {
                sql.AddParameter("@ismobile", SqlDbType.Bit, json.IsMobile.Value);
            }
            if (!string.IsNullOrEmpty(json.Mobile))
            {
                sql.AddParameter("@name", SqlDbType.NVarChar, json.Mobile);
            }
            if (json.IsEmail != null)
            {
                sql.AddParameter("@isemail", SqlDbType.Bit, json.IsEmail.Value);
            }
            if (!string.IsNullOrEmpty(json.Email))
            {
                sql.AddParameter("@email", SqlDbType.NVarChar, json.Email);
            }

            if (json.UserType != null)
            {
                sql.AddParameter("@name", SqlDbType.Int, json.UserType.Value);
            }

            if (json.Unit != null)
            {
                sql.AddParameter("@unit", SqlDbType.UniqueIdentifier, json.Unit.Value);
            }

            if (json.StartRegisterTime != null && json.StartRegisterTime.Value > DateTime.MinValue)
            {
                sql.AddParameter("@startregistertime", SqlDbType.DateTime, json.StartRegisterTime.Value);
            }
            if (json.EndRegisterTime != null && json.EndRegisterTime.Value > DateTime.MinValue && json.EndRegisterTime.Value >= json.StartRegisterTime.Value)
            {
                sql.AddParameter("@endregistertime", SqlDbType.DateTime, json.EndRegisterTime.Value);
            }

            if (!string.IsNullOrEmpty(json.Department))
            {
                sql.AddParameter("@department", SqlDbType.NVarChar, json.Department);
            }

            if (json.Status != null)
            {
                sql.AddParameter("@status", SqlDbType.Int, json.Status.Value);
            }

            int totalCount = 0;

            SqlDataReader reader = sql.ExecuteSPReader("usp_SelectUserTotalCount");

            if (reader != null)
            {
                while (reader.Read() && !reader.IsClosed)
                {
                    if (!reader.IsDBNull(0)) totalCount = reader.GetInt32(0);
                }
                reader.Close();
            }
            return totalCount;
        }