void OnUpdateOrderRecordRequest(IMessage msg, SessionEventArgs e)
        {
            var state = OrderRecordOptState.Failed;

            OrderRecord orderRecord = msg.Obj as OrderRecord;

            if (e.Session.SessionId != null)
            {
                try
                {
                    var record = _orderRecordBll.GetSubAccountIdAndOrderState(orderRecord.Id);
                    if (record.OrderStateId < 20)
                    {
                        if (orderRecord.OrderStateId >= 20 && orderRecord.OrderStateId <= 40)
                        {
                            _subAccountUsageInfoBll.UpdateOrderCount(record.ClientUserSubAccountId);
                        }
                    }
                }
                catch (Exception ex)
                {
                    ErrorLog(msg.Header.Type, ex);
                }

                try
                {
                    if (_orderRecordBll.Update(orderRecord))
                    {
                        state = OrderRecordOptState.Successed;
                    }
                }
                catch (Exception ex)
                {
                    ErrorLog(msg.Header.Type, ex);
                }
            }
            else
            {
                state = OrderRecordOptState.InvalidOpt;
            }

            e.Session.Send(state, MessageType.UpdateOrderRecordResponse);
        }
Ejemplo n.º 2
0
        void UpdateOrderRecord()
        {
            var orderState = scbOrderState.SelectedItem as OrderState;

            if (orderState.Id == -1)
            {
                errorProvider.SetError(scbOrderState, "必须选择刷单状态!");
                return;
            }

            if (orderState.Id == 999999 || orderState.Id < CurrentOrderRecord.OrderStateId)
            {
                errorProvider.SetError(scbOrderState,
                                       "刷单状态不能倒退选择,必须保持当前刷单状态或选择下一个刷单状态!");
                var orderStateList = scbOrderState.DataSource as IList <OrderState>;
                scbOrderState.SelectedItem = orderStateList.First(state =>
                {
                    return(state.Id == CurrentOrderRecord.OrderStateId);
                });
                return;
            }

            if (orderState.Id >= 20)
            {
                if (string.IsNullOrEmpty(stbOrderNum.SkinTxt.Text))
                {
                    errorProvider.SetError(stbOrderNum, "必须输入订单号!");
                    return;
                }
            }

            Action <OrderRecordOptState> updateResponse = state =>
            {
                string info = string.Empty;

                switch (state)
                {
                case OrderRecordOptState.CannotConnectServer:
                    info = "服务器连接失败,未能更新刷单信息!";
                    break;

                case OrderRecordOptState.Failed:
                    info = "服务器异常,更新刷单信息失败!";
                    break;

                case OrderRecordOptState.InvalidOpt:
                    info = "非法操作!与服务器连接断开,请稍后重试!";
                    break;
                }

                Invoke(() =>
                {
                    if (state != OrderRecordOptState.Successed)
                    {
                        MessageBoxEx.Show(this, info, "更新刷单信息",
                                          MessageBoxButtons.OK, MessageBoxIcon.Information);
                        return;
                    }

                    this.DialogResult = DialogResult.OK;
                    this.Close();
                });
            };

            _orderRecordBll.Update(new OrderRecord
            {
                Id = CurrentOrderRecord.Id,
                ClientUserSubAccountId = CurrentOrderRecord.ClientUserSubAccountId,
                OrderStateId           = orderState.Id,
                OrderNum           = stbOrderNum.SkinTxt.Text.Trim(),
                LastUpdateDateTime = DateTime.Now,
                OrderIp            = CurrentOrderRecord.OrderIp
            }, updateResponse);
        }