Esempio n. 1
0
        /// <summary>
        /// Sends an event. Note that ConnectionToken is used for invoking this API instead of
        /// ParticipantToken.
        ///
        ///
        /// <para>
        /// The Amazon Connect Participant Service APIs do not use <a href="https://docs.aws.amazon.com/general/latest/gr/signature-version-4.html">Signature
        /// Version 4 authentication</a>.
        /// </para>
        /// </summary>
        /// <param name="request">Container for the necessary parameters to execute the SendEvent service method.</param>
        /// <param name="cancellationToken">
        ///     A cancellation token that can be used by other objects or threads to receive notice of cancellation.
        /// </param>
        ///
        /// <returns>The response from the SendEvent service method, as returned by ConnectParticipant.</returns>
        /// <exception cref="Amazon.ConnectParticipant.Model.AccessDeniedException">
        /// You do not have sufficient access to perform this action.
        /// </exception>
        /// <exception cref="Amazon.ConnectParticipant.Model.InternalServerException">
        /// This exception occurs when there is an internal failure in the Amazon Connect service.
        /// </exception>
        /// <exception cref="Amazon.ConnectParticipant.Model.ThrottlingException">
        /// The request was denied due to request throttling.
        /// </exception>
        /// <exception cref="Amazon.ConnectParticipant.Model.ValidationException">
        /// The input fails to satisfy the constraints specified by Amazon Connect.
        /// </exception>
        /// <seealso href="http://docs.aws.amazon.com/goto/WebAPI/connectparticipant-2018-09-07/SendEvent">REST API Reference for SendEvent Operation</seealso>
        public virtual Task <SendEventResponse> SendEventAsync(SendEventRequest request, System.Threading.CancellationToken cancellationToken = default(CancellationToken))
        {
            var options = new InvokeOptions();

            options.RequestMarshaller    = SendEventRequestMarshaller.Instance;
            options.ResponseUnmarshaller = SendEventResponseUnmarshaller.Instance;

            return(InvokeAsync <SendEventResponse>(request, options, cancellationToken));
        }
Esempio n. 2
0
        /// <summary>
        /// Initiates the asynchronous execution of the SendEvent operation.
        /// </summary>
        ///
        /// <param name="request">Container for the necessary parameters to execute the SendEvent operation on AmazonConnectParticipantClient.</param>
        /// <param name="callback">An AsyncCallback delegate that is invoked when the operation completes.</param>
        /// <param name="state">A user-defined state object that is passed to the callback procedure. Retrieve this object from within the callback
        ///          procedure using the AsyncState property.</param>
        ///
        /// <returns>An IAsyncResult that can be used to poll or wait for results, or both; this value is also needed when invoking EndSendEvent
        ///         operation.</returns>
        /// <seealso href="http://docs.aws.amazon.com/goto/WebAPI/connectparticipant-2018-09-07/SendEvent">REST API Reference for SendEvent Operation</seealso>
        public virtual IAsyncResult BeginSendEvent(SendEventRequest request, AsyncCallback callback, object state)
        {
            var options = new InvokeOptions();

            options.RequestMarshaller    = SendEventRequestMarshaller.Instance;
            options.ResponseUnmarshaller = SendEventResponseUnmarshaller.Instance;

            return(BeginInvoke(request, options, callback, state));
        }
Esempio n. 3
0
        internal virtual SendEventResponse SendEvent(SendEventRequest request)
        {
            var options = new InvokeOptions();

            options.RequestMarshaller    = SendEventRequestMarshaller.Instance;
            options.ResponseUnmarshaller = SendEventResponseUnmarshaller.Instance;

            return(Invoke <SendEventResponse>(request, options));
        }
Esempio n. 4
0
        public void ChangeImportanceTest()
        {
            var account      = TestHelper.GetTestAccount();
            var user         = TestHelper.GetAccountAdminUser(account.Id);
            var eventType    = TestHelper.GetTestEventType(account.Id);
            var component    = account.CreateRandomComponentControl();
            var dispatcher   = DispatcherHelper.GetDispatcherService();
            var eventRequest = new SendEventRequest()
            {
                Token = account.GetCoreToken(),
                Data  = new SendEventData()
                {
                    ComponentId    = component.Info.Id,
                    TypeSystemName = eventType.SystemName,
                    Category       = EventCategory.ComponentEvent,
                    Version        = "1.2.3.4",
                    JoinInterval   = TimeSpan.FromSeconds(0).TotalSeconds
                }
            };
            var sendEventResponse = dispatcher.SendEvent(eventRequest);

            Assert.True(sendEventResponse.Success);
            var eventId       = sendEventResponse.Data.EventId;
            var eventResponse = dispatcher.GetEventById(new GetEventByIdRequest()
            {
                Token = account.GetCoreToken(),
                Data  = new GetEventByIdRequestData()
                {
                    EventId = eventId
                }
            });

            Assert.True(eventResponse.Success);
            var event_ = eventResponse.Data;

            ChangeImportanceModel model;

            using (var controller = new EventsController(account.Id, user.Id))
            {
                var result = (ViewResultBase)controller.ChangeImportance(eventId);
                model = (ChangeImportanceModel)result.Model;
            }
            model.Importance = EventImportance.Warning;
            using (var controller = new EventsController(account.Id, user.Id))
            {
                controller.ChangeImportance(model);
            }
            using (var accountContext = AccountDbContext.CreateFromAccountId(account.Id))
            {
                var eventTypeRepository = accountContext.GetEventTypeRepository();
                eventType = eventTypeRepository.GetById(model.EventTypeId);
                Assert.Equal(model.EventTypeId, eventType.Id);
                Assert.Equal(model.Version, event_.Version);
                Assert.Equal(model.Importance, eventType.ImportanceForOld);
            }
        }
Esempio n. 5
0
        public void DeletedComponentTest()
        {
            var account = TestHelper.GetTestAccount();
            var user    = TestHelper.GetAccountAdminUser(account.Id);

            // Создадим компонент
            var component = account.CreateRandomComponentControl();

            // Создадим тип события
            var eventType = TestHelper.GetTestEventType(account.Id);

            // Создадим событие, актуальное 1 день
            var dispatcher   = DispatcherHelper.GetDispatcherService();
            var eventRequest = new SendEventRequest()
            {
                Token = account.GetCoreToken(),
                Data  = new SendEventData()
                {
                    ComponentId    = component.Info.Id,
                    TypeSystemName = eventType.SystemName,
                    Category       = EventCategory.ComponentEvent,
                    Version        = "1.2.3.4",
                    JoinInterval   = TimeSpan.FromSeconds(0).TotalSeconds,
                }
            };
            var sendEventResponse = dispatcher.SendEvent(eventRequest);

            Assert.True(sendEventResponse.Success);

            // Удалим компонент
            var deleteComponentResponse = dispatcher.DeleteComponent(new DeleteComponentRequest()
            {
                Token = account.GetCoreToken(),
                Data  = new DeleteComponentRequestData()
                {
                    ComponentId = component.Info.Id
                }
            });

            Assert.True(deleteComponentResponse.Success);

            // Проверим, что список событий открывается без ошибки
            using (var controller = new EventsController(account.Id, user.Id))
            {
                var viewResult = (ViewResultBase)controller.Index();
            }
        }
        public void NotificationShowTest()
        {
            var account   = TestHelper.GetTestAccount();
            var user      = TestHelper.GetAccountAdminUser(account.Id);
            var component = account.CreateRandomComponentControl();

            var eventType    = TestHelper.GetTestEventType(account.Id);
            var dispatcher   = DispatcherHelper.GetDispatcherService();
            var eventRequest = new SendEventRequest()
            {
                Token = account.GetCoreToken(),
                Data  = new SendEventData()
                {
                    ComponentId    = component.Info.Id,
                    TypeSystemName = eventType.SystemName,
                    Category       = EventCategory.ComponentEvent,
                    Version        = "1.2.3.4",
                    JoinInterval   = TimeSpan.FromSeconds(0).TotalSeconds
                }
            };
            var sendEventResponse = dispatcher.SendEvent(eventRequest);

            Assert.True(sendEventResponse.Success);
            var eventId = sendEventResponse.Data.EventId;

            var dispatcherClient = TestHelper.GetDispatcherClient();
            var response         = dispatcherClient.CreateSubscription(account.Id, new CreateSubscriptionRequestData()
            {
                UserId          = user.Id,
                Object          = SubscriptionObject.ComponentType,
                Channel         = SubscriptionChannel.Email,
                ComponentTypeId = component.Type.Info.Id
            });
            var subscription = response.Data;

            Notification notification;

            using (var accountDbContext = account.CreateAccountDbContext())
            {
                var repository = accountDbContext.GetNotificationRepository();
                notification = new Notification()
                {
                    Id             = Guid.NewGuid(),
                    CreationDate   = DateTime.Now,
                    EventId        = eventId,
                    SendDate       = DateTime.Now.AddDays(1),
                    Status         = NotificationStatus.Sended,
                    SubscriptionId = subscription.Id,
                    Type           = NotificationType.Email,
                    UserId         = user.Id,
                    Address        = "*****@*****.**"
                };
                notification = repository.Add(notification);
                accountDbContext.SaveChanges();
            }

            using (var controller = new NotificationsController(account.Id, user.Id))
            {
                var result = (ViewResultBase)controller.Show(notification.Id, component.Info.Id);
                var model  = (NotificationDetailsModel)result.Model;
                Assert.Equal(notification.Id, model.Id);
                Assert.Equal(notification.EventId, model.Event.Id);
                Assert.Equal(notification.SendError, model.SendError);
                Assert.Equal(notification.Status, model.Status);
                Assert.Equal(notification.SubscriptionId, model.Subscription.Id);
                Assert.Equal(notification.Type, model.Channel);
                Assert.Equal(notification.UserId, model.User.Id);
                Assert.Equal(notification.Address, model.Address);
            }
        }
Esempio n. 7
0
 public void SentEventTypeB([FromBody] SendEventRequest request)
 {
     _eventProducer.Publish(new EventTypeB {
         MessageB = request.Messagge
     });
 }
Esempio n. 8
0
        public void StartsReportTest()
        {
            var account    = TestHelper.GetTestAccount();
            var user       = TestHelper.GetAccountAdminUser(account.Id);
            var component  = account.CreateRandomComponentControl();
            var dispatcher = DispatcherHelper.GetDispatcherService();

            // Отправим событие о запуске вчера
            var eventType = TestHelper.GetOrCreateEventType(
                account.Id,
                EventCategory.ComponentEvent,
                SystemEventType.ComponentStart);

            var eventRequestYesterday = new SendEventRequest()
            {
                Token = account.GetCoreToken(),
                Data  = new SendEventData()
                {
                    ComponentId    = component.Info.Id,
                    StartDate      = DateTime.Now.AddDays(-1),
                    TypeSystemName = eventType.SystemName,
                    Category       = EventCategory.ComponentEvent,
                    Version        = "1.2.3.4",
                    JoinInterval   = TimeSpan.FromSeconds(0).TotalSeconds
                }
            };
            var sendEventResponseYesterday = dispatcher.SendEvent(eventRequestYesterday);

            sendEventResponseYesterday.Check();
            var eventResponseYesterday = dispatcher.GetEventById(new GetEventByIdRequest()
            {
                Token = account.GetCoreToken(),
                Data  = new GetEventByIdRequestData()
                {
                    EventId = sendEventResponseYesterday.Data.EventId
                }
            });

            Assert.True(eventResponseYesterday.Success);
            var eventYesterday = eventResponseYesterday.Data;

            // Отправим событие о запуске сегодня
            var eventRequestToday = new SendEventRequest()
            {
                Token = account.GetCoreToken(),
                Data  = new SendEventData()
                {
                    ComponentId    = component.Info.Id,
                    StartDate      = DateTime.Now,
                    TypeSystemName = eventType.SystemName,
                    Category       = EventCategory.ComponentEvent,
                    Version        = "1.2.3.4",
                    JoinInterval   = TimeSpan.FromSeconds(0).TotalSeconds
                }
            };
            var sendEventResponseToday = dispatcher.SendEvent(eventRequestToday);

            Assert.True(sendEventResponseToday.Success);
            var eventResponseToday = dispatcher.GetEventById(new GetEventByIdRequest()
            {
                Token = account.GetCoreToken(),
                Data  = new GetEventByIdRequestData()
                {
                    EventId = sendEventResponseToday.Data.EventId
                }
            });

            Assert.True(eventResponseToday.Success);
            var eventToday = eventResponseToday.Data;

            // Проверим отчёт без фильтров
            using (var controller = new ReportsController(account.Id, user.Id))
            {
                var result = (ViewResultBase)controller.Starts(component.Type.Info.Id);
                var model  = (StartsReportModel)result.Model;

                Assert.Null(model.Error);

                var row = model.Items.SingleOrDefault(t => t.ComponentId == component.Info.Id);
                Assert.NotNull(row);

                Assert.Equal(component.Info.DisplayName, row.ComponentDisplayName);
                Assert.Equal(component.SystemName, row.ComponentSystemName);
                Assert.Equal(TestHelper.GetRoundDateTime(component.Info.CreatedDate), TestHelper.GetRoundDateTime(row.CreateDate));
                Assert.Equal(component.Version, row.Version);
                Assert.Equal(TestHelper.GetRoundDateTime(eventYesterday.StartDate), TestHelper.GetRoundDateTime(row.FirstStart.Value));
                Assert.Equal(eventYesterday.Id, row.FirstStartId);
                Assert.Equal(TestHelper.GetRoundDateTime(eventToday.StartDate), TestHelper.GetRoundDateTime(row.LastStart.Value));
                Assert.Equal(eventToday.Id, row.LastStartId);
                Assert.Equal(2, row.Count);

                var statYesterday = model.Graph.SingleOrDefault(t => t.Date == eventYesterday.StartDate.Date);
                Assert.NotNull(statYesterday);
                Assert.Equal(1, statYesterday.Count);

                var statToday = model.Graph.SingleOrDefault(t => t.Date == eventToday.StartDate.Date);
                Assert.NotNull(statToday);
                Assert.Equal(1, statToday.Count);

                Assert.Equal(2, model.Total);
            }

            // Проверим отчёт с фильтром за вчера
            using (var controller = new ReportsController(account.Id, user.Id))
            {
                var fromDate = eventYesterday.StartDate.Date.ToString(DateTimeFormat.UrlFormat);
                var toDate   = eventYesterday.StartDate.Date.AddDays(1).ToString(DateTimeFormat.UrlFormat);
                var result   = (ViewResultBase)controller.Starts(component.Type.Info.Id, component.Info.Id, fromDate, toDate);
                var model    = (StartsReportModel)result.Model;

                Assert.Null(model.Error);

                var row = model.Items.SingleOrDefault(t => t.ComponentId == component.Info.Id);
                Assert.NotNull(row);

                Assert.Equal(component.Info.DisplayName, row.ComponentDisplayName);
                Assert.Equal(component.SystemName, row.ComponentSystemName);
                Assert.Equal(TestHelper.GetRoundDateTime(component.Info.CreatedDate), TestHelper.GetRoundDateTime(row.CreateDate));
                Assert.Equal(component.Version, row.Version);
                Assert.Equal(TestHelper.GetRoundDateTime(eventYesterday.StartDate), TestHelper.GetRoundDateTime(row.FirstStart.Value));
                Assert.Equal(eventYesterday.Id, row.FirstStartId);
                Assert.Equal(TestHelper.GetRoundDateTime(eventYesterday.StartDate), TestHelper.GetRoundDateTime(row.LastStart.Value));
                Assert.Equal(eventYesterday.Id, row.LastStartId);
                Assert.Equal(1, row.Count);
            }
        }
 public SendEventResponse SendEvent(SendEventRequest request)
 {
     return(ExecuteAction <SendEventResponse>(request));
 }
Esempio n. 10
0
 public SendEventResponse SendEvent(SendEventRequest request)
 {
     return(Execute(() => InternalService.SendEvent(request)));
 }