Ejemplo n.º 1
0
        private void CloseIncidentBusinessProcessClient(Guid?incidentId)
        {
            if (incidentId == null || incidentId.Value == Guid.Empty)
            {
                return;
            }

            var incident = _incidentXrmRepository.FindEntityById((Guid)incidentId);

            if (incident?.StateCode == null ||
                (incident.StateCode != null &&
                 incident.StateCode.Value != IncidentState.Active))
            {
                return;
            }

            var zSupport = _systemUserService.GetZSupportSystemUser();

            const string comment = "Обращение закрыто автоматически, т.к. длительное время не получено подтверждение от пользователя.";

            var closeIncidentModel = new CloseIncidentModel
            {
                IncidentId    = incidentId,
                CommentString =
                    "Обращение закрыто автоматически, т.к. длительное время не получено подтверждение от пользователя.",
                SubjectAnnotation =
                    $"*WEB* *IncidentActivationService* *AutoClose* *Support:{(zSupport == null ? string.Empty : zSupport.NickName)}*",
                NoteTextAnnotation        = $"*WEB* {comment}",
                Reason                    = "Бизнес-процесс клиента",
                FunctionalEntityReference = new EntityReference(svk_functional.EntityLogicalName,
                                                                Guid.Parse(EnumHelper <FunctionalType> .GetDisplayValue(FunctionalType.BusinessProcess))),
                SubjectEntityReference = new EntityReference(Subject.EntityLogicalName,
                                                             Guid.Parse(EnumHelper <SubjectType> .GetDisplayValue(SubjectType.BusinessProcesses))),
                IncidentResolutionSubject = "Обращение закрыто автоматически",
                Status = new OptionSetValue((int)StatusIncidentType.ProblemSolved),
                StateInternalOptionSetValue = new OptionSetValue((int)StateInternalIncidentType.Closed),
                ProblemSide = new OptionSetValue((int)ProblemSideType.Client),
            };

            _incidentService.CloseIncidentFromModel(closeIncidentModel);
        }