Exemplo n.º 1
0
        private void GenerateServiceBusMessageForJobProfileUnPublish(DynamicContent item, MessageAction eventAction)
        {
            var jobProfileMessage = new JobProfileMessage();

            jobProfileMessage.JobProfileId = item.OriginalContentId;
            jobProfileMessage.Title        = dynamicContentExtensions.GetFieldValue <Lstring>(item, nameof(JobProfileMessage.Title));
            serviceBusMessageProcessor.SendJobProfileMessage(jobProfileMessage, item.GetType().Name, eventAction.ToString());
        }
        public void HtbTitleIsOverridenCorrectly(string title, string widgetContentTitle, string expectedTitle)
        {
            //Arrange
            var jobProfileMessage = new JobProfileMessage()
            {
                DynamicTitlePrefix = "No Prefix", Title = title, WidgetContentTitle = widgetContentTitle
            };
            var message = JsonConvert.SerializeObject(jobProfileMessage);

            //Act
            var actualMappedModel = mappingService.MapToSegmentModel(message, SequenceNumber);

            //Asserts
            actualMappedModel.Data.Title.Should().Be(expectedTitle);
        }
        public async Task SendJobProfileMessage(JobProfileMessage jpData, string contentType, string actionType)
        {
            applicationLogger.Info($" CREATED service bus message for sitefinity event {actionType.ToUpper()} on JobProfile with Title -- {jpData.Title} and Jobprofile Id -- {jpData.JobProfileId.ToString()}");
            var connectionStringServiceBus = configurationProvider.GetConfig <string>("DFC.Digital.ServiceBus.ConnectionString");
            var topicName = configurationProvider.GetConfig <string>("DFC.Digital.ServiceBus.TopicName");

            if (actionType == "Draft")
            {
                topicName = configurationProvider.GetConfig <string>("DFC.Digital.ServiceBus.TopicName.Draft");
            }

            var topicClient = new TopicClient(connectionStringServiceBus, topicName);

            // Send Messages
            var jsonData = JsonConvert.SerializeObject(jpData);

            try
            {
                applicationLogger.Info($" SENDING service bus message for sitefinity event {actionType.ToUpper()} on JobProfile with Title -- {jpData.Title} and with Jobprofile Id -- {jpData.JobProfileId.ToString()} ");

                // Message that send to the queue
                var message = new Message(Encoding.UTF8.GetBytes(jsonData));
                message.ContentType = "application/json";
                message.Label       = jpData.Title;
                message.UserProperties.Add("Id", jpData.JobProfileId);
                message.UserProperties.Add("ActionType", actionType);
                message.UserProperties.Add("CType", contentType);
                message.CorrelationId = Guid.NewGuid().ToString();
                await topicClient.SendAsync(message);

                applicationLogger.Info($" SENT service bus message for sitefinity event {actionType.ToUpper()} on JobProfile with Title -- {jpData.Title} with Jobprofile Id -- {jpData.JobProfileId.ToString()} and with Correlation Id -- {message.CorrelationId.ToString()}");
            }
            catch (Exception ex)
            {
                applicationLogger.Info($" FAILED service bus message for sitefinity event {actionType.ToUpper()} on JobProfile with Title -- {jpData.Title} and with Jobprofile Id -- {jpData.JobProfileId.ToString()} has an exception \n {ex.Message} ");
            }
            finally
            {
                await topicClient.CloseAsync();
            }
        }
Exemplo n.º 4
0
        private void GenerateServiceBusMessageForJobProfile(DynamicContent item, MessageAction eventAction)
        {
            JobProfileMessage jobprofileData = dynamicContentConverter.ConvertFrom(item);

            serviceBusMessageProcessor.SendJobProfileMessage(jobprofileData, item.GetType().Name, eventAction.ToString());
        }