AdvanceClock APIs

Advance the clock on a specific scenario or on all scenarios

Examples in this guide reference code from the APS Web Service Client Sample project with 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 API is used to automatically Advance the clock on a specific scenario or all scenarios. There are three variations: AdvanceClock API, which takes a DateTime date parameter; AdvanceClockStringDate API, which takes a string date parameter; and AdvanceClockTicks API, which takes a long date parameter.

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 getting 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 to run the clock advance on. If not provided, API will run it on all scenarios.
  • DateTime  (DateTime) / DateTime (string) / DateTimeTicks (long) - parameter for AdvanceClock API / AdvanceClockStringDate API / AdvanceClockTicks API specifying the date to advance the clock to. If not provided DateTime.Now is used

    Parameters Types

     
    The above parameters are all received as string types and converted by the related web client application into the specified types indicated before performing the API call using ExtraServices.

    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 AdvanceClockRequest :ApsWebServiceScenarioRequest
    {
    [DataMember(IsRequired = false)]
    public DateTime DateTime { get; set; }
    }

    [DataContract]
    public class AdvanceClockStringDateRequest : ApsWebServiceScenarioRequest
    {
    [DataMember(IsRequired = false)]
    public string DateTime { get; set; }
    }

    [DataContract]
    public class AdvanceClockTicksRequest : ApsWebServiceScenarioRequest
    {
    [DataMember(IsRequired = false)]
    public long DateTimeTicks { get; set; }
    }
    • Request Examples
    //Create an AdvanceClock request
    APSWebServiceRef.AdvanceClockRequest advanceClockRequest = new AdvanceClockRequest () {
    DateTime = DateTime.MinValue
    };

    //Create an AdvanceClockStringDate request
    APSWebServiceRef.AdvanceClockRequest optimizeReuqest = new AdvanceClockRequest () {
    DateTime = DateTime.Now.ToString("yyyy-MM-ddTHH:mm")
    };

    //Create an AdvanceClock request
    APSWebServiceRef.AdvanceClockRequest optimizeReuqest = new AdvanceClockRequest () {
    DateTime = DateTime.MinValue
    };

    //Request Base
    advanceClockRequest.UserName = username;
    advanceClockRequest.Password = pwd;
    advanceClockRequest.TimeoutDuration = TimeSpan.FromMinutes(5);
    advanceClockRequest.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.Optimize(optimizeRequest);
        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);
        }

        Related APIs

        When a scenario name or Id is specified, the GetScenarios API is used to validate the input. When a specified scenario does not exist—and the CreateScenarioIfNew is true—the CopyScenarios API creates a new scenario from the LiveScenario.