Ejemplo n.º 1
0
        public async Task <IActionResult> Start(string id)
        {
            var message = new ServiceMessage();

            message.CommChannel      = "PubSub";
            message.SessionId        = id;
            message.StampOne.Visited = true;
            message.StampOne.TimeNow = DateTime.UtcNow;

            ConfigurationPackage configPackage = this._context.CodePackageActivationContext.GetConfigurationPackageObject("Config");
            ConfigurationSection configSection = configPackage.Settings.Sections[Constants.SB_CONFIG_SECTION];
            var connString = (configSection.Parameters[Constants.SB_CONN_STRING]).Value;
            var topicName  = (configSection.Parameters[Constants.SB_TOPIC]).Value;

            try
            {
                await ServiceBusSenderClient2.Send(connString, topicName, message, (e) => { ServiceEventSource.Current.ServiceMessage(_context, e.Message); });

                return(Ok(new { id = id }));
            }
            catch (Exception e)
            {
                return(BadRequest(e.Message));
            }
        }
Ejemplo n.º 2
0
        void ProcessTopicMessage(ServiceMessage message)
        {
            EndWithHttpPost(message).GetAwaiter().GetResult();

            ConfigurationPackage configPackage = this.Context.CodePackageActivationContext.GetConfigurationPackageObject("Config");
            ConfigurationSection configSection = configPackage.Settings.Sections[Constants.SB_CONFIG_SECTION];
            var connString = (configSection.Parameters[Constants.SB_CONN_STRING]).Value;

            ServiceBusSenderClient2.Send(connString, "end", message, LogError)
            .GetAwaiter()
            .GetResult();
        }
Ejemplo n.º 3
0
        void ProcessTopicMessage(ServiceMessage message)
        {
            message.StampThree.Visited = true;
            message.StampThree.TimeNow = DateTime.UtcNow;

            ConfigurationPackage configPackage = this.Context.CodePackageActivationContext.GetConfigurationPackageObject("Config");
            ConfigurationSection configSection = configPackage.Settings.Sections[Constants.SB_CONFIG_SECTION];
            var connString = (configSection.Parameters[Constants.SB_CONN_STRING]).Value;

            ServiceBusSenderClient2.Send(connString, "svc4", message, LogError)
            .GetAwaiter()
            .GetResult();
        }