BatchSetJobInfo - Intergraph Batch Services - Help

Intergraph Batch Services Help

Language
English
Product
Intergraph Batch Services
Search by Category
Help

Description

Sets or modifies various job attributes. You can modify the following job properties:

Level

Properties

1

  1. priority

  2. name

2

  1. priority

  2. name

  3. runpriority

  4. restartable

  5. job recurrence information

The other job attributes are ignored, and are not set. If a job attribute is missing or is not valid, then it is not set, and the function returns success. The caller must own the job or have operator privileges to use this function.

Syntax

DWORD BatchSetJobInfo(LPCTSTR jobid, DWORD level, LPBYTE jobinfo);

Parameters

LPCTSTR jobid

Specifies the unique job-identification string.

DWORD level

Specifies the amount of information to be returned for each job. Currently, only levels 1 and 2 are supported, which correspond to the BATCH_JOB_INFO_1 and BATCH_JOB_INFO_2 structures, respectively.

LPBYTE jobinfo

Points to a buffer containing the job info structure. Note that some job attributes cannot be set with this call.

Return Values

BATCH_ERROR_JOB_IS_RUNNING

You cannot modify job attributes while the job is running.

BATCH_ERROR_NO_SUCH_JOB

The system could not find the named job.

ERROR_INVALID_LEVEL

The value of the level parameter is not 1 or 2.

BATCH_ERROR_BAD_JOB_NAME

The jobid was null or the syntax was incorrect.

BATCH_ERROR_OWNER_OR_OPERATOR_ACCESS_DENIED

The caller neither owns the job nor has operator privileges.

Example Program

#include <iostream.h>

#include "batchapi.h"

#define MAX_LENGTH 25

void main()

{

LPBYTE Buff;

long Priority;

LPCTSTR JobId;

char * pTempName;

char * pTemp;

char * pName;

DWORD Need;

DWORD Level;

DWORD CbSize;

DWORD m_ReturnVal;

DWORD RunPriority;

DWORD Restartable;

pTemp = new char[MAX_LENGTH];

if (pTemp == NULL){

cout << "unable to allocate the memory.\n Exiting the program"<<endl;

exit(0);

}

pTempName = new char[MAX_LENGTH];

if (pTempName == NULL){

cout << "unable to allocate the memory.\n Exiting the program"<<endl;

delete [] pTemp;

exit(0);

}

cout << "STARTING THE EXECUTION OF BATCHSETJOBINFO API"<<endl;

cout << " YOU CAN CHANGE only priority,name,runpriority,restartable properties"<< endl;

cout << " Enter the Job id for which to get the info ";

cin >> pTemp;

JobId = (const char *)pTemp;

cout << " Enter the Level of Extraction ( 1 or 2) ";

cin >> Level;

cout << " Enter the priority to set for the job " ;

cin >> Priority;

cout << " Enter the Runpriority to set for the job ";

cin >> RunPriority;

cout << " Enter whether to restart the job " ;

cin >> Restartable;

cout << " Enter the name to set for the job ";

cin >> pTempName;

pName = pTempName;

m_ReturnVal = BatchGetJobInfo ( JobId , Level , NULL , 0 , &Need);

Buff = (LPBYTE)LocalAlloc(0,Need);

if (Buff == NULL){

cout << "unable to allocate the memory.\n Exiting the program"<<endl;

delete [] pTemp; delete []pTempName;

exit(0);

}

CbSize= Need;

m_ReturnVal = BatchGetJobInfo ( JobId , Level , Buff , CbSize , &Need);

if (Level==2)

{

BATCH_JOB_INFO_2 * Jinfo;

Jinfo = (BATCH_JOB_INFO_2 *)Buff;

Jinfo->priority = Priority;

Jinfo->runpriority = RunPriority;

Jinfo->restartable = Restartable;

Jinfo->name = pName;

m_ReturnVal = BatchSetJobInfo (JobId , Level, (LPBYTE)Jinfo);

}

else

if (Level == 1)

{

BATCH_JOB_INFO_1 * Jinfo;

Jinfo = (BATCH_JOB_INFO_1 *)Buff;

Jinfo->priority = Priority;

Jinfo->name = pName;

m_ReturnVal = BatchSetJobInfo (JobId , Level, (LPBYTE)Jinfo);

}

switch (m_ReturnVal)

{

case BATCH_ERROR_JOB_IS_RUNNING :

cout << " You cannot modify job attributes while the job is running." << endl;

break;

case BATCH_ERROR_NO_SUCH_JOB :

cout << " The system could not find the named job." << endl;

break;

case ERROR_INVALID_LEVEL :

cout << " The value of the level parameter is not 1 or 2." << endl;

break;

case BATCH_ERROR_BAD_JOB_NAME :

cout << " The jobid was null or the syntax was incorrect. " << endl;

break;

case BATCH_ERROR_OWNER_OR_OPERATOR_ACCESS_DENIED :

cout << " The caller neither owns the job nor has operator privileges. " << endl;

break;

case ERROR_ACCESS_DENIED :

cout << " The user was not the job owner and did not have operator "

<<"privileges." <<endl;

break;

default:

cout << "SUCCESSFUL COMPLETION OF SETTING UP THE JOB INFO" << endl;

}

cout << "FINISHED THE EXECUTION OF BATCHSETJOBINFO API"<<endl;

delete [] pTemp;

delete [] pTempName;

LocalFree(Buff);

}