sardineany 发表于 2021-10-19 17:52:23

U8 API 事务问题

我用API生成采购发票,一次会生成很多,如果有一个失败了,其余都失败,就想到了用API自带的事务。
UFIDA.U8.MomServiceCommon.MomCallContextCache envCtxCache = new UFIDA.U8.MomServiceCommon.MomCallContextCache();
            UFIDA.U8.MomServiceCommon.MomCallContext envCtx = new UFIDA.U8.MomServiceCommon.MomCallContext();
            envCtx = envCtxCache.CurrentMomCallContext;
            U8Login.clsLogin objLogin = (U8Login.clsLogin)envCtx.U8Login;
            //事物连接数据库
            ADODB.Connection conn = (ADODB.Connection)envCtx.BizDbConnection;
            string eventid = envCtx.EventIdentity;
            conn.CursorLocation = ADODB.CursorLocationEnum.adUseClient;

            //第二步:构造环境上下文对象,传入login,并按需设置其它上下文参数
            U8EnvContext envContext = new U8EnvContext();
            envContext.U8Login = u8Login;

            //采购所有接口均支持内部独立事务和外部事务,默认内部事务
            //如果是外部事务,则需要传递ADO.Connection对象,并将IsIndependenceTransaction属性设置为false
         envContext.BizDbConnection = conn;
            envContext.IsIndependenceTransaction = false;

但这种方法只能实现内部事务,我想循环调用同一个API,并且在在同一个事务内,执行这些API,这种要怎么实现,请教各位

sardineany 发表于 2021-10-20 09:34:25

有没有做过的大佬解答一下,感激不尽
页: [1]
查看完整版本: U8 API 事务问题