Пример #1
0
        public void ProcessRequest(HttpContext context)
        {
            context.Response.ContentType = "application/json";

            long bookId;
            CY.UME.Core.Business.Account account;

            #region -Validation-

            if (!long.TryParse(context.Request.QueryString["bookId"], out bookId) )
            {
                context.Response.Write("{success: false, msg: '参数错误'}");
                return;
            }

            account = CY.UME.Core.Global.GetCurrentAccount();
            if (account==null || account.Id==0)
            {
                context.Response.Write("{success: false, msg: '用户登录失败,请重新登录'}");
                return;
            }
            #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.ArrayOfAnyType2anyTypeMap result = client.getBookLgInfo(bookId);

                context.Response.Clear();
                TimeSpan cacheDuration = TimeSpan.FromHours(1);
                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, bs: ");
                context.Response.Write(Newtonsoft.Json.JavaScriptConvert.SerializeObject(result));
                context.Response.Write("}");
            }
            catch
            {
                context.Response.Write("{success: false, msg: '服务器忙,请稍后再试!'}");
                return;
            }
        }