コード例 #1
0
        /// <summary>
        /// Updates the AgentGroupMembers of the specified AgentGroup id
        /// </summary>
        /// <param name="agentGroupId"></param>
        /// <param name="agentId"></param>
        /// <returns></returns>
        public IEnumerable <AgentGroupMember> UpdateGroupMembers(string agentGroupId, IEnumerable <AgentGroupMember> groupMembers)
        {
            var agentGroupGuid = Guid.Parse(agentGroupId);

            AgentGroup agentGroup = _agentGroupRepository.GetOne(agentGroupGuid);

            if (agentGroup == null)
            {
                throw new EntityDoesNotExistException("No agent group was found with the specified id");
            }

            List <AgentGroupMember> memberList = new List <AgentGroupMember>();

            DeleteGroupMembers(agentGroupId);//delete existing members

            foreach (var member in groupMembers ?? Enumerable.Empty <AgentGroupMember>())
            {
                member.AgentGroupId = agentGroupGuid;
                member.CreatedBy    = _caller.Identity.Name;
                member.CreatedOn    = DateTime.UtcNow;

                _agentGroupMemberRepository.Add(member);
                memberList.Add(member);
            }

            _webhookPublisher.PublishAsync("AgentGroups.AgentGroupMemberUpdated", agentGroupId, agentGroup.Name).ConfigureAwait(false);
            return(memberList.AsEnumerable());
        }
コード例 #2
0
        public async Task <IActionResult> Patch(string id,
                                                [FromBody] JsonPatchDocument <AgentGroup> request)
        {
            try
            {
                Guid entityId = new Guid(id);

                var existingAgentGroup = _agentGroupRepository.GetOne(entityId);
                if (existingAgentGroup == null)
                {
                    throw new EntityDoesNotExistException("No agent group exists with the specified id");
                }

                _agentGroupsManager.AttemptPatchUpdate(request, entityId);
                var result = await base.PatchEntity(id, request);

                await _webhookPublisher.PublishAsync("AgentGroups.AgentGroupUpdated", existingAgentGroup.Id.ToString(), existingAgentGroup.Name).ConfigureAwait(false);

                return(result);
            }
            catch (Exception ex)
            {
                return(ex.GetActionResult());
            }
        }
コード例 #3
0
        public JobViewModel GetJobView(JobViewModel jobView)
        {
            jobView.AgentName      = _agentRepo.GetOne(jobView.AgentId ?? Guid.Empty)?.Name;
            jobView.AgentGroupName = _agentGroupRepository.GetOne(jobView.AgentGroupId ?? Guid.Empty)?.Name;
            jobView.AutomationName = _automationRepo.GetOne(jobView.AutomationId ?? Guid.Empty)?.Name;
            jobView.JobParameters  = GetJobParameters(jobView.Id ?? Guid.Empty);

            return(jobView);
        }
コード例 #4
0
        public ScheduleViewModel GetScheduleViewModel(ScheduleViewModel scheduleView)
        {
            scheduleView.AgentName          = _agentRepository.GetOne(scheduleView.AgentId ?? Guid.Empty)?.Name;
            scheduleView.AgentGroupName     = _agentGroupRepository.GetOne(scheduleView.AgentGroupId ?? Guid.Empty)?.Name;
            scheduleView.AutomationName     = _automationRepository.GetOne(scheduleView.AutomationId ?? Guid.Empty)?.Name;
            scheduleView.ScheduleParameters = GetScheduleParameters(scheduleView.Id ?? Guid.Empty);

            return(scheduleView);
        }