コード例 #1
0
        public async Task SendAsync(FlowMasterAdapterModel flowMasterAdapterModel,
                                    ApproveOpinionModel approveOpinionModel)
        {
            CleanTrackingHelper.Clean <FlowMaster>(context);
            CleanTrackingHelper.Clean <FlowUser>(context);
            CleanTrackingHelper.Clean <FlowHistory>(context);
            CleanTrackingHelper.Clean <MyUser>(context);
            (var flowUsers, var user) = await GetUsersDataAsync(flowMasterAdapterModel);

            if (user.Id != flowMasterAdapterModel.MyUserId)
            {
                return;
            }

            var flowUser = flowUsers.FirstOrDefault(x => x.Level == 0);

            flowUser.Completion = true;
            flowMasterAdapterModel.ProcessLevel = 1;
            flowMasterAdapterModel.Status       = 1;

            CopyUserAutoCompletion(flowUsers, flowMasterAdapterModel.ProcessLevel);

            FindNextActionUser(flowUsers, flowMasterAdapterModel);

            await context.BulkUpdateAsync(flowUsers);

            await UpdateAsync(flowMasterAdapterModel);

            await AddHistoryRecord(user, flowMasterAdapterModel,
                                   $"{approveOpinionModel.Summary}", $"{approveOpinionModel.Comment}", true);

            #region 產生收件匣紀錄
            await NotifyInboxUsers(flowUsers, flowMasterAdapterModel, flowMasterAdapterModel.ProcessLevel);

            #endregion

            CleanTrackingHelper.Clean <FlowMaster>(context);
            CleanTrackingHelper.Clean <FlowUser>(context);
            CleanTrackingHelper.Clean <FlowHistory>(context);
            CleanTrackingHelper.Clean <MyUser>(context);
        }