public void GetRoomList(int wid, string openid, int hotelId) { AjaxResult ajaxResult; try { GetRoomListResponse responseData = null; IAsyncResult asyncResult = new BusEntry("WeixinPF.Hotel.Plugins").MyBus.Send("WeixinPF.Hotel.Plugins.Service", new GetRoomListRequest() { HotelId = hotelId }) .Register(response => { CompletionResult result = response.AsyncState as CompletionResult; if (result != null) { responseData = result.Messages[0] as GetRoomListResponse; } }, this); WaitHandle asyncWaitHandle = asyncResult.AsyncWaitHandle; asyncWaitHandle.WaitOne(WaitSeconds); ajaxResult = asyncResult.IsCompleted ? AjaxResult.Succeed(responseData.Rooms) : AjaxResult.Fail("获取房间列表失败。"); } catch { ajaxResult = AjaxResult.Fail("获取房间列表失败。"); } this.WriteJson(ajaxResult); }
public void GetHotelInfo(int wid, string openid, int hotelId) { AjaxResult ajaxResult; try { GetHotelResponse responseData = null; IAsyncResult asyncResult = new BusEntry("WeixinPF.Hotel.Plugins").MyBus.Send("WeixinPF.Hotel.Plugins.Service", new GetHotelRequest() { HotelId = hotelId }) .Register(response => { CompletionResult result = response.AsyncState as CompletionResult; if (result != null) { responseData = result.Messages[0] as GetHotelResponse; } }, this); WaitHandle asyncWaitHandle = asyncResult.AsyncWaitHandle; asyncWaitHandle.WaitOne(WaitSeconds); ajaxResult = asyncResult.IsCompleted ? AjaxResult.Succeed(responseData) : AjaxResult.Fail("获取酒店信息失败。"); } catch (Exception ex) { ajaxResult = AjaxResult.Fail("获取酒店信息失败。"); } this.WriteJson(ajaxResult); }
public void GetOrderLastUserInfo(int wid, string openid) { AjaxResult ajaxResult = AjaxResult.Succeed(OrderUserDto.Empty()); try { GetOrderUserInfoResponse responseData = null; IAsyncResult asyncResult = new BusEntry("WeixinPF.Hotel.Plugins").MyBus.Send("WeixinPF.Hotel.Plugins.Service", new GetOrderUserInfoRequest() { OpenId = openid }) .Register(response => { CompletionResult result = response.AsyncState as CompletionResult; if (result != null) { responseData = result.Messages[0] as GetOrderUserInfoResponse; } }, this); WaitHandle asyncWaitHandle = asyncResult.AsyncWaitHandle; asyncWaitHandle.WaitOne(WaitSeconds); if (asyncResult.IsCompleted) { AjaxResult.Succeed(responseData.User); } } catch { //ajaxResult = AjaxResult.Fail("获取房间信息失败。"); } this.WriteJson(ajaxResult); }
protected override void OnStart(string[] args) { var bus = new BusEntry("WeixinPF.Hotel.Plugins.Service"); //加载AutoMapper配置。 //AutoMapperConfiguration.Configure(); Console.WriteLine("Service start"); }
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); }
protected void Application_Start(object sender, EventArgs e) { Bus = new BusEntry("WeixinPF.Hotel.Plugins"); WebApiConfig.Register(GlobalConfiguration.Configuration); }
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); }