Пример #1
0
        private void AssertThingDescription(ThingDescription td)
        {
            if (td == null)
            {
                throw new ArgumentNullException("td");
            }

            td.Assert();
        }
Пример #2
0
        public void ActivateThing(ThingDescription td)
        {
            AssertInternetOfThings();
            AssertThingDescription(td);

            try
            {
                _thingRepository.ActivateThing(td.Id);
            }
            catch (Exception ex)
            {
                throw new ProvisioningException(EXCEPTION_THING, ex)
                      {
                          Stage = ProvisioningStage.ActivateThing
                      };
            }
        }
Пример #3
0
        public async Task <ThingDescription> CreateThingAsync(ThingDescription td)
        {
            int    commandTopic;
            string secret;
            var    stage = ProvisioningStage.None;

            AssertInternetOfThings();
            AssertThingDescription(td);

            try
            {
                stage = ProvisioningStage.StoreThingInDatabase;
                StoreThingInDatabase(td.Id, td.Description, td.Area);

                stage        = ProvisioningStage.CreateThingInServiceBus;
                commandTopic = await CreateThingInServiceBus(td.Id);

                stage  = ProvisioningStage.CreateThingInServiceIdentity;
                secret = CreateThingInServiceIdentity(td.Id);

                stage = ProvisioningStage.CreateThingInRuleIngestion;
                CreateThingInRule(td.Id, PARTITION_INGESTION_RULEGROUP, ServiceBusOperation.Send);

                stage = ProvisioningStage.CreateThingInAccessControl;
                CreateThingInAccessControl(td.Id);

                stage = ProvisioningStage.CreateThingInRuleCommand;
                CreateThingInRule(td.Id, string.Format(PARTITION_COMMAND_RULEGROUP, td.Id), ServiceBusOperation.Listen);

                stage = ProvisioningStage.CreateThingConnectionString;
                td.SetConnectionString(CreateThingConnectionString(td.Id, secret));
                td.SetCommandTopic(commandTopic);
            }
            catch (Exception ex)
            {
                throw new ProvisioningException(EXCEPTION_THING, ex)
                      {
                          Stage = stage
                      };
            }

            return(td);
        }
Пример #4
0
 public ThingDescription CreateThing(ThingDescription td)
 {
     return(CreateThingAsync(td).Result);
 }