public IAsyncResult BeginProcessRequest(HttpContext context, AsyncCallback cb, object extraData) { try { var xlUserName = context.User.Identity.Name; object p1 = context.Request["pageitemcount"]; object p2 = context.Request["pageindex"]; if (p1 == null || p2 == null) { context.Response.Write("0param invalid"); return(null); } int pageitemcount = Convert.ToInt32(p1); int pageindex = Convert.ToInt32(p2); MyGetNotFinishedSellStoneAsyncResult asyncResult = new MyGetNotFinishedSellStoneAsyncResult(context, cb, () => { if (string.IsNullOrEmpty(xlUserName)) { throw new Exception("登录失败"); } return(WcfClient.Instance.GetUserBuyStoneOrders(xlUserName, pageitemcount, pageindex)); }, xlUserName); asyncResult.StartWork(); return(asyncResult); } catch (Exception exc) { LogHelper.Instance.AddErrorLog("AsyncGetBuyStoneRecordHandler.BeginProcessRequest Exception", exc); return(null); } }
public IAsyncResult BeginProcessRequest(HttpContext context, AsyncCallback cb, object extraData) { try { context.Response.ContentType = "text/plain"; context.Response.Cache.SetNoStore(); var xlUserName = context.User.Identity.Name; MyGetNotFinishedSellStoneAsyncResult asyncResult = new MyGetNotFinishedSellStoneAsyncResult(context, cb, () => { if (string.IsNullOrEmpty(xlUserName)) { throw new Exception("登录失败"); } return(WcfClient.Instance.GetAllNotFinishedSellOrders(xlUserName)); }, xlUserName); asyncResult.StartWork(); return(asyncResult); } catch (Exception exc) { LogHelper.Instance.AddErrorLog("AsyncGetSellStoneOrderHandler.BeginProcessRequest Exception", exc); return(null); } }
public void EndProcessRequest(IAsyncResult result) { try { MyGetNotFinishedSellStoneAsyncResult myresult = result as MyGetNotFinishedSellStoneAsyncResult; if (myresult == null) { return; } myresult.Context.Response.ContentType = "text/plain"; myresult.Context.Response.Cache.SetNoStore(); //myresult.Context.Response.Cache.VaryByParams.IgnoreParams = false; //myresult.Context.Response.Cache.SetCacheability(HttpCacheability.Private); //myresult.Context.Response.Cache.SetExpires(DateTime.Now.AddSeconds(10)); if (myresult.Exception != null) { LogHelper.Instance.AddErrorLog("AsyncGetGoldCoinBuyRecordHandler.GetResult Exception", myresult.Exception); myresult.Context.Response.Write("0" + myresult.Exception.Message); return; } string jsonString = ""; if (myresult.Result != null) { GoldCoinRechargeRecord[] orders = myresult.Result as GoldCoinRechargeRecord[]; DataContractJsonSerializer serializer = new DataContractJsonSerializer(orders.GetType()); MemoryStream ms = new MemoryStream(); serializer.WriteObject(ms, orders); jsonString = Encoding.UTF8.GetString(ms.ToArray()); ms.Close(); } myresult.Context.Response.Write("1" + jsonString); } catch (Exception exc) { LogHelper.Instance.AddErrorLog("AsyncGetGoldCoinBuyRecordHandler.EndProcessRequest Exception", exc); } }
public void EndProcessRequest(IAsyncResult result) { try { MyGetNotFinishedSellStoneAsyncResult myresult = result as MyGetNotFinishedSellStoneAsyncResult; if (myresult == null) { return; } myresult.Context.Response.ContentType = "text/plain"; myresult.Context.Response.Cache.SetNoStore(); if (myresult.Exception != null) { LogHelper.Instance.AddErrorLog("AsyncGetBuyStoneRecordHandler.GetResult Exception", myresult.Exception); myresult.Context.Response.Write("0" + myresult.Exception.Message); return; } string jsonString = ""; if (myresult.Result != null) { BuyStonesOrder[] orders = myresult.Result as BuyStonesOrder[]; DataContractJsonSerializer serializer = new DataContractJsonSerializer(orders.GetType()); MemoryStream ms = new MemoryStream(); serializer.WriteObject(ms, orders); jsonString = Encoding.UTF8.GetString(ms.ToArray()); ms.Close(); } myresult.Context.Response.Write("1" + jsonString); } catch (Exception exc) { LogHelper.Instance.AddErrorLog("AsyncGetBuyStoneRecordHandler.EndProcessRequest Exception", exc); } }
public void EndProcessRequest(IAsyncResult result) { try { MyGetNotFinishedSellStoneAsyncResult myresult = result as MyGetNotFinishedSellStoneAsyncResult; if (myresult == null) { return; } myresult.Context.Response.ContentType = "text/plain"; myresult.Context.Response.Cache.VaryByParams.IgnoreParams = false; myresult.Context.Response.Cache.SetCacheability(HttpCacheability.Public); myresult.Context.Response.Cache.SetExpires(DateTime.Now.AddSeconds(5)); if (myresult.Exception != null) { LogHelper.Instance.AddErrorLog("AsyncGetSellStoneOrderHandler.GetResult Exception", myresult.Exception); myresult.Context.Response.Write("0" + myresult.Exception.Message); return; } string jsonString = ""; if (myresult.Result != null) { SellStonesOrder[] orders = myresult.Result as SellStonesOrder[]; Dictionary <string, SellStonesOrder> dicOrders_VipPlayer = new Dictionary <string, SellStonesOrder>(); List <SellStonesOrder> listOrders_NormalPlayer = new List <SellStonesOrder>(); foreach (var item in orders) { if (item.OrderState == SellOrderState.Wait && item.SellerExpLevel > 0) { if (!dicOrders_VipPlayer.ContainsKey(item.SellerUserName)) { dicOrders_VipPlayer.Add(item.SellerUserName, item); continue; } } listOrders_NormalPlayer.Add(item); } var listASC_VipOrders = dicOrders_VipPlayer.Values.OrderByDescending(s => s.SellTime).OrderByDescending(s => s.SellerCreditValue); var listASC_NormalOrders = listOrders_NormalPlayer.OrderByDescending(s => s.SellTime).OrderByDescending(s => s.SellerCreditValue).OrderBy(s => s.OrderStateInt); SellStonesOrder[] listAll = new SellStonesOrder[orders.Length]; int i = 0; foreach (var item in listASC_VipOrders) { listAll[i] = item; i++; } foreach (var item in listASC_NormalOrders) { listAll[i] = item; i++; } DataContractJsonSerializer serializer = new DataContractJsonSerializer(typeof(SellStonesOrder[])); MemoryStream ms = new MemoryStream(); serializer.WriteObject(ms, listAll); jsonString = Encoding.UTF8.GetString(ms.ToArray()); ms.Close(); } myresult.Context.Response.Write("1" + jsonString); } catch (Exception exc) { LogHelper.Instance.AddErrorLog("AsyncGetSellStoneOrderHandler.EndProcessRequest Exception", exc); } }