private void GenerateTagInfoDictionary(GetAppInfoResult appInfo)
 {
     foreach (var allowTag in appInfo.allow_tags.tagid)
     {
         tagMemberdDictionary.Add(allowTag, WeChatCommonService.GetTagMembers(allowTag, int.Parse(appInfo.agentid)));
     }
 }
        private bool CheckTag(GetAppInfoResult appInfo, int AccountMangageID, IList <int> selectedTagIds, IEnumerable <string> allAssignedUsers, CheckResult checkResult)
        {
            if (!selectedTagIds.Any())
            {
                return(true);
            }

            var needTags = selectedTagIds.Select(selectedTagId => new TagEntity {
                TagId = selectedTagId, TagMember = WeChatCommonService.GetTagMembers(selectedTagId, int.Parse(appInfo.agentid))
            }).ToList();

            //needTags.Select(x => new { TagId = x.Key, TagMember = x.Value }).ToList();

            var needUsers = needTags.SelectMany(x => x.TagMember.userlist.Select(y => y.userid)).ToList();

            var needParties = WeChatCommonService.GetSubDepartments(needTags.SelectMany(x => x.TagMember.partylist).ToList(), AccountMangageID).ToList();

            needUsers.AddRange(WeChatCommonService.lstUser(AccountMangageID).Where(x => needParties.Any(y => x.department.Any(z => z == y.id))).Select(x => x.userid).ToList());

            var errorUsers = needUsers.Where(x => allAssignedUsers.Any(y => x == y)).ToList();

            var errorTags = needTags.Where(x => errorUsers.Any(y => x.TagMember.userlist.Any(z => z.userid == y))).Select(x => x.TagId).ToList();

            if (!errorTags.Any())
            {
                return(true);
            }

            checkResult.ErrorTags = GetErrorTags(errorTags, AccountMangageID);
            return(false);
        }
Пример #3
0
        public ConfigedInfo(GetAppInfoResult appInfo)
        {
            Dictionary    = new Dictionary <int, GetTagMemberResult>();
            AppInfoResult = appInfo;

            AssignedDepartmentIds = (appInfo.allow_partys == null || appInfo.allow_partys.partyid == null || !appInfo.allow_partys.partyid.Any()) ? new List <int>() : appInfo.allow_partys.partyid.ToList();

            AssignedUserIds = (appInfo.allow_userinfos == null || appInfo.allow_userinfos.user == null || !appInfo.allow_userinfos.user.Any()) ? new List <string>() : appInfo.allow_userinfos.user.Select(x => x.userid).ToList();

            //append depart and user of tag
            var tagIds = (appInfo.allow_tags == null || appInfo.allow_tags.tagid == null || !appInfo.allow_tags.tagid.Any()) ? new List <int>() : appInfo.allow_tags.tagid.ToList();

            foreach (var tagId in tagIds)
            {
                var memberResult = WeChatCommonService.GetTagMembers(tagId, int.Parse(appInfo.agentid));

                AssignedDepartmentIds.AddRange(memberResult.partylist);

                AssignedUserIds.AddRange(memberResult.userlist.Select(x => x.userid).ToList());

                Dictionary.Add(tagId, memberResult);
            }

            var subDepartments = WeChatCommonService.GetSubDepartments(AssignedDepartmentIds.Distinct().ToList()).ToList();

            AssignedUserIds.AddRange(WeChatCommonService.lstUser.Where(x => x.department.Any(y => subDepartments.Any(d => d.id == y))).Select(x => x.userid).ToList());

            AssignedUserIds = AssignedUserIds.Distinct().ToList();
        }
Пример #4
0
        public bool IsHseAdmin(string lillyId)
        {
            var configed =
                CommonService.lstSysConfig.FirstOrDefault(
                    x => x.ConfigName.Equals(HseAdminTagKey, StringComparison.OrdinalIgnoreCase));

            var isAdmin = false;

            if (configed == null)
            {
                _logger.Error("Have not config hseadmin tag info.");
            }
            else
            {
                var tagInfo = WeChatCommonService.lstTag.FirstOrDefault(x => x.tagname.Equals(configed.ConfigValue, StringComparison.OrdinalIgnoreCase));
                if (tagInfo != null)
                {
                    var users = WeChatCommonService.GetTagMembers(int.Parse(tagInfo.tagid), 0);
                    if (users.errcode != ReturnCode_QY.请求成功)
                    {
                        _logger.Error(users.errcode);
                    }
                    else
                    {
                        if (users.userlist.Any(x => x.userid == lillyId))
                        {
                            //admin
                            isAdmin = true;
                        }
                    }
                }
                else
                {
                    _logger.Error("Have not config hse tag info.");
                }
            }

            return(isAdmin);
        }