Exemple #1
0
 private static void DiscoveryServer_ServiceInstanceShutdown(object sender, ServiceInstanceEventArgs e)
 {
     try
     {
         if (assetAdministrationShellRegistry != null && e.TxtRecords?.Count > 0)
         {
             string aasIdKeyValue = e.TxtRecords.FirstOrDefault(t => t.StartsWith(ASSETADMINISTRATIONSHELL_ID + KEY_VALUE_SEPERATOR));
             if (!string.IsNullOrEmpty(aasIdKeyValue))
             {
                 string[] splittedItem = aasIdKeyValue.Split(new char[] { '=' }, StringSplitOptions.RemoveEmptyEntries);
                 if (splittedItem != null && splittedItem.Length == 2)
                 {
                     if (splittedItem[0] == ASSETADMINISTRATIONSHELL_ID)
                     {
                         var deletedResult = assetAdministrationShellRegistry.DeleteAssetAdministrationShell(splittedItem[1]);
                         if (deletedResult.Success)
                         {
                             deletedResult.LogResult(logger, LogLevel.Info, "Successfully deregistered AAS from registry");
                         }
                         else
                         {
                             deletedResult.LogResult(logger, LogLevel.Error, "Could not unregister AAS from registry");
                         }
                     }
                 }
             }
         }
     }
     catch (Exception exc)
     {
         logger.Error(exc, "Error service instance shutdown");
     }
 }
 public IResult DeleteAssetAdministrationShell(string aasId)
 {
     return(aasRegistryImpl.DeleteAssetAdministrationShell(aasId));
 }