Ejemplo n.º 1
0
        public List <sysBpmsTask> GetAvailableProccess(Guid userID)
        {
            string             staticAccessType = $"<AccessType>{(int)UserTaskRuleModel.e_UserAccessType.Static}</AccessType>";
            string             userIdString     = userID.ToString();
            List <sysBpmsTask> items            = (from T in this.Context.sysBpmsTasks
                                                   join P in this.Context.sysBpmsProcesses on T.ProcessID equals P.ID
                                                   join D in this.Context.sysBpmsDepartmentMembers on userID equals D.UserID into Dlist
                                                   join E in this.Context.sysBpmsEvents on P.ID equals E.ProcessID into Elist
                                                   where
                                                   (P.TypeLU == (int)sysBpmsProcess.e_TypeLU.General) &&
                                                   (P.StatusLU == (int)sysBpmsProcess.Enum_StatusLU.Published) &&
                                                   (Elist.Count(c => c.TypeLU == (int)sysBpmsEvent.e_TypeLU.StartEvent && c.SubType == (int)WorkflowStartEvent.BPMNStartEventType.None) > 0) &&
                                                   (this.Context.sysBpmsSplit(P.BeginTasks, ",").Any(c => c.Data == T.ElementID)) &&
                                                   (
                                                       (T.OwnerTypeLU == (int)Domain.sysBpmsTask.e_OwnerTypeLU.User && T.UserID.Contains(userIdString)) ||
                                                       (T.OwnerTypeLU == (int)Domain.sysBpmsTask.e_OwnerTypeLU.Role &&
                                                        (T.RoleName == string.Empty ||
                                                         T.RoleName == (",0:" + (int)sysBpmsDepartmentMember.e_RoleLU.Requester + ",") ||//it means that everyone can start this proccess.
                                                         Dlist.Count(c => this.Context.sysBpmsSplit(T.RoleName, ",").Any(f => f.Data == ("0:" + c.RoleLU.ToString().Trim()) || f.Data == (c.DepartmentID.ToString() + ":" + c.RoleLU.ToString().Trim()))) > 0)
                                                       ) ||
                                                       (!T.Rule.Contains(staticAccessType)))//it will be calculated in engine.
                                                   select T).OrderBy(d => d.Element.Process.Name).Include(c => c.Element.Process).AsNoTracking().ToList();

            return(items);
        }
        public List <sysBpmsApplicationPage> GetAvailable(Guid?userID, bool?ShowInMenu)
        {
            List <sysBpmsApplicationPage> retVal = null;

            retVal = (from P in this.Context.sysBpmsApplicationPages
                      join A in this.Context.sysBpmsApplicationPageAccesses.Where(c => c.AllowView) on P.ID equals A.ApplicationPageID into access
                      join D in this.Context.sysBpmsDepartmentMembers on userID equals D.UserID into Dlist
                      where
                      (!ShowInMenu.HasValue || P.ShowInMenu == ShowInMenu) &&
                      (access.Count() == 0 ||
                       (
                           userID.HasValue &&
                           (access.Count(c => c.UserID.HasValue && c.UserID == userID) > 0 ||
                            access.Count(c => c.RoleLU.HasValue && Dlist.Count(d => c.RoleLU == d.RoleLU && (!c.DepartmentID.HasValue || c.DepartmentID == d.DepartmentID)) > 0) > 0)
                       ))
                      select P).OrderBy(c => c.DynamicForms.FirstOrDefault().Name).Include(c => c.DynamicForms).AsNoTracking().ToList();

            return(retVal);
        }
        public List <sysBpmsThreadTask> GetListKartable(Guid UserID, int[] statusLU, PagingProperties currentPaging)
        {
            List <sysBpmsThreadTask> list = new List <sysBpmsThreadTask>();

            statusLU = statusLU ?? new int[] { };
            if (UserID != Guid.Empty)
            {
                var query = (from P in this.Context.sysBpmsThreadTasks
                             join T in this.Context.sysBpmsTasks on P.TaskID equals T.ID
                             join D in this.Context.sysBpmsDepartmentMembers on UserID equals D.UserID into Dlist
                             where
                             (!statusLU.Any() || statusLU.Contains(P.StatusLU)) &&
                             (P.OwnerUserID.HasValue || (P.OwnerRole != null && P.OwnerRole != string.Empty)) &&
                             (!P.OwnerUserID.HasValue || UserID == P.OwnerUserID) &&
                             (P.OwnerRole == string.Empty || Dlist.Count(c => this.Context.sysBpmsSplit(P.OwnerRole, ",").Any(f => f.Data == ("0:" + c.RoleLU.ToString().Trim()) || f.Data == (c.DepartmentID.ToString() + ":" + c.RoleLU.ToString().Trim()))) > 0) &&
                             (!T.MarkerTypeLU.HasValue || T.MarkerTypeLU == (int)Domain.sysBpmsTask.e_MarkerTypeLU.NonSequential ||
                              T.MarkerTypeLU == (int)Domain.sysBpmsTask.e_MarkerTypeLU.Loop ||
                              (T.MarkerTypeLU == (int)Domain.sysBpmsTask.e_MarkerTypeLU.Sequential && this.Context.sysBpmsThreadTasks.Count(c => c.ThreadID == P.ThreadID && c.TaskID == P.TaskID && c.StartDate < P.StartDate && c.StatusLU != (int)sysBpmsThreadTask.e_StatusLU.Done) == 0))
                             select P).Include(c => c.Task.Element).Include(c => c.Thread.Process).AsNoTracking();


                if (currentPaging != null)
                {
                    currentPaging.RowsCount = query.Count();
                    if (Math.Ceiling(Convert.ToDecimal(currentPaging.RowsCount) / Convert.ToDecimal(currentPaging.PageSize)) < currentPaging.PageIndex)
                    {
                        currentPaging.PageIndex = 1;
                    }

                    list = query.OrderByDescending(p => p.StartDate).Skip((currentPaging.PageIndex - 1) * currentPaging.PageSize).Take(currentPaging.PageSize).ToList();
                }
                else
                {
                    list = query.ToList();
                }
            }
            return(list);
        }