<?xml version="1.0" encoding="utf-8"?>
<Templates xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns="http://gpsgate.com/xml/">
  <Template type="ApplicationEntity">
    <Object>
      <TemplateGuid>6837165a-c7cc-44ad-8dfb-c64b10853f27</TemplateGuid>
      <TemplateVersion>1</TemplateVersion>
      <ObjectType>GpsGate.Online.Event.EventExpressionEvaluatorWriter</ObjectType>
      <ObjectData>
        <Name>Driver login report</Name>
        <Description>rule to be used for driver login report purposes</Description>
        <EvaluationOperator>AND</EvaluationOperator>
        <EndEvaluationOperator>AND</EndEvaluationOperator>
        <SupportUI>false</SupportUI>
        <AutoClose>true</AutoClose>
        <Disabled>true</Disabled>
        <FinishOnPreCondition>true</FinishOnPreCondition>
        <UserMatchMethod>Tags</UserMatchMethod>
        <Expressions>
          <ExpressionRef>3bddd48f-9fd0-4e62-9bcc-8e961c949b02</ExpressionRef>
        </Expressions>
        <Notifiers>
          <NotifierRef>e29d53ee-0b46-47de-a524-4bb712460ff2</NotifierRef>
          <NotifierRef>2bddca20-27ac-4e78-90dc-ace7d1d6fe5f</NotifierRef>
        </Notifiers>
        <PostConditions>
          <PostConditionRef>ab91e149-b620-4d5d-a734-2d58000b0470</PostConditionRef>
        </PostConditions>
        <PreConditions>
          <PreConditionRef>46ddb9ab-5e25-4ad1-86ea-5d04cf1eb2a5</PreConditionRef>
        </PreConditions>
        <TagIDs />
      </ObjectData>
    </Object>
    <Object>
      <TemplateGuid>3bddd48f-9fd0-4e62-9bcc-8e961c949b02</TemplateGuid>
      <TemplateVersion>1</TemplateVersion>
      <ObjectType>GpsGate.Online.Event.ScriptExpression</ObjectType>
      <ObjectData>
        <IsEndExpression>false</IsEndExpression>
        <IsOneShot>false</IsOneShot>
        <Script>// init state
var st = context.state || {};
 
// username of vehicle for a driver, or a driver for a vehicle
var linkedUsername = session.user.isDriver ? session.vehicle.id : (session.driver ? session.driver.id : null);
 
if (linkedUsername != st.linkedUsername &amp;&amp; st.linkedUsername != null) {
  // if has changed and it has existed before, end the event on previous message
  // (as that was the last one for which the old vehicle-driver link should exist)
  report.context.endEventOnPrevious(st.linkedUsername);
}
 
if (linkedUsername != null) {
  // if not empty now, start event, using the username of associated driver/vehicle as namespace
  // (note that this does nothing if event with the same namespace is already started)
  context.startEvent(linkedUsername);
  // store for next evaulation
  st.linkedUsername = linkedUsername;
}
 
// save state
context.setState(st);
 
// return false as we start/end events explicitly by this script
return false;</Script>
      </ObjectData>
    </Object>
    <Object>
      <TemplateGuid>e29d53ee-0b46-47de-a524-4bb712460ff2</TemplateGuid>
      <TemplateVersion>1</TemplateVersion>
      <ObjectType>GpsGate.Reporting.v3.Notification.ReportArgumentNotifier</ObjectType>
      <ObjectData>
        <Name>Report Argument</Name>
        <NotifierGroup>default</NotifierGroup>
        <Mode>Start</Mode>
        <ArgumentName>Vehicle</ArgumentName>
        <Template>[ASSIGNED_VEHICLE_NAME]</Template>
      </ObjectData>
    </Object>
    <Object>
      <TemplateGuid>2bddca20-27ac-4e78-90dc-ace7d1d6fe5f</TemplateGuid>
      <TemplateVersion>1</TemplateVersion>
      <ObjectType>GpsGate.Reporting.v3.Notification.ReportArgumentNotifier</ObjectType>
      <ObjectData>
        <Name>Report Argument</Name>
        <NotifierGroup>default</NotifierGroup>
        <Mode>Start</Mode>
        <ArgumentName>Driver</ArgumentName>
        <Template>[DRIVER_NAME]</Template>
      </ObjectData>
    </Object>
    <Object>
      <TemplateGuid>ab91e149-b620-4d5d-a734-2d58000b0470</TemplateGuid>
      <TemplateVersion>1</TemplateVersion>
      <ObjectType>GpsGate.Online.Event.EventDurationEvaluatorPostCondition</ObjectType>
      <ObjectData>
        <Name>Event duration evaluator post condition</Name>
        <RelationalOperator>GREATER_OR_EQUAL</RelationalOperator>
        <EventDuration>0</EventDuration>
        <AutoTrigger>false</AutoTrigger>
      </ObjectData>
    </Object>
    <Object>
      <TemplateGuid>46ddb9ab-5e25-4ad1-86ea-5d04cf1eb2a5</TemplateGuid>
      <TemplateVersion>1</TemplateVersion>
      <ObjectType>GpsGate.Online.Event.DayOfWeekPeriodEvaluatorPreCondition</ObjectType>
      <ObjectData>
        <Name>Day of week evaluator pre condition</Name>
        <Periods>
          <Period>
            <StartTimeOfDay>0</StartTimeOfDay>
            <StopTimeOfDay>863999990000</StopTimeOfDay>
            <DayOfWeek>All</DayOfWeek>
            <EvaluationMethod>Inside</EvaluationMethod>
          </Period>
        </Periods>
      </ObjectData>
    </Object>
  </Template>
</Templates>