Exemplo n.º 1
0
        public static async Task <OmfConnection> CreateOmfConnectionAsync()
        {
            // Create the Connection
            OmfConnection omfConnection = await _omfIngressClient.CreateOmfConnectionAsync(DeviceClientId, ConnectionName, NamespaceId).ConfigureAwait(false);

            return(omfConnection);
        }
Exemplo n.º 2
0
        public static async Task <OmfConnection> CreateOmfConnectionAsync()
        {
            //Create the Connection
            OmfConnection omfConnection = await _omfIngressClient.CreateOmfConnectionAsync(_deviceClientId, _connectionName, _namespaceId);

            return(omfConnection);
        }
Exemplo n.º 3
0
        public async Task DeleteOmfConnectionAsync(OmfConnection omfConnection)
        {
            if (omfConnection == null)
            {
                throw new ArgumentException("Omf Connection cannot be null", nameof(omfConnection));
            }

            // Delete the Topic and Subscription
            Console.WriteLine($"Deleting the Subscription with Id {omfConnection.Subscription.Id}");
            Console.WriteLine();

            await _omfIngressService.DeleteSubscriptionAsync(omfConnection.Subscription.Id).ConfigureAwait(false);

            Console.WriteLine($"Deleted the Subscription with Id {omfConnection.Subscription.Id}");
            Console.WriteLine();

            // Delete the Topic
            Console.WriteLine($"Deleting the Topic with Id {omfConnection.Topic.Id}");
            Console.WriteLine();

            await _omfIngressService.DeleteTopicAsync(omfConnection.Topic.Id).ConfigureAwait(false);

            Console.WriteLine($"Deleted the Topic with Id {omfConnection.Topic.Id}");
            Console.WriteLine();
        }
Exemplo n.º 4
0
        public static void Main()
        {
            Setup();
            OmfConnection omfConnection = null;

            try
            {
                //Create the Connection, send OMF
                omfConnection = CreateOmfConnectionAsync().GetAwaiter().GetResult();
                SendTypeContainerAndDataAsync().GetAwaiter().GetResult();
            }
            catch (Exception ex)
            {
                success = false;
                Console.WriteLine(ex.Message);
                toThrow = ex;
            }
            finally
            {
                //Delete the Type and Stream
                try
                {
                    DeleteTypeAndContainerAsync().GetAwaiter().GetResult();
                }
                catch (Exception ex)
                {
                    Console.WriteLine(ex.Message);
                    if (toThrow == null)
                    {
                        success = false;
                        toThrow = ex;
                    }
                }

                //Delete the Connection
                try
                {
                    DeleteOmfConnectionAsync(omfConnection).GetAwaiter().GetResult();
                }
                catch (Exception ex)
                {
                    Console.WriteLine(ex.Message);
                    if (toThrow == null)
                    {
                        success = false;
                        toThrow = ex;
                    }
                }
                Console.WriteLine("Done");
                Console.ReadKey();
            }
            if (!success)
            {
                throw toThrow;
            }
        }
Exemplo n.º 5
0
        public static void Main()
        {
            Setup();
            Exception     toThrow       = null;
            OmfConnection omfConnection = null;

            try
            {
                // Create the Connection, send OMF
                omfConnection = CreateOmfConnectionAsync().GetAwaiter().GetResult();
                SendTypeContainerAndDataAsync().GetAwaiter().GetResult();
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.Message);
                toThrow = ex;
            }
            finally
            {
                // Delete the Type and Stream
                try
                {
                    DeleteTypeAndContainerAsync().GetAwaiter().GetResult();
                }
                catch (Exception ex)
                {
                    Console.WriteLine(ex.Message);
                    toThrow = ex;
                }

                if (omfConnection != null)
                {
                    // Delete the Connection
                    try
                    {
                        DeleteOmfConnectionAsync(omfConnection).GetAwaiter().GetResult();
                    }
                    catch (Exception ex)
                    {
                        Console.WriteLine(ex.Message);
                        toThrow = ex;
                    }
                }

                Console.WriteLine("Complete!");
            }

            if (toThrow != null)
            {
                throw toThrow;
            }
        }
Exemplo n.º 6
0
        public async Task <OmfConnection> CreateOmfConnectionAsync(string deviceClientId, string connectionName, string destinationNamespaceId)
        {
            // Create a Topic
            Console.WriteLine($"Creating a Topic in Namespace {_namespaceId} for Client with Id {deviceClientId}");
            Console.WriteLine();
            Topic topic = new Topic()
            {
                Name        = connectionName,
                Description = "This is a sample Topic",
                ClientIds   = new List <string>()
                {
                    deviceClientId
                }
            };
            Topic createdTopic = await _omfIngressService.CreateTopicAsync(topic);

            Console.WriteLine($"Created a Topic with Id {createdTopic.Id}");
            Console.WriteLine();

            // Create a Subscription
            Console.WriteLine($"Creating a Subscription in Namespace {destinationNamespaceId} for Topic with Id {createdTopic.Id}");
            Console.WriteLine();
            Subscription subscription = new Subscription()
            {
                TenantId         = _tenantId,
                NamespaceId      = destinationNamespaceId,
                Name             = $"{connectionName}-{destinationNamespaceId}",
                Description      = "This is a sample Subscription",
                Type             = SubscriptionType.Sds,
                TopicId          = createdTopic.Id,
                TopicTenantId    = _tenantId,
                TopicNamespaceId = _namespaceId
            };
            Subscription createdSubscription = await _omfIngressService.CreateSubscriptionAsync(subscription);

            Console.WriteLine($"Created a Subscription with Id {createdSubscription.Id}");
            Console.WriteLine();
            OmfConnection omfConnection = new OmfConnection()
            {
                ClientIds    = new string[] { deviceClientId },
                Topic        = createdTopic,
                Subscription = createdSubscription
            };

            return(omfConnection);
        }
Exemplo n.º 7
0
        public async Task DeleteOmfConnectionAsync(OmfConnection omfConnection)
        {
            // Delete the Topic and Subscription
            Console.WriteLine($"Deleting the Subscription with Id {omfConnection.Subscription.Id}");
            Console.WriteLine();

            await _omfIngressService.DeleteSubscriptionAsync(omfConnection.Subscription.Id);

            Console.WriteLine($"Deleted the Subscription with Id {omfConnection.Subscription.Id}");
            Console.WriteLine();

            // Delete the Topic
            Console.WriteLine($"Deleting the Topic with Id {omfConnection.Topic.Id}");
            Console.WriteLine();

            await _omfIngressService.DeleteTopicAsync(omfConnection.Topic.Id);

            Console.WriteLine($"Deleted the Topic with Id {omfConnection.Topic.Id}");
            Console.WriteLine();
        }
Exemplo n.º 8
0
        public async Task <OmfConnection> CreateOmfConnectionAsync(string deviceClientId, string connectionName, string destinationNamespaceId)
        {
            // Create a Topic
            Console.WriteLine($"Creating a Topic in Namespace {_namespaceId} for Client with Id {deviceClientId}");
            Console.WriteLine();
            CreateTopic topic = new CreateTopic()
            {
                Name        = connectionName,
                Description = "This is a sample Topic",
            };

            topic.ClientIds.Add(deviceClientId);
            Topic createdTopic = await _omfIngressService.CreateTopicAsync(topic).ConfigureAwait(false);

            Console.WriteLine($"Created a Topic with Id {createdTopic.Id}");
            Console.WriteLine();

            // Create a Subscription
            Console.WriteLine($"Creating a Subscription in Namespace {destinationNamespaceId} for Topic with Id {createdTopic.Id}");
            Console.WriteLine();
            CreateSubscription subscription = new CreateSubscription()
            {
                Name             = $"{connectionName}-{destinationNamespaceId}",
                Description      = "This is a sample Subscription",
                TopicId          = createdTopic.Id,
                TopicTenantId    = _tenantId,
                TopicNamespaceId = _namespaceId,
            };
            Subscription createdSubscription = await _omfIngressService.CreateSubscriptionAsync(subscription).ConfigureAwait(false);

            Console.WriteLine($"Created a Subscription with Id {createdSubscription.Id}");
            Console.WriteLine();
            OmfConnection omfConnection = new OmfConnection(new List <string> {
                deviceClientId
            }, createdTopic, createdSubscription);

            return(omfConnection);
        }
Exemplo n.º 9
0
 public static async Task DeleteOmfConnectionAsync(OmfConnection omfConnection)
 {
     // Delete the Connection
     await _omfIngressClient.DeleteOmfConnectionAsync(omfConnection).ConfigureAwait(false);
 }