Exemple #1
0
        public JsonResult CheckLogin()
        {
            string Account = Request.Form["Account"];          //账户
            string Pwd = Request.Form["Password"];                    //密码
            BASE_USERBLL BASE_USERibll = new BASE_USERBLL();
            BASE_USER BASE_USER = new BASE_USER();
            BASE_COMPANYBLL BASE_COMPANYibll = new BASE_COMPANYBLL();
            BASE_COMPANY BASE_COMPANY = new BASE_COMPANY();
            AMS_SysLogBLL ams_syslogibll = new AMS_SysLogBLL();
            AMS_IPBlacklistBLL ams_ipblacklistibll = new AMS_IPBlacklistBLL();
            IPScanerHelper objScan = new IPScanerHelper();
            string Msg = "";
            #region 登录
            try
            {
                string IPAddress = RequestHelper.GetIPAddress();
                objScan.IP = IPAddress;
                objScan.DataPath = Server.MapPath("../Themes/IPScaner/QQWry.Dat");
                string IPAddressName = objScan.IPLocation();
                //系统管理
                if (Account == ConfigHelper.GetValue("CurrentUserName") && Md5Helper.MD5(Pwd, 32) == ConfigHelper.GetValue("CurrentPassword"))
                {
                    SessionUser user = new SessionUser();
                    user.UserId = "System";
                    user.Account = "System";
                    user.UserName = "******";
                    user.Gender = 1;
                    user.Password = ams_user.Password;
                    user.DepartmentId = "超级管理员";
                    user.DepartmentName = "超级管理员";
                    RequestSession.AddSessionUser(user);
                    Msg = "3";//验证成功
                    ams_syslogibll.AddSysLoginLog(ams_user.Account, "登录成功", IPAddress, IPAddressName);
                }
                else
                {
                    #region 验证
                    ams_ipblacklistibll.TheIpIsRange(IPAddress);
                    string outmsg;
                    ams_user = ams_useribll.UserLogin(Account.Trim(), Pwd.Trim(), out outmsg);
                    if (outmsg != "-1")
                    {
                        if (outmsg == "succeed")
                        {
                            if (ams_user.Enabled == 1)
                            {
                                string DepartmentName = "";
                                ams_organization = ams_organizationibll.GetEntity(ams_user.DepartmentId);
                                if (ams_organization != null)
                                {
                                    DepartmentName = ams_organization.FullName;
                                }
                                SessionUser user = new SessionUser();
                                user.UserId = ams_user.UserId;
                                user.Account = ams_user.Account;
                                user.UserName = ams_user.RealName;
                                user.Gender = ams_user.Gender;
                                user.Password = ams_user.Password;
                                user.Secretkey = ams_user.Secretkey;
                                user.DepartmentId = ams_user.DepartmentId;
                                user.DepartmentName = DepartmentName;
                                RequestSession.AddSessionUser(user);
                                Msg = "3";//验证成功
                                ams_syslogibll.AddSysLoginLog(ams_user.Account, "登录成功", IPAddress, IPAddressName);
                            }
                            else
                            {
                                Msg = "2";//账户锁定
                                ams_syslogibll.AddSysLoginLog(ams_user.Account, "账户锁定", IPAddress, IPAddressName);
                            }
                        }
                        else
                        {
                            Msg = "4";//账户或者密码有错误
                            ams_syslogibll.AddSysLoginLog(ams_user.Account, "登录失败", IPAddress, IPAddressName);
                        }
                    }
                    else if (outmsg == "-1")
                    {
                        Msg = "-1";
                    }
                    else
                    {
                        Msg = DbErrorMsg.ReturnMsg;//服务连接不上
                    }
                    #endregion
                }
            }

            catch (Exception ex)
            {
                Msg = ex.Message;
            }
            #endregion
            return Json(Msg);
        }
Exemple #2
0
 public string Insert_Update(AMS_User user)
 {
     bool IsOk = false;
     if (!string.IsNullOrEmpty(user.UserId))//判断是否编辑
     {
         IsOk = ams_userbll.Update(user);
         if (IsOk) { return ShowMsgHelper.AlertParmCallback(MessageHelper.MSG0006); }
     }
     else
     {
         user.UserId = CommonHelper.GetGuid;
         user.CreateUserId = RequestSession.GetSessionUser().UserId.ToString();
         user.CreateUserName = RequestSession.GetSessionUser().UserName.ToString();
         IsOk = ams_userbll.Insert(user);
         if (IsOk) { return ShowMsgHelper.AlertParmCallback(MessageHelper.MSG0005); }
     }
     if (!IsOk)
         return ShowMsgHelper.Alert_Error(MessageHelper.MSG0022);
     return null;
 }
Exemple #3
0
 /// <summary>
 /// 得到一个对象实体
 /// </summary>
 public void InitControl()
 {
     if (!string.IsNullOrEmpty(_key))
     {
         ams_user = ams_userbll.GetEntity(_key);
         if (ams_user.Gender == 1)
         {
             imgGender = "man.png";
         }
         else
         {
             imgGender = "woman.png";
         }
         strUserInfo = ams_user.RealName + "(" + ams_user.Account + ")";
     }
 }
Exemple #4
0
 /// <summary>
 /// 更新一条数据
 /// </summary>
 /// <param name="entity">实体类</param>
 /// <returns></returns>
 public int UpdateNotLog(AMS_User entity)
 {
     return DbUtils.Update(entity, "UserId");
 }
Exemple #5
0
 /// <summary>
 /// 更新一条数据
 /// </summary>
 /// <param name="entity">实体类</param>
 /// <returns></returns>
 public bool Update(AMS_User entity)
 {
     //return dal.Update(entity) >= 0 ? true : false;
     #region 获取旧值
     var oldEntity = this.GetEntity(AMS_SysLogBLL.Instance.GetKeyFieldValue<AMS_User>(entity).ToString());
     #endregion
     int IsOk = DbUtils.Update(entity, "UserId");
     #region 写日操作日志
     if (IsOk > 0)
     {
         AMS_SysLogBLL.Instance.UpdateTaskLog<AMS_User>(oldEntity, entity, RequestSession.GetSessionUser().UserId, RequestSession.GetSessionUser().UserName);
     }
     #endregion
     return IsOk >= 0 ? true : false;
 }
Exemple #6
0
 /// <summary>
 /// 增加一条数据
 /// </summary>
 /// <param name="entity">实体类</param>
 /// <returns></returns>
 public bool Insert(AMS_User entity)
 {
     //return dal.Insert(entity) >= 0 ? true : false;
     entity.SortCode = CommonHelper.GetInt(this.GetMaxCode());
     int IsOk = DbUtils.Insert(entity);
     #region 写日操作日志
     if (IsOk > 0)
     {
         AMS_SysLogBLL.Instance.AddTaskLog<AMS_User>(entity, RequestSession.GetSessionUser().UserId, RequestSession.GetSessionUser().UserName);
     }
     #endregion
     return IsOk >= 0 ? true : false;
 }