Exemplo n.º 1
0
        public void CreatePointToPointChannel(PointToPointChannel pointToPointChannel, IChannelManager channelmanager)
        {
            if (pointToPointChannel.ConnectionStringExtractorType != null)
            {
                var extractorconnectionstring = _factory.Create <IValueSettingFinder>(pointToPointChannel.ConnectionStringExtractorType);

                var toconnectionextractor = pointToPointChannel.ToConnectionStringExtractor as Func <IValueSettingFinder, string>;

                if (toconnectionextractor != null)
                {
                    try
                    {
                        var connectionstring = toconnectionextractor(extractorconnectionstring);

                        var created = channelmanager.CreateIfNotExistPointToPointChannel(connectionstring, pointToPointChannel.Path);

                        if (created)
                        {
                            Console.WriteLine($"Created {pointToPointChannel.Path} point to point channel");
                        }
                        else
                        {
                            Console.WriteLine($"Point to point channel {pointToPointChannel.Path} already exists");
                        }
                    }
                    catch (Exception ex)
                    {
                        Console.WriteLine($"Exception {pointToPointChannel.Path} point to point channel: {ex}");
                    }
                }
            }
        }
Exemplo n.º 2
0
        public void CreatePointToPointChannel(PointToPointChannel channel, IChannelManager manager, StringBuilder errors)
        {
            if (channel.ConnectionStringExtractorType != null)
            {
                var finder = _factory.Create <IValueSettingFinder>(channel.ConnectionStringExtractorType);

                var extractor = channel.ConnectionStringExtractor as Func <IValueSettingFinder, string>;

                channel.ConnectionString = extractor?.Invoke(finder);

                if (string.IsNullOrWhiteSpace(channel.ConnectionString))
                {
                    var error = $"Empty connection string, point to point channel {channel.Path}";

                    errors.AppendLine(error);

                    _logger.Log(error);

                    return;
                }

                if (string.IsNullOrWhiteSpace(channel.Path))
                {
                    var error = $"Empty path, point to point channel {channel.Path}";

                    errors.AppendLine(error);

                    _logger.Log(error);

                    return;
                }

                try
                {
                    var created = manager.CreateIfNotExistPointToPointChannel(channel.ConnectionString, channel.Path);

                    if (created)
                    {
                        _logger.Log($"Created {channel.Path} point to point channel");
                    }
                    else
                    {
                        _logger.Log($"Point to point channel {channel.Path} already exists");
                    }
                }
                catch (Exception ex)
                {
                    var error = $"Exception {channel.Path} point to point channel: {ex}";

                    errors.AppendLine(error);

                    _logger.Log(error);
                }
            }
        }