예제 #1
0
        public string CurrentActivityName()
        {
            if (DocumentState == DocumentState.Agreement || DocumentState == DocumentState.Execution)
            {
                IWorkflowTrackerService      _service = DependencyResolver.Current.GetService <IWorkflowTrackerService>();
                IEnumerable <WFTrackerTable> items    = _service.GetCurrentStep(x => x.DocumentTableId == Id && x.TrackerType == TrackerType.Waiting);
                string currentName = String.Empty;

                if (items != null)
                {
                    foreach (var item in items)
                    {
                        currentName += item.ActivityName + "/";
                    }
                }

                if (currentName != String.Empty)
                {
                    currentName = currentName.Remove(currentName.Length - 1);
                }

                return(currentName);
            }
            else
            {
                return("");
            }
        }
예제 #2
0
        public bool isShowDocument(Guid documentId, Guid ProcessId, string currentUserName = "", bool isAfterView = false)
        {
            string localUserName = getCurrentUserName(currentUserName);

            IEnumerable <WFTrackerTable> trackerTables = null;

            if (isAfterView == false)
            {
                trackerTables = _WorkflowTrackerService.GetCurrentStep(x => x.DocumentTableId == documentId && x.SignUserId == null);
            }
            else
            {
                trackerTables = _WorkflowTrackerService.GetPartial(x => x.DocumentTableId == documentId);
            }

            DocumentTable   documentTable = Find(documentId);
            ApplicationUser user          = _AccountService.FirstOrDefault(x => x.UserName == localUserName);

            if (user.Id == documentTable.ApplicationUserCreatedId)
            {
                return(true);
            }

            if (checkTrackUsers(trackerTables, user.Id))
            {
                return(true);
            }

            ApplicationDbContext          context     = new ApplicationDbContext();
            UserManager <ApplicationUser> UserManager = new UserManager <ApplicationUser>(new UserStore <ApplicationUser>(context));

            if (UserManager.IsInRole(user.Id, "Administrator"))
            {
                return(true);
            }

            var delegationItems = _DelegationService.GetPartial(x => x.EmplTableTo.ApplicationUserId == user.Id &&
                                                                x.DateFrom <= DateTime.UtcNow && x.DateTo >= DateTime.UtcNow &&
                                                                x.isArchive == false && x.CompanyTableId == user.CompanyTableId);

            foreach (var delegationItem in delegationItems)
            {
                if (delegationItem.GroupProcessTableId != null || delegationItem.ProcessTableId != null)
                {
                    if (delegationItem.ProcessTableId == ProcessId)
                    {
                        if (checkTrackUsers(trackerTables, delegationItem.EmplTableFrom.ApplicationUserId))
                        {
                            return(true);
                        }
                    }
                    else if (_ProcessService.Find(ProcessId).GroupProcessTableId == delegationItem.GroupProcessTableId)
                    {
                        if (checkTrackUsers(trackerTables, delegationItem.EmplTableFrom.ApplicationUserId))
                        {
                            return(true);
                        }
                    }
                }
                else
                {
                    if (checkTrackUsers(trackerTables, delegationItem.EmplTableFrom.ApplicationUserId))
                    {
                        return(true);
                    }
                }
            }

            if (_DocumentReaderService.Contains(x => x.DocumentTableId == documentId && x.UserId == user.Id))
            {
                return(true);
            }


            return(false);
        }