cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
Showing results for 
Search instead for 
Did you mean: 

C# Integration using editissue to update Project parameters list

SOLVED
Regular Member

C# Integration using editissue to update Project parameters list

This is a follow up to my other project parameters thread:

I am using C# to try to update the project parameters list (see other thread for which project parameters) I have the sample code I found on another thread running with no issues.

APIFactory.MKSInitialize();

ip = APIFactory.CreateIntegrationPoint("mks.corp.knorr-bremse.com", 7001, false, 4, 13);

session = ip.CreateSession(<user name>,<password>);

Command issuesView;

issuesView = new Command(Command.IM, "editissue");

issuesView.AddOption("field", "'parameter values'='a_16_Auto_FV_Minus_20_psi=64'");

issuesView.AddSelection("478424");

r = session.RunCommand(issuesView);

and now I get "A first chance exception of type 'MKS.ManagedAPI.CommandCancelledException' occurred in MKS.ManagedAPI.dll"

the Stack trace give me

StackTrace " at MKS.ManagedAPI.CmdRunner.Execute(Command cmd)\r\n at MKS.ManagedAPI.Session.RunCommand(Command command)\r\n at Integrity_Parameters.IntegrityInterface.setParametersList() in C:\\Software.Development\\Integrity Parameters\\Integrity Parameters\\IntegrityInterface.cs:line 103" string

I have run the same code sequence for "viewissue", got the same error with a Stack Trace of ::

StackTrace " at MKS.ManagedAPI.CmdRunner.Execute(Command cmd)\r\n at MKS.ManagedAPI.Session.RunCommand(Command command)\r\n at Integrity_Parameters.IntegrityInterface.viewIssue(Int32 num) in C:\\Software.Development\\Integrity Parameters\\Integrity Parameters\\IntegrityInterface.cs:line 52" string

I am not sure if there is a common problem there or if they are two different issues

Tags (3)
1 ACCEPTED SOLUTION

Accepted Solutions

Re: C# Integration using editissue to update Project parameters list

The following code fixed my issue thank you Nolin Borrero Jr.. per his email

*********************************

I(Nolin Borrero Jr) believe the error is telling you it cancelled because you
didn't give it enough info. For some reason you need to specify host and port
twice. Once for the IIntegrationPoint and once in the Command. Here's a sample
from my code:
Command cmd = new Command("im", "viewissue");
cmd.AddOption("hostname", hostServer);
cmd.AddOption("port", hostPort.ToString());
cmd.AddOption("user", userName);
cmd.AddOption("password", userPassword);
cmd.AddOption("substituteParams");
cmd.AddSelection(IssueID.ToString());

APIFactory.MKSInitialize();

IIntegrationPoint ip = APIFactory.CreateIntegrationPoint(hostServer, hostPort,
false, 4, 13);

Let me know if this helps or not.

Also, as an fyi, take a look at the Integrations Builders Guid and look for the
section "Accessing Item Fields" for info on how to parse the
response. I have a lot of bad code written that I'm going to have to go back
and fix because I didn't read this section.

*********************************

WORKING CODE SNIPET

APIFactory.MKSInitialize();

ip = APIFactory.CreateIntegrationPoint("mks.corp.knorr-bremse.com", 7001, false, 4, 13);

session = ip.CreateSession(<user name>,<password>);

Command issuesView;

issuesView = new Command(Command.IM, "editissue");

issuesView.AddOption("field", "parameter values=a_16_Auto_FV_Minus_20_psi=64");
issuesView.AddOption("hostname", hostName);
issuesView.AddOption("port", port.ToString());
issuesView.AddOption("user", userName);
issuesView.AddOption("password", password);

issuesView.AddSelection("478424");

r = session.RunCommand(issuesView);

View solution in original post

3 REPLIES 3

Re: C# Integration using editissue to update Project parameters list

The following code fixed my issue thank you Nolin Borrero Jr.. per his email

*********************************

I(Nolin Borrero Jr) believe the error is telling you it cancelled because you
didn't give it enough info. For some reason you need to specify host and port
twice. Once for the IIntegrationPoint and once in the Command. Here's a sample
from my code:
Command cmd = new Command("im", "viewissue");
cmd.AddOption("hostname", hostServer);
cmd.AddOption("port", hostPort.ToString());
cmd.AddOption("user", userName);
cmd.AddOption("password", userPassword);
cmd.AddOption("substituteParams");
cmd.AddSelection(IssueID.ToString());

APIFactory.MKSInitialize();

IIntegrationPoint ip = APIFactory.CreateIntegrationPoint(hostServer, hostPort,
false, 4, 13);

Let me know if this helps or not.

Also, as an fyi, take a look at the Integrations Builders Guid and look for the
section "Accessing Item Fields" for info on how to parse the
response. I have a lot of bad code written that I'm going to have to go back
and fix because I didn't read this section.

*********************************

WORKING CODE SNIPET

APIFactory.MKSInitialize();

ip = APIFactory.CreateIntegrationPoint("mks.corp.knorr-bremse.com", 7001, false, 4, 13);

session = ip.CreateSession(<user name>,<password>);

Command issuesView;

issuesView = new Command(Command.IM, "editissue");

issuesView.AddOption("field", "parameter values=a_16_Auto_FV_Minus_20_psi=64");
issuesView.AddOption("hostname", hostName);
issuesView.AddOption("port", port.ToString());
issuesView.AddOption("user", userName);
issuesView.AddOption("password", password);

issuesView.AddSelection("478424");

r = session.RunCommand(issuesView);

View solution in original post

Re: C# Integration using editissue to update Project parameters list

Does MKS/PTC 10.x  exposes its functionality in a .NET assembly or COM library ? How did you write the code above ? Thanks!

Re: C# Integration using editissue to update Project parameters list

Announcements