Exemplo n.º 1
0
        private void ImportLocation(VacancyData locationData)
        {
            if (LocationsFromVacancies.ContainsKey(locationData.id))
            {
                return;
            }
            _operationLog.Info($"GROUP FROM VACANCY {locationData}");
            var characterGroup = new CharacterGroup()
            {
                AvaiableDirectSlots = locationData.kolvo,
                CharacterGroupName  = locationData.name.Trim(),
                ProjectId           = Project.ProjectId,
                Project             = Project,
                IsRoot = false,
                ParentCharacterGroupIds = new int[] { GetGroupByAllrpgId(locationData.locat).CharacterGroupId },
                IsActive            = true,
                HaveDirectSlots     = true,
                IsPublic            = true,
                Description         = new MarkdownString(locationData.content.Trim()),
                ChildGroupsOrdering = $"allrpg!{locationData.code:00000}"
            };

            LocationsFromVacancies.Add(locationData.id, characterGroup);

            _operationLog.Info($"GROUP.CREATE FROM VACANCY {characterGroup}");
        }
Exemplo n.º 2
0
        private void ImportClaim(RoleData roleData)
        {
            if (Claims.ContainsKey(roleData.id))
            {
                return;
            }

            var claim = new Claim
            {
                Project   = Project,
                ProjectId = Project.ProjectId,
                Character = null, //see later
                Group     = null, // see later
                Comments  = new List <Comment>()
                {
                    new Comment()
                    {
                        Author      = Project.ProjectAcls.Single(acl => acl.IsOwner).User,
                        CommentText = new CommentText()
                        {
                            Text = new MarkdownString($"<a href=\"http://site.allrpg.info/orders/orders/{roleData.id}/act=view&site={Project.Details.AllrpgId}\">Заявка в allrpg</a>")
                        },
                        CreatedTime       = UnixTime.ToDateTime(roleData.datesent),
                        IsCommentByPlayer = false,
                        IsVisibleToPlayer = false,
                        LastEditTime      = UnixTime.ToDateTime(roleData.datesent),
                        ParentCommentId   = null,
                        Project           = Project,
                    }
                },
                CreateDate         = UnixTime.ToDateTime(roleData.datesent),
                Player             = Users[roleData.sid],
                MasterDeclinedDate =
                    roleData.todelete2 == 0 && roleData.status != 4 ? (DateTime?)null : UnixTime.ToDateTime(roleData.date),
                PlayerDeclinedDate = roleData.todelete == 0 ? (DateTime?)null : UnixTime.ToDateTime(roleData.date),
                PlayerAcceptedDate = UnixTime.ToDateTime(roleData.datesent),
                LastUpdateDateTime = UnixTime.ToDateTime(roleData.date)
            };

            foreach (var virtualField in roleData.@virtual)
            {
                if (virtualField.Key == 7152) //Known steam2016 "responsible master"
                {
                    int responsibleMasterIdx;
                    if (int.TryParse(virtualField.Value, out responsibleMasterIdx))
                    {
                        var responsibleSid = Steam2016ResponsibleMasters[responsibleMasterIdx];
                        claim.ResponsibleMasterUser = responsibleSid == null ? null : Users[(int)responsibleSid];
                    }
                }
                else if (ConvertToCommentVirtualFields.Contains(virtualField.Key) && !string.IsNullOrWhiteSpace(virtualField.Value))
                {
                    claim.Comments.Add(new Comment()
                    {
                        Author      = Users[roleData.sid],
                        CommentText = new CommentText()
                        {
                            Text = new MarkdownString(virtualField.Value)
                        },
                        CreatedTime       = claim.CreateDate,
                        IsCommentByPlayer = true,
                        IsVisibleToPlayer = true,
                        LastEditTime      = DateTime.UtcNow,
                        ParentCommentId   = null,
                        Project           = Project,
                    });
                }
            }

            bool canbeApproved = false;

            Character      character;
            CharacterGroup characterGroup;

            if (Characters.TryGetValue(roleData.vacancy, out character))
            {
                claim.Character = character;
                canbeApproved   = true;
            }
            else if (LocationsFromVacancies.TryGetValue(roleData.vacancy, out characterGroup))
            {
                claim.Group = characterGroup;
            }
            else if (Locations.TryGetValue(roleData.locat, out characterGroup))
            {
                claim.Group = characterGroup;
            }
            else
            {
                claim.Group = Project.RootGroup;
            }

            claim.MasterAcceptedDate = canbeApproved && roleData.status == 3
        ? UnixTime.ToDateTime(roleData.date)
        : (DateTime?)null;

            claim.ClaimStatus = ConvertAllrpgStatus(roleData, canbeApproved);

            Claims.Add(roleData.id, claim);
        }