public bool SaleOrderUpload(List <string> billNos) { var auditType = AuditEnums.提交同步; ICPOBILLAuditor auditor = new ICPOBILLAuditor("System", auditType); var err = auditor.CheckOption(billNos, auditType); if (!err.Equals("")) { throw new ArgumentException(err); } var token = CommonToken.GetToken(); var http = new ArrowInterface.ArrowInterface(); var Helper = new OracleDBHelper(); string where = $" AND LHOUTSYSTEMOD IN ('{string.Join("','", billNos)}')"; var bills = Helper.GetWithWhereStr <SaleOrderUploadParam>(where); bills.ForEach(b => { var details = Helper.GetWhere(new SaleOrderUploadDetailedParam() { lHOutSystemID = b.lHOutSystemID }).ToArray(); b.saleOrderItemList = details; }); List <string> errors = new List <string>(); bills.ForEach(b => { var conn = Helper.GetNewConnection(); conn.Open(); var tran = conn.BeginTransaction(); try { var result = http.SaleOrderUpload(token.Token, b); if (result.Success) { var saleorderRepository = new DefaultRepository <Order>(DBTypeEnums.ORACLE); ///返写箭牌销售单号到本地采购订单表ICPOBILL的FDesBillNo字段 var whereStr = $" AND FBILLNO='{b.lHOutSystemOd}'"; var icpobill = Helper.GetWithTranWithWhereStr <ICPOBILLMODEL>(whereStr, tran) .SingleOrDefault(); saleorderRepository.Delete(new { lHOutSystemID = b.lHOutSystemID }, tran); foreach (var row in result.item.AsParallel()) { Helper.InsertWithTransation(row, tran); icpobill.FDesBillNo = row.orderNo; } //更新本地采购订单表ICPOBILL icpobill.FSTATUS = (int)ICPOBILLStatus.关闭; icpobill.FSYNCSTATUS = (int)ICPOBILLSyneStatus.已同步; Helper.UpdateWithTransation(icpobill, tran); } else { errors.Add($"单据【{b.lHOutSystemOd}】上传失败:{result.Message}"); } tran.Commit(); conn.Close(); } catch (Exception e) { tran.Rollback(); conn.Close(); var message = $"销售订单【{b.lHOutSystemOd}】上传失败:{e.Message}"; LogHelper.Info(message); LogHelper.Error(e); throw; } }); if (errors.Count > 0) { throw new Exception(string.Join("\r\n", errors)); } return(true); }