public IHttpActionResult GetUserInfo(GetUserInfoInput input) { Init(); input.AccessToken = ApiSession.AccessToken; GetUserInfoOutput output = _authSvc.GetUserInfo(input); return Ok(output); }
public GetUserInfoOutput GetUserInfo(GetUserInfoInput input) { try { RestHTTP http = new RestHTTP(); RestRequest req = null; if (!string.IsNullOrEmpty(input.Id)) { req = new RestRequest("api/accounts/getUser", RestSharp.Method.POST); } else if (!string.IsNullOrEmpty(input.Username)) { req = new RestRequest("api/accounts/getUserByUsername", RestSharp.Method.POST); } else { return(default(GetUserInfoOutput));; } req.AddHeader("Authorization", "Bearer " + input.AccessToken); req.RequestFormat = DataFormat.Json; req.AddJsonBody(input); var response = http.HttpPost <GetUserInfoOutput>(req); return(response); } catch (Exception ex) { WriteLogFile.Append("GetUserInfo : "); WriteLogFile.Append(ex.Message); WriteLogFile.Append(ex.StackTrace); return(default(GetUserInfoOutput)); } }
public GetUserInfoReturn GetUserInfo([FromBody] GetUserInfoInput input) { base.SetHeader(); GetUserInfoReturn re = new GetUserInfoReturn(); if (this.CheckUserIden(input.CurUserId, input.CurUserIden) == false) { re.Result = false; re.ErrorMsg = "系统检测到非法获取数据,请传入正确的用户会话Key与用户Id参数!"; return(re); } try { re.UserCol = COOrgans.Instance().GetUserByUserIds(input.UserIds); re.UserCol = re.UserCol.OrderBy(t => t.UserName).ToList(); re.Result = true; return(re); } catch (Exception ex) { re.Result = false; re.ErrorMsg = ex.Message.ToString(); return(re); } }
public async Task Execute(GetUserInfoInput input) { var user = await identityService.FindByIdAsync(currentUser.UserId); outputPort.Standart(new GetUserInfoOutput( user.Id, user.Name, user.Surname, user.Email, user.Created, user.LastModified)); }
public async Task <GetUserInfoOutput> GetUserInfo(GetUserInfoInput input) { Expression <Func <User, object> >[] propertySelectors = new Expression <Func <User, object> >[] { e => e.Account }; var user = _userRepository.GetAllIncluding(propertySelectors).FirstOrDefault(e => e.Id == (int)(_abpSession.UserId ?? 0)); if (user == null) { throw new MessageException("未找到当前用户的信息"); } return(new GetUserInfoOutput() { User = AutoMapper.Mapper.Map <UserDto>(user) }); }
public async Task <GetUserInfoOutput> GetUserInfo(GetUserInfoInput input) { Expression <Func <User, object> >[] propertySelectors = new Expression <Func <User, object> >[] { e => e.Account }; var user = _userRepository.GetAllIncluding(propertySelectors).FirstOrDefault(e => e.Id == (int)(_abpSession.UserId ?? 0)); if (user == null) { throw new UserFriendlyException("未找到当前用户的信息"); } var userDto = _objectMapper.Map <UserDto>(user); userDto.Account.Password = null; userDto.Account.SafetyProblem = null; return(new GetUserInfoOutput() { User = userDto }); }
/// <summary> /// Fetches information on authorized user file types and service IDs. /// In case of an error an exception is thrown. /// </summary> /// <returns>JToken. Properties: FileReference, TargetId</returns> public static JToken GetUserInfo(GetUserInfoInput input, CancellationToken cancellationToken) { string customerId = input.CustomerId; string environment = input.Environment; string url = input.Url; var stringParameters = new[] { new KeyValuePair <string, string>("customerId", customerId), }; X509Certificate2 cert = CertificateService.FindCertificate(input.CertificateIssuedBy); Validators.ValidateParameters(url, cert, environment, stringParameters); var env = (Environment)Enum.Parse(typeof(Environment), environment); var message = MessageService.GetUserInfoMessage(cert, customerId, input.TargetId, env, input.RequestId); var result = WebService.CallWebService(url, message, MessageService.SoftwareId, input.ConnectionTimeOutSeconds, cancellationToken); string resultXml = result.Result.Body; var applicationResponse = CheckResultForErrorsAndReturnApplicationResult(resultXml); return(Helper.GetUserInfoFromResponseXml(applicationResponse)); }
public void ProcessRequest(HttpContext context) { try { ApiLoginRequest parm = new ApiLoginRequest(); using (StreamReader sr = new StreamReader(context.Request.InputStream)) { String data = sr.ReadToEnd(); parm = new JavaScriptSerializer().Deserialize <ApiLoginRequest>(data); } ApiLoginResponse ap = new ApiLoginResponse(); using (DLSMEntities db = new DLSMEntities()) { using (var dbContextTransaction = db.Database.BeginTransaction()) { try { var passold = parm.passWord; var bytes = new UTF8Encoding().GetBytes(parm.passWord); var hasBytes = System.Security.Cryptography.MD5.Create().ComputeHash(bytes); var hashpass = Convert.ToBase64String(hasBytes); parm.passWord = hashpass; if (CodeConfig == "1") { _mdmServiceWrapper.AuthenticationUserAsync(new MdmAuthenticationInput()) DLSM.MdmServiceTest.MdmUserServiceClient soap = new DLSM.MdmServiceTest.MdmUserServiceClient(); try { MdmServiceTest.authenUser client = new MdmServiceTest.authenUser(); authenUserBean bean = new authenUserBean(); bean.userId = parm.userName; bean.password = passold; bean.ipAddress = ip; //bean.userId = "3859900089704"; //bean.password = "******"; AuthenticationInput input = new AuthenticationInput(); input.userId = uid; input.password = upw; AuthenUserInput aut = new AuthenUserInput(); aut.authenticationInput = input; aut.authenUserBeanInput = bean; authenUser au = new authenUser(); au.AuthenUserInput = aut; authenUserResponse resp = soap.authenUser(au); if (resp.AuthenUserOutput.authenUserResponse.@return.authenUserResult.ToString() == "True") { try { MdmServiceTest.getUserInfo clientget = new MdmServiceTest.getUserInfo(); getUserInfoBean beanget = new getUserInfoBean(); beanget.authenUserToken = [email protected]; GetUserInfoInput inputget = new GetUserInfoInput(); inputget.getUserInfoBeanInput = beanget; inputget.authenticationInput = input; clientget.GetUserInfoInput = inputget; getUserInfoResponse respget = soap.getUserInfo(clientget); if (respget.GetUserInfoOutput.getUserInfoResponse.@return.name.ToString() != "") { try { GetUserInfo gui = new GetUserInfo(); gui.Title = [email protected]; gui.Name = [email protected]; gui.Surname = [email protected]; gui.OffLocCode = [email protected]; gui.OffLocDesc = [email protected]; gui.OrgFullNameDes = respget.GetUserInfoOutput.getUserInfoResponse.@return.orgFullNameDes; gui.PositionDesc = respget.GetUserInfoOutput.getUserInfoResponse.@return.positionDesc; db.GetUserInfoes.Add(gui); db.SaveChanges(); } catch (Exception ex) { dbContextTransaction.Rollback(); ap.valid_authen = "0"; ap.message = "GetUserInfo Error"; } } else { ap.valid_authen = "0"; ap.message = "getUserInfo Error"; } } catch (Exception ex) { ap.valid_authen = "0"; ap.message = "authenUser Error"; } } else { ap.valid_authen = "0"; ap.message = resp.AuthenUserOutput.authenUserResponse.@return.authenUserResult.ToString(); } } catch (Exception ex) { dbContextTransaction.Rollback(); ap.valid_authen = "0"; ap.message = "authenUser Error"; } } //else //{ // //ไม่วิ่งผ่าน mdmservice // parm.passWord = null; //} } finally { try { var result = db.sp_ApiLogin(parm.userName, parm.passWord, parm.workStationName).ToList(); if (result.Count() > 0) { ap.WH_ID = "" + result[0].WH_ID; ap.userName = result[0].userName; ap.staffId = "" + result[0].staffId; ap.Offname = result[0].OffName; ap.regisIdNumb = result[0].regisIdNumb; ap.regisFirstName = result[0].regisFirstName; ap.regisLastName = result[0].regisLastName; ap.regisFirstNameENG = result[0].regisFirstNameENG; ap.regisLastNameENG = result[0].regisLastNameENG; ap.titleName = result[0].titleName; ap.titleNameENG = result[0].titleNameENG; ap.workstationId = "" + result[0].workstationId; ap.workstationName = result[0].workstationName; ap.officeCode = result[0].officeCode; ap.printerName = result[0].printerName; ap.printerIP = result[0].printerIP; ap.valid_authen = "1"; ap.authorized = "" + result[0].authorized; ap.camaraName = result[0].camaraName; ap.cameraSerialNo = result[0].cameraSerialNo; ap.androidName = result[0].androidName; ap.anroidSerialNo = result[0].anroidSerialNo; ap.signImage = result[0].signImage; ap.message = "OK"; dbContextTransaction.Commit(); } else { dbContextTransaction.Rollback(); ap.valid_authen = "0"; ap.message = "not found"; } } catch (Exception ex) { dbContextTransaction.Rollback(); ap.valid_authen = "0"; ap.message = ex.InnerException == null ? (ex.Message == null ? "Error: Login catch 2" : ex.Message) : ex.InnerException.Message; } } } } string json = new JavaScriptSerializer().Serialize(ap); context.Response.ContentType = "text/javascript"; context.Response.Write(json); } catch (Exception ex) { ApiLoginResponse ap = new ApiLoginResponse(); ap.valid_authen = "0"; ap.message = ex.InnerException == null ? (ex.Message == null ? "Error: Login catch 1" : ex.Message) : ex.InnerException.Message; string json = new JavaScriptSerializer().Serialize(ap); context.Response.ContentType = "text/javascript"; context.Response.Write(json); } }