Beispiel #1
0
 public ActionResult Index(Model.UserAdmin UserAdmin)
 {
     Business.Sys_UserAdmin Sys_UserAdmin = new Business.Sys_UserAdmin();
     UserAdmin.PassWord = Utility.ChangeText.md5(UserAdmin.PassWord);
     UserAdmin          = Sys_UserAdmin.AdminLogin(UserAdmin);
     if (UserAdmin != null)
     {
         if (UserAdmin.IsEnable == 1)
         {
             ViewBag.LoginError = "您的账号已经被禁止使用";
             return(View());
         }
         //登录成功
         Session["UsersId"] = UserAdmin.ID;
         //Session["OpenId"] = UserAdmin.OpenId;//没有openid的,赋值"",更新也是""。
         Session["UserName"] = UserAdmin.UserName;
         Session["RealName"] = UserAdmin.RealName;
         Session["RoleCode"] = UserAdmin.RoleCode;
         if (string.IsNullOrEmpty(UserAdmin.OpenId))
         {
             Sys_UserAdmin.UpdateOpenId(Session["OpenId"] != null ? Session["OpenId"].ToString() : "", UserAdmin.ID);
         }
         //记录日志  跳转界面
         Business.Sys_UsersLoginLog Sys_Userlog = new Business.Sys_UsersLoginLog();
         Model.UsersLoginLog        model       = new Model.UsersLoginLog();
         model.UsersId   = UserAdmin.ID.ToString();
         model.UserName  = UserAdmin.UserName;
         model.RealName  = UserAdmin.RealName;
         model.LoginTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
         System.DateTime currentTime = DateTime.Now;
         model.Year  = currentTime.Year.ToString();
         model.Month = currentTime.Month.ToString();
         model.Day   = currentTime.Day.ToString();
         Sys_Userlog.InsertUsersLoginLog(model);
         //return RedirectToAction("Index", "MMIndex");//跳转到首页。
         if (!string.IsNullOrEmpty(Request["ArrangementId"]))
         {
             return(RedirectToAction("GetArrangementInfo", "MMain", new { ArrangementId = Request["ArrangementId"] }));
         }
         else
         {
             return(RedirectToAction("Index", "MMIndex"));//跳转到首页。
         }
     }
     ViewBag.LoginError = "账号或密码错误";
     return(View());
 }
Beispiel #2
0
        /// <summary>
        /// 修改一条登录日志
        /// </summary>
        /// <param name="UserAdmin"></param>
        /// <returns></returns>
        public bool UpdateLoginLog(Model.UsersLoginLog UserAdmin)
        {
            const string sql = @"UPDATE UsersLoginLog SET UsersId=@UsersId,Year=@Year,Month=@Month,
PhoneNum=@PhoneNum,RoleName=@RoleName,Day=@Day,LoginTime=@LoginTime,Content=@Content WHERE ID=@ID";

            return(Factory.DBHelper.ExecSQL(SQLConString, sql.ToString(), new DynamicParameters(new
            {
                UserAdmin.UsersId,
                UserAdmin.Year,
                UserAdmin.Month,
                UserAdmin.PhoneNum,
                UserAdmin.Day,
                UserAdmin.LoginTime,
                UserAdmin.Content,
                UserAdmin.ID,
            })));
        }
Beispiel #3
0
        /// <summary>
        /// 添加一条登录日志
        /// </summary>
        /// <param name="UserAdmin"></param>
        /// <returns></returns>
        public bool InsertUsersLoginLog(Model.UsersLoginLog UserAdmin)
        {
            const string sql =
                @"INSERT INTO UsersLoginLog(UsersId,Year,Month,PhoneNum,Day,LoginTime,Content) VALUES(
@UsersId,@Year,@Month,@PhoneNum,@Day,@LoginTime,@Content)";

            return(Factory.DBHelper.ExecSQL(SQLConString, sql.ToString(), new DynamicParameters(new
            {
                UserAdmin.UsersId,
                UserAdmin.Year,
                UserAdmin.Month,
                UserAdmin.PhoneNum,
                UserAdmin.Day,
                UserAdmin.LoginTime,
                UserAdmin.Content,
            })));
        }
Beispiel #4
0
 public ActionResult GetCode()
 {
     try
     {
         string code = Request["code"];
         Business.Sys_UserAdmin Sys_UserAdmin = new Business.Sys_UserAdmin();
         string          OpenId    = WxHelper.WxMain.Getopenid(code);
         Model.UserAdmin UserAdmin = Sys_UserAdmin.GetUserAdminByOpendId(OpenId);
         Session["OpenId"] = OpenId;
         if (UserAdmin != null && UserAdmin.RoleCode != "Tourist")
         {
             Session["UsersId"]  = UserAdmin.ID;
             Session["UserName"] = UserAdmin.UserName;
             Session["RealName"] = UserAdmin.RealName;
             Session["RoleCode"] = UserAdmin.RoleCode;
             //记录登录日志
             Business.Sys_UsersLoginLog Sys_Userlog = new Business.Sys_UsersLoginLog();
             Model.UsersLoginLog        model       = new Model.UsersLoginLog();
             model.UsersId   = UserAdmin.ID.ToString();
             model.UserName  = UserAdmin.UserName;
             model.RealName  = UserAdmin.RealName;
             model.LoginTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
             System.DateTime currentTime = DateTime.Now;
             model.Year  = currentTime.Year.ToString();
             model.Month = currentTime.Month.ToString();
             model.Day   = currentTime.Day.ToString();
             Sys_Userlog.InsertUsersLoginLog(model);
             //if (Request["way"] == "Arrangement")
             //{
             //  string gzhurl = "https://mp.weixin.qq.com/mp/profile_ext?action=home&__biz=" + System.Configuration.ConfigurationManager.AppSettings["WxAppId"] + "&scene=110#wechat_redirect";
             // string result=Utility.PostData.GetData(gzhurl);
             // Utility.Log.WriteTextLog("微信自动关注公众号", "result", result , "gzhurl", gzhurl);
             return(RedirectToAction("GetArrangementInfo", "MMain", new { ArrangementId = Request["id"] }));
             //}
             // else
             //{
             //  return RedirectToAction("Index", "MMIndex");
             //}
         }
         else // if (Request["way"] == "Arrangement" )
         {
             //string gzhurl = "https://mp.weixin.qq.com/mp/profile_ext?action=home&__biz=" + System.Configuration.ConfigurationManager.AppSettings["WxAppId"] + "&scene=110#wechat_redirect";
             //string result = Utility.PostData.GetData(gzhurl);
             //Utility.Log.WriteTextLog("微信自动关注公众号", "result", result, "gzhurl", gzhurl);
             if (UserAdmin == null)
             {
                 #region 旧逻辑
                 //System.Random Random = new System.Random();
                 //int Result = Random.Next(0, 9999);
                 //Business.Sys_Role Sys_Role = new Business.Sys_Role();
                 //Model.RoleInfo RoleInfo = Sys_Role.GetRoleInfoByRoleCode("Tourist");
                 ////写入一条记录 标识为游客
                 //Model.UserAdmin UserAdminTourist = new Model.UserAdmin();
                 //UserAdminTourist.UserName = "******" + Result.ToString() + DateTime.Now.ToString("yyyy-MM-dd");
                 //UserAdminTourist.PassWord = Utility.ChangeText.md5("123456");
                 //UserAdminTourist.IsEnable = 0;
                 //UserAdminTourist.OpenId = OpenId;
                 //UserAdminTourist.RoleCode = RoleInfo.RoleCode;
                 //UserAdminTourist.RoleName = RoleInfo.RoleName;
                 //UserAdminTourist.RealName = "游客未知";
                 //Session["UsersId"] = Sys_UserAdmin.InsertUserAdminGetId(UserAdminTourist);
                 //Session["UserName"] = UserAdminTourist.UserName;
                 //Session["RealName"] = UserAdminTourist.RealName;
                 //Session["RoleCode"] = UserAdminTourist.RoleCode;
                 ////记录登录日志
                 //Business.Sys_UsersLoginLog Sys_Userlog = new Business.Sys_UsersLoginLog();
                 //Model.UsersLoginLog model = new Model.UsersLoginLog();
                 //model.UsersId = UserAdmin.ID.ToString();
                 //model.UserName = UserAdmin.UserName;
                 //model.RealName = UserAdmin.RealName;
                 //model.LoginTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
                 //System.DateTime currentTime = DateTime.Now;
                 //model.Year = currentTime.Year.ToString();
                 //model.Month = currentTime.Month.ToString();
                 //model.Day = currentTime.Day.ToString();
                 //Sys_Userlog.InsertUsersLoginLog(model);
                 //return RedirectToAction("GetArrangementInfo", "MMain", new { ArrangementId = Request["id"]});
                 #endregion
                 return(RedirectToAction("Index", "MLogin", new { ArrangementId = Request["id"] }));
             }
             #region 旧逻辑
             //if (UserAdmin.RoleCode=="Tourist")
             //{
             //    Session["UsersId"] = UserAdmin.ID;
             //    Session["UserName"] = UserAdmin.UserName;
             //    Session["RealName"] = UserAdmin.RealName;
             //    Session["RoleCode"] = UserAdmin.RoleCode;
             //    //记录登录日志
             //    Business.Sys_UsersLoginLog Sys_Userlog = new Business.Sys_UsersLoginLog();
             //    Model.UsersLoginLog model = new Model.UsersLoginLog();
             //    model.UsersId = UserAdmin.ID.ToString();
             //    model.UserName = UserAdmin.UserName;
             //    model.RealName = UserAdmin.RealName;
             //    model.LoginTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
             //    System.DateTime currentTime = DateTime.Now;
             //    model.Year = currentTime.Year.ToString();
             //    model.Month = currentTime.Month.ToString();
             //    model.Day = currentTime.Day.ToString();
             //    Sys_Userlog.InsertUsersLoginLog(model);
             //    return RedirectToAction("GetArrangementInfo", "MMain", new { ArrangementId = Request["id"] });
             //}
             #endregion
         }
         return(RedirectToAction("Index", "MLogin"));
     }
     catch (Exception ex)
     {
         Utility.Log.WriteTextLog("微信自动登陆异常", "", "", "", ex.ToString());
         return(null);
     }
 }