Пример #1
0
        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("}");
        }