Zusammenfassung
The Job object provides access to properties and methods to interact with a Workflow Manager job.
Diskussion
A Job is a single unit of work that is carried out within an organization. It may have one or many people working on it. It can work with a single dataset, multiple dataset, or no data at all. A Job is created based off of a template known as a Job Type, which is configured with the desired properties and components (such as the Workflow and Maps) that will be used in the job.
Eigenschaften
Eigenschaft | Erläuterung | Datentyp |
assignedTo (Lesen und schreiben) | The user name or group that the job is assigned to. | String |
assignedType (Lesen und schreiben) | The type of assignment for the job. Below is a list of valid strings to use when setting the job assignment. If an invalid string is used the job will default to unassigned.
| String |
createdBy (Lesen und schreiben) | The user name of the user who created the job. | String |
createdDate (Schreibgeschützt) | Returns the date the job was created. | DateTime |
currentSteps (Schreibgeschützt) | Returns a list of step IDs representing the steps that are active in the workflow. | List |
description (Lesen und schreiben) | The description of the job. | String |
dueDate (Lesen und schreiben) | The date the job was scheduled to end. | DateTime |
endDate (Schreibgeschützt) | Returns the date the job ended. | DateTime |
hasAOI (Schreibgeschützt) | Returns True when the job has an area of interest defined. | Boolean |
id (Schreibgeschützt) | Return's the job id. | Integer |
jobTypeID (Schreibgeschützt) | Gets the ID of the job type for the job. | Integer |
name (Lesen und schreiben) | The job's name. | String |
owner (Lesen und schreiben) | The user name of the user who owns the job. | String |
parent (Lesen und schreiben) | The ID of the parent job for the current job. | Integer |
parentVersion (Lesen und schreiben) | The name of the parent version of the job. | String |
percentComplete (Schreibgeschützt) | Returns the percent complete of the job. | Double |
priority (Lesen und schreiben) | The priority of the job. | Integer |
startDate (Lesen und schreiben) | The date the job was scheduled to start. | DateTime |
startedDate (Schreibgeschützt) | Returns the date the job was started. | DateTime |
status (Lesen und schreiben) | The status name for the job. The statuses available for use are those defined as status types in the Workflow Manager database. | String |
versionExists (Schreibgeschützt) | Returns True when a version exists for a job. | Boolean |
versionName (Lesen und schreiben) | The name of the version for the job. | String |
Methodenübersicht
Methode | Erläuterung |
getPendingDays (consider_hold) | Returns the number of days that the job has been pending. This can also optionally consider the holds and subtract them from the number of days the job was pending. |
save () | Saves any changes made to the job back to the Workflow Manager database. |
setAOI (aoi) | Sets the area of interest (AOI) polygon for the job. |
setDataWorkspace (data_workspace_id) | Sets the data workspace for the job. |
Methoden
getPendingDays (consider_hold)
Parameter | Erläuterung | Datentyp |
consider_hold | Flag to determine whether to consider the holds when calculating the number of pending days. | Boolean |
Rückgabewert
Datentyp | Erläuterung |
Integer | Returns the number of days the job has been pending. |
Pending days refers to the number of days the job has been worked on or the number of days the job has been pending before being completed. The start date used for the calculation is either the Start Date if it was set or the Created Date otherwise. The end date for the calculation is either the current date or the End Date if the job is closed.
The following script returns the number of pending days, both when considering and not considering holds in the calculation.
import arcpy
import arcpywmx
#Establish a connection to a Workflow database
conn = arcpywmx.Connect(r'c:\test\Workflow.jtc')
#Access a Workflow Job
job = conn.getJob(99999)
#Get pending days for job while considering days on hold
pendingwithholds = job.getPendingDays(True)
print "The number of days pending for job when considering days on hold: " + str(pendingwithholds)
#Get pending days for job while ignoring days on hold
pendingwithoutholds = job.getPendingDays(False)
print "The number of days pending for job when ignoring days on hold: " + str(pendingwithholds)
save ()
The following script saves an updated job assignment.
import arcpy
import arcpywmx
#Establish a connection to a Workflow database
conn = arcpywmx.Connect(r'c:\test\Workflow.jtc')
#Access a Workflow Job
job = conn.getJob(99999)
# Update and save the job assignment
job.assignedTo = 'user0000'
job.save()
setAOI (aoi)
Parameter | Erläuterung | Datentyp |
aoi | The AOI polygon to be assigned to the job | Geometry |
Define's an area of interest for a job. To get a job's area of interest polygon, use the Get Job AOI tool.
The following script defines a polygon geometry and sets it as the job's area of interest.
import arcpy
import arcpywmx
#Establish a connection to a Workflow database
conn = arcpywmx.Connect(r'c:\test\Workflow.jtc')
#Access a Workflow Job
job = conn.getJob(99999)
# Create polygon geometry
coordList = [[-105.0, 39.0], [-100.0, 39.0], [-100.0, 35.0], [-105.0, 35.0]]
array = arcpy.Array([arcpy.Point(x, y) for x, y in coordList])
aoi = arcpy.Polygon(array)
#Set the job's Area of interest to the polygon geometry
job.setAOI(aoi)
job.save()
setDataWorkspace (data_workspace_id)
Parameter | Erläuterung | Datentyp |
data_workspace_id | The GUID of the data workspace to be made active for the job. | String |
Set the data workspace for a job. To get a job's data workspace, use the Get Job Data Workspace tool.
The following script sets a data workspace for a job.
import arcpy
import arcpywmx
#Establish a connection to a Workflow database
conn = arcpywmx.Connect(r'c:\test\Workflow.jtc')
#Access a Workflow Job
job = connect.getjob(99999)
#Set the job's data workspace to a workspace GUID
job.setDataWorkspace("{7887F5C8-CACD-4ADD-88E9-8B37E25C7FF6}")
Codebeispiel
The following script updates the assignment of a job and checks that a spatial data version exists by using the job's properties.
import arcpy
import arcpywmx
#Establish a connection to a Workflow database
conn = arcpywmx.Connect(r'c:\sample\Workflow.jtc')
#Access a Workflow Job
job = conn.getJob(99999)
# Update the job assignment
job.assignedTo = 'user0000'
job.assignedType = 'user'
job.save()
# Reload the job
job = job.conn.getJob(99999)
#Check a version exists for the job and get the version name
if job.version == True:
jobversion = job.versionName
print "The job's data workspace is " + jobversion