Ejemplo n.º 1
0
        private static void DeleteAllModels(int iteration)
        {
            foreach (ModelData md in client.GetModels())
            {
                try
                {
                    client.DeleteModel(md.Id);
                    Log.Ok("Successfully deleted Model {" + md.Id + "}. Attempt [" + iteration + "]");
                }
                catch (RequestFailedException e2)
                {
                    //Log.Error("Failed to delete Model {" + md.Id + "}");
                    //Log.Error(e2.Message);
                    // skip this and go to the next one
                }
            }

            try
            {
                IEnumerable <ModelData> c = client.GetModels() as IEnumerable <ModelData>;
                if (c.Count <ModelData>() > 0)
                {
                    DeleteAllModels(iteration + 1);
                }
            }
            catch (Exception)
            {
                return;
            }
        }
Ejemplo n.º 2
0
        public List <ModelDto> GetModels()
        {
            var modelData = _digitalTwinsClient.GetModels(new GetModelsOptions {
                IncludeModelDefinition = true
            }).ToList();

            return(ModelDto.MapFromModelData(modelData));
        }
Ejemplo n.º 3
0
        private void DeleteAllModels(DigitalTwinsClient client, int iteration)
        {
            foreach (DigitalTwinsModelData modelData in client.GetModels())
            {
                try
                {
                    client.DeleteModel(modelData.Id);
                    Log.Ok($"Deleted model '{modelData.Id}' (Iteration {iteration})");
                }
                catch (RequestFailedException ex) when(ex.Status == (int)HttpStatusCode.Conflict)
                {
                    // This model is a dependent and will be deleted in the next iteration.
                }
                catch (Exception ex)
                {
                    Log.Error($"Failed to delete model '{modelData.Id}': {ex.Message}");
                }
            }

            if (client.GetModels().Any())
            {
                DeleteAllModels(client, iteration + 1);
            }
        }
Ejemplo n.º 4
0
        public List <ModelDto> GetModels()
        {
            var modelData = _digitalTwinsClient.GetModels(includeModelDefinition: true).ToList();

            return(ModelDto.MapFromModelData(modelData));
        }