private int WithdrawBasketCallback(CallerToken token, DataParser dataParser) { var errorResponse = T2ErrorHandler.Handle(dataParser); List <UFXBasketWithdrawResponse> responseItems = new List <UFXBasketWithdrawResponse>(); var dataFieldMap = UFXDataBindingHelper.GetProperty <UFXBasketWithdrawResponse>(); for (int i = 1, count = dataParser.DataSets.Count; i < count; i++) { var dataSet = dataParser.DataSets[i]; foreach (var dataRow in dataSet.Rows) { UFXBasketWithdrawResponse p = new UFXBasketWithdrawResponse(); UFXDataSetHelper.SetValue <UFXBasketWithdrawResponse>(ref p, dataRow.Columns, dataFieldMap); responseItems.Add(p); } } List <EntrustSecurityItem> entrustSecuItems = new List <EntrustSecurityItem>(); int ret = -1; if (token.SubmitId > 0) { if (T2ErrorHandler.Success(errorResponse.ErrorCode)) { foreach (var responseItem in responseItems) { var entrustItem = new EntrustSecurityItem { SubmitId = token.SubmitId, CommandId = token.CommandId, SecuCode = responseItem.StockCode, EntrustNo = responseItem.EntrustNo, }; entrustSecuItems.Add(entrustItem); } ret = _entrustdao.UpdateSecurityEntrustStatus(entrustSecuItems, Model.EnumType.EntrustStatus.CancelSuccess); ret = _entrustcmddao.UpdateEntrustCommandStatus(token.SubmitId, Model.EnumType.EntrustStatus.CancelSuccess); ret = _tradecmddao.UpdateTargetNumBySubmitId(token.SubmitId, token.CommandId); } } if (token.Caller != null) { token.Caller(token, entrustSecuItems, errorResponse); } if (token.WaitEvent != null) { token.WaitEvent.Set(); } return(ret); }
private int EntrustBasketCallback(CallerToken token, DataParser dataParser) { int ret = -1; List <EntrustSecurityItem> entrustSecuItems = new List <EntrustSecurityItem>(); var errorResponse = T2ErrorHandler.Handle(dataParser); token.OutArgs = errorResponse; if (T2ErrorHandler.Success(errorResponse.ErrorCode)) { List <UFXBasketEntrustResponse> responseItems = new List <UFXBasketEntrustResponse>(); var dataFieldMap = UFXDataBindingHelper.GetProperty <UFXBasketEntrustResponse>(); for (int i = 1, count = dataParser.DataSets.Count; i < count; i++) { var dataSet = dataParser.DataSets[i]; foreach (var dataRow in dataSet.Rows) { UFXBasketEntrustResponse p = new UFXBasketEntrustResponse(); UFXDataSetHelper.SetValue <UFXBasketEntrustResponse>(ref p, dataRow.Columns, dataFieldMap); responseItems.Add(p); } } foreach (var responseItem in responseItems) { var entrustItem = new EntrustSecurityItem { SubmitId = token.SubmitId, RequestId = responseItem.ExtSystemId, SecuCode = responseItem.StockCode, EntrustNo = responseItem.EntrustNo, BatchNo = responseItem.BatchNo, EntrustFailCode = responseItem.EntrustFailCode, EntrustFailCause = responseItem.FailCause, }; entrustSecuItems.Add(entrustItem); } ret = _entrustdao.UpdateSecurityEntrustResponseByRequestId(entrustSecuItems); if (token.InArgs != null && token.InArgs is EntrustCommandItem) { var cmdItem = token.InArgs as EntrustCommandItem; ret = _tradecmddao.UpdateTargetNum(cmdItem.CommandId, cmdItem.Copies); } var batchNos = responseItems.Select(p => p.BatchNo).Distinct().ToList(); if (batchNos.Count == 1) { int batchNo = batchNos[0]; ret = _entrustcmddao.UpdateEntrustCommandBatchNo(token.SubmitId, batchNo, Model.EnumType.EntrustStatus.Completed, errorResponse.ErrorCode, errorResponse.ErrorMessage); } else { //TODO: string msg = string.Format("The SubmitId [{0}] was split into several batch no", token.SubmitId); logger.Warn(msg); } } else { ret = -1; } if (token.Caller != null) { token.Caller(token, entrustSecuItems, errorResponse); } if (token.WaitEvent != null) { token.WaitEvent.Set(); } return(ret); }