Ejemplo n.º 1
0
        public ResultOperation DoneThreadTask(sysBpmsThreadTask currentThreadTask, sysBpmsUser currentUser)
        {
            ThreadTaskService threadTaskService = new ThreadTaskService(base.UnitOfWork);

            currentThreadTask.Update(DateTime.Now, (int)sysBpmsThreadTask.e_StatusLU.Done,
                                     currentThreadTask.OwnerUserID ?? currentUser?.ID);
            return(threadTaskService.Update(currentThreadTask));
        }
Ejemplo n.º 2
0
        /// <summary>
        /// It is called by Process engine for adding theadtask related to task element.
        /// </summary>
        /// <param name="item"></param>
        public (ResultOperation result, List <sysBpmsThreadTask> listTask) AddThreadTask(sysBpmsTask item, bool isFirstTask)
        {
            ThreadTaskService        threadTaskService = new ThreadTaskService(base.UnitOfWork);
            ResultOperation          result            = new ResultOperation();
            List <sysBpmsThreadTask> listTask          = new List <sysBpmsThreadTask>();

            switch ((sysBpmsTask.e_TypeLU)item.TypeLU)
            {
            case sysBpmsTask.e_TypeLU.UserTask:
                if (item.MarkerTypeLU.HasValue)
                {
                    foreach (sysBpmsThreadTask threadTaskItem in threadTaskService.GetMultiInstanceTask(item, base.EngineSharedModel))
                    {
                        //if user has access to this method, set thread task access Info to userID
                        if (isFirstTask && this.CheckAccessByThreadTask(item, threadTaskItem, base.EngineSharedModel.CurrentThread.UserID, null))
                        {
                            threadTaskItem.UpdateAccessInfo(base.EngineSharedModel.CurrentThread.UserID, null);
                        }
                        threadTaskService.Add(threadTaskItem);
                        listTask.Add(threadTaskItem);
                    }
                }
                else
                {
                    sysBpmsThreadTask threadTask = new sysBpmsThreadTask();
                    threadTask.Update(base.EngineSharedModel.CurrentThreadID.Value, item.ID, DateTime.Now, null, string.Empty, 0, (int)sysBpmsThreadTask.e_StatusLU.New);
                    threadTaskService.SetAccessInfoTo(threadTask, item, base.EngineSharedModel);
                    //if user has access to this method, set thread task access Info to thread userID
                    if (isFirstTask && this.CheckAccessByThreadTask(item, threadTask, base.EngineSharedModel.CurrentThread.UserID, null))
                    {
                        threadTask.UpdateAccessInfo(base.EngineSharedModel.CurrentThread.UserID, null);
                    }

                    threadTaskService.Add(threadTask);
                    listTask.Add(threadTask);
                }
                break;
            }
            return(result, listTask);
        }
        public ResultOperation SaveIntoDataBase(ContentHtml contentHtml, sysBpmsThreadTask threadTask, List <VariableModel> setExternalVariable, string threadTaskDescription)
        {
            ResultOperation resultOperation = new ResultOperation();

            try
            {
                base.BeginTransaction();

                //First set variable according to elements.
                //resultOperation = this.SetValuesToElements(contentHtml);

                //Then set external variables, filled by user defined actions.
                if (setExternalVariable != null)
                {
                    foreach (var item in setExternalVariable)
                    {
                        foreach (var dataModel in item.Items)
                        {
                            foreach (var val in dataModel.ToList())
                            {
                                this.SetValueByBinding(val.Key, val.Value);
                            }
                        }
                    }
                }

                if (resultOperation.IsSuccess)
                {
                    resultOperation = this.SaveInto();
                }

                if (resultOperation.IsSuccess)
                {
                    DocumentEngine documentEngine = new DocumentEngine(base.EngineSharedModel, base.UnitOfWork);
                    foreach (FileUploadHtml item in contentHtml.Rows.SelectMany(r => (r is RowHtml ? ((RowHtml)r).Columns : ((AccordionHtml)r).GetListColumn()).SelectMany(d => d.children.Where(f => f is FileUploadHtml).ToList())))
                    {
                        if (resultOperation.IsSuccess)
                        {
                            sysBpmsVariable variable = item.VariableId.ToGuidObjNull() == null ? null :
                                                       new VariableService(base.UnitOfWork).GetInfo(item.VariableId.ToGuidObj());

                            Guid?entityId    = (variable != null && this.SetDataList.ContainsKey(variable.Name)) ? this.SetDataList[variable?.Name].GetValue <Guid>("ID") : (Guid?)null;
                            Guid?entityDefId = variable?.EntityDefID;
                            resultOperation = documentEngine.IsValid(item, variable, entityId, entityDefId, base.EngineSharedModel.CurrentUserName);
                            if (resultOperation.IsSuccess)
                            {
                                resultOperation = documentEngine.SaveFile(item, variable, entityId, entityDefId, "", base.EngineSharedModel.CurrentUserName);
                            }
                        }
                    }
                }
                if (resultOperation.IsSuccess)
                {
                    if (!string.IsNullOrWhiteSpace(this.ThreadTaskDescription))
                    {
                        threadTask.Update(this.ThreadTaskDescription);
                        new ThreadTaskService(base.UnitOfWork).Update(threadTask);
                    }
                }
            }
            catch (Exception ex)
            {
                return(base.ExceptionHandler(ex));
            }
            base.FinalizeService(resultOperation);
            return(resultOperation);
        }
        public List <sysBpmsThreadTask> GetMultiInstanceTask(Domain.sysBpmsTask task, EngineSharedModel engineSharedModel)
        {
            sysBpmsThreadTask        threadTask = null;
            List <sysBpmsThreadTask> list       = new List <sysBpmsThreadTask>();

            switch ((sysBpmsTask.e_OwnerTypeLU)task.OwnerTypeLU)
            {
            case sysBpmsTask.e_OwnerTypeLU.User:
                switch ((UserTaskRuleModel.e_UserAccessType)task.UserTaskRuleModel.AccessType)
                {
                case UserTaskRuleModel.e_UserAccessType.Static:
                case UserTaskRuleModel.e_UserAccessType.Variable:
                    string userId = task.UserID;
                    if (task.UserTaskRuleModel.AccessType == (int)UserTaskRuleModel.e_UserAccessType.Variable)
                    {
                        userId = new DataManageEngine(engineSharedModel, base.UnitOfWork).GetValueByBinding(task.UserTaskRuleModel.Variable).ToStringObj();
                    }
                    int i = 0;
                    foreach (string item in userId.Split(','))
                    {
                        threadTask = new sysBpmsThreadTask();
                        threadTask.Update(engineSharedModel.CurrentThreadID.Value, task.ID, DateTime.Now.AddSeconds(i++), null, string.Empty, 0, (int)sysBpmsThreadTask.e_StatusLU.New);
                        threadTask.UpdateAccessInfo(item.ToGuidObj(), null);
                        list.Add(threadTask);
                    }
                    break;
                }
                break;

            case sysBpmsTask.e_OwnerTypeLU.Role:
                switch ((UserTaskRuleModel.e_RoleAccessType)task.UserTaskRuleModel.AccessType)
                {
                case UserTaskRuleModel.e_RoleAccessType.Static:
                case UserTaskRuleModel.e_RoleAccessType.Variable:
                    if (task.UserTaskRuleModel.AccessType == (int)UserTaskRuleModel.e_RoleAccessType.Variable)
                    {
                        task.SetRoleDepartment(new DataManageEngine(engineSharedModel, base.UnitOfWork).GetValueByBinding(task.UserTaskRuleModel.Variable).ToStringObj(), task.UserTaskRuleModel.SpecificDepartmentId);
                    }
                    foreach (var item in task.GetDepartmentRoles)
                    {
                        List <Guid> users = new DepartmentMemberService(base.UnitOfWork).GetList(item.Item1, item.Item2.ToIntObj(), null).Select(c => c.UserID).ToList();
                        //It is used  for sequential task.
                        int i = 0;
                        foreach (Guid uId in users)
                        {
                            threadTask = new sysBpmsThreadTask();
                            threadTask.Update(engineSharedModel.CurrentThreadID.Value, task.ID, DateTime.Now.AddSeconds(i++), null, string.Empty, 0, (int)sysBpmsThreadTask.e_StatusLU.New);
                            threadTask.UpdateAccessInfo(uId, null);
                            list.Add(threadTask);
                        }
                    }
                    break;

                case UserTaskRuleModel.e_RoleAccessType.CorrespondentRole:

                    Guid?userId       = task.UserTaskRuleModel.UserType == (int)UserTaskRuleModel.e_UserType.CurrentUserID ? new UserService(base.UnitOfWork).GetInfo(engineSharedModel.CurrentUserName ?? "")?.ID : engineSharedModel.CurrentThread?.UserID;
                    Guid?departmentId = new AccessCodeHelper(base.UnitOfWork).GetDepartmentHierarchyByUserId(userId.ToGuidObj(), task.UserTaskRuleModel.RoleCode.ToIntObj(), task.UserTaskRuleModel.GoUpDepartment);
                    if (!departmentId.HasValue)
                    {
                        throw new Exception(LangUtility.Get("OrganizationNotFound.Text", nameof(sysBpmsThreadTask)));
                    }
                    {
                        List <Guid> users = new DepartmentMemberService(base.UnitOfWork).GetList(departmentId, task.UserTaskRuleModel.RoleCode.ToIntObj(), null).Select(c => c.UserID).ToList();
                        //It is used  for sequential task.
                        int i = 0;
                        foreach (Guid uId in users)
                        {
                            threadTask = new sysBpmsThreadTask();
                            threadTask.Update(engineSharedModel.CurrentThreadID.Value, task.ID, DateTime.Now.AddSeconds(i++), null, string.Empty, 0, (int)sysBpmsThreadTask.e_StatusLU.New);
                            threadTask.UpdateAccessInfo(uId, null);
                            list.Add(threadTask);
                        }
                    }
                    break;
                }

                break;
            }
            return(list);
        }