コード例 #1
0
        public ResultOperation TerminateIfPossible(sysBpmsUser currentUser)
        {
            ResultOperation          resultOperation    = new ResultOperation();
            ThreadTaskService        threadTaskService  = new ThreadTaskService(base.UnitOfWork);
            ThreadEventService       threadEventService = new ThreadEventService(base.UnitOfWork);
            List <sysBpmsThreadTask> listActiveTask     = threadTaskService.GetList(this.EngineSharedModel.CurrentThreadID.Value, null, null, null).Where(c => c.StatusLU != (int)sysBpmsThreadTask.e_StatusLU.Done).ToList();

            //if terminated
            if (this.EngineSharedModel.CurrentThread.StatusLU == (int)sysBpmsThread.Enum_StatusLU.Done)
            {
                foreach (var itm in listActiveTask)
                {
                    itm.Update(DateTime.Now, (int)sysBpmsThreadTask.e_StatusLU.Done,
                               itm.OwnerUserID ?? currentUser?.ID);
                    resultOperation = threadTaskService.Update(itm);
                }
                List <sysBpmsThreadEvent> listEvents = threadEventService.GetActive(base.EngineSharedModel.CurrentThreadID.Value);
                foreach (var item in listEvents)
                {
                    item.Done();
                    resultOperation = threadEventService.Update(item);
                }
            }
            else
            {
                if (!listActiveTask.Any() && !threadEventService.GetActive(base.EngineSharedModel.CurrentThreadID.Value).Any())
                {
                    resultOperation = new ThreadService(this.UnitOfWork).DoneThread(base.EngineSharedModel.CurrentThreadID.Value);
                }
            }
            return(resultOperation);
        }
コード例 #2
0
        public ResultOperation Delete(Guid threadId)
        {
            ResultOperation resultOperation = new ResultOperation();

            try
            {
                this.BeginTransaction();

                //Delete sysBpmsDocument
                DocumentService documentService = new DocumentService(base.UnitOfWork);
                foreach (sysBpmsDocument document in documentService.GetList(null, null, null, "", null, null, threadId))
                {
                    if (resultOperation.IsSuccess)
                    {
                        resultOperation = documentService.Delete(document.GUID);
                    }
                }

                //Delete sysBpmsThreadVariable
                ThreadVariableService threadVariableService = new ThreadVariableService(base.UnitOfWork);
                foreach (sysBpmsThreadVariable sysThreadVariable in threadVariableService.GetList(threadId, null, ""))
                {
                    if (resultOperation.IsSuccess)
                    {
                        resultOperation = threadVariableService.Delete(sysThreadVariable.ID);
                    }
                }

                //Delete sysBpmsThreadEvent
                ThreadEventService threadEventService = new ThreadEventService(base.UnitOfWork);
                foreach (sysBpmsThreadEvent sysBpmsThreadEvent in threadEventService.GetList(threadId))
                {
                    if (resultOperation.IsSuccess)
                    {
                        resultOperation = threadEventService.Delete(sysBpmsThreadEvent.ID);
                    }
                }

                //Delete sysBpmsThreadTask
                ThreadTaskService threadTaskService = new ThreadTaskService(base.UnitOfWork);
                foreach (sysBpmsThreadTask sysBpmsThreadTask in threadTaskService.GetList(threadId, null, null, null))
                {
                    if (resultOperation.IsSuccess)
                    {
                        resultOperation = threadTaskService.Delete(sysBpmsThreadTask.ID);
                    }
                }

                //Delete Thread
                if (resultOperation.IsSuccess)
                {
                    this.UnitOfWork.Repository <IThreadRepository>().Delete(threadId);
                    this.UnitOfWork.Save();
                }
            }
            catch (Exception ex)
            {
                return(base.ExceptionHandler(ex));
            }
            base.FinalizeService(resultOperation);
            return(resultOperation);
        }