void OnGetOrderTypeListRequest(IMessage msg, SessionEventArgs e) { var state = OrderTypeOptState.Failed; IList <OrderType> orderTypeList = null; if (e.Session.SessionId != null) { try { orderTypeList = _orderTypeBll.GetList(); state = OrderTypeOptState.Successed; } catch (Exception ex) { ErrorLog(msg.Header.Type, ex); } } else { state = OrderTypeOptState.InvalidOpt; } e.Session.Send(new DataResponse <OrderTypeOptState, IList <OrderType> > { State = state, Data = orderTypeList }, MessageType.GetOrderTypeListResponse); }
void LoadOrderType() { _orderTypeBll.GetList(response => { string info = string.Empty; switch (response.State) { case OrderTypeOptState.CannotConnectServer: info = "服务器连接失败,未能获订单类别信息!"; break; case OrderTypeOptState.Failed: info = "服务器异常,获取订单类别失败!"; break; case OrderTypeOptState.InvalidOpt: info = "非法操作!与服务器连接断开,请稍后重试!"; break; } Invoke(() => { if (response.State != OrderTypeOptState.Successed) { MessageBoxEx.Show(this, info, "获取订单类别信息", MessageBoxButtons.OK, MessageBoxIcon.Information); return; } var orderTypeList = response.Data; orderTypeList.Insert(0, new OrderType { Id = -1, Name = string.Empty }); scbOrderType.DisplayMember = "Name"; scbOrderType.DataSource = orderTypeList; LoadOrderRecord(); }); }); }