public bool AcctOaStatus(AcctOAStatusParam pars) { var token = CommonToken.GetToken(); var http = new ArrowInterface.ArrowInterface(); pars.acctCode = ConfigurationManager.AppSettings["dealerCode"]; var result = http.AcctOaStatus(token.Token, pars); var Helper = new OracleDBHelper(); if (result.Success) { foreach (var row in result.Rows.AsParallel()) { var conn = Helper.GetNewConnection(); conn.Open(); var tran = conn.BeginTransaction(); try { Helper.DeleteWithTran(row, tran); Helper.DeleteWithTran <AcctOAStatusDetailed>($" AND ORDERNO='{row.orderNo}'", tran); Helper.InsertWithTransation(row, tran); } catch (Exception e) { tran.Rollback(); conn.Close(); var message = $"OA同步结果插入失败:{JsonConvert.SerializeObject(row)}"; LogHelper.Info(message); LogHelper.Error(e); return(false); } tran.Commit(); } } return(result.Success); }
public string SaveClient(ICPOBILLMODEL ICPOBILL, IEnumerable <ICPOBILLENTRYMODEL> ICPOBILLENTRYList) { OracleDBHelper helper = new OracleDBHelper(); var conn = helper.GetNewConnection(); conn.Open(); var tran = conn.BeginTransaction(); try { string FID = null; #region 执行前检测 if (!ICPOBILL.FID.IsGuid()) { ICPOBILLMODEL temp = ICPOBILLDAL.Instance.GetWhere(new { FBILLNO = ICPOBILL.FBILLNO }).FirstOrDefault(); if (temp != null && temp.FID != ICPOBILL.FID) { return("采购订单编号重复!"); } } #endregion #region 保存主表 if (!ICPOBILL.FID.IsGuid()) { FID = Guid.NewGuid().ToString(); ICPOBILL.FSTATUS = 1; ICPOBILL.FSTATE = 1; ICPOBILL.FBILLERNAME = ICPOBILL.FBILLER; ICPOBILL.FBILLDATE = DateTime.Now; ICPOBILL.FID = FID; ICPOBILL.FSYNCSTATUS = 0; helper.InsertWithTransation(ICPOBILL, tran); } else { FID = ICPOBILL.FID; //var model = ICPOBILLDAL.Instance.Get(FID); //model.FCLIENTID = ICPOBILL.FCLIENTID; //model.FREMARK = ICPOBILL.FREMARK; //model.FDATE = ICPOBILL.FDATE; //model.FTELEPHONE = ICPOBILL.FTELEPHONE; //model.Fpricepolicy = ICPOBILL.Fpricepolicy; //model.FPOtype = ICPOBILL.FPOtype; //model.Fnote = ICPOBILL.Fnote; //model.FPREMISEID = ICPOBILL.FPREMISEID; helper.UpdateWithTransation(ICPOBILL, tran); } #endregion #region 保存子表 //删除明细 //ICPOBILLENTRYBLL.Instance.DeleteByICPOBILLID(FID); helper.DeleteWithTran <ICPOBILLENTRYMODEL>($"AND FICPOBILLID='{FID}'", tran); //保存明细 foreach (var item in ICPOBILLENTRYList) { item.FICPOBILLID = FID; item.FID = Guid.NewGuid().ToString(); helper.InsertWithTransation(item, tran); } #endregion tran.Commit(); conn.Dispose(); return(null); } catch (Exception e) { tran.Rollback(); LogHelper.Info("e.Message=" + e.Message); throw; } }