Пример #1
0
        private static IeUsersGroups FromXmlModel(XmlUsersGroups xmlUsersGroups,
                                                  ISet <int> userIdsToCollect, ISet <int> groupIdsToCollect)
        {
            if (xmlUsersGroups == null)
            {
                return(null);
            }

            var ieUsersGroups = new IeUsersGroups
            {
                IncludeCurrentUser = xmlUsersGroups.IncludeCurrentUser,
                UsersGroups        = FromXmlModel(xmlUsersGroups.UsersGroups, userIdsToCollect, groupIdsToCollect)
            };

            return(ieUsersGroups);
        }
Пример #2
0
        private static XmlUsersGroups ToXmlModel(IeUsersGroups ieUsersGroups, WorkflowDataMaps dataMaps)
        {
            if (ieUsersGroups == null)
            {
                return(null);
            }

            var xmlUsersGroups = new XmlUsersGroups
            {
                IncludeCurrentUser = ieUsersGroups.IncludeCurrentUser,
                UsersGroups        = !ieUsersGroups.UsersGroups.IsEmpty()
                    ? new List <XmlUserGroup>()
                    : null
            };

            ieUsersGroups.UsersGroups?.ForEach(ug =>
            {
                var isGroup = ug.IsGroup.GetValueOrDefault();
                int ugId;
                if (isGroup)
                {
                    if (!dataMaps.GroupMap.TryGetValue(Tuple.Create(ug.Name, ug.GroupProjectId), out ugId))
                    {
                        throw new ExceptionWithErrorCode(I18NHelper.FormatInvariant("Id of Group '{1}' is not found.", ug.Name),
                                                         ErrorCodes.UnexpectedError);
                    }
                }
                else
                {
                    if (!dataMaps.UserMap.TryGetValue(ug.Name, out ugId))
                    {
                        throw new ExceptionWithErrorCode(I18NHelper.FormatInvariant("Id of User '{0}' is not found.", ug.Name),
                                                         ErrorCodes.UnexpectedError);
                    }
                }

                xmlUsersGroups.UsersGroups.Add(new XmlUserGroup
                {
                    IsGroup = isGroup,
                    Id      = ugId
                });
            });

            return(xmlUsersGroups);
        }