Beispiel #1
0
 /// <summary>
 /// 登录
 /// </summary>
 /// <param name="Email"></param>
 /// <param name="PassWord"></param>
 /// <returns></returns>
 public Sys_User CheckLogin(string Email, string PassWord)
 {
     try
     {
         Sys_User entity = null;
         //MongoDb取
         entity = Mongo.FindSingleIndex<Sys_User>(a => a.Email == Email);
         if (entity == null)
         {
             //redis取
             try
             {
                 entity = Redis.RedisString.Value.StringGet<Sys_User>(Email);
             }
             catch (Exception)
             {
             }
         }
         if (entity == null)
         {
             //数据库取
             string sql = "select Id,UserName,Password,email from Sys_User as a where a.Email ='{0}' and  a.PassWord ='******'";
             string select = string.Format(sql, Email, PassWord);
             entity = context.user.SqlQuery(select).FirstOrDefault();
         }
         return entity;
     }
     catch (Exception e)
     {
         return null;
     }
 }