Exemplo n.º 1
0
        public ContentResult ToEditPDAUser(FormCollection userform)
        {
            int     ID      = int.Parse(userform["UserId"].ToString());
            PDAUser pdauser = PDAUser.GetEntityByID(ID);

            pdauser.Password   = userform["Password"].ToString();
            pdauser.PRealName  = userform["PRealName"].ToString();
            pdauser.Remark     = userform["Remark"].ToString();
            pdauser.SupplierID = userform["SupplierID"] != null?int.Parse(userform["SupplierID"]) : 0;

            int iRet = pdauser.UpdateByID();

            if (iRet > 0)
            {
                return(Content("ok"));
            }
            else
            {
                return(Content("添加失败!"));
            }
        }
Exemplo n.º 2
0
        public RequestResult Login(string DeviceCode, string UserName, string Password)
        {
            RequestResult result = new RequestResult();

            try
            {
                PDA pda = PDA.GetEntityByKeys(DeviceCode);
                if (pda == null)
                {
                    result.code    = 1009;
                    result.message = "该设备验证不通过,禁止访问服务器";
                    result.success = false;

                    PDALog.Write("用户登录", "登录", "", UserName, string.Format("DeviceCode:{0}", DeviceCode), result.message);
                    return(result);
                }

                PDAUser user = PDAUser.PDAUserLogin(UserName, Password);
                if (user == null)
                {
                    result.message = "用户名或密码错误";
                    result.success = false;

                    PDALog.Write("用户登录", "登录", "", UserName, string.Format("DeviceCode:{0}", DeviceCode), result.message);
                    return(result);
                }

                string IsUserToken = PDAUserMsg.PDAUserLogin(DeviceCode, UserName);     // 验证重复登录

                CachePDAUser muser = new CachePDAUser();
                muser.DeviceCode = DeviceCode;
                muser.UserID     = user.ID;
                muser.UserName   = user.PUserName;
                muser.Timestamp  = CommonFunc.GetNowMTimestamp();
                muser.UserToken  = string.IsNullOrEmpty(IsUserToken) ? PDAUserMsg.CreateUserToken() : IsUserToken;
                //muser.AuthCodeList = B_RoleRights.GetEntitysByRoleID(user.C_UserTypeID);  // 权限控制

                PDAUserMsg.CacheMobileUserList.Add(muser);

                UserLoginInfo UserInfo = new UserLoginInfo();
                UserInfo.UserToken  = muser.UserToken;
                UserInfo.ExpireDate = DateTime.Now.AddHours(20).ToString("yyyy-MM-dd HH:mm:ss");

                result.data      = UserInfo;
                result.timestamp = CommonFunc.GetNowTimestamp();
                result.message   = "登录成功";
                result.success   = true;

                user.LastLoginTime  = DateTime.Now;
                user.LastLoginDCode = DeviceCode;
                user.UpdateByID();

                PDALog.Write("用户登录", "登录", "", user.PUserName + "-" + user.PRealName, string.Format("DeviceCode:{0}", DeviceCode), result.message);
            }
            catch (Exception ex)
            {
                result.code    = 500;
                result.message = "服务出错";
                result.success = false;
                DAL.Log.Instance.Write("PDA登录出错:" + ex.Message, "PDA登录出错");
            }

            return(result);
        }