public ActionResult Post([FromBody] JToken token) { string loginguid = string.Empty; HttpContext.Request.Cookies.TryGetValue("loginguid", out loginguid); string jsonStr = JsonConvert.SerializeObject(token); string action = token.Value <string>("action"); XmlNode node = JsonConvert.DeserializeXmlNode(jsonStr, "OBJ"); XmlGet xmlget = new XmlGet { loginguid = loginguid, action = action, obj = node }; var result = PDMUtils.getExportData(xmlget); // 保存到Session中,然后返回session的key,也就是随机guid string key = Guid.NewGuid().ToString("N"); _cache.Set(key, result); return(Ok(new ResultInfo <string> { code = "0", obj = key })); }
public ResultInfo <XmlResultUserLogin> Authenticate(string username, string password) { ResultInfo <XmlResultUserLogin> result = PDMUtils.login(username, password, "chpdms"); if (result.code != "0") { return(result); } var user = result.obj; // authentication successful so generate jwt token var tokenHandler = new JwtSecurityTokenHandler(); var key = Encoding.ASCII.GetBytes(_jwtSettings.SecretKey); var tokenDescriptor = new SecurityTokenDescriptor { Issuer = _jwtSettings.Issuer, Audience = _jwtSettings.Audience, Subject = new ClaimsIdentity(new Claim[] { new Claim(ClaimTypes.Name, user.username) }), Expires = DateTime.UtcNow.AddDays(_jwtSettings.Expires), SigningCredentials = new SigningCredentials(new SymmetricSecurityKey(key), SecurityAlgorithms.HmacSha256Signature) }; var token = tokenHandler.CreateToken(tokenDescriptor); user.token = tokenHandler.WriteToken(token); return(result); }
public ActionResult Post([FromBody] XmlSet xmlset) { string loginguid = string.Empty; HttpContext.Request.Cookies.TryGetValue("loginguid", out loginguid); xmlset.loginguid = loginguid; var result = PDMUtils.changeRole(xmlset); return(Json(result)); }
public ActionResult Get() { string loginguid = string.Empty; HttpContext.Request.Cookies.TryGetValue("loginguid", out loginguid); XmlGet xmlGet = new XmlGet { loginguid = loginguid }; return(Json(PDMUtils.getMessage(xmlGet))); }
public ActionResult Post([FromBody] JToken token) { string loginguid = string.Empty; HttpContext.Request.Cookies.TryGetValue("loginguid", out loginguid); string jsonStr = JsonConvert.SerializeObject(token); XmlDocument doc = JsonConvert.DeserializeXmlNode(jsonStr, "SET"); XmlElement root = doc.DocumentElement; XmlElement elemLoginguid = doc.CreateElement("LOGINGUID"); elemLoginguid.InnerText = loginguid; root.AppendChild(elemLoginguid); var result = PDMUtils.getString(doc); return(Json(result)); }
public ActionResult Put([FromBody] JToken token) { string loginguid = string.Empty; HttpContext.Request.Cookies.TryGetValue("loginguid", out loginguid); string jsonStr = JsonConvert.SerializeObject(token); XmlNode node = JsonConvert.DeserializeXmlNode(jsonStr, "OBJ"); XmlSet xmlset = new XmlSet { loginguid = loginguid, obj = node }; var result = PDMUtils.modifyFormData(xmlset); return(Json(result)); }
public ActionResult Post([FromBody] JToken token) { string loginguid = string.Empty; HttpContext.Request.Cookies.TryGetValue("loginguid", out loginguid); string jsonStr = JsonConvert.SerializeObject(token); string action = token.Value <string>("action"); XmlNode node = JsonConvert.DeserializeXmlNode(jsonStr, "OBJ"); XmlGet xmlget = new XmlGet { loginguid = loginguid, action = action, obj = node }; var result = PDMUtils.getDataRows(xmlget); return(Json(result)); }
public ActionResult Post([FromBody] JToken token) { string loginguid = string.Empty; HttpContext.Request.Cookies.TryGetValue("loginguid", out loginguid); string jsonStr = JsonConvert.SerializeObject(token); XmlDocument doc = JsonConvert.DeserializeXmlNode(jsonStr, "SET"); XmlElement root = doc.DocumentElement; XmlElement elemLoginguid = doc.CreateElement("LOGINGUID"); elemLoginguid.InnerText = loginguid; root.AppendChild(elemLoginguid); ResultInfo <XmlResultFile> result = PDMUtils.getDownload(doc); // 保存到Session中,然后返回session的key,也就是随机guid string key = Guid.NewGuid().ToString("N"); _cache.Set(key, result); return(Ok(new ResultInfo <string> { code = "0", obj = key })); }