Пример #1
0
        public bool IsRole(Guid flowID, Guid groupID, string InstanceID, int Type, string Field = "CreatorUserId")
        {
            var id        = Guid.Parse(InstanceID);
            var flowModel = _workFlowCacheManager.GetWorkFlowModelFromCache(flowID);

            if (flowModel == null)
            {
                throw new UserFriendlyException((int)ErrorCode.DataAccessErr, "流程不存在");
            }
            var firstDB       = flowModel.DataBases.First();
            var query_Sql     = $"select {Field} from {flowModel.TitleField.Table} where  {firstDB.PrimaryKey}=\'{InstanceID}\'";
            var instanceModel = _dynamicRepository.QueryFirst(query_Sql);

            if (instanceModel == null)
            {
                throw new UserFriendlyException(0, $"缺少{Field}.");
            }
            long userId = 0;

            foreach (var item in instanceModel)
            {
                if (item.Key == Field)
                {
                    userId = Convert.ToInt64(item.Value);
                }
            }
            if (userId == 0)
            {
                throw new UserFriendlyException(0, $"未查到{Field}用户.");
            }

            var userManager = Abp.AbpBootstrapper.Create <Abp.Modules.AbpModule>().IocManager.IocContainer.Resolve <UserManagerNotRemote>();
            var userRoles   = userManager.GetRoles(userId);


            var manager = Abp.AbpBootstrapper.Create <Abp.Modules.AbpModule>().IocManager.IocContainer.Resolve <WorkFlowOrganizationUnitsManager>();

            switch (Type)
            {
            case 1:    //总经理
                return(userRoles.Any(r => r == "ZJL"));

            case 2:    //分管领导
                //return !userRoles.Any(r => r == "ZJL") && userRoles.Any(r => r == "FGLD");
                return(!userRoles.Any(r => r == "ZJL") && (manager.IsChargerLeader(userId) || userRoles.Any(r => r == "FGLD")));

            case 3:    // 部门领导
                //return !userRoles.Any(r => r == "ZJL") && !userRoles.Any(r => r == "FGLD") && manager.IsChargerLeader(userId);
                return(!userRoles.Any(r => r == "ZJL") && !userRoles.Any(r => r == "FGLD") && !manager.IsChargerLeader(userId) && manager.IsLeader(userId));

            case 4:    //普通员工
                return(!userRoles.Any(r => r == "ZJL") && !userRoles.Any(r => r == "FGLD") && !manager.IsChargerLeader(userId) && !manager.IsLeader(userId));
            }
            return(false);
        }
Пример #2
0
        /// <summary>
        /// 根据主键获取实体
        /// </summary>
        /// <param name="input">主键</param>
        /// <returns></returns>

        public async Task <TaskManagementRelationOutputDto> Get(GetTaskManagementRelationInput input)
        {
            var models = _repository.GetAll().Where(x => x.FlowId == input.FlowId && x.TaskManagementId == input.RelationTaskId).Select(x => x.InStanceId).ToList();

            if (models == null)
            {
                return(null);
            }

            var currentwfInstallModel = _workFlowCacheManager.GetWorkFlowModelFromCache(input.FlowId);

            if (currentwfInstallModel.TitleField != null && !currentwfInstallModel.TitleField.Table.IsNullOrEmpty() &&
                !currentwfInstallModel.TitleField.Field.IsNullOrEmpty() && currentwfInstallModel.DataBases.Any())
            {
                var firstDB = currentwfInstallModel.DataBases.First();
                try
                {
                    var indata = "";
                    foreach (var item in models)
                    {
                        indata += "'" + item + "',";
                    }

                    var query_Sql    = $"select top 1 Id,Status  from {currentwfInstallModel.TitleField.Table}  where {firstDB.PrimaryKey} in ({indata.TrimEnd(',')}) order by CreationTime desc";
                    var dynamicModel = _dynamicRepository.QueryFirst(query_Sql);
                    if (dynamicModel != null)
                    {
                        var model = new TaskManagementRelationOutputDto();
                        model.InstanceId = Convert.ToString(dynamicModel.Id);
                        model.Status     = dynamicModel.Status;
                        _workFlowBusinessTaskManager.SupplementWorkFlowBusinessList(input.FlowId, model);
                        return(model);
                    }
                }
                catch (Exception e)
                {
                }
            }

            return(null);
        }