예제 #1
0
        public object GetUserMenu(long projectId)
        {
            try
            {
                if (projectId <= 0)
                {
                    return(APIResult.GetSuccessNoDatas());
                }

                var user = CurrentUserView;
                if (user != null)
                {
                    var list = Enum <BusinessType> .AsEnumerable().ToDictionary(i => i.ToString(), j => j.GetText()).Select(p => new { code = p.Key }).ToList();

                    if (user.CompanyType.Equals(RoleType.Owner.ToString()))
                    {
                        list = list.Where(p =>
                                          p.code == BusinessType.SecurityCheck.ToString() ||
                                          p.code == BusinessType.Question.ToString()).ToList();
                    }
                    if (user.CompanyType.Equals(RoleType.Supplier.ToString()))
                    {
                        using (ClientSiteClientProxy proxy = new ClientSiteClientProxy(ProxyEx(user)))
                        {
                            if (proxy.IsSupervisor(projectId, user.UserId))
                            {
                                list = list.Where(p =>
                                                  p.code == BusinessType.Log.ToString() ||
                                                  p.code == BusinessType.Equipment.ToString() ||
                                                  p.code == BusinessType.Visa.ToString() ||
                                                  p.code == BusinessType.Question.ToString() ||
                                                  p.code == BusinessType.SecurityCheck.ToString() || //返回监理现场检查类型;
                                                  p.code == BusinessType.Rectification.ToString() || //发起整改单
                                                  p.code == BusinessType.Dangerous.ToString()).ToList();
                            }
                            else
                            {
                                list = list.Where(p =>
                                                  p.code == BusinessType.Track.ToString() ||
                                                  p.code == BusinessType.DelayApply.ToString() ||
                                                  p.code == BusinessType.Question.ToString()).ToList();

                                //list.Add(new
                                //{
                                //    code = SystemRight.UploadSecurityCheck.ToString()
                                //});
                                list.Add(new
                                {
                                    code = SystemRight.UploadWork.ToString()
                                });
                            }
                        }
                    }
                    list.Add(new
                    {
                        code = SystemRight.UploadSecurityCheck.ToString()
                    });
                    list.Add(new
                    {
                        code = SystemRight.FaceAI.ToString()
                    });
                    return(APIResult.GetSuccessResult(list));
                }
                return(APIResult.GetErrorResult(MsgCode.InvalidToken));
            }
            catch (Exception ex)
            {
                return(APIResult.GetErrorResult(ex.Message));
            }
            finally
            {
            }
        }