public void ProcessRequest(HttpContext context) { context.Response.ContentType = "application/json"; long bookId; CY.UME.Core.Business.Account account; #region -Validation- account = CY.UME.Core.Global.GetCurrentAccount(); if (account == null || account.Id == 0) { context.Response.Write("{success:false,msg:'用户登录失败,请重新登录'}"); return; } if (!long.TryParse(context.Request.QueryString["bookId"], out bookId)) { context.Response.Write("{success: false, msg: '参数错误'}"); return; } #endregion CY.UME.Core.Business.University university = account.UniversityInfo; if (university == null) { context.Response.Write("{success:false,msg:'用户不存在'}"); return; } string url = university.LibServicesAddress; if (url.Trim().Length == 0) { context.Response.Write("{success: false, msg: '请求服务不存在'}"); return; } UMEService.UMEServicePortTypeClient client = new CY.UME.Web.UMEService.UMEServicePortTypeClient(new BasicHttpBinding(),new EndpointAddress(url)); UMEService.anyType2anyTypeMap result = client.getBookBasicInfo(bookId); context.Response.Clear(); TimeSpan cacheDuration = TimeSpan.FromDays(10); context.Response.Cache.SetCacheability(HttpCacheability.Public); context.Response.Cache.SetExpires(DateTime.Now.Add(cacheDuration)); context.Response.Cache.SetMaxAge(cacheDuration); context.Response.Cache.AppendCacheExtension("must-revalidate, proxy-revalidate"); context.Response.Write("{success: true, book: "); context.Response.Write(Newtonsoft.Json.JavaScriptConvert.SerializeObject(result)); context.Response.Write("}"); }
public void ProcessRequest(HttpContext context) { context.Response.ContentType = "text/plain"; CY.UME.Core.Business.Account account; string pwd = string.Empty; #region -Validation and Get Basic Info- account = CY.UME.Core.Global.GetCurrentAccount(); if (account == null) { context.Response.Write("{success: false, msg: '用户登录超时,请重新登录!'}"); return; } if (string.IsNullOrEmpty(context.Request.Form["pwd"])) { context.Response.Write("{success: false, msg: '参数错误!'}"); return; } pwd = context.Request.Form["pwd"]; #endregion try { CY.UME.Core.Business.University university = account.UniversityInfo; if (university == null) { context.Response.Write("{success:false,msg:'用户不存在'}"); return; } string url = university.LibServicesAddress; if (url.Trim().Length == 0) { context.Response.Write("{success: false, msg: '请求服务不存在'}"); return; } UMEService.UMEServicePortTypeClient client = new CY.UME.Web.UMEService.UMEServicePortTypeClient(new BasicHttpBinding(), new EndpointAddress(url)); UMEService.anyType2anyTypeMap result = client.getUserinfoByLogin(account.Code, pwd); if (result.Count != 7) // error { context.Response.Write("{success: false, msg: '绑定失败,用户名密码不正确'}"); return; } else { long libId; for (int i = result.Count - 1; i > -1; i--) { if (result[i].key.ToString().ToLower() == "id") { if (long.TryParse(result[i].value.ToString(), out libId)) { account.ExtendInfo.LibUserId = libId; account.ExtendInfo.Save(); } break; } } } StringBuilder sb = new StringBuilder(); sb.Append("{success: true}"); context.Response.Write(sb.ToString()); } catch { context.Response.Clear(); context.Response.Write("{success: false, msg: '服务器忙,请稍后再试'}"); } }