Activity Update APIs

API calls to perform Status, Quantity and Date updates on Activities

Examples in this guide reference code from the APS Web Service Client Sample project that has a web service proxy configured. If you are just getting started with the APS Web Services APIs, please see our client sample.

API Function

The APIs are used to update activities. There are three variations: ActivityStatusUpdate API which can be used to update various status properties, ActivityQuantitiesUpdate API, which can be used to update reported quantities, and ActivityDatesUpdate API, which can be used to update reported hours, start and end dates.

API Parameters

  • Username (string) - the user's username performing the call
  • Password (string) - the user's related password
  • TimeoutDuration (TimeSpan) - the time to wait when trying to connect to Extra Services or attempting to get a data lock. If this parameter is not included in the request, a default value of 30 seconds will be used.
  • ScenarioId (long) - Id of the scenario.
  • ActivityStatusUpdates (ActivityStatusUpdateObject[]) / ActivityQuantitiesUpdates (ActivityQuantitiesUpdateObject[]) / ActivityDateUpdates(string) - parameters for ActivityStatusUpdate API / ActivityQuantitiesUpdate API / ActivityDatesUpdate API specifying the activity updates. These objects will be described in depth in the section below.

Activity Update Objects

The three Update objects inherit from a base object

[DataContract]
public class BaseActivityUpdateObject
{
[DataMember(IsRequired = true)]
public PtObjectId PtObjectId { get; set; }
}

PtObject contains 4 string parameters-- JobExternalId, MoExternalId, OperationExternalId and ActivityExternalId. If only JobExternalId is specified, all activities within the job are updated. If JobExternalId and MoExternalId, activities within the specific manufacturing order are updated. If the JobExternalId, MoExternalId, and OperationExternalId are specified, only activities for the specified operation are updated. Finally, if all are specified, only one activity is updated.

  • ActivityStatusUpdateObject
[DataContract]
public class ActivityStatusUpdateObject : BaseActivityUpdateObject
{
[DataMember(IsRequired = false)]
public string ProductionStatus { get; set; } = String.Empty;

[DataMember(IsRequired = false)]
public string Comments { get; set; } = String.Empty;

[DataMember(IsRequired = false)]
public bool Paused { get; set; }

[DataMember(IsRequired = false)]
public bool OnHold { get; set; }

[DataMember(IsRequired = false)]
public string HoldReason { get; set; } = String.Empty;

[DataMember(IsRequired = false)]
public DateTime HoldUntil { get; set; } = DateTime.MinValue;
}
  • ActivityQuantitiesUpdateObject
[DataContract]
public class ActivityQuantitiesUpdateObject : BaseActivityUpdateObject
{
[DataMember(IsRequired = false)]
public decimal ReportedGoodQty { get; set; } = decimal.MinValue;

[DataMember(IsRequired = false)]
public decimal ReportedScrapQty { get; set; } = decimal.MinValue;
}
  • ActivityDatesUpdateObject
[DataContract]
public class ActivityDatesUpdateObject : BaseActivityUpdateObject
{
[DataMember(IsRequired = false)]
public double ReportedSetupHrs { get; set; } = -1;

[DataMember(IsRequired = false)]
public double ReportedRunHrs { get; set; } = -1;

[DataMember(IsRequired = false)]
public double ReportedPostProcessingHrs { get; set; } = -1;

[DataMember(IsRequired = false)]
public DateTime ReportedStartDate { get; set; } = DateTime.MinValue;

[DataMember(IsRequired = false)]
public DateTime ReportedFinishDate { get; set; } = DateTime.MinValue;
}

When building the API requests the user is not required to pass all the parameters. Only pass parameters for properties that need to be modified.

API Request

This API request inherits from ApsWebScenarioRequest. Check out our KB article on the API Request Base classes to learn more: Basic API Structure

To use the API you must create a typed Request using the Request Data Contract. The related web client will use this Request to trigger the process.

  • Data Contract
[DataContract]
public class ActivityStatusUpdateRequest : ApsWebServiceScenarioRequest
{
[DataMember(IsRequired = true)]
public ActivityStatusUpdateObject[] ActivityStatusUpdates { get; set; }
}

[DataContract]
public class ActivityQuantitiesUpdateRequest : ApsWebServiceScenarioRequest
{
[DataMember(IsRequired = true)]
public ActivityQuantitiesUpdateObject[] ActivityQuantitiesUpdates { get; set; }
}

[DataContract]
public class ActivityDatesUpdateRequest : ApsWebServiceScenarioRequest
{
[DataMember(IsRequired = true)]
public ActivityDatesUpdateObject[] ActivityDatesUpdates { get; set; }
}
  • Status Update Request Example
//Create an ActivityStatusUpdate request
APSWebServiceRef.ActivityStatusUpdateRequest activityUpdateRequest = new ActivityStatusUpdateRequest() {
};

ActivityStatusUpdateObject updateObject = new ActivityStatusUpdateObject();
updateObject.PtObjectId = new PtObjectId() { JobExternalId = "job1", MoExternalId = "MO010", OperationExternalId = "Op010", ActivityExternalId = "PT00001" };
updateObject.ProductionStatus = "Running";
updateObject.Comments = "test comment";
updateObject.Paused = true;

activityUpdateRequest.ActivityStatusUpdates = new[] { updateObject };

//Request Base
activityUpdateRequest.UserName = username;
activityUpdateRequest.Password = pwd;
activityUpdateRequest.TimeoutDuration = TimeSpan.FromMinutes(5);
activityUpdateRequest.ScenarioId = long.MinValue;
    • Quantities Update Request Example
    //Create an ActivityQuantitiesUpdate request
    APSWebServiceRef.ActivityQuantitiesUpdateRequest activityUpdateRequest = new ActivityQuantitiesUpdateRequest() {
    };

    ActivityQuantitiesUpdateObject updateObject = new ActivityQuantitiesUpdateObject();
    updateObject.PtObjectId = new PtObjectId() { JobExternalId = "job1", MoExternalId = "MO010", OperationExternalId = "Op010", ActivityExternalId = "PT00001" };
    updateObject.ReportedGoodQty = 25;
    updateObject.ReportedScrapQty = 10;

    activityUpdateRequest.ActivityQuantitiesUpdates = new[] { updateObject };

    //Request Base
    activityUpdateRequest.UserName = username;
    activityUpdateRequest.Password = pwd;
    activityUpdateRequest.TimeoutDuration = TimeSpan.FromMinutes(5);
    activityUpdateRequest.ScenarioId = long.MinValue;
    • Dates Update Request Example
    //Create an ActivitiesDatesUpdate request
    APSWebServiceRef.ActivityDatesUpdateRequest activityUpdateRequest = new ActivityDatesUpdateRequest() {
    };

    ActivityDatesUpdateObject updateObject = new ActivityDatesUpdateObject();
    updateObject.PtObjectId = new PtObjectId() { JobExternalId = "job1", MoExternalId = "MO010", OperationExternalId = "Op010", ActivityExternalId = "PT00001" };
    updateObject.ReportedRunHrs = 1;
    updateObject.ReportedSetupHrs = 3;
    updateObject.ReportedStartDate = DateTime.Now;

    //Request Base
    activityUpdateRequest.UserName = username;
    activityUpdateRequest.Password = pwd;
    activityUpdateRequest.TimeoutDuration = TimeSpan.FromMinutes(5);
    activityUpdateRequest.ScenarioId = long.MinValue;

    API Response

    All API calls return a Response object to help determine the result of the call. Check out our Basic API Structure KB article for more information.

    Response Example

    //Sending a request
    start = DateTime.Now;
    ApsWebServiceResponseBase resp = client.ActivityStatusUpdate(activityUpdateRequest);
    Console.WriteLine($"Response received after '{DateTime.Now.Subtract(start)}'");

    //Display results
    if (!a_response.Exception)
    {
    Trace($"Completed with Zero Errors");
    }
    else
    {
    Trace($"Completed with Errors");
    Trace(a_response.FullExceptionText);
    }