public int Handle(DataParser dataParser) { List <UFXWithdrawFailedResponse> responseItems = new List <UFXWithdrawFailedResponse>(); var errorResponse = T2ErrorHandler.Handle(dataParser); if (T2ErrorHandler.Success(errorResponse.ErrorCode)) { responseItems = responseItems = UFXDataSetHelper.ParseSubscribeData <UFXWithdrawFailedResponse>(dataParser); } //update the database if (responseItems != null && responseItems.Count > 0) { foreach (var responseItem in responseItems) { int commandId; int submitId; int requestId; //TODO: add log if (EntrustRequestHelper.ParseThirdReff(responseItem.ThirdReff, out commandId, out submitId, out requestId)) { _entrustSecurityBLL.UpdateEntrustStatus(submitId, commandId, responseItem.StockCode, Model.EnumType.EntrustStatus.CancelFail); } else { string msg = string.Format("Fail to parse the third_reff: [{0}], entrust_no: [{1}].", responseItem.ThirdReff, responseItem.EntrustNo); logger.Error(msg); } } } return(responseItems.Count); }
private int DataHandlerCallback(CallerToken token, DataParser dataParser) { int ret = -1; var errorResponse = T2ErrorHandler.Handle(dataParser); token.ErrorResponse = errorResponse; List <UFXMultipleHoldingResponse> responseItems = new List <UFXMultipleHoldingResponse>(); if (T2ErrorHandler.Success(errorResponse.ErrorCode)) { responseItems = UFXDataSetHelper.ParseData <UFXMultipleHoldingResponse>(dataParser); var futures = responseItems.Where(p => p.MarketNo == "7").ToList(); var validItems = responseItems.Where(p => p.CurrentAmount > 0).ToList(); } else { ret = -1; } if (token.WaitEvent != null) { token.WaitEvent.Set(); } return(ret); }
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); }
public ConnectionCode Subscribe(LoginUser user, IUFXMessageHandlerFactory handlerFactory) { callback = new T2SubCallback(handlerFactory); subcribe = _conn.NewSubscriber(callback, SubscribeName, (int)_timeOut, 2000, 100); if (subcribe == null) { string msg = string.Format("主推业务订阅创建失败: {0}", _conn.GetMCLastError()); logger.Error(msg); return(ConnectionCode.ErrorFailSubscribe); } CT2SubscribeParamInterface args = new CT2SubscribeParamInterface(); args.SetTopicName("ufx_topic"); args.SetReplace(false); args.SetFilter("operator_no", user.Operator); CT2Packer req = new CT2Packer(2); req.BeginPack(); req.AddField("login_operator_no", Convert.ToSByte('S'), 16, 4); req.AddField("password", Convert.ToSByte('S'), 16, 4); req.AddStr(user.Operator); req.AddStr(user.Password); req.EndPack(); CT2UnPacker unpacker = null; int ret = subcribe.SubscribeTopicEx(args, 50000, out unpacker, req); req.Dispose(); //根据文档说明,返回值大于0表示有效的订阅标识,否则其他表示错误。 if (ret > 0) { string msg = string.Format("主推业务订阅创建成功, 返回码: {0}, 消息: {1}", ret, _conn.GetErrorMsg(ret)); logger.Info(msg); return(ConnectionCode.SuccessSubscribe); } else { string outMsg = string.Empty; if (unpacker != null) { //Show(back); DataParser parser = new DataParser(); parser.Parse(unpacker); unpacker.Dispose(); var errResponse = T2ErrorHandler.Handle(parser); outMsg = errResponse.MessageDetail; } string msg = string.Format("主推业务订阅创建失败,返回码: {0}, 消息: {1}, 返回数据包消息: {2}", ret, _conn.GetErrorMsg(ret), outMsg); logger.Error(msg); return(ConnectionCode.ErrorFailSubscribe); } }
private int WithdrawDataHandler(CallerToken token, DataParser dataParser) { List <UFXBasketWithdrawResponse> responseItems = new List <UFXBasketWithdrawResponse>(); var errorResponse = T2ErrorHandler.Handle(dataParser); token.ErrorResponse = errorResponse; //Verify the dataParser before reading the data. if (T2ErrorHandler.Success(errorResponse.ErrorCode)) { responseItems = UFXDataSetHelper.ParseData <UFXBasketWithdrawResponse>(dataParser); } int ret = -1; List <EntrustSecurity> entrustSecuItems = new List <EntrustSecurity>(); if (token.SubmitId > 0) { //TODO: check the withdraw status foreach (var responseItem in responseItems) { var entrustItem = new EntrustSecurity { SubmitId = token.SubmitId, CommandId = token.CommandId, SecuCode = responseItem.StockCode, EntrustNo = responseItem.EntrustNo, }; entrustSecuItems.Add(entrustItem); } if (entrustSecuItems.Count > 0) { ret = _entrustCombineBLL.UpdateSecurityEntrustStatus(entrustSecuItems, Model.EnumType.EntrustStatus.CancelSuccess); } } try { if (token.Caller != null) { token.Caller(token, entrustSecuItems, errorResponse); } } finally { if (token.WaitEvent != null) { token.WaitEvent.Set(); } } return(ret); }
public int Handle(DataParser dataParser) { List <UFXEntrustDealResponse> responseItems = new List <UFXEntrustDealResponse>(); var errorResponse = T2ErrorHandler.Handle(dataParser); if (T2ErrorHandler.Success(errorResponse.ErrorCode)) { //TODO: check the count of dataset. responseItems = UFXDataSetHelper.ParseSubscribeData <UFXEntrustDealResponse>(dataParser); } //update the database if (responseItems != null && responseItems.Count > 0) { List <EntrustSecurity> entrustSecuItems = new List <EntrustSecurity>(); foreach (var responseItem in responseItems) { int commandId; int submitId; int requestId; //TODO: add log if (EntrustRequestHelper.ParseThirdReff(responseItem.ThirdReff, out commandId, out submitId, out requestId)) { var dealItem = Convert(responseItem); //If it was stored in the database, then ignore //TODO: save into database if (_dealSecurityBLL.IsExist(commandId, submitId, requestId, dealItem.DealNo)) { string msg = string.Format("Duplicate to parse the third_reff: {0}, DealNo:{1}", responseItem.ThirdReff, dealItem.DealNo); logger.Error(msg); } else { //save the deal record in dealsecurity table _dealSecurityBLL.Create(dealItem); //update the entrustsecurity table _entrustSecurityBLL.UpdateDeal(submitId, commandId, responseItem.StockCode, responseItem.DealAmount, responseItem.DealBalance, responseItem.DealFee); //Update the TradingInstanceSecurity _tradeInstanceSecuBLL.UpdateToday(dealItem.EntrustDirection, commandId, dealItem.SecuCode, dealItem.DealAmount, dealItem.DealBalance, dealItem.DealFee); } } else { string msg = string.Format("Fail to parse the third_reff: {0}", responseItem.ThirdReff); logger.Error(msg); } } } return(responseItems.Count); }
private int WithdrawDataHandler(CallerToken token, DataParser dataParser) { var errorResponse = T2ErrorHandler.Handle(dataParser); token.ErrorResponse = errorResponse; List <UFXBasketWithdrawResponse> responseItems = UFXDataSetHelper.ParseData <UFXBasketWithdrawResponse>(dataParser); //TODO: It needs to verify the response data. Only the can set cancel successfully in those without no error. int ret = -1; List <EntrustSecurity> entrustSecuItems = new List <EntrustSecurity>(); if (token.SubmitId > 0) { foreach (var responseItem in responseItems) { var entrustItem = new EntrustSecurity { SubmitId = token.SubmitId, CommandId = token.CommandId, SecuCode = responseItem.StockCode, EntrustNo = responseItem.EntrustNo, }; entrustSecuItems.Add(entrustItem); } if (entrustSecuItems.Count > 0) { ret = _entrustCombineBLL.UpdateSecurityEntrustStatus(entrustSecuItems, Model.EnumType.EntrustStatus.CancelSuccess); ret = _entrustCommandBLL.UpdateEntrustCommandStatus(token.SubmitId, Model.EnumType.EntrustStatus.CancelSuccess); } } try { if (token.Caller != null) { token.Caller(token, entrustSecuItems, errorResponse); } } finally { if (token.WaitEvent != null) { token.WaitEvent.Set(); } } return(ret); }
private List <UFXBasketWithdrawResponse> GetResponse(DataParser parser) { var errorResponse = T2ErrorHandler.Handle(parser); if (T2ErrorHandler.Success(errorResponse.ErrorCode)) { return(UFXDataSetHelper.ParseData <UFXBasketWithdrawResponse>(parser)); } else { string msg = string.Format("Fail to withdraw - error code: {0}, message: {1}, detail: {2}", errorResponse.ErrorCode, errorResponse.ErrorMessage, errorResponse.MessageDetail); logger.Error(msg); return(new List <UFXBasketWithdrawResponse>()); } }
private int DataHandlerCallback(CallerToken token, DataParser dataParser) { int ret = -1; var errorResponse = T2ErrorHandler.Handle(dataParser); token.ErrorResponse = errorResponse; List <UFXHoldingResponse> responseItems = new List <UFXHoldingResponse>(); if (T2ErrorHandler.Success(errorResponse.ErrorCode)) { responseItems = UFXDataSetHelper.ParseData <UFXHoldingResponse>(dataParser); var futures = responseItems.Where(p => p.MarketNo == "7").ToList(); var validItems = responseItems.Where(p => p.CurrentAmount > 0).ToList(); if (validItems != null && validItems.Count > 0 && token.OutArgs != null && token.OutArgs is List <UFXHoldingResponse> ) { ((List <UFXHoldingResponse>)token.OutArgs).AddRange(validItems); } } else { ret = -1; } if (token.Caller != null) { token.Caller(token, null, errorResponse); } if (token.WaitEvent != null) { token.WaitEvent.Set(); } return(ret); }
private int QueryDataHandler(CallerToken token, DataParser dataParser) { List <UFXQueryFuturesEntrustResponse> responseItems = new List <UFXQueryFuturesEntrustResponse>(); var errorResponse = T2ErrorHandler.Handle(dataParser); token.ErrorResponse = errorResponse; if (T2ErrorHandler.Success(errorResponse.ErrorCode)) { responseItems = UFXDataSetHelper.ParseData <UFXQueryFuturesEntrustResponse>(dataParser); } try { if (token.Caller != null) { var entrustFlowItems = GetFlowItems(token, responseItems); if (token.OutArgs != null && token.OutArgs is List <EntrustFlowItem> && entrustFlowItems != null && entrustFlowItems.Count > 0 ) { ((List <EntrustFlowItem>)token.OutArgs).AddRange(entrustFlowItems); } token.Caller(token, entrustFlowItems, errorResponse); } } finally { if (token.WaitEvent != null) { token.WaitEvent.Set(); } } return(responseItems.Count()); }
public ConnectionCode HeartBeat() { UFXFunctionCode functionCode = UFXFunctionCode.HeartBeat; FunctionItem functionItem = ConfigManager.Instance.GetFunctionConfig().GetFunctionItem(functionCode); if (functionItem == null || functionItem.RequestFields == null || functionItem.RequestFields.Count == 0) { return(ConnectionCode.ErrorLogin); } CT2BizMessage bizMessage = new CT2BizMessage(); //初始化 bizMessage.SetFunction((int)functionCode); bizMessage.SetPacketType(CT2tag_def.REQUEST_PACKET); //业务包 CT2Packer packer = new CT2Packer(2); packer.BeginPack(); foreach (FieldItem item in functionItem.RequestFields) { packer.AddField(item.Name, item.Type, item.Width, item.Scale); } foreach (FieldItem item in functionItem.RequestFields) { switch (item.Name) { case "user_token": packer.AddStr(LoginManager.Instance.LoginUser.Token); break; default: break; } } packer.EndPack(); unsafe { bizMessage.SetContent(packer.GetPackBuf(), packer.GetPackLen()); } var parser = _t2SDKWrap.SendSync2(bizMessage); packer.Dispose(); bizMessage.Dispose(); if (parser.ErrorCode == ConnectionCode.Success) { var response = T2ErrorHandler.Handle(parser); if (!T2ErrorHandler.Success(response.ErrorCode)) { UFXLogger.Error(logger, functionCode, response); return(ConnectionCode.ErrorFailContent); } } else { UFXLogger.Error(logger, functionCode, "心跳检测失败"); return(ConnectionCode.ErrorConn); } return(ConnectionCode.Success); }
public ConnectionCode Login(LoginUser user) { UFXFunctionCode functionCode = UFXFunctionCode.Login; FunctionItem functionItem = ConfigManager.Instance.GetFunctionConfig().GetFunctionItem(functionCode); if (functionItem == null || functionItem.RequestFields == null || functionItem.RequestFields.Count == 0) { return(ConnectionCode.ErrorLogin); } LoginManager.Instance.LoginUser = user; CT2BizMessage bizMessage = new CT2BizMessage(); //初始化 bizMessage.SetFunction((int)functionCode); bizMessage.SetPacketType(CT2tag_def.REQUEST_PACKET); //业务包 CT2Packer packer = new CT2Packer(2); packer.BeginPack(); foreach (FieldItem item in functionItem.RequestFields) { packer.AddField(item.Name, item.Type, item.Width, item.Scale); } foreach (FieldItem item in functionItem.RequestFields) { switch (item.Name) { case "operator_no": packer.AddStr(user.Operator); break; case "password": packer.AddStr(user.Password); break; case "mac_address": { packer.AddStr(ConfigManager.Instance.GetTerminalConfig().MacAddress); } break; case "op_station": { packer.AddStr("www.htsec.com"); } break; case "ip_address": { packer.AddStr(ConfigManager.Instance.GetTerminalConfig().IPAddress); } break; case "hd_volserial": { packer.AddStr(""); } break; case "authorization_id": { //TODO: packer.AddStr("authorization_id"); } break; default: if (item.Type == UFXPackFieldType.IntType) { packer.AddInt(-1); } else if (item.Type == UFXPackFieldType.StringType || item.Type == UFXPackFieldType.CharType) { packer.AddStr(item.Name); } else { packer.AddStr(item.Name); } break; } } packer.EndPack(); unsafe { bizMessage.SetContent(packer.GetPackBuf(), packer.GetPackLen()); } var parser = _t2SDKWrap.SendSync2(bizMessage); packer.Dispose(); bizMessage.Dispose(); var ret = parser.ErrorCode; if (ret == ConnectionCode.Success) { string token = string.Empty; string version = string.Empty; var response = T2ErrorHandler.Handle(parser); if (T2ErrorHandler.Success(response.ErrorCode)) { if (parser.DataSets[1].Rows[0].Columns.ContainsKey("user_token")) { token = parser.DataSets[1].Rows[0].Columns["user_token"].GetStr(); } if (parser.DataSets[1].Rows[0].Columns.ContainsKey("version_no")) { version = parser.DataSets[1].Rows[0].Columns["version_no"].GetStr(); } string msg = string.Format("Login success - token: [{0}], version: [{1}]", token, version); UFXLogger.Info(logger, functionCode, msg); } else { UFXLogger.Error(logger, functionCode, response); } if (!string.IsNullOrEmpty(token)) { LoginManager.Instance.LoginUser.Token = token; ret = ConnectionCode.Success; } else { ret = ConnectionCode.ErrorLogin; } } return(ret); }
public ConnectionCode QueryHolder() { UFXFunctionCode functionCode = UFXFunctionCode.QueryHolder; FunctionItem functionItem = ConfigManager.Instance.GetFunctionConfig().GetFunctionItem(functionCode); if (functionItem == null || functionItem.RequestFields == null || functionItem.RequestFields.Count == 0) { return(ConnectionCode.ErrorLogin); } CT2BizMessage bizMessage = new CT2BizMessage(); //初始化 bizMessage.SetFunction((int)functionCode); bizMessage.SetPacketType(CT2tag_def.REQUEST_PACKET); //业务包 CT2Packer packer = new CT2Packer(2); packer.BeginPack(); foreach (FieldItem item in functionItem.RequestFields) { packer.AddField(item.Name, item.Type, item.Width, item.Scale); } foreach (FieldItem item in functionItem.RequestFields) { switch (item.Name) { case "user_token": packer.AddStr(LoginManager.Instance.LoginUser.Token); break; case "account_code": packer.AddStr(""); break; case "asset_no": packer.AddStr(""); break; case "combi_no": packer.AddStr(""); break; case "market_no": packer.AddStr(""); break; default: break; } } packer.EndPack(); unsafe { bizMessage.SetContent(packer.GetPackBuf(), packer.GetPackLen()); } var parser = _t2SDKWrap.SendSync2(bizMessage); packer.Dispose(); bizMessage.Dispose(); if (parser.ErrorCode != ConnectionCode.Success) { UFXLogger.Error(logger, functionCode, "交易股东查询失败"); return(parser.ErrorCode); } var response = T2ErrorHandler.Handle(parser); if (T2ErrorHandler.Success(response.ErrorCode)) { if (parser.DataSets.Count > 1) { var dataSet = parser.DataSets[1]; foreach (var dataRow in dataSet.Rows) { HolderItem p = new HolderItem(); p.AccountCode = dataRow.Columns["account_code"].GetStr(); p.AssetNo = dataRow.Columns["asset_no"].GetStr(); p.CombiNo = dataRow.Columns["combi_no"].GetStr(); p.StockHolderId = dataRow.Columns["stockholder_id"].GetStr(); p.MarketNo = dataRow.Columns["market_no"].GetStr(); LoginManager.Instance.AddHolder(p); } } return(ConnectionCode.Success); } else { UFXLogger.Error(logger, functionCode, response); return(ConnectionCode.ErrorFailContent); } }
public ConnectionCode QueryAccount() { UFXFunctionCode functionCode = UFXFunctionCode.QueryAccount; FunctionItem functionItem = ConfigManager.Instance.GetFunctionConfig().GetFunctionItem(functionCode); if (functionItem == null || functionItem.RequestFields == null || functionItem.RequestFields.Count == 0) { return(ConnectionCode.ErrorLogin); } CT2BizMessage bizMessage = new CT2BizMessage(); //初始化 bizMessage.SetFunction((int)functionCode); bizMessage.SetPacketType(CT2tag_def.REQUEST_PACKET); //业务包 CT2Packer packer = new CT2Packer(2); packer.BeginPack(); foreach (FieldItem item in functionItem.RequestFields) { packer.AddField(item.Name, item.Type, item.Width, item.Scale); } foreach (FieldItem item in functionItem.RequestFields) { switch (item.Name) { case "user_token": packer.AddStr(LoginManager.Instance.LoginUser.Token); break; case "account_code": packer.AddStr(""); break; default: break; } } packer.EndPack(); unsafe { bizMessage.SetContent(packer.GetPackBuf(), packer.GetPackLen()); } var parser = _t2SDKWrap.SendSync2(bizMessage); packer.Dispose(); bizMessage.Dispose(); if (parser.ErrorCode != ConnectionCode.Success) { UFXLogger.Error(logger, functionCode, "账户查询失败"); return(ConnectionCode.ErrorConn); } var response = T2ErrorHandler.Handle(parser); if (T2ErrorHandler.Success(response.ErrorCode)) { if (parser.DataSets.Count > 1) { var dataSet = parser.DataSets[1]; foreach (var dataRow in dataSet.Rows) { AccountItem acc = new AccountItem(); acc.AccountCode = dataRow.Columns["account_code"].GetStr(); acc.AccountName = dataRow.Columns["account_name"].GetStr(); string accType = dataRow.Columns["account_type"].GetStr(); int temp; if (int.TryParse(accType, out temp)) { acc.AccountType = (FundAccountType)temp; } LoginManager.Instance.AddAccount(acc); } } return(ConnectionCode.Success); } else { UFXLogger.Error(logger, functionCode, response); return(ConnectionCode.ErrorFailContent); } }
private int EntrustDataHandler(CallerToken token, DataParser dataParser) { var errorResponse = T2ErrorHandler.Handle(dataParser); token.ErrorResponse = errorResponse; List <UFXBasketEntrustResponse> responseItems = UFXDataSetHelper.ParseData <UFXBasketEntrustResponse>(dataParser); int ret = -1; List <EntrustSecurity> entrustSecuItems = new List <EntrustSecurity>(); foreach (var responseItem in responseItems) { var entrustItem = new EntrustSecurity { 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 = _entrustCombineBLL.UpdateSecurityEntrustResponseByRequestId(entrustSecuItems); if (T2ErrorHandler.Success(errorResponse.ErrorCode)) { int batchNo = 0; var batchNos = responseItems.Select(p => p.BatchNo).Distinct().ToList(); if (batchNos.Count == 1) { batchNo = batchNos[0]; } ret = _entrustCommandBLL.UpdateEntrustCommandBatchNo(token.SubmitId, batchNo, Model.EnumType.EntrustStatus.Completed, errorResponse.ErrorCode, errorResponse.ErrorMessage); } else { ret = _entrustCommandBLL.UpdateEntrustCommandBatchNo(token.SubmitId, 0, Model.EnumType.EntrustStatus.EntrustFailed, errorResponse.ErrorCode, errorResponse.ErrorMessage); //TODO: string msg = string.Format("The SubmitId [{0}] fail to entrust. ErrorCode: {1}, ErrorMessage: {2}, MessageDetail: {3}", token.SubmitId, errorResponse.ErrorCode, errorResponse.ErrorMessage, errorResponse.MessageDetail); logger.Error(msg); } try { if (token.Caller != null) { token.Caller(token, entrustSecuItems, errorResponse); } } finally { 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); }