0

I developed an addin for Enterprise Architect using C#. I want to know how to update the direction of a propertyFlow. I tried this method and it is not working. I also tried with debug with attached process and I see the value tagValue.Value is taking the value, but no update in DB after I call element.Update();

UpdateFlowPropertyProperties(element, new Dictionary<string, string> {{"direction","in"}}
public void UpdateFlowPropertyProperties(Element flowProperty, Dictionary<string, string> elementProprieties)
{
    foreach (TaggedValue tagValue in flowProperty.TaggedValues)
    {
        if (elementProprieties.ContainsKey(tagValue.Name))
        {
            tagValue.Value = elementProprieties[tagValue.Name];
        }
    }
    flowProperty.Update();
}

I also tried to run a query in the Enterprise Architect in section "SQL Scratch Pad" and it is still not working: UPDATE t_objectproperties SET t_objectproperties.Value = "in" where Object_ID = 23573 And Property ="direction". I'm thinking if it is not working to update in C# code via element.Update() to use EARepos.Execute(...).

Mark Rotteveel
  • 100,966
  • 191
  • 140
  • 197
Ice
  • 193
  • 1
  • 2
  • 13

1 Answers1

1

If you don't update the tagged value after changing it, the change will not be saved in the database

public void UpdateFlowPropertyProperties(Element flowProperty, Dictionary<string, string> elementProprieties)
{
    foreach (TaggedValue tagValue in flowProperty.TaggedValues)
    {
        if (elementProprieties.ContainsKey(tagValue.Name))
        {
            tagValue.Value = elementProprieties[tagValue.Name];
            tagValue.Update(); // <-- this actually saves the updated value to the database
        }
    }
    flowProperty.Update();// you don't need this if you only want to update tagged values.
}
Geert Bellekens
  • 12,788
  • 2
  • 23
  • 50