TeamShare API
Reference Guide
Last updated: 02 May 2001
Copyright © 1998, 1999, 2000 TeamShare, Inc.
All Rights Reserved
Dear Customer,
This document describes TeamShares database schema and Application Programming Interface (API) for TeamTrack.
With TeamTrack 4.0, we have opened our API to our customers to be used to safely modify TeamTrack databases. Through the database you can extend TeamTrack functionality to meet your company needs. Using the schema is a great means to read and report on information collected through TeamTrack that is not readily available through standard reporting. While this document is available upon customer request, we recommend using the schema only to report on data that is not easily accessible via TeamTrack. Modifications to the database should only be performed using the TeamTrack administrator or our Application Programming Interface (API).
Database
The TeamTrack database is stored in an underlying relational database. This document describes the tables, columns, and relationships of the database. This information should be used cautiously. Please note, TeamShare Customer Support does not support backend modifications. Additionally, changes, deletions and modifications performed directly to the database are not recommended as TeamShare reserves the right to modify the schema when necessary to implement new features. Hence changes made directly to the database may not be upward compatible. If a new table or column is added in a future version, any code written to a prior version will not have knowledge of the new tables or columns, and thus may not perform correctly.
Through TeamTrack, important information is captured in the database. Companies may have unique needs to gather, organize and analyze this data. While keeping in mind the schema may change with new releases of the product, it is safe to use this information to read and display data from the database. For example, you may wish to write a custom report that processes issues in a special way or you may want to capture time metrics (historical data) using the TS_CHANGES table. This document will aid you in creating reports of this nature and more.
Application Programming Interface (API)
TeamShare recommends performing database modifications through the Administrator or by creating an application which uses the API. Alterations that can not be done through the Administrator should be performed through the API. TeamShare makes best efforts to ensure upward compatibility should database changes be performed in this manner. The API is available to all TeamTrack customers.
The TeamShare API is written in C++. Using the API, modification to the database can now be done safely. Applications can be written to this API, which import and export data between TeamShare applications and other application programs. C++ programming experience is required to create an application using this class library. Please note, TeamShare does not support the API through its standard Customer Support contract. API support will be available in time-blocks through our Professional Services Group (PSG). PSG staffs expert C++ developers who are available to support and/or develop these applications to meet your needs. Should assistance be required in creating or understanding API classes, please contact your sales executive.
For more information about securing PSG services to support and/or develop API applications to meet your needs, contact your TeamShare account manager.
Thank you,
TeamShare, Inc.
TeamShare API
Overview
The TeamShare API is a collection of C++ source files that can be used to build a Windows DLL or a Linux library file. This library allows a client program to connect to the teamtrack server and query or update data in the database. The client program can run on the same computer as the teamtrack server or on any computer that has network access to the server.
Getting Started
Using the TeamShare API consists of the following steps.
The API and sample programs should compile on Windows 95, 98, NT, 2000 and Linux. For Windows platforms, we supply workspace and project files for MS Developers Studio. For Linux, we supply a basic makefile.
All the following directions are written for users of MSVC++ 6.0. If you are using some other development environment, you will need to use the menu commands appropriate for that tool.
Building the API and Sample Programs
The easiest way to do this is to load the workspace file samples.dsw and rebuild all. Use Build->Batch Build->Rebuild All from the menu. This will build the debug and release versions of the sample programs and the API DLLs. These binaries will all be put in the directories \Build\Debug and \Build\Release.
Now you can run each of the samples and get a feeling for how they operate. It may be a good idea to run against a sample database rather than your production system until you are accustomed to how the API operates. You can choose which server the sample programs connect to when you run them.
Note Concerning Developer Studio 97: In order to build the sample programs under Dev Studio 97, the preprocessor definition _DEV_STUDIO_5 will need to be added to each sample program's project settings as well. In addition, you should expect compiler warnings in Debug mode using Dev Studio 97.
Note Concerning User Privileges: The ability to connect to the server via the API is controlled on a per-user basis. By default, users do not have the privilege to connect using the API turned on. You will need to use ttAdmin to set this privilege for the appropriate users.
Building Your Own Custom Program Using the TeamShare API
This task requires significant skill in C++ programming and it is far beyond the scope of this document to provide detailed instructions. The following instructions will help get you started.
Preprocessor Symbols
Reference Guide
The TeamShare Application Programming Interface (hereafter API) can be used as an alternative means of manipulating data found in the TeamTrack database. It can be used to import or export data between TeamTrack and other application API programs, to add issues, incidents, users, groups, companies, contacts, projects, folders, and fields, or simply to move folders and projects around in the hierarchy. It can also be used to verify and establish privileges, mass transition issues or incidents, to verify data or develop custom reporting. In addition, the API provides a means to communicate or share data between applications. The API can be used to create an application that updates TeamTrack data with data from other applications.
The API is a C++ class library. C++ programming knowledge is required to create an application using this library. Note: TeamShare does not support the API through the standard Technical Support contract. Should assistance be required in creating or understanding API classes, please contact your sales representative.
Class synopsis
Classes the API Programmer will use on a regular basis:
|
TSServer |
Representation of the TeamTrack server in the API program |
|
TSRecord |
A generic representation of a single record from any table in the TeamTrack database |
|
TSRecordList |
List of TSRecord objects. |
|
TSTreeList |
List of TSRecord objects in hierarchical order. |
|
TSField |
Represents a single field of a record. This generic field object will contain either a text string, an integer or a double depending on the datatype of the field. |
|
TSFieldList |
List of TSField objects. |
|
TSPosition |
Pointer to a position in a list. Used for iterating through a list of records or fields. |
|
TSString |
Class to manage a text string, perform comparisons, concatenations etc. |
|
TSSchema |
Schema for record. |
|
TSRecordRef |
Class can be instantiated directly or through derived classes in order to retrieve the name of an item. |
|
TSProject |
Class to provide sFullProjectName which contains a tab-delimited ( ^i ) string representing the full project hierarchy. |
|
TSTransition |
Class describes a transition. |
|
TSItem |
Class defines the base interface for both primary and auxiliary items. |
|
TSAuxiliaryItem |
Class defines the interface for an item that has variable fields and is not a Primary Item. |
|
TSPrimaryItem |
Class defines a primary item. |
|
TSDisplayField |
Class describes fields as they are displayed. |
|
TSItemLink |
Class describes item links. |
|
TSAttachment |
Class describes a file, URL, or a note attachment. |
|
TSChangeHistory |
Class describes the change history for a record. |
Additional classes the typical API Programmer shouldnt ever need to use:
|
TSObject |
Abstract base class for any object to be put on a TSList |
|
TSList |
Base class for all list classes. |
|
TSSocket |
Object to send a receive data on a TCP/IP socket. |
|
CSocket |
Base class for the TSSocket class. Depending on whether you are writing your API program on UNIX or Windows this will either be the MFC CSocket class or TeamShares own CSocket class. |
|
TSIntObject |
Class to manage integers. |
|
TSIntList |
List of integer objects. |
TSServer is the main interface used to communicate with a webserver hosting a TeamTrack database. It is the primary entry class to TeamTrack. Methods called in TSServer build a string with the name of the method and any parameters needed for that method. This string is then sent across the socket to the web server. The API application then issues a Receive and waits for data to come back. The web server parses the string and calls the appropriate method in TeamTracks source code. Once the request has been processed, data is sent back across the socket. The data is received and processed on the API side.
The other exposed classes are supporting classes. This document outlines all available classes, member functions and variables. Sample programs can be found in the TeamShare directory under API/samples. Individual or all the sample applications can be built using the Samples.dsw project workspace.
The sample programs are:
ConsolidateFields
Syntax: ConsolidateFields
This is a windows application which uses MFC classes. This program is used to combine two fields of the same type into one of the fields. For example, if there are two numeric fields, one that is used often and one that is rarely used, this program can be used to move the data from the field that is rarely used into the other field. The first field could then be used for something else. This program demonstrates the use of a dialog box for authenticating the user and obtaining input. The user will be prompted to select the appropriate table which has fields defined which the user wishes to consolidate. The user will also be prompted to select which field is the destination and which field is the source for the consolidation.
DeletedItemsReport
Syntax: DeletedItemsReport
Lists the issues or incidents that have been deleted, when, and by which user. Demonstrates the use of command prompts to obtain authentication for running the program.
GetTableId
Syntax: GetTableId
Prompts the user to enter the database name of a table and returns the numeric Id of the table.
ListGroupMembers
Syntax: ListGroupMembers
Lists the names of all the members of a specific group. Demonstrates use of command prompts to obtain the parameters for the program.
ListGroups
Syntax: ListGroups
Lists all group names defined in the database. Demonstrates using command prompts to obtain authentication for running the program.
ListPrivs
Syntax: ListPrivs
Lists the privileges for either a user or a group. Demonstrates using command prompts to obtain the parameters for the program. Privileges are not broken down by project.
ReadListWithWhere
Syntax: ReadListWithWhere <server_name><login_id> <password> <table_id> "where clause" (w/o the word "where")
Reads all the records from a specified table based on the WHERE clause passed. The user does not need to type the word "WHERE".
ReadRecord
Syntax: ReadRecord <server_name> <login_id> <password> <table_id> <record_id> <optional_field_type>
Reads a particular record from a table for a specified ID and displays the data on the screen.
ReadRecordMFC
Syntax: ReadRecordMFC /h | <server_name> <login_id> <password> <table_id> <record_id>
Reads a particular record from a table for a specified ID and displays the data on the screen. Demonstrates how to use the MFC CSocket class to connect to the webserver.
ReadUser
Syntax: ReadUser <server_name> <login_id> <password> <user_name>
Reads a record from the TS_USERS table and displays the data to the screen. This user is required to type all parameters after the program name.
ReadWithWhere
Syntax: ReadWithWhere
Reads the records from the specified table based on the WHERE clause passed. The user does not need to type the word "WHERE". This sample demonstrates the use of command prompts to obtain the parameters for the program.
ShowAvailableTables
This is a windows program that lists the names of the tables defined in the database. All tableids are defined in TSDef.h using the naming convention: TS_TBLID_tablename. "Tablename" would be capitalized. For example, to reference the tableid for the TS_CONTACTS table, use TS_TBLID_CONTACTS. This sample demonstrates the use of dialog to obtain authentication for running the program and displaying information.
SubmitIssue
Syntax: SubmitIssue
Submits either an Issue or an Incident. This sample demonstrates the use of command prompts to obtain the parameters for the program. It is important to note that any fields can be skipped if the user does not wish to enter a value. If the field is required, the user will be re-prompted for the value. Multi-select fields are listed as data type "string" and need to be entered with the appropriate corresponding selection ids strung together. For example: 98, 99, 101.
TransitionIssue
Syntax: TransitionIssue
Transitions an Issue or an Incident record. This sample demonstrates the use of command prompts to obtain the parameters for the program. Note: The Transition Name parameter is case-sensitive.
Update
Syntax: Update
Updates an item in the database. Demonstrates the use of command prompts to obtain authentication for running the program and for indicating which table record to update and the records new field values.
Getting Started
A TeamTrack login id and password are required to establish a connection with the TeamTrack database across a socket. In order to run API programs on a machine other than the webserver, the login id and password must correspond to a user who has also been granted the privilege to "Connect using the API". This is a new system privilege in version 4.0 of TeamTrack.
Steps to Building a Simple API Application Program
TSServer teamtrack;
teamtrack.Connect("admin","password","teamtrack_host");
TSRecordList statesList;
TSRecord user(TS_TBLID_USERS, &teamtrack);
Teamtrack.ReadRecord(&user, 5);
user.SetString("email","chris_tester@teamshare.com");
if(teamtrack.ReadAllRecords(&statesList, TS_TBLID_STATES) != TS_OK)
{
printf("Error reading from states table\n");
return 1;
}
Platform Dependencies
TS_USE_MFC
The API assumes no dependencies on the MFC CSocket class. In order to use MFC, define a preprocessor directive in the Project Settings called TS_USE_MFC. This definition directs the API to use the MFC CSocket class. If there is no definition, a generic CSocket class will be used. If using Linux or Unix, there is no definition necessary.
If the user is on Windows but not using MFC, it is not necessary to define any preprocessor directives. In this case, TS_USE_WINSOCK is defined and Windows Sockets is used. (Refer to TSSocket.h for the source code.)
Table Dependencies
To enforce the referential integrity between tables in the database, it is helpful to be knowledgeable about the relationships.
TS_TABLES This table holds the last id value that was used for every table in the database. Any time a record is added to a table, the TS_LASTID column corresponding to that table needs to get incremented. The id values for every table are defined as constants in TSDef.h.
Reading data from tables
The majority of tables can be read using a generic read function, such as ReadAllRecords. This function has the added overhead of carrying any supporting lists of data that relate to the record being read. For example, if reading the list of Users, the supporting Membership and Privilege information is also read and added to the returning recordlist.
The Cases and Incidents tables are special.
Both TS_CASES and TS_INCIDENTS have only a few true fields (for example, id, parentid, tempid, etc.). Reading data from these tables requires thought. Fields are defined for a Workflow and the Workflow is associated with a Project. In addition, each project can override the field definition of the workflow. To read or write Issues or Incidents requires determining what project that issue belongs to, then which fields are valid for that project by which workflow is associated to it, then determining how fields have been affected by overrides.
The TSTreeList class is provided to facilitate reading data from tables that are recursive, for example, Projects, Workflows, Incidents, Folders, etc. It inherits from TSRecordList and should be used instead of TSRecordList when reading from these tables. To know which field is the sublist of a tree item, use the schema type called TS_SCHEMATYPE_TREELIST. Its like a TS_SCHEMATYPE_LIST in every way except the field that has this schematype is the field that contains the sublist.
Table Schemas
There are certain tables that contain a few non-database columns in addition to their physical database columns. These non-database columns are built programmatically to prevent the user from have to issue a separate read for the information. They are helpful for coding purposed because they contain information related to the records in the table. For example, the schema for the Groups table contains database columns of ID, NAME, STATUS, ACCESSTYPE, and TYPE. It also contains non-database columns of MEMBERLIST and PRIVILEGES, which are lists of the members belonging to the group and the privileges attributed, respectively.
Helpful schema information (the fieldname is in bold):
Folders table
TREELIST(CFolder, 0, subfolders, DATATYPE_OBLISTEX)
Groups table
LIST(CGroup, 0, memberList, DATATYPE_OBLISTEX)
LIST(CGroup, 0, privileges, DATATYPE_OBLISTEX)
Notifications table
LIST(CNotification, 0, subscribers, DATATYPE_OBLISTEX)
Projects table
TREELIST(CProject, 0, subprojects, DATATYPE_OBLISTEX)
Selections table
LIST(CSelection, 0, projSelections, DATATYPE_OBLISTEX)
States table
LIST(CState, 0, transtriggerstates, DATATYPE_OBLISTEX)
Transitions table
LIST(CTransition, 0, properties, DATATYPE_OBLISTEX)
LIST(CTransition, 0, issueTypes, DATATYPE_OBLISTEX)
LIST(CTransition, 0, projectTransitions, DATATYPE_OBLISTEX)
LIST(CTransition, 0, transtriggers, DATATYPE_OBLISTEX)
Users table
LIST(CUser, 0, memberList, DATATYPE_OBLISTEX)
LIST(CUser, 0, privileges, DATATYPE_OBLISTEX)
Workflows table
TREELIST(CWorkflow, 0, subworkflows, DATATYPE_OBLISTEX)
How can the API be used?
The TeamShare API can be used for a variety of tasks. The following list of tasks corresponds directly to the individual methods defined in the TSServer class. Any of the methods can be used in combination to accomplish larger tasks.
Method |
Description |
|
AddField |
Use to add a custom field to the following tables: Cases, Companies, Contacts, Incidents, Merchandise, Problems, Products, Resolutions, and Service Agreements |
|
AddRecord |
Add a new record to any table (i.e. new issues, incidents, users, groups, projects, folders, companies, contacts, establish privileges, create reports, etc. |
|
BuildFieldList |
Obtain a list of fields defined for any given table. |
|
DeleteRecord |
Delete any record from any table |
|
GetConnectionInfo |
Obtain information about the database connection |
|
GetDbInfo |
Obtain information about the database (i.e. version number, etc.) |
|
GetInt |
Obtain the numeric value of a column in any table |
|
GetLastErrorMessage |
Obtain the last error that occurred |
|
GetSchema |
Obtain the table schema for any table |
|
GetString |
Obtain the string value of any column in any table |
|
GetSubmitTransition |
Obtain the id value for the submit transition |
|
HasPrivilege |
Verify a users privileges |
|
MoveFolder |
Move a folder to a new place in the hierarchy |
|
MoveProject |
Move a project to a new place in the hierarchy |
|
ReadAllRecords |
Obtain all the records from any table |
|
ReadAttachmentList |
Obtain a list of the attachments to a given item |
|
ReadChangeList |
Obtain a list of changes made to any issue or incident. Its possible to order the changes from newest to oldest. The default order is oldest to newest. |
|
ReadFolderItems |
Obtain a list of the items currently in a given folder |
|
ReadFolderList |
Obtain a list of folders defined for a given user |
|
ReadProjectSelectionList |
Obtain a list of selections for a given project |
|
ReadProjectTransitionList |
Obtain a list of transitions available for a given project |
|
ReadPropertyList |
Obtain a list of property records for a given transition |
|
ReadRecord |
Obtain one record from any table |
|
ReadRecordForId |
Obtain a record based on a given id value |
|
ReadRecordListWithWhere |
Obtain a list of records from a given table based on a set of conditions |
|
ReadRecordWithWhere |
Obtain one record from a given table based on a set of conditions |
|
ReadReport |
Obtain a report based on the name |
|
ReadReportList |
Obtain a list of reports available to a given user based on their privileges |
|
ReadSelectionList |
Obtain a list of selection values defined for a given field and that are available to a given project |
|
ReadStateList |
Obtain a list of states that are available to a given project |
|
ReadTransitionList |
Obtain a list of transitions and the fields they use / that are available |
|
ReadUserDefinedFields |
Obtain a list of the user-defined fields for a given table |
|
ReadUserListForPrivilege |
Obtain privilege information for a given user |
|
ReadUserSelectionList |
Obtain a list of selection field values available to a given user for a given project |
Method |
Description |
|
ReadVCActions |
Obtain a list of Version Control activity for a given issue |
|
ReadVCActionsForModule |
Obtain a list of Version Control activity for a given user |
|
SetExitUrl |
Sets the exit URL string stored in the SystemInfo table |
|
Submit |
Submit a new Issue or Incident to the database |
|
Transition |
Transition an existing Issue or Incident |
|
UpdateList |
Update a list of records for a given table; could be used to mass transition issues or incidents, or for importing a list of users instead of individually creating them |
|
UpdateRecord |
Update a single record in a table. |
|
ValidateUser |
Validate the login id for a given user, returns TRUE if the login id and password are valid |
|
ValidateVersion |
Validate the version of API against the version of TeamTrack installed on the webserver for compatibility |
TSAPI objects / classes
API Object Hierarchy ~
TSObject
|_____ TSField
|_____ TSRecord
|_____ TSSchema
|_____ TSString
|_____ TSIntObject
TSList
|_____ TSFieldList
|_____ TSRecordList
|_____ TSTreeList
|_____ TSIntList
TSPosition
TSServer
CSocket (MFC)
|_____ TSSocket
TSRecordRef
|_____ TSProject
|_____ TSTransition
|_____ TSItem
|_____ TSAuxiliaryItem
|_____ TSPrimaryItem
|_____ TSDisplayField
|_____ TSItemLink
|_____ TSAttachment
|_____ TSChangeHistory
TSAPI Object Definition
TSAuxiliaryItem
This class is a derivative of TSItem and defines the interface for an object that has variable fields and is not a primary item.
Methods
TSAuxiliaryItem( TSServer& server, int nTableId = 0, int nItemId = 0 )
TSAuxiliaryItem( const TSAuxiliaryItem& that )
TSAuxiliaryItem& operator = ( const TSAuxiliaryItem& that )
virtual ~TSAuxiliaryItem()
virtual int StartUpdate( bool bLockFlag = true )
virtual int FinishUpdate()
virtual int CancelUpdate()
TSString StringDump( TSString sIndentation )
Member Variables
None
TSAttachment
This class is a derivative of TSRecordRef and describes a file, URL, or a note attachment.
Methods
TSAttachment( TSServer& server, int nItemId = 0 )
TSAttachment( const TSAttachment& that )
TSAttachment& operator = ( const TSAttachment& that )
virtual ~TSAttachment()
int GetType() const
const TSString& GetText() const
const TSString& GetDateTimeCreated() const
const TSString& GetAuthor() const
int GetFileLength() const
const char* GetFileData() const
TSString StringDump( TSString sIndentation )
int Receive( TSSocket* socket )
virtual int Read()
int ReadById( int nItemId )
Member Variables
int m_nType
TSString m_sText
TSString m_sDateTimeCreated
TSString m_sAuthor
char* m_pFileData
int m_nFileLength
TSChangeHistory
This class is a derivative of TSRecordRef and describes the change history for an item.
Methods
TSChangeHistory( TSServer& server, int nItemId = 0 )
- Constructor method; initializes the object and automatically sets table id member.
TSChangeHistory( const TSChangeHistory& that )
TSChangeHistory& operator = ( const TSChangeHistory& that )
virtual ~TSChangeHistory()
int GetFieldId() const
int GetFieldType() const
- Gets the field type, e.g. user, of the field being modified
int GetFieldAttribute() const
const TSString& GetFieldName() const
int GetActionType() const
const TSString& GetDateTime() const
const TSString& GetAuthor() const
const TSString& GetPriorDisplayValue() const
int GetPriorInt() const
const TSString& GetNewDisplayValue() const
int GetNewInt() const
int GetType() const
TSString StringDump( TSString sIndentation )
int Receive( TSSocket* socket )
virtual int Read()
int ReadById( int nItemId )
Member Variables
int m_nFieldId
int m_nFieldType
int m_nFieldAttribute
TSString m_sFieldName
int m_nActionType
int m_nType
TSString m_sDateTime
TSString m_sAuthor
TSString m_sPriorDisplayValue
int m_nPriorInt
TSString m_sNewDisplayValue
int m_nNewInt
TSDisplayField
This class is a derivative of TSRecordRef and describes the fields in the display form for an item.
Methods
TSDisplayField( TSServer& server, int nItemId = 0 )
TSDisplayField( const TSDisplayField& that )
TSDisplayField& operator = ( const TSDisplayField& that )
virtual ~TSDisplayField()
const TSString& GetDisplayValue() const
void SetDisplayValue( const TSString& sNewDisplayValue )
void SetDisplayValue( const TSRecordRef* sNewSelection )
int GetType() const
const TSString& GetPrefix() const
int GetAttribute() const
int GetProperty() const
int GetRequired() const
const TSString& GetSuffix() const
int GetSection() const
bool IsModified() const
bool IsUpdateable() const
const TSRecordRefList& GetSelections() const
TSString StringDump( TSString sIndentation )
int Receive( TSSocket* socket )
virtual int Read()
int ReadById( int nItemId )
Member Variables
TSString m_sDisplayValue
int m_nType
int m_nAttribute
int m_nProperty
int m_nRequired
int m_nSection
bool m_bModifiedFlag
TSRecordRefList m_selections
bool m_bCanUpdate
TSString m_sPrefix
TSString m_sSuffix
TSField
This class represents a single field of a record. This generic field object will contain either a text string, an integer, or a double, depending on the datatype of the field.
Methods
void Copy (TSObject *newObjsourceField)
TSString DumpSchema (TSString indentation)
TSObject * Duplicate()
TSString FieldTypeToName (int fieldType)
TSObject * NewObject()
int Receive(TSSocket *socket, TSServer *server)
int ReceiveSchema (TSSocket *socket)
int SocketString (TSString &str)
TSString StringDump(int recursive, TSString indentation)
TSField()
TSField (const TSField &/*field*/)
~ TSField()
Member Variables
Int schemaType
Char fieldName[64]
Int dataType
Int fieldType (For use if this is a field of the Fields table)
Field data. One of these variables will contain data. The others will be 0 or NULL.
Char *charValue
Int charValueMax
Int intValue
Double doubleValue
TSRecordList *recordList
FieldType will be populated with the TS_FLDTYPE_X values defined in TSDef.h, if reading from the TS_FIELDS table. If reading from any other table, fieldType will be null and dataType will be populated with the TS_DATATYPE_X values defined in TSDef.h. The values indicate the type of data the field contains, for example, integer value, string value, boolean value, etc.
Use the TS_AUTO_X values defined in TSDef.h to have TeamTrack automatically set the fields value. See the sample program Update for example code.
TSFieldList
This class is a descendant of the TSList class. It is used to contain a list of TSField objects.
Methods
TSString DumpSchema (TSString indentation)
TSField * FindFieldByName(const char *fieldName, int fieldType)
TSField * GetAt (TSPosition *pos)
Member Variables
None
TSIntList
This class is a derivative of TSList. It is used to maintain a list of TSIntObject objects, used with binary and selection type fields.
Methods
TSIntList()
~TSIntList()
int Receive( TSServer* server, TSSocket* socket )
TSIntObject* GetAt()
TSString CommaSeparatedList()
void PopulateByCommaSeparatedList( TSString* sList )
Member Variables
None
TSIntObject
This class is a derivative of TSObject. It provides the means to make a TSList of integers for use with binary and selection type fields.
Methods
TSIntObject()
TSIntObject( int newIntValue )
TSIntObject( const TSIntObject& intObject )
~TSIntObject()
int Receive( TSSocket* socket, TSServer* server )
TSObject* NewObject()
TSObject* Duplicate()
void Copy( TSObject* sourceIntObject )
TSString StringDump( int recursive, TSString indentation )
int SocketString( TSString& out )
Member Variables
int intValue
TSItem
This class is derived from a TSRecordRef and defines the base interface for both primary and auxiliary items. These items have several shared characteristics, so a base class makes sense. This class should not be instantiated directly, so the constructor is protected. Please see the TSAuxiliaryItem and TSPrimaryItem derived classes.
Methods
TSItem( TSServer& server, int nTableId = 0, int nItemId = 0 )
- Constructor method; protected, not to be accessed directly.
TSItem( const TSItem& that )
TSItem& operator = ( const TSItem& that )
virtual ~TSItem()
virtual bool IsValid() const
TSDisplayFieldList& GetFieldList()
const TSDisplayFieldList& GetFieldList() const
const TSChangeList& GetChangeList() const
TSAttachmentList& GetAttachmentList()
const TSAttachmentList& GetAttachmentList() const
TSItemLinkList& GetLinkList()
const TSItemLinkList& GetLinkList() const
The bit masks describing the sections that will be obtained when this call is made are:
The constructors will set all bit masks, except TS_SECTMASK_FILE_CONTENTS.
------------------------------------------------------------------------------------------------- */
int GetSectionMask() const
void SetSectionMask( int nNewSectionMask )
void SetSectionMaskBits( int nBitsToSet )
void ClearSectionMaskBits( int nBitsToClear )
virtual int Read()
virtual int StartSubmit()
virtual int FinishSubmit()
int AddAttachment( int nType, const TSString& sLabel, const TSString& sText )
int AddItemLinkByNumber( int nDestProjectId, int nDestItemNumber, int nLinkType )
TS_STORE_ACTION_TWOWAYLINK = 0x0100
TS_STORE_ACTION_SOURCETRIGGER = 0x0200
TS_STORE_ACTION_DESTTRIGGER = 0x0400
int AddItemLinkById( int nDestTableId, int nDestItemId, int nLinkType )
TS_STORE_ACTION_TWOWAYLINK = 0x0100
TS_STORE_ACTION_SOURCETRIGGER = 0x0200
TS_STORE_ACTION_DESTTRIGGER = 0x0400.
int DeleteAttachment( TSAttachmentList::iterator it )
- Deletes the attachment from this item and the attachment list. Requires a roundtrip to the server.
int DeleteItemLink(TSItemLinkList::iterator it, bool bDeleteBothSides = true )
- Deletes the item link from this item and the link list. The bDeleteBothSides argument specifies
whether to also delete a link back to this item if it exists. Requires a roundtrip to the server.
Member Variables
TSDisplayFieldList m_fieldList
TSChangeList m_changeList
TSAttachmentList m_attachmentList
TSItemLinkList m_linkList
int m_nSectionMask
int m_nMode
TSItemLink
This class describes item links.
Methods
TSItemLink( TSServer& server, int nItemId = 0 )
- Constructor method; initializes object and automatically sets the table id member.
TSItemLink( const TSItemLink& that )
TSItemLink& operator = ( const TSItemLink& that )
virtual ~TSItemLink()
int GetLinkType() const
const TSString& GetCreator() const
const TSString& GetDateTimeCreated() const
int GetDestProjectId() const
int GetDestItemNumber() const
int GetDestTableId() const
- Gets the table id of the item associated with the link.
int GetDestItemId() const
TSString StringDump( TSString sIndentation )
int Receive(TSSocket* socket)
virtual int Read()
int ReadById( int nItemId )
Member Variables
int m_nLinkType
TSString m_sCreator
TSString m_sDateTimeCreated
int m_nDestProjectId
int m_nDestItemNumber
int m_nDestTableId
int m_nDestItemId
TSList
This class is the base class from which all types of lists inherit.
Methods
int AddHead(TSObject *object)
int AddTail(TSObject *object)
int Copy(TSList *newListsourceList)
int Duplicate(TSList *newList)
void EmptyAndDestroyList()
void EmptyList()
TSPosition * Get(int index)
TSObject * GetAt(TSPosition *pos)
TSPosition * GetFirst()
TSPosition * GetLast()
TSPosition * GetNext(TSPosition *pos)
TSPosition * GetPrev(TSPosition *pos)
int InsertAfter(TSPosition *pos, TSObject *object)
int InsertBefore(TSPosition *pos, TSObject *object)
int Length()
TSObject* RemoveObject(TSObject *pObject)
TSObject * RemoveObject(TSPosition *pos)
TSObject * RemoveObject(int index)
int SocketString(TSString &str)
TSString StringDump(int recursive, TSString indentation)
TSList()
~TSList()
Member Variables
TSPosition *first
TSPosition *last
int length
TSObject
This class is an abstract base class for any object to be put on a TSList. Most API classes inherit from this class.
Methods
virtual void Copy(TSObject *) = 0
virtual *Duplicate() = 0
virtual *NewObject() = 0
virtual int SocketString(TSString &str) = 0
virtual TSString StringDump(int recursive, TSString indentation) = 0
virtual ~TSObject()
Member Variables
None
TSPosition
This class is used to iterate through a list of records or fields. It is a pointer to a position in a list.
Methods
TSPosition()
TSPosition(TSPosition *nextPos, TSPosition *prevPos, TSObject *thisObj)
Member Variables
TSPosition *next
TSObject *object
TSPosition *prev
TSPrimaryItem
This class is derived from TSItem and defines a primary item.
Methods
TSPrimaryItem( TSServer& server, int nTableId = 0, int nItemId = 0 )
TSPrimaryItem( TSServer& server, const TSProject& project, int nItemNumber = 0 )
TSPrimaryItem( const TSPrimaryItem& that )
TSPrimaryItem& operator = ( const TSPrimaryItem& that )
virtual ~TSPrimaryItem()
virtual void SetItemId( int nNewItemId )
int GetProjectId() const
void SetProjectId( int nNewProjectId )
int GetItemNumber() const
void SetItemNumber( int nNewItem )
int GetStateId() const
const TSString& GetItemType() const
virtual int Read()
int ReadByNumber( int nProjectId, int nItemNumber )
virtual int StartSubmit()
int StartSubmitIntoProject( int nProjectId )
int StartSubmitIntoProject( TSProject& project )
virtual int GetTransitionList( TSTransitionList& results )
virtual int StartTransition( int nTransitionId )
virtual int StartTransition( TSString sTransitionName )
virtual int StartTransition( const TSTransition& transitionItem )
virtual int FinishTransition()
virtual int CancelTransition()
int Receive( TSSocket* socket )
virtual bool IsValid() const
TSString StringDump( TSString sIndentation )
Member Variables
int m_nProjectId
int m_nItemNumber
int m_nStateId
TSString m_sItemType
int m_nTransitionId
TSProject
The TSProject class is a descendant of the TSRecordRef class. It is used to provide the
sFullProjectName in a tab-delimited ( ^i ) string representing the full project hierarchy, for example: TeamShare Projects^iEngineering^iProducts^itSupport.Methods
TSProject(TSServer& server, TSString sFullProjectName)
TSProject(TSServer& server, int nItemId = 0)
TSProject(const TSProject& that)
TSProject& operator = ( const TSProject& that )
virtual ~TSProject()
TSString GetFullProjectName() const
int GetPrimaryTableId() const
int GetProjectId() const
virtual void SetItemId( int nNewItemId )
void SetProjectId( int nNewProjectId )
void SetFullProjectName( const TSString& sNewFullProjectName )
virtual int Read()
int ReadByFullProjectName( TSString sFullProjectName )
TSString StringDump( TSString sIndentation )
virtual bool IsValid() const
int Receive( TSSocket* socket )
void SetTableId( int nNewTableId )
Member Variables
TSString m_sFullProjectName
int m_nPrimaryTableId
The TSRecord class contains the data for a particular record in the database. The constructor asks for the list of fields for a record of its type from the server. The API programmer can fill in fields for performing an AddRecord or use it to perform a ReadRecord or any other method that returns a record.
Methods
void ClearDeletedRecord()
void ClearNewRecord()
void ClearNewRecordWithID()
void ClearUpdatedRecord()
void Copy(TSObject *objsourceRecord)
void CopyUserDefFieldsFrom()
void CopyUserDefFieldsTo()
TSObject * Duplicate()
double GetDouble(const char *fieldName)
int GetDouble(const char *fieldName, double *value)
int GetInt(const char *fieldName)
int GetInt(const char *fieldName, int *value)
int GetRecordList(const char *fieldName, TSRecordList **value)
TSRecordList * GetRecordList(const char *fieldName)
int GetString( const char* fieldName, char** value )
int GetString(const char *fieldName, char **value)
char* GetString( const char* fieldName )
char * GetString(const char *fieldName)
int GetString( const char* fieldName, char* value, int bufferSize )
int GetString(const char *fieldName, char *value, int bufferSize)
int GetString( const char* fieldName, TSString* value )
int GetString(const char *fieldName, TSString *value)
TSTreeList * GetSubTreeList()
void Initialize(int tableId, TSServer *server)
int MembersToStringBySchemaType(TSString &out, int schemaType)
TSObject * NewObject()
int Receive(TSSocket *socket)
int ReceiveFieldsBySchemaType(TSSocket *socket, int schemaType)
int ReceiveUserDefinedFields(TSSocket *socket)
void SetDeletedRecord() { recordState |= RecordDeleted; }
int SetDouble(const char *fieldName, double value)
int SetInt(const char *fieldName, int value)
void SetNewRecord() { recordState |= RecordNew; }
void SetNewRecordWithID() { recordState |= RecordNewWithID; }
int SetString(const char *fieldName, const char *value)
void SetUpdatedRecord() { recordState |= RecordUpdated; }
int SocketString(TSString &str)
TSString StringDump(int recursive, TSString indentation)
TSRecord()
TSRecord
~TSRecord()
int UserDefinedFieldsToSocketString(TSString &out)
Member Variables
TSFieldList fieldLlist (The field list will be public)
Int fieldType
BOOL fromPos
Static const int RecordDeleted
Static const int RecordNew
Static const int RecordNewWithId
BOOL recordState
Static const int RecordUpdated
TSServer serverRef
Int sqlDataType
Int tableId
TSString tableName
TSRecordList userDefinedFields
TSRecordRef
This class is the base class for several other class objects. It can also be instantiated stand-alone, when only the name of an item needs retrieved.
Methods
TSRecordRef( TSServer& server, int nTableId = 0, int nItemId = 0 )
TSRecordRef( const TSRecordRef& that )
virtual ~TSRecordRef()
TSRecordRef& operator =( const TSRecordRef& that )
int GetTableId() const
virtual bool IsValid() const
TSString StringDump( TSString sIndentation )
void SetTableId(int nNewTableId )
int GetItemId() const
void SetItemId( int nNewItemId )
const TSString& GetItemName() const
virtual int Read()
int ReadById( int nItemId )
int Receive( TSSocket* socket)
Member Variables
int m_nTableId
int m_nItemId
TSString m_sItemName
TSServer& m_server
TSRecordList
The TSRecordList class is a child of TSList. It is used to maintain a list of TSRecord objects that are returned from one of the Read methods.
Methods
TSRecord * FindRecord(const char *fieldName, int searchValue)
TSRecord * FindRecord(int recId)
TSRecord * FindRecord(const char *fieldName, const char *searchValue)
TSRecord * FindRecord(const char *fieldName, double searchValue)
TSRecord* FindRecord(const char *fieldName, int nTableId, int nFieldType, int nSqlDataType)
TSRecord * GetAt(TSPosition *pos)
int Receive(TSServer *server, TSSocket *socket)
void SetIsFieldList( BOOL bIsFields ) { m_bIsFieldList = bIsFields; }
int SocketString(TSString &str)
Member Variables
BOOL m_bIsFieldList (For internal use. This flags the list of user-defined fields).
TSSchema
This class provides a means for obtaining a given tables field list.
Methods
void Copy(TSObject *objsourceSchema)
TSObject * Duplicate()
TSObject * NewObject()
int SocketString(TSString &/*str*/)
TSString StringDump(int /*recursive*/, TSString indentation)
~TSSchema()
Member Variables
TSFieldList fieldList
TSString name
int tableId
int userDefinedFields
TSServer
TSServer is the main class used to communicate with TeamTrack systems. TSServer will encode data in a string to be sent through the web server to TeamTrack. TSServer knows how to connect to the web server, check permissions for the actions being performed and maintain lists of fields for each record type.
The first time a TSRecord is instantiated for a particular record type, the TSServer will retrieve a list of the fields for that record type from TeamTrack and cache that list of fields. Each subsequent time a TSRecord of that type is created, its field information will be filled in from the cache.
TSServer will connect to the web server using either the server name (machine name) or the servers IP address. If it fails to connect, the constructor will throw an exception. If the username doesnt exist or the password is invalid, the constructor will also throw an exception.
The Send() method of the TSServer class is what the other methods use to talk to the server. It sends the string across the socket to the server, it receives the resulting string, and loads it into a TSRecord class for the API programmer to use.
Methods
int AddField(TSRecord *field, int tableid, int fieldType)
int AddRecord(TSRecord *rec, TSRecord *newRecord /*=NULL*/)
int BuildFieldList(int tableId, TSFieldList &fieldList)
int Connect(const char *userName, const char *password, const char *serverAddress)
Connects the user to a webserver running TeamTrack
int DeleteRecord(int tableId, int id)
TSString EncodePassword(const char *password)
int GetConnectionInfo(char *dsn, char *databaseName, char *serverName)
int GetConnectionInfo(char **dsn, char **databaseName, char **serverName)
int GetDbInfo(int infoType, void * out)
int GetInt(int tableId, const char *columnName, int recId, int *result)
int GetProjectList( int nTableId, int nProjectsMask, TSList* results )
const char *GetLastErrorMessage()
TSSchema * GetSchema(int tableId)
int GetString(int tableId, const char *columnName, int recId, char **result)
int GetString(int tableId, const char *columnName, int recId, char *result, int size)
int GetSubmitTransition(int projectId, int *id)
int HasGroupPrivilege( int groupId, int itemId, enum privId_e privId )
int HasPrivilege(int userId, int projectId, int maskNumber, int mask)
int HasUserPrivilege( int userId, int itemId, enum privId_e privId )
int HasRecordPrivilege( enum recPriv_e recPriv, int userId, int tableId, int recId )
int MoveFolder(int folderId, int newParentId, int position)
int MoveProject(int projectId, int newParentId, int position)
TSSocket *OpenSocket()
int ReadAllRecords(TSRecordList *list, int tableId)
int ReadAttachmentList(TSRecordList *list, int tableId, int recId)
int ReadAvailableTransitionList( TSRecordList* list, int tableId, int recId )
int ReadChangeList(TSRecordList *list, int caseId, BOOL newFirst /*=FALSE*/)
int ReadFolderItems(TSRecordList *list, int folderId)
int ReadFolderList(TSRecordList *list, int owner, int parentId)
int ReadProjectSelectionList(TSRecordList *list, int selectid)
int ReadProjectTransitionList(TSRecordList *list, int transId)
int ReadPropertyList(TSRecordList *list, int transId)
int ReadRecord(TSRecord *rec, int id)
TSRecord::TSRecord(int tableId, TSServer *server, int fieldtype /*=0*/)
int ReadRecordForId(TSRecord *record, const char *searchId)
TSRecord::TSRecord(int tableId, TSServer *server, int fieldtype /*=0*/)
int ReadRecordListWithWhere(TSRecordList *list, int tableId, const char *whereClause )
int ReadRecordListWithWhere( TSRecordList* recordList, int tableId, const char* whereClause,
const std::vector< int >& fields )
int ReadRecordWithWhere(TSRecord *record, const char *whereClause)
ReadRecordWithWhere( TSRecord* record, const char* whereClause, const std::vector< int >& fields )
int ReadReport(TSRecord *report, const char *name)
int ReadReportList(TSRecordList *list, long userId, int perm)
int ReadSelectionList(TSRecordList *list, int fieldId, int projectId)
int ReadStateList(TSRecordList *list, int workflowId, BOOL incParent /*=FALSE*/)
int ReadTransitionList(TSRecordList *list, int projectId)
int ReadUserDefinedFields(TSRecordList *list, int tableId)
int ReadUserListForPrivilege(TSRecordList *list, int userid, TSRecordList *fieldList, int mask)
int ReadUserSelectionList(TSRecordList *list, int fieldId, int projectId, BOOL incDeleted /* = FALSE */)
int ReadVCActions(TSRecordList *list, int caseId)
int ReadVCActionsForModule(TSRecordList *list, const char *filename, int userid, int action2)
"D:\Program Files\TeamShare\API\Samples\SubmitIssue\SubmitIssue.cpp"
int ReleaseRecordLockByNumber( int nProjectId, int nItemNumber )
int ReleaseRecordLockById( int nTableId, int nItemId )
int Send(TSSocket *socket, const char *str)
int SetAlternateUser( TSString sLoginId, TSString sPassword, bool bValidatePwd )
int SetExitUrl(const char *exiturl)
int SetRecordLockByNumber( int nProjectId, int nItemNumber )
int SetRecordLockById( int nTableId, int nItemId )
int Submit(int *nIssueId, TSString &sLoginid, TSRecord *pRec, int nTableId, int nProjectId, int nFolderId, int nType )
int Transition(TSString &sLoginid, TSRecord *pRec, int nProjectId, int nTableId, int nRecordId, int nTransition)
TSServer()
~TSServer()
int UpdateList(TSRecordList *list, int tableId, int recid1, int recid2)
Member userid groupid
Privilege userid groupid
Selection fieldid (Not used)
TransIssueType transitionid (Not used)
TransTriggerState stateid (Not used)
TransTriggerTransition transitionid (Not used)
int UpdateList(TSRecordList *list, int tableId, int recid1, int recid2)
int UpdateRecord(TSRecord *rec, TSRecord *newRecord /*=NULL*/)
int ValidateUser(const char * loginid, const char *pwd, BOOL validatePwd/*=TRUE*/, int *userId /*=NULL*/)
int ValidateVersion()
Member Variables
TSString authentication
TSString errorMsg
int portNumber
TSString postHeader
TSList schemaCache
TSString webAddress
TSSocket
This class is a child of the MFC CSocket class. Certain methods are overridden for specific use in this API. It is the object used to send and receive data on a TCP/IP socket.
Note: On either the Linux or Unix platforms, a generic, non-MFC, CSocket class is used. The definition for that class can be found in TSSocket.h.
Methods
void ClearBuffer()
BOOL Connect( const char *hostAddress, unsigned int portNumber )
BOOL Create( unsigned int socketPort, int socketType, char * socketAddress)
int FillBuffer()
void Initialize()
int IsConnected()
int Read(char *buffer, int size)
char ReadChar()
int ReadLine(char *buffer, int size)
int ReceiveDouble(double *val)
int ReceiveInt(int *val)
int ReceiveString(TSString *str)
int ReceiveString(char *str, int size)
TSSocket()
~TSSocket()
Member Variables
int bufferEnd
int bufferStart
int connected
char *socketBuffer
int socketBufferSize
TSString
Objects of this type are used to manage the strings of data transmitted to and from the database across the socket. It can be used to perform comparisons, concatenations, etc.
Methods
int CompareNoCase(const char *str)
void Copy(TSObject *newObjsourceString)
TSObject *Duplicate()
char *GetBuffer()
char *GetBuffer(size_t minsize)
int Length()
TSObject* NewObject()
TSString operator + (char *str)
TSString operator + (TSString second)
TSString& operator += (TSString str)
TSString& operator += (char c)
TSString& operator += (char *str)
TSString& operator = (const char *str)
TSString& operator = (TSString str)
BOOL operator == (TSString str)
BOOL operator == (const char *str)
char operator [] (int idx)
int SocketString(TSString &str)
TSString StringDump(int /*recursive*/, TSString indentation)
void TrimLeft ( const char* str=NULL )void TrimLeft( const char c )
void TrimLeft( const char c )
void TrimLeft( const TSString str )
void TrimRight( const char* str=NULL )void TrimRight( const TSString str )
void TrimRight( const char c )
void TrimRight( const char cTSString str )
TSString(const char * str)
TSString()
TSString(const TSString& str)
~TSString()
Member Variables
char *buffer
static int BUFFER_EXCESS
unsigned int bufsize
TSTransition
The class inherits from TSRecordRef, and it describes a transition.
Methods
TSTransition
( TSServer& server, int nTransitionId = 0 )TSTransition( const TSTransition& that )
TSTransition& operator =( const TSTransition& that )
virtual ~TSTransition()
TSString StringDump( TSString sIndentation )
void SetTableId( int nNewTableId )
Member Variables
None
TSTreeList
This class inherits from TSRecordList and should be used in place of a TSRecordList when working with tables that are recursive (Projects, Folders, Workflows, etc.) TSTreeList doesnt have to be used, but it must be used if calling any of the FindRecord() functions on the list. These functions wont work correctly for these tables unless a TSTreeList is used.
Methods
TSRecord *FindRecord(const char *fieldName, double searchValue)
TSRecord *FindRecord(const char *fieldName, int searchValue)
TSRecord *FindRecord(const char *fieldName, char *searchValue)
TSRecord *FindRecord(int recId)
Member Variables
None
Gl