6
« on: September 15, 2008, 07:49:14 pm »
Hi News Group,
I like to generate a Sequence Chart with objects and messages using the automation interface. When doing this with the follwing code, I get an exception in the connector update() method. What's wrong with my c# code? Any hints?
// first generate a sd
var x = 200;
var diagram = (IDualDiagram)oPackage.Diagrams.AddNew(oEADMLSequence.Name, "Sequence");
if (diagram.Update() == false)
{
Console.WriteLine(diagram.GetLastError());
}
diagram.Notes = "Diagram was generated by myTool";
diagram.Update();
// create first object in SD
var o1 = (Element)oPackage.Elements.AddNew("o1", "object");
o1.Update();
shownElementList.Add(o1);
// add element to diagram - supply optional rectangle co-ordinates
var client = (DiagramObject)diagram.DiagramObjects.AddNew(string.Format("l={0};r={1};t=200;b=400;", 200 + x, 400 + x), "");
Console.WriteLine("{0} {1} {2} {3}", client.left, client.right, client.top, client.bottom);
client.ElementID = o1.ElementID;
client.Update();
x += 300;
// create 2.nd object in SD
var o2 = (Element)oPackage.Elements.AddNew("o2", "object");
o2.Update();
shownElementList.Add(o2);
// add element to diagram - supply optional rectangle co-ordinates
var supplier = (DiagramObject)diagram.DiagramObjects.AddNew(string.Format("l={0};r={1};t=200;b=400;", 200 + x, 400 + x), "");
Console.WriteLine("{0} {1} {2} {3}", supplier.left, supplier.right, supplier.top, supplier.bottom);
supplier.ElementID = o2.ElementID;
supplier.Update();
// create a message connector of type "sequence" between o1 and o2
var con = (EA.Connector)oClient.Connectors.AddNew("msg1", "sequence");
con.SupplierID = oSupplier.ElementID;
con.DiagramID = diagram.DiagramID;
//con.SequenceNo = 1;
con.TransitionAction = "Call";
con.TransitionEvent = "Asynchronous";
con.TransitionGuard = "retval=void;";
con.Direction = "Source -> Destination";
Console.WriteLine("{0} {1} {2} {3} {4} {5} {6} {7} {8}", con.Name, con.SequenceNo, con.ClientID, con.SupplierID, con.MetaType, con.DiagramID, con.TransitionGuard, con.StyleEx, con.TransitionAction);
con.Update();
oClient.Connectors.Refresh();
Problem is, when calling the method "con.Update()" I get the following DAO exception:
"DAO.Recordset [3022]
Die von Ihnen vorgenommenen Änderungen an der Tabelle konnten nicht vorgenommen werden, da der Index, Primärschlüssel oder die Beziehung mehrfach vorkommende Werte enthalten würde. Ändern Sie die Daten in den Feldern, die gleiche Daten enthalten, entfernen Sie den Index, oder definieren Sie den Index neu, damit doppelte Einträge möglich sind, und versuchen Sie es erneut."
Any help is really appreciated.
Regards,
Wolfgang