public static DataTable SearchUser(XiHuan_UserSearchFilter f, out int rowcount) { int minId = f.PageIndex * f.PageSize; int maxId = (f.PageIndex + 1) * f.PageSize + 1; string sql = @"DECLARE @indextable table(Id int identity(1,1) PRIMARY KEY,uid int); insert into @indextable(uid) select Id from XiHuan_UserInfo with(nolock) where IsLocked=0 {0}; select @@ROWCOUNT; select {1} from XiHuan_UserInfo u with(nolock) inner join @indextable t on u.Id=t.uid and t.Id>{2} and t.Id<{3} "; StringBuilder sqlwhere = new StringBuilder(""); if (f.UserName.Trim().Length > 0) { sqlwhere.AppendFormat(" AND UserName like'%{0}%' ", ValidatorHelper.SafeSql(f.UserName.Trim())); } if (f.ProvinceId != int.MaxValue) { sqlwhere.AppendFormat(" AND ProvinceId={0} ", f.ProvinceId); } if (f.CityId != int.MaxValue) { sqlwhere.AppendFormat(" AND CityId={0} ", f.CityId); } if (f.AreaId != int.MaxValue) { sqlwhere.AppendFormat(" AND AreaId={0} ", f.AreaId); } if (f.SchooId != int.MaxValue) { sqlwhere.AppendFormat(" AND SchoolId={0} ", f.SchooId); } if (f.IsStartUser != int.MaxValue) { sqlwhere.AppendFormat(" AND IsStarUser={0} ", f.IsStartUser); } if (f.Gender != int.MaxValue) { sqlwhere.AppendFormat(" AND Gender={0} ", f.Gender); } if (f.IsHavePhoto != int.MaxValue) { sqlwhere.Append(" AND HeadImage <> 'images/nophoto.gif'"); } if (f.CreateDateBegin != DateTime.MinValue) { sqlwhere.AppendFormat(" AND RegisterDate>='{0}' ", f.CreateDateBegin); } if (f.CreateDateEnd != DateTime.MaxValue) { sqlwhere.AppendFormat(" AND RegisterDate<'{0}' ", f.CreateDateEnd.AddDays(1)); } DataSet ds = Query.ProcessMultiSql(string.Format(sql, sqlwhere.ToString() + " order by " + f.OrderByParam, f.SelectFileds, minId, maxId), GlobalVar.DataBase_Name); rowcount = CommonMethodFacade.ConvertToInt(ds.Tables[0].Rows[0][0], 0); return(ds.Tables[1]); }
public static DataTable GetUserRequire(XiHuan_ChangeRequireSearchFilter f) { string sql = "select * from XiHuan_UserGoodsChangeRequire with(nolock) where 1=1 "; if (f.GoodsId != int.MaxValue) { sql += string.Format(" and GoodsId={0} ", f.GoodsId); } if (f.OwnerId != int.MaxValue) { sql += string.Format(" and OwnerId={0} ", f.OwnerId); } if (f.SenderId != int.MaxValue) { sql += string.Format(" and SenderId={0} ", f.SenderId); } if (f.OwnerName.Trim().Length > 0) { sql += string.Format(" and OwnerName={0} ", ValidatorHelper.SafeSql(f.OwnerName.Trim())); } if (f.GoodsName.Trim().Length > 0) { sql += string.Format(" and GoodsName like '%{0}%' ", ValidatorHelper.SafeSql(f.GoodsName.Trim())); } if (f.SenderName.Trim().Length > 0) { sql += string.Format(" and SenderName like '%{0}%' ", ValidatorHelper.SafeSql(f.SenderName.Trim())); } if (f.RequireType != int.MaxValue) { sql += string.Format(" and RequireType={0} ", f.RequireType); } if (f.Flag != int.MaxValue) { sql += string.Format(" and Flag={0} ", f.Flag); } if (f.Flags.Trim().Length > 0) { sql += string.Format(" and Flag in({1}) ", f.Flags.Trim()); } if (f.RequireDateBegin != DateTime.MinValue) { sql += string.Format(" and RequireDate>='{0}' ", f.RequireDateBegin); } if (f.RequireDateEnd != DateTime.MaxValue) { sql += string.Format(" and RequireDate<'{1}' ", f.RequireDateEnd.AddDays(1)); } return(Query.ProcessSql(sql + " order by RequireDate desc; ", GlobalVar.DataBase_Name)); }
/// <summary> /// 发送邮件 /// </summary> /// <param name="maito">接收人,多个接收人,用逗号隔开</param> /// <param name="subject">标题</param> /// <param name="body">内容</param> public static void sendEmail(string maito, string subject, string body) { //发邮件的账号 string mailsender = CommonMethodFacade.GetConfigValue("EmailSender"); //显示的账号名称 string maildisplayname = CommonMethodFacade.GetConfigValue("EmailDisplayName"); //使用的SMTP主机 string mailhost = CommonMethodFacade.GetConfigValue("EmailSmtpHost"); // 账号密码 string mailpwd = CommonMethodFacade.GetConfigValue("EmailSmtpPassword"); System.Net.Mail.MailMessage msg = new System.Net.Mail.MailMessage(); msg.From = new MailAddress(mailsender, maildisplayname, Encoding.UTF8); string[] mailto = maito.Split(';'); MailAddressCollection addcollection = new MailAddressCollection(); for (int i = 0; i < mailto.Length; i++) { if (ValidatorHelper.IsEmail(mailto[i])) { msg.To.Add(new MailAddress(mailto[i])); } } msg.Subject = subject; msg.Body = body; msg.IsBodyHtml = true; //设置正文是否为html格式的值 msg.Priority = System.Net.Mail.MailPriority.High; //设置此邮件具有高优先级 SmtpClient smtp = new SmtpClient(mailhost); //允许应用程序使用SMTP发邮件 smtp.Credentials = new System.Net.NetworkCredential(mailsender, mailpwd); //设置验证发件人的凭据(邮件服务器需要身份验证) smtp.Timeout = 60 * 1000; //设定超时时间为1分钟 try { smtp.Send(msg); //发信 msg.Dispose(); //释放有MailMessage使用的所有资源 } catch { } }
public static bool IsUserValid(string uname, string upass) { uname = CommonMethodFacade.FinalString(uname); upass = CommonMethodFacade.FinalString(upass); if (uname.Length > 0 && upass.Length > 0) { string sqlLogin = @"UPDATE XiHuan_UserInfo SET LastLoginTime=getdate(), Score=Score+(CASE WHEN LastLoginTime<'{0}' THEN {1} ELSE 0 END ) WHERE UserName='******' AND OrignalPwd='{3}' ;"; int effcount = Query.ProcessSqlNonQuery(string.Format(sqlLogin, DateTime.Now.ToString("yyyy-MM-dd"), SystemConfigFacade.Instance().LoginAddScore(), ValidatorHelper.SafeSql(uname), ValidatorHelper.SafeSql(upass)), GlobalVar.DataBase_Name); return(effcount > 0); } else { return(false); } }