You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

92 lines
2.4 KiB

//==================================================
//
// Copyright 2017 Siemens Product Lifecycle Management Software Inc. All Rights Reserved.
//
//==================================================
using System;
using Teamcenter.ClientX;
using User = Teamcenter.Soa.Client.Model.Strong.User;
namespace Teamcenter.Hello
{
/**
* This sample client application demonstrates some of the basic features of the
* Teamcenter Services framework and a few of the services.
*
* An instance of the Connection object is created with implementations of the
* ExceptionHandler, PartialErrorListener, ChangeListener, and DeleteListeners
* intefaces. This client application performs the following functions:
* 1. Establishes a session with the Teamcenter server
* 2. Display the contents of the Home Folder
* 3. Performs a simple query of the database
* 4. Create, revise, and delete an Item
*
*/
public class Hello
{
/**
* @param args -help or -h will print out a Usage statement
*/
public static void Main(string[] args)
{
String serverHost = "http://localhost:7001/tc";
if (args.Length > 0)
{
if (args[0].Equals("-help") || args[0].Equals("-h"))
{
System.Console.Out.WriteLine("usage: Hello [-host http://server:port/tc]");
return;
}
if (args[0].Equals("-host") && args.Length > 1)
{
// Get optional host information
serverHost = args[1];
}
}
try
{
Session session = new Session(serverHost);
HomeFolder home = new HomeFolder();
Query query = new Query();
DataManagement dm = new DataManagement();
// Establish a session with the Teamcenter Server
User user = session.login();
// Using the User object returned from the login service request
// display the contents of the Home Folder
home.listHomeFolder(user);
// Perform a simple query of the database
query.queryItems();
// Perform some basic data management functions
dm.createReviseAndDelete();
// Terminate the session with the Teamcenter server
session.logout();
}
catch (SystemException e)
{
Console.WriteLine(e.Message);
}
}
}
}