Example #1
0
        //  保证外部异常不会对框架内部运转造成影响
        //  如果失败返回 RunFailed 保证系统后续重试处理
        private async Task <DoResp <TTRes> > TryDo(TTData data, int loopTimes, int triedTimes)
        {
            var doRes = default(DoResp <TTRes>);

            try
            {
                doRes = await Do(data, loopTimes, triedTimes);

                if (doRes.resp == null)
                {
                    doRes.resp = new TTRes().WithResp(SysRespTypes.NoResponse, "Have no response during task [Do]!");
                }
            }
            catch (Exception e)
            {
                if (doRes == null)
                {
                    doRes = new DoResp <TTRes>();
                }

                doRes.run_status = TaskRunStatus.RunFailed;
                doRes.resp       =
                    new TTRes().WithResp(SysRespTypes.ApplicationError, "Error occurred during task [Do]!");

                LogUtil.Error(
                    $"sys_ret:{doRes.resp.sys_ret}, ret:{doRes.resp.ret},msg:{doRes.resp.msg}, Detail:{e}"
                    , TaskMeta.task_id, EventTaskProvider.ModuleName);
            }

            return(doRes);
        }
Example #2
0
        protected override Task <DoResp <Resp> > Do(AddOrderReq data, int loopTimes, int triedTimes)
        {
            var resp = new DoResp <Resp>
            {
                run_status = TaskRunStatus.RunCompoleted,
                resp       = new Resp()
            };

            return(Task.FromResult(resp));
        }