예제 #1
0
        public CreateOrderResponse Save(CreateOrderRequest request)
        {
            try
            {
                var result = Global.Bus.Send<CreateOrderResponse>(Constants.HotelServiceAddress, request);
                if (!result.IsSuccess)
                {

                    throw new HttpResponseException(
                        Request.CreateErrorResponse(HttpStatusCode.InternalServerError,
                            "保存订失败。"));
                }
                return result.Data;
            }
            catch
            {
                throw new HttpResponseException(
                    Request.CreateErrorResponse(HttpStatusCode.InternalServerError,
                    "保存订失败。"));
            }

        }
예제 #2
0
        public void SaveOrder(int wid, string openid, int hotelId, int roomId, string roomType, string order)
        {
            AjaxResult ajaxResult;
            try
            {
                CreateOrderResponse responseData = null;
                CreateOrderRequest request = new CreateOrderRequest()
                {
                    Wid = wid,
                    OpenId = openid,
                    HotelId = hotelId,
                    RoomId = roomId,
                    RoomType = roomType,
                    Order = JSONHelper.Deserialize<OrderDto>(order)
                };
                IAsyncResult asyncResult = new BusEntry("WeixinPF.Hotel.Plugins").MyBus.Send("WeixinPF.Hotel.Plugins.Service", request)
                        .Register(response =>
                        {
                            CompletionResult result = response.AsyncState as CompletionResult;
                            if (result != null)
                            {
                                responseData = result.Messages[0] as CreateOrderResponse;

                            }
                        }, this);

                WaitHandle asyncWaitHandle = asyncResult.AsyncWaitHandle;
                asyncWaitHandle.WaitOne(WaitSeconds);

                ajaxResult = asyncResult.IsCompleted ?
                          AjaxResult.Succeed(responseData.OrderId) :
                          AjaxResult.Fail("保存订失败。");
            }
            catch
            {
                ajaxResult = AjaxResult.Fail("保存订失败。");
            }

            this.WriteJson(ajaxResult);
        }