Book a Demo

Author Topic: Why delete package cannot effective immediately ?  (Read 5113 times)

Thyiad

  • EA Novice
  • *
  • Posts: 4
  • Karma: +0/-0
    • View Profile
Why delete package cannot effective immediately ?
« on: February 26, 2014, 04:02:10 pm »
Well, i use the parentPackage.Packages delete it's one child package.
But it looks like not deleted. When click it , it pops:

Warning: Underlying model data may have been modified by another user. Press OK to refresh.

After delete child package, i had refresh and update the parent package. It's there some more is needed [ch65311]

Aaron B

  • EA Administrator
  • EA User
  • *****
  • Posts: 941
  • Karma: +18/-0
    • View Profile
Re: Why delete package cannot effective immediatel
« Reply #1 on: February 26, 2014, 04:24:33 pm »
Try calling Repository.RefreshModelView to refresh the package contents in the Project Browser.

Thyiad

  • EA Novice
  • *
  • Posts: 4
  • Karma: +0/-0
    • View Profile
Re: Why delete package cannot effective immediatel
« Reply #2 on: February 26, 2014, 04:39:59 pm »
Thank you very much. It works great!
Please allow me to ask one more question:
When i use EA.Element.TaggedValues.GetByName(name),
if the name doesn't in TaggedValues, it cause COMExeption.
It looks like that if EA.Collection have no right key, it will cause error.
Why ?

Thyiad

  • EA Novice
  • *
  • Posts: 4
  • Karma: +0/-0
    • View Profile
Re: Why delete package cannot effective immediatel
« Reply #3 on: February 26, 2014, 04:41:09 pm »
Quote
Try calling Repository.RefreshModelView to refresh the package contents in the Project Browser.

Aaron B

  • EA Administrator
  • EA User
  • *****
  • Posts: 941
  • Karma: +18/-0
    • View Profile
Re: Why delete package cannot effective immediatel
« Reply #4 on: February 26, 2014, 04:58:20 pm »
Quote
When i use EA.Element.TaggedValues.GetByName(name),
if the name doesn't in TaggedValues, it cause COMExeption.
It looks like that if EA.Collection have no right key, it will cause error.
Why ?

This is intentional and documented:
"If the collection does not contain any items, the method returns a null value. If the collection contains items, but it was unable to find an object with the specified name, the method raises an exception."
http://www.sparxsystems.com/enterprise_architect_user_guide/10/automation_and_scripting/collection.html

You need to add error handling to your code to catch the exception.  How exactly you do this depends on the programming language you are using.  E.g. For VBScript use On Error Resume Next, For JScript use a try...catch block.

Thyiad

  • EA Novice
  • *
  • Posts: 4
  • Karma: +0/-0
    • View Profile
Re: Why delete package cannot effective immediatel
« Reply #5 on: February 26, 2014, 05:54:39 pm »
Quote
Quote
When i use EA.Element.TaggedValues.GetByName(name),
if the name doesn't in TaggedValues, it cause COMExeption.
It looks like that if EA.Collection have no right key, it will cause error.
Why ?

This is intentional and documented:
"If the collection does not contain any items, the method returns a null value. If the collection contains items, but it was unable to find an object with the specified name, the method raises an exception."
http://www.sparxsystems.com/enterprise_architect_user_guide/10/automation_and_scripting/collection.html

You need to add error handling to your code to catch the exception.  How exactly you do this depends on the programming language you are using.  E.g. For VBScript use On Error Resume Next, For JScript use a try...catch block.

It's useful and helped me. Thanks very much for your help.