<?xml version="1.0" encoding="utf-8" standalone="no"?>
<schema>
  <screens>
    <AccessGroups maintable="MAccGrp" hostcallback="True" sendtoallpanels="True" key1name="AGrpNo" operation="16">
      <tables>
        <table>AccGrp</table>
        <table>MAccGrp</table>
      </tables>
      <lookups>
        <table source="accessgroupdetailsgrid" param1name="operatorid" nodelay="True">accessgroupdetailsgrid1</table>
        <table source="accessgroupslookup" nodelay="False">accessgroupslookup2</table>
        <table source="mtimezonlookup" nodelay="True">mtimezonlookup8</table>
      </lookups>
    </AccessGroups>
	<ActivityLinks maintable="MActiveLinks" key1table="MActiveLinks" key2table="MActiveLinks" key3table="MActiveLinks" key4table="MActiveLinks" subTable="ActiveLinks" panelkeyname="PnlRef" hostcallback="True" sendtoallpanels="False" key1name="ProgNo" key2name="EventCode" key3name="Device" key4name="Category" deleteprocname="ca_sp_DeleteActivityLinks" operation="11">
      <tables>
        <table>ActiveLinks</table>
        <table>MActiveLinks</table>
      </tables>
      <lookups>
        <table source="aclinkpanelgrid" param1name="progno" param1value="ProgNo" param1table="MActiveLinks" param2name="pnlref" param2value="PnlRef" param2table="MActiveLinks" nodelay="True">aclinkpanelgrid1</table>
        <table source="activitylinkslookupjoin" param1name="pnlref" param1value="PnlRef" param1table="MActiveLinks" param2name="progno" param2value="ProgNo" param2table="MActiveLinks" nodelay="True">activitylinkslookupjoin1</table>
        <table source="alplookup" param1name="pnlref" param1value="PnlRef" param1table="MActiveLinks" param2name="progno" param2value="ProgNo" param2table="MActiveLinks" nodelay="True">alplookup1</table>
        <table source="alpundocount" param1name="pnlref" param1value="PnlRef" param1table="MActiveLinks" param2name="progno" param2value="ProgNo" param2table="MActiveLinks" nodelay="True">alpundocount1</table>
        <table source="apbfirstinlookup" nodelay="False">apbfirstinlookup1</table>
        <table source="AreaLockdownlookup" nodelay="False">AreaLockdownlookup1</table>
        <table source="categorycounterlookup" nodelay="False">categorycounterlookup2</table>
        <table source="devicelookup" nodelay="False">devicelookup1</table>
        <table source="eventlookup" nodelay="True">eventlookup1</table>
        <table source="inputlookupbypanel" param1name="pnlref" param1value="PnlRef" param1table="MActiveLinks" nodelay="False">inputlookupbypanel1</table>
        <table source="linklookup" param1name="pnlref" param1value="PnlRef" param1table="MActiveLinks" nodelay="True">linklookup1</table>
        <table source="mactivelinkslookup" param1name="pnlref" param1value="PnlRef" param1table="MActiveLinks" nodelay="False">mactivelinkslookup1</table>
        <table source="mactivelinksundolookup" param1name="pnlref" param1value="PnlRef" param1table="MActiveLinks" nodelay="False">mactivelinksundolookup1</table>
        <table source="mtimezonlookup" nodelay="False">mtimezonlookup15</table>
        <table source="newgenpanellookup" nodelay="False">newgenpanellookup1</table>
        <table source="newpanellookup" nodelay="False">newpanellookup1</table>
        <table source="newpanellookup" nodelay="False">newpanellookup2</table>
        <table source="panellookup" nodelay="False">panellookup7</table>
        <table source="readerlookup" param1name="pnlref" param1value="PnlRef" param1table="MActiveLinks" nodelay="True">readerlookup1</table>
        <table source="readerlookup" nodelay="False">readerlookup2</table>
        <table source="relaylookupbypanel" param1name="pnlref" param1value="PnlRef" param1table="MActiveLinks" nodelay="False">relaylookupbypanel1</table>
      </lookups>
      <listlookups>
        <table source="catcntrcontrollist">catcntrcontrollist1</table>
        <table source="categorycontrollist">categorycontrollist1</table>
        <table source="controllist">controllist1</table>
        <table source="inputcontrollist">inputcontrollist1</table>
        <table source="manprivlist">manprivlist4</table>
        <table source="manprivlist">manprivlist5</table>
        <table source="readercontrollist">readercontrollist1</table>
        <table source="readerundocontrollist">readerundocontrollist1</table>
      </listlookups>
    </ActivityLinks>
    <APBAreas maintable="APBAreas" key1table="Reader" panelkeytable="Reader" panelkeyname="PnlRef" hostcallback="True" sendtoallpanels="False" key1name="RdrNo" deleteprocname="ca_sp_DeleteAPBArea" operation="41">
      <tables>
        <table>APBAreas</table>
        <table>Reader</table>
      </tables>
      <lookups>
        <table source="allapbarealookup" nodelay="False">allapbarealookup1</table>
        <table source="allreadercolonbasisofpaneltype" nodelay="False">allreadercolonbasisofpaneltype1</table>
        <table source="allreaderlookup" nodelay="False">allreaderlookup1</table>
        <table source="allreaderonbasisofpaneltype" nodelay="False">allreaderonbasisofpaneltype1</table>
        <table source="APBAreaLinkLookup" nodelay="False">APBAreaLinkLookup1</table>
        <table source="APBAreaLinkLookup" nodelay="False">APBAreaLinkLookup2</table>
        <table source="APBAreaLinkLookup" nodelay="False">APBAreaLinkLookup3</table>
        <table source="APBAreaLinkLookup" nodelay="False">APBAreaLinkLookup4</table>
        <table source="apbareaslookup" nodelay="False">apbareaslookup1</table>
        <table source="apbareaslookup" nodelay="False">apbareaslookup2</table>
        <table source="mtimezonlookup" nodelay="False">mtimezonlookup1</table>
        <table source="mtimezonlookup" nodelay="False">mtimezonlookup16</table>
        <table source="mtimezonlookup" nodelay="False">mtimezonlookup2</table>
        <table source="mtimezonlookup" nodelay="False">mtimezonlookup3</table>
        <table source="mtimezonlookup" nodelay="False">mtimezonlookup4</table>
        <table source="mtimezonlookup" nodelay="False">mtimezonlookup5</table>
        <table source="mtimezonlookup" nodelay="False">mtimezonlookup6</table>
        <table source="panellookup" nodelay="False">panellookup1</table>
        <table source="readergrid" nodelay="False">readergrid1</table>
        <table source="selectapbarealookup" nodelay="False">selectapbarealookup1</table>
        <table source="SelectNestedAPBAreas" nodelay="False">SelectNestedAPBAreas1</table>
        <table source="allapbareaallPartitionlookup" nodelay="False">allapbareaallPartitionlookup1</table>
      </lookups>
      <listlookups>
        <table source="apbtypelist">apbtypelist1</table>
        <table source="lockcontrollist">lockcontrollist1</table>
        <table source="manprivlist">manprivlist1</table>
        <table source="taapbtypelist">taapbtypelist1</table>
        <table source="twopersonreadertypelist">twopersonreadertypelist1</table>
      </listlookups>
    </APBAreas>
    <AuditTrail maintable="DBAudit" hostcallback="false" sendtoallpanels="false" operation="0">
      <tables>
        <table>DBAudit</table>
      </tables>
    </AuditTrail>
    <BadgeFormat maintable="Format" hostcallback="True" sendtoallpanels="False" operation="14">      
      <tables>
        <table>Format</table>
      </tables>
      <lookups>
        <table source="formatlookupjoin" param1name="fmtno" param1value="FmtNo" param1table="Format" nodelay="True">formatlookupjoin1</table>
      </lookups>
      <listlookups>
        <table source="badgeformatlist">badgeformatlist1</table>
      </listlookups>
    </BadgeFormat>
    <BatchModify hostcallback="false" sendtoallpanels="false" operation="0">
      <lookups>
        <table source="accessgroupslookup" nodelay="False">accessgroupslookup3</table>
        <table source="accessgroupsnofilterlookup" nodelay="False">accessgroupsnofilterlookup1</table>
        <table source="apbareasnofilterlookup" nodelay="False">apbareasnofilterlookup1</table>
        <table source="apbareaswithsetnextlookup" nodelay="False">apbareaswithsetnextlookup2</table>
        <table source="companyidlookup" nodelay="False">companyidlookup2</table>
        <table source="customfieldlookup" nodelay="False">customfieldlookup2</table>
        <table source="departmentlookup" nodelay="False">departmentlookup2</table>
        <table source="departmentlookupnofilter" nodelay="False">departmentlookupnofilter1</table>
        <table source="locationlookup" nodelay="False">locationlookup2</table>
        <table source="mholidaylookup" nodelay="False">mholidaylookup3</table>
        <table source="mholidaynofilterlookup" nodelay="False">mholidaynofilterlookup1</table>
        <table source="mshuntlookup" nodelay="False">mshuntlookup2</table>
        <table source="supervisorlookup" nodelay="False">supervisorlookup2</table>
        <table source="ThreatLevelSelect" nodelay="False">ThreatLevelSelect1</table>
      </lookups>
      <listlookups>
        <table source="genderlist">genderlist2</table>
        <table source="orgcatlist">orgcatlist2</table>
        <table source="persorglist">persorglist2</table>
      </listlookups>
    </BatchModify>
    <CategoryCounters maintable="CategoryCounters" key1table="CategoryCounters" panelkeytable="CategoryCounters" panelkeyname="PnlNo" hostcallback="True" sendtoallpanels="False" key1name="CatNo" operation="12">
      <tables>
        <table>CategoryCounters</table>
      </tables>
    </CategoryCounters>
    <CentralStationLinks maintable="CentralStationLinks" hostcallback="false" sendtoallpanels="false" operation="0">
      <tables>
        <table>CentralStationLinks</table>
      </tables>
      <lookups>
        <table source="centralstationserver" nodelay="False">centralstationserver2</table>
      </lookups>
    </CentralStationLinks>
    <DataChannel maintable="MCom" childtable="Com" key1table="Com" hcsnotable="MCom" hcsnocolumnname="HCSNo" hostcallback="True" sendtoallpanels="False" key1name="Comport" childdeleteprocname="ca_sp_DeleteComPort" operation="18">
      <tables>
        <table>Com</table>
        <table>MCom</table>
      </tables>
      <lookups>
        <table source="zonelookup" nodelay="False">zonelookup1</table>
      </lookups>
      <listlookups>
        <table source="baudlist">baudlist1</table>
        <table source="typelist">typelist1</table>
      </listlookups>
    </DataChannel>
    <DVRCamera maintable="DvrCamera" hostcallback="false" sendtoallpanels="false" operation="0">
      <tables>
        <table>DvrCamera</table>
      </tables>
      <lookups>
        <table source="mtimezonlookup" nodelay="False">mtimezonlookup17</table>
      </lookups>
    </DVRCamera>
    <DVRVideo maintable="DvrConfig" hostcallback="False" sendtoallpanels="False" operation="0">
      <tables>
        <table>DvrCamera</table>
        <table>DvrConfig</table>
      </tables>
      <lookups>
        <table source="mtimezonlookup" nodelay="False">mtimezonlookup17</table>
        <table source="zonelookup" nodelay="False">zonelookup2</table>
      </lookups>
      <listlookups>
        <table source="dvrtypelist">dvrtypelist1</table>
      </listlookups>
    </DVRVideo>
    <FacilityCode maintable="Facility" panelkeyname="PnlRef" hostcallback="True" sendtoallpanels="False" key1name="PnlRef" operation="13">
      <tables>
        <table>Facility</table>
      </tables>
      <lookups>
        <table source="facilitylookupjoin" param1name="pnlref" param1value="PnlRef" param1table="Facility" nodelay="True">facilitylookupjoin1</table>
        <table source="panellookup" nodelay="False">panellookup5</table>
      </lookups>
    </FacilityCode>
    <FacilityMaps maintable="FacilityMap" hostcallback="false" sendtoallpanels="flase" operation="0">
      <tables>
        <table>FacilityMap</table>
        <table>FacilityMapPoints</table>
      </tables>
    </FacilityMaps>
    <Holiday maintable="MHoliday" hostcallback="True" sendtoallpanels="True" key1name="CalendarNo" operation="17">
      <tables>
        <table>Holiday</table>
        <table>MHoliday</table>
      </tables>
    </Holiday>
    <Input maintable="Input" panelkeyname="PnlRef" hostcallback="True" sendtoallpanels="false" key1name="InpNo" operation="8">
      <tables>
        <table>Input</table>
      </tables>
      <lookups>
        <table source="categorycounterlookup" param1name="pnlno" param1value="pnlno" param1table="Input" nodelay="False">categorycounterlookup3</table>
        <table source="dvrcameralookup" param1name="ServerID" param1value="DvrServerID" param1table="Input" nodelay="False">dvrcameralookup3</table>
        <table source="dvrconfiglookup" nodelay="False">dvrconfiglookup3</table>
        <table source="inputlookupjoin" param1name="pnlref" param1value="PnlRef" param1table="Input" param2name="inpno" param2value="InpNo" param2table="Input" nodelay="True">inputlookupjoin1</table>
        <table source="mtimezonlookup" nodelay="False">mtimezonlookup10</table>
        <table source="mtimezonlookup" nodelay="False">mtimezonlookup11</table>
        <table source="panellookupwithoutlock" nodelay="False">panellookupwithoutlock2</table>
        <table source="readerlookupinput" param1name="pnlref" param1value="PnlRef" param1table="Input" nodelay="False">readerlookup3</table>
        <table source="timeschedulelookup" nodelay="False">timeschedulelookup4</table>
        <table source="timeschedulelookup" nodelay="False">timeschedulelookup5</table>
      </lookups>
      <listlookups>
        <table source="ptzpresetlist">ptzpresetlist3</table>
        <table source="videoeventtypelist">videoeventtypelist1</table>
      </listlookups>
    </Input>
    <Link maintable="Link" panelkeyname="PnlRef" hostcallback="True" sendtoallpanels="false" key1name="ProgNo" deleteprocname="ca_sp_DeleteLinks" operation="10">
      <tables>
        <table>Link</table>
      </tables>
      <lookups>
        <table source="inputlookup" param1name="pnlref" param1value="PnlRef" param1table="Link" nodelay="False">inputlookup1</table>
        <table source="inputlookup" param1name="pnlref" param1value="PnlRef" param1table="Link" nodelay="False">inputlookup2</table>
        <table source="inputlookup" param1name="pnlref" param1value="PnlRef" param1table="Link" nodelay="False">inputlookup3</table>
        <table source="inputlookup" param1name="pnlref" param1value="PnlRef" param1table="Link" nodelay="False">inputlookup4</table>
        <table source="inputlookup" param1name="pnlref" param1value="PnlRef" param1table="Link" nodelay="False">inputlookup5</table>
        <table source="linkbypanellookup" nodelay="True">linkbypanellookup1</table>
        <table source="linklookupjoin" param1name="pnlref" param1value="PnlRef" param1table="Link" param2name="progno" param2value="ProgNo" param2table="Link" nodelay="True">linklookupjoin1</table>
        <table source="mtimezonlookup" nodelay="False">mtimezonlookup13</table>
        <table source="mtimezonlookup" nodelay="False">mtimezonlookup9</table>
        <table source="panellookupwithoutlock" nodelay="False">panellookupwithoutlock1</table>
        <table source="relaylookup" param1name="pnlref" param1value="PnlRef" param1table="Link" nodelay="False">relaylookup10</table>
        <table source="relaylookup" param1name="pnlref" param1value="PnlRef" param1table="Link" nodelay="False">relaylookup11</table>
        <table source="relaylookup" param1name="pnlref" param1value="PnlRef" param1table="Link" nodelay="False">relaylookup12</table>
        <table source="relaylookup" param1name="pnlref" param1value="PnlRef" param1table="Link" nodelay="False">relaylookup13</table>
        <table source="relaylookup" param1name="pnlref" param1value="PnlRef" param1table="Link" nodelay="False">relaylookup14</table>
        <table source="relaylookup" param1name="pnlref" param1value="PnlRef" param1table="Link" nodelay="False">relaylookup15</table>
        <table source="relaylookup" param1name="pnlref" param1value="PnlRef" param1table="Link" nodelay="False">relaylookup16</table>
        <table source="relaylookup" param1name="pnlref" param1value="PnlRef" param1table="Link" nodelay="False">relaylookup2</table>
        <table source="relaylookup" param1name="pnlref" param1value="PnlRef" param1table="Link" nodelay="False">relaylookup3</table>
        <table source="relaylookup" param1name="pnlref" param1value="PnlRef" param1table="Link" nodelay="False">relaylookup4</table>
        <table source="relaylookup" param1name="pnlref" param1value="PnlRef" param1table="Link" nodelay="False">relaylookup5</table>
        <table source="relaylookup" param1name="pnlref" param1value="PnlRef" param1table="Link" nodelay="False">relaylookup6</table>
        <table source="relaylookup" param1name="pnlref" param1value="PnlRef" param1table="Link" nodelay="False">relaylookup7</table>
        <table source="relaylookup" param1name="pnlref" param1value="PnlRef" param1table="Link" nodelay="False">relaylookup8</table>
        <table source="relaylookup" param1name="pnlref" param1value="PnlRef" param1table="Link" nodelay="False">relaylookup9</table>
      </lookups>
      <listlookups>
        <table source="manprivlist">manprivlookup5</table>
      </listlookups>
    </Link>
    <LockdownAreas maintable="MLockdownAreas" hostcallback="false" sendtoallpanels="false" operation="0">
      <tables>
        <table>LockdownAreas</table>
        <table>MLockdownAreas</table>
      </tables>
      <lookups>
        <table source="lockdownareadetailgrid" param1name="AreaNo" param1value="AreaNo" param1table="MLockdownAreas" nodelay="False">lockdownareadetailgrid1</table>
      </lookups>
    </LockdownAreas>
    <ManualPrivileges maintable="ManualPrivilege" hostcallback="false" sendtoallpanels="false" operation="0">
      <tables>
        <table>ManualPrivilege</table>
      </tables>
    </ManualPrivileges>
    <NapcoArea maintable="napcoPanelAreas" hostcallback="false" sendtoallpanels="false" operation="0">
      <tables>
        <table>napcoPanelAreaEventDef</table>
        <table>napcoPanelAreas</table>
      </tables>
      <lookups>
        <table source="napcoareaeventdefgrid" param1name="alarmpanelid" param1value="AlarmPanelID" param1table="napcoPanelAreas" param2name="areanumber" param2value="AreaNumber" param2table="napcoPanelAreas" nodelay="False">napcoareaeventdefgrid1</table>
        <table source="napcoareatypelookup" nodelay="False">napcoareatypelookup1</table>
        <table source="napcoeventdeflookup" nodelay="False">napcoeventdeflookup4</table>
        <table source="napcopanellookup" nodelay="False">napcopanellookup1</table>
        <table source="napcopanellookup" nodelay="False">napcopanellookup3</table>
        <table source="napcorelaylookup" filter1name="AlarmPanelID" filter1value="RelayControlPanel" filter1table="napcoPanelAreas" nodelay="False">napcorelaylookup1</table>
        <table source="panellookup" nodelay="False">panellookup8</table>
        <table source="relaylookup" nodelay="False">relaylookup18</table>
      </lookups>
      <listlookups>
        <table source="manprivlist">manprivlist3</table>
        <table source="relaycontrollist">relaycontrollist1</table>
      </listlookups>
    </NapcoArea>
    <NapcoPanel maintable="napcoPanels" hostcallback="False" sendtoallpanels="False" deleteprocname="ca_sp_DeleteNapcoPanel" operation="0">
      <tables>
        <table>napcoPanelAreaEventDef</table>
        <table>napcoPanelAreas</table>
        <table>napcoPanelEventDef</table>
        <table>napcoPanelRelayEventDef</table>
        <table>napcoPanelRelays</table>
        <table>napcoPanels</table>
        <table>napcoPanelUsers</table>
        <table>napcoPanelZoneEventDef</table>
        <table>napcoPanelZones</table>
      </tables>
      <lookups>
        <table source="dvrcameralookup" param1name="serverid" param1value="DvrServerID" param1table="napcoPanelZones" nodelay="False">dvrcameralookup1</table>
        <table source="mtimezonlookup" nodelay="False">mtimezonlookup18</table>
        <table source="napcoareatypelookup" nodelay="False">napcoareatypelookup1</table>
        <table source="napcoconnectiontypeslookup" nodelay="False">napcoconnectiontypeslookup1</table>
        <table source="napcoeventdeflookup" nodelay="False">napcoeventdeflookup1</table>
        <table source="napcoeventdeflookup" nodelay="False">napcoeventdeflookup2</table>
        <table source="napcoeventdeflookup" nodelay="False">napcoeventdeflookup3</table>
        <table source="napcoeventdeflookup" nodelay="False">napcoeventdeflookup4</table>
        <table source="napcopanelareaslookup" param1name="alarmpanelid" param1value="AlarmPanelID" param1table="napcoPanels" nodelay="False">napcopanelareaslookup2</table>
        <table source="napcopaneleventdefgrid" param1name="alarmpanelid" param1value="AlarmPanelID" param1table="napcoPanels" nodelay="False">napcopaneleventdefgrid1</table>
        <table source="napcopanellookup" nodelay="False">napcopanellookup1</table>
        <table source="napcopanellookup" nodelay="False">napcopanellookup2</table>
        <table source="napcopanellookup" nodelay="False">napcopanellookup4</table>
        <table source="napcopanellookup" nodelay="False">napcopanellookup5</table>
        <table source="napcopaneltypelookup" nodelay="False">napcopaneltypelookup1</table>
        <table source="napcorelaylookup" nodelay="False">napcorelaylookup1</table>
        <table source="napcoworkstationlookup" nodelay="False">napcoworkstationlookup1</table>
      </lookups>
      <listlookups>
        <table source="manprivlist">manprivlist3</table>
        <table source="relaycontrollist">relaycontrollist1</table>
      </listlookups>
    </NapcoPanel>
    <NapcoPermission maintable="napcoMPermissions" hostcallback="false" sendtoallpanels="false" deleteprocname="ca_sp_DeleteNapcoPermissions" operation="0">
      <tables>
        <table>napcoMPermissions</table>
        <table>napcoPermissions</table>
      </tables>
      <lookups>
        <table source="napcopermissiontree" param1name="PermissionID" param1value="PermissionID" param1table="napcoMPermissions" nodelay="False">napcopermissiontree1</table>
      </lookups>
    </NapcoPermission>
    <NapcoRelay maintable="napcoPanelRelays" hostcallback="false" sendtoallpanels="false" operation="0">
      <tables>
        <table>napcoPanelRelayEventDef</table>
        <table>napcoPanelRelays</table>
      </tables>
      <lookups>
        <table source="napcoeventdeflookup" nodelay="False">napcoeventdeflookup2</table>
        <table source="napcopanellookup" nodelay="False">napcopanellookup4</table>
        <table source="napcorelayeventdefgrid" param1name="alarmpanelid" param1value="AlarmPanelID" param1table="napcoPanelRelays" param2name="relaynumber" param2value="RelayNumber" param2table="napcoPanelRelays" nodelay="False">napcorelayeventdefgrid1</table>
      </lookups>
    </NapcoRelay>
    <NapcoZone maintable="napcoPanelZones" hostcallback="false" sendtoallpanels="false" operation="0">
      <tables>
        <table>napcoPanelZoneEventDef</table>
        <table>napcoPanelZones</table>
      </tables>
      <lookups>
        <table source="dvrcameralookup" param1name="ServerID" param1value="DvrServerID" param1table="napcoPanelZones" nodelay="False">dvrcameralookup1</table>
        <table source="mtimezonlookup" nodelay="False">mtimezonlookup18</table>
        <table source="napcoeventdeflookup" nodelay="False">napcoeventdeflookup1</table>
        <table source="napcopanelareaslookup" param1name="alarmpanelid" param1value="AlarmPanelID" param1table="napcoPanelZoneEventDef" nodelay="False">napcopanelareaslookup1</table>
        <table source="napcopanellookup" nodelay="False">napcopanellookup5</table>
        <table source="napcozoneeventdefgrid" param1name="alarmpanelid" param1value="AlarmPanelID" param1table="napcoPanelZones" param2name="zonenumber" param2value="ZoneNumber" param2table="napcoPanelZones" nodelay="False">napcozoneeventdefgrid1</table>
      </lookups>
    </NapcoZone>
    <NewMap maintable="Map" hostcallback="false" sendtoallpanels="false" operation="0">
      <tables>
        <table>Map</table>
        <table>MapAPBArea</table>
        <table>MapEventFilter</table>
        <table>MapPoints</table>
        <table>MapPointsEventFilter</table>
      </tables>
      <lookups>
        <table source="allapblookup" nodelay="False">apblookup1</table>
        <table source="DeviceInfoLookup" nodelay="False">DeviceInfoLookup1</table>
      </lookups>
    </NewMap>
    <NodePanels maintable="Panel" hostcallback="false" sendtoallpanels="false" operation="0">
      <tables>
        <table>Panel</table>
      </tables>
      <lookups>
        <table source="comlookup" nodelay="False">comlookup1</table>
        <table source="mcomlookup" nodelay="False">mcomlookup1</table>
        <table source="mholidaylookup" nodelay="False">mholidaylookup1</table>
        <table source="napcoconnectiontypeslookup" nodelay="False">napcoconnectiontypeslookup2</table>
        <table source="NapcoPanelNoneLookup" nodelay="False">NapcoPanelNoneLookup1</table>
        <table source="paneltypelookup" nodelay="False">paneltypelookup1</table>
      </lookups>
    </NodePanels>
    <Nodes maintable="Nodes" hostcallback="false" sendtoallpanels="false" operation="0">
      <tables>
        <table>Nodes</table>
      </tables>
      <lookups>
        <table source="mcomlookup" nodelay="False">mcomlookup2</table>
        <table source="mtimezonlookup" nodelay="False">mtimezonlookup14</table>
        <table source="nodelookupjoin" param1name="nodeid" param1value="NodeId" param1table="Nodes" nodelay="True">nodelookupjoin1</table>
        <table source="nodespanellookup" nodelay="True">nodespanellookup1</table>
        <table source="panelsbynode" param1name="nodeid" param1value="NodeId" param1table="Nodes" nodelay="True">panelsbynode1</table>
      </lookups>
    </Nodes>
    <OperatorInstructions maintable="operatorInstructions" hostcallback="false" sendtoallpanels="false" operation="0">
      <tables>
        <table>operatorInstructions</table>
      </tables>
    </OperatorInstructions>
    <OperatorInstructLink maintable="operatorInstructLink" hostcallback="false" sendtoallpanels="false" operation="0">
      <tables>
        <table>operatorInstructLink</table>
      </tables>
      <lookups>
        <table source="operatorinstructionlookup" nodelay="False">operatorinstructionlookup1</table>
      </lookups>
    </OperatorInstructLink>
    <OperatorPrivileges maintable="OperatorPrivileges" hostcallback="false" sendtoallpanels="false" operation="0">
      <tables>
        <table>OperatorPrivileges</table>
      </tables>
    </OperatorPrivileges>
    <RolePrivileges maintable="RolePrivileges" hostcallback="false" sendtoallpanels="false" operation="0">
      <tables>
        <table>RolePrivileges</table>
      </tables>
    </RolePrivileges>
    <OperatorResponse maintable="Resp" hostcallback="false" sendtoallpanels="false" operation="0">
      <tables>
        <table>Resp</table>
      </tables>
    </OperatorResponse>
    <Operators maintable="Operators" hostcallback="false" sendtoallpanels="false" operation="0">
      <tables>
        <table>ManualPrivilege</table>
        <table>Operators</table>
      </tables>
      <lookups>
        <table source="rolelookup" nodelay="False">rolelookup1</table>
        <table source="smsproviderslookup" nodelay="False">smsproviderslookup1</table>
        <table source="snppproviderslookup" nodelay="False">snppproviderslookup1</table>
      </lookups>
      <listlookups>
        <table source="operatormanprivlist">operatormanprivlist1</table>
      </listlookups>
    </Operators>
    <Panel maintable="Panel" panelkeyname="PnlNo" hostcallback="True" sendtoallpanels="False" key1name="PnlNo" deleteprocname="ca_sp_DeletePanel" operation="6">
      <tables>
        <table>Panel</table>
      </tables>
      <lookups>
        <table source="comlookup" filter1name="HCSNo" filter1value="HCSNo" filter1table="Panel" nodelay="True">comlookup1</table>
        <table source="mcomlookup" nodelay="True">mcomlookup1</table>
        <table source="mholidaylookup" nodelay="False">mholidaylookup1</table>
        <table source="NapcoPanelNoneLookup" nodelay="False">NapcoPanelNoneLookup1</table>
        <table source="panellookupjoin" param1name="pnlno" param1value="PnlNo" param1table="Panel" nodelay="True">panellookupjoin1</table>
        <table source="paneltypelookup" nodelay="True">paneltypelookup1</table>
        <table source="zonebyid" param1name="zoneid" param1value="ZoneId" param1table="Panel" nodelay="True">zonebyid1</table>
      </lookups>
    </Panel>
    <Partitions maintable="Partition" hostcallback="false" sendtoallpanels="false" operation="0">
      <tables>
        <table>Partition</table>
      </tables>
    </Partitions>
    <Personnel maintable="Person" key1table="Badge" key4table="Badge" hostcallback="True" sendtoallpanels="True" key1name="facility" key4name="badge" deleteprocname="ca_sp_DeletePerson" operation="5">
      <tables>
        <table>AccGrp</table>
        <table>Badge</table>
        <table>BadgeAccess</table>
        <table>BadgeCategories</table>
        <table>Person</table>
        <table>UserFields</table>
      </tables>
      <lookups>
        <table source="accessgroupsPartitionlookup" nodelay="False">accessgroupslookup1</table>
        <table source="agbybadgefacility" param1name="badge" param1value="Badge" param1table="Badge" param2name="facility" param2value="Facility" param2table="Badge" nodelay="True">agbybadgefacility1</table>
        <table source="apbareaswithsetnextlookup" nodelay="True">apbareaswithsetnextlookup1</table>
        <table source="badgecustom" param1name="personid" param1value="PersonID" param1table="Person" param2name="badge" param2value="Badge" param2table="Badge" param3name="facility" param3value="Facility" param3table="Badge" nodelay="False">badgecustom1</table>
        <table source="badgelookupjoin" param1name="personid" param1value="PersonID" param1table="Person" param2name="badge" param2value="Badge" param2table="Badge" param3name="facility" param3value="Facility" param3table="Badge" nodelay="True">badgelookupjoin1</table>
        <table source="companyidlookup" nodelay="False">companyidlookup1</table>
        <table source="customfields" nodelay="False">customfields1</table>
        <table source="departmentlookup" nodelay="False">departmentlookup1</table>
        <table source="lastvalidaccess" param1name="Badge" param1value="Badge" param1table="Badge" param2name="Facility" param2value="Facility" param2table="Badge" nodelay="True">lastvalidaccess1</table>
        <table source="locationlookup" nodelay="False">locationlookup1</table>
        <table source="mholidaylookup" nodelay="False">mholidaylookup2</table>
        <table source="mshuntlookup" nodelay="False">mshuntlookup1</table>
        <table source="mtimezonlookup" nodelay="True">mtimezonlookup12</table>
        <table source="napcompermissionslookup" nodelay="False">napcompermissionslookup1</table>
        <table source="personlookupjoin" param1name="personid" param1value="PersonID" param1table="Person" nodelay="True">personlookupjoin1</table>
        <table source="supervisorlookup" nodelay="False">supervisorlookup1</table>
      </lookups>
      <listlookups>
        <table source="genderlist">genderlist1</table>
        <table source="orgcatlist">orgcatlist1</table>
        <table source="persorglist">persorglist1</table>
      </listlookups>
    </Personnel>
    <Reader maintable="Reader" panelkeyname="PnlRef" hostcallback="True" sendtoallpanels="false" key1name="RdrNo" operation="7">
      <tables>
        <table>ElevAg</table>
        <table>Reader</table>
        <table>ReaderCategories</table>
        <table>ReaderPriority</table>
        <table>ElevAgFloors</table>
      </tables>
      <lookups>
        <table source="apbareaslookup" nodelay="False">apbareaslookup1</table>
        <table source="apbareaslookup" nodelay="False">apbareaslookup2</table>
        <table source="assignagfromreader" nodelay="True">assignagfromreader1</table>
        <table source="categorycounterlookup" nodelay="False">categorycounterlookup1</table>
        <table source="dvrcameralookup" nodelay="False">dvrcameralookup2</table>
        <table source="dvrconfiglookup" nodelay="False">dvrconfiglookup2</table>
        <table source="elevserverlookup" nodelay="False">elevserverlookup1</table>
        <table source="elevaglookup" param1name="pnlref" param1value="PnlRef" param1table="Reader" param2name="rdrref" param2value="RdrNo" param2table="Reader" nodelay="True">elevaglookup1</table>
        <table source="elevagfloorlookup" param1name="pnlref" param1value="PnlRef" param1table="Reader" param2name="rdrref" param2value="RdrNo" param2table="Reader" nodelay="True">elevagfloorlookup1</table>
        <table source="elevlookup" param1name="pnlref" param1value="PnlRef" param1table="Reader" format1table="Reader" format1value="RdrNo" nodelay="True">elevlookup1</table>
        <table source="elevrelaylookup" param1name="pnlref" param1value="PnlRef" param1table="Reader" nodelay="True">elevrelaylookup1</table>
        <table source="mtimezonlookup" nodelay="False">mtimezonlookup1</table>
        <table source="mtimezonlookup" nodelay="False">mtimezonlookup16</table>
        <table source="mtimezonlookup" nodelay="False">mtimezonlookup19</table>
        <table source="mtimezonlookup" nodelay="False">mtimezonlookup2</table>
        <table source="mtimezonlookup" nodelay="False">mtimezonlookup3</table>
        <table source="mtimezonlookup" nodelay="False">mtimezonlookup4</table>
        <table source="mtimezonlookup" nodelay="False">mtimezonlookup5</table>
        <table source="mtimezonlookup" nodelay="False">mtimezonlookup6</table>
        <table source="napcoareas" param1name="pnlno" param1value="PnlRef" param1table="Reader" nodelay="True">napcoareas1</table>
        <table source="panellookup" nodelay="False">panellookup1</table>
        <table source="readerlookupjoin" param1name="pnlref" param1value="PnlRef" param1table="Reader" param2name="rdrno" param2value="RdrNo" param2table="Reader" nodelay="True">readerlookupjoin1</table>
        <table source="relaylookup" param1name="pnlref" param1value="PnlRef" param1table="Reader" nodelay="True">relaylookup1</table>
        <table source="vehicletagreaderlookup" nodelay="False">vehicletagreaderlookup1</table>
        <table source="elevfloorlookup" nodelay="True">elevfloorlookup1</table>
      </lookups>
      <listlookups>
        <table source="apbtypelist">apbtypelist1</table>
        <table source="lockcontrollist">lockcontrollist1</table>
        <table source="manprivlist">manprivlist1</table>
        <table source="ptzpresetlist">ptzpresetlist1</table>
        <table source="taapbtypelist">taapbtypelist1</table>
        <table source="twopersonreadertypelist">twopersonreadertypelist1</table>
      </listlookups>
    </Reader>
    <Relay maintable="Relay" panelkeyname="PnlRef" hostcallback="True" sendtoallpanels="false" key1name="RelNo" operation="9">
      <tables>
        <table>Relay</table>
      </tables>
      <lookups>
        <table source="mtimezonlookup" nodelay="False">mtimezonlookup7</table>
        <table source="allpanellookupwithcondition" nodelay="False">allpanellookupwithcondition1</table>
        <table source="relaylookupjoin" param1name="pnlref" param1value="PnlRef" param1table="Relay" param2name="relno" param2value="RelNo" param2table="Relay" nodelay="True">relaylookupjoin1</table>
      </lookups>
      <listlookups>
        <table source="manprivlist">manprivlist2</table>
      </listlookups>
    </Relay>
    <Roles maintable="Roles" hostcallback="false" sendtoallpanels="false" operation="0">
      <tables>
        <table>RolePlugins</table>
        <table>Roles</table>
      </tables>
      <lookups>
        <table source="getassignedroles" param1name="roleid" param1value="RoleID" param1table="Roles" nodelay="False">getassignedroles1</table>
        <table source="getunassignedroles" param1name="roleid" param1value="RoleID" param1table="Roles" nodelay="False">getunassignedroles1</table>
      </lookups>
    </Roles>
    <ScheduledChange maintable="SchedEvent" hostcallback="false" sendtoallpanels="false" operation="0">
      <tables>
        <table>SchedEvent</table>
      </tables>
      <lookups>
        <table source="inputprivenabledlookup" nodelay="False">inputprivenabledlookup1</table>
        <table source="linkscprivenabledlookup" nodelay="False">linkscprivenabledlookup1</table>
        <table source="readerscprivenabledlookup" nodelay="False">readerscprivenabledlookup1</table>
        <table source="relayscprivenabledlookup" nodelay="False">relayscprivenabledlookup1</table>
        <table source="schedeventlookupjoin" param1name="schid" param1value="SchId" param1table="SchedEvent" nodelay="True">schedeventlookupjoin1</table>
        <table source="timeschedulelookup" nodelay="False">timeschedulelookup2</table>
      </lookups>
    </ScheduledChange>
    <Schedules maintable="MTimezon" hostcallback="True" sendtoallpanels="True" key1name="TzNum" operation="15">
      <tables>
        <table>MTimezon</table>
        <table>Timezone</table>
      </tables>
      <listlookups>
        <table source="daylist">daylist1</table>
        <table source="daylist">daylist2</table>
      </listlookups>
    </Schedules>
    <ScriptEditor maintable="alarmLink_scripts" hostcallback="false" sendtoallpanels="false" deleteprocname="ca_sp_DeleteAlarmLink_Scripts" operation="0">
      <tables>
        <table>alarmLink_scripts</table>
      </tables>
    </ScriptEditor>
    <ScriptLink maintable="alarmLink_ScriptLinks" hostcallback="false" sendtoallpanels="false" operation="0">
      <tables>
        <table>alarmLink_ScriptLinks</table>
      </tables>
      <lookups>
        <table source="panellookup" nodelay="False">panellookup6</table>
        <table source="ScriptingServersList" nodelay="False">ScriptingServersList1</table>
        <table source="ScriptLink_GetAll" nodelay="False">ScriptLink_GetAll1</table>
        <table source="scriptLookup_WithGUID" nodelay="False">scriptLookup1</table>
        <table source="scriptServerLookup" nodelay="False">scriptServerLookup1</table>
        <table source="ScriptTypeLookup" nodelay="False">ScriptTypeLookup1</table>
        <table source="ScriptTypeLookup" nodelay="False">ScriptTypeLookup2</table>
        <table source="ScriptTypeStatusLookup" nodelay="False">ScriptTypeStatusLookup1</table>
        <table source="ScriptWizard_ActivityLink_GetALL" nodelay="False">ScriptWizard_ActivityLink_GetALL2</table>
        <table source="ScriptWizard_APBAreas_GetALL" nodelay="False">ScriptWizard_APBAreas_GetALL2</table>
        <table source="ScriptWizard_CategoryCounters_GetALL" nodelay="False">ScriptWizard_CategoryCounters_GetALL2</table>
        <table source="ScriptWizard_Input_GetALL" nodelay="False">ScriptWizard_Input_GetALL2</table>
        <table source="ScriptWizard_Link_GetALL" nodelay="False">ScriptWizard_Link_GetALL2</table>
        <table source="ScriptWizard_LockDownAreas_GetALL" nodelay="False">ScriptWizard_LockDownAreas_GetALL2</table>
        <table source="ScriptWizard_NapcoEventDef_GetALL" nodelay="False">ScriptWizard_NapcoEventDef_GetALL2</table>
        <table source="ScriptWizard_NapcoPanel_GetALL" nodelay="False">ScriptWizard_NapcoPanel_GetALL2</table>
        <table source="ScriptWizard_NapcoPanelArea_GetALL" nodelay="False">ScriptWizard_NapcoPanelArea_GetALL2</table>
        <table source="ScriptWizard_NapcoPanelRelays_GetALL" nodelay="False">ScriptWizard_NapcoPanelRelays_GetALL2</table>
        <table source="ScriptWizard_NapcoPanelZones_GetALL" nodelay="False">ScriptWizard_NapcoPanelZones_GetALL2</table>
        <table source="ScriptWizard_Panel_GetALL" nodelay="False">ScriptWizard_Panel_GetALL2</table>
        <table source="ScriptWizard_Reader_GetALL" nodelay="False">ScriptWizard_Reader_GetALL2</table>
        <table source="ScriptWizard_Relay_GetALL" nodelay="False">ScriptWizard_Relay_GetALL2</table>
      </lookups>
    </ScriptLink>
    <ScriptScheduler maintable="AlarmLink_Schedule" childtable="AlarmLink_ScheduleDetail" hostcallback="False" sendtoallpanels="False" deleteprocname="ca_sp_DeleteScriptSchedule" childdeleteprocname="ca_sp_DeleteScriptScheduleDetail" operation="0">
      <tables>
        <table>AlarmLink_Schedule</table>
        <table>AlarmLink_ScheduleDetail</table>
      </tables>
      <lookups>
        <table source="ScheduleLookup" nodelay="False">ScheduleLookup1</table>
        <table source="ScheduleTypeLookup" nodelay="False">ScheduleTypeLookup1</table>
        <table source="scriptLookup" nodelay="False">scriptLookup2</table>
        <table source="scriptServerLookup" nodelay="False">scriptServerLookup2</table>
        <table source="ScriptWizard_ActivityLink_GetALL" nodelay="False">ScriptWizard_ActivityLink_GetALL3</table>
        <table source="ScriptWizard_APBAreas_GetALL" nodelay="False">ScriptWizard_APBAreas_GetALL3</table>
        <table source="ScriptWizard_CategoryCounters_GetALL" nodelay="False">ScriptWizard_CategoryCounters_GetALL3</table>
        <table source="ScriptWizard_Input_GetALL" nodelay="False">ScriptWizard_Input_GetALL3</table>
        <table source="ScriptWizard_Link_GetALL" nodelay="False">ScriptWizard_Link_GetALL3</table>
        <table source="ScriptWizard_LockDownAreas_GetALL" nodelay="False">ScriptWizard_LockDownAreas_GetALL3</table>
        <table source="ScriptWizard_NapcoEventDef_GetALL" nodelay="False">ScriptWizard_NapcoEventDef_GetALL3</table>
        <table source="ScriptWizard_NapcoPanel_GetALL" nodelay="False">ScriptWizard_NapcoPanel_GetALL3</table>
        <table source="ScriptWizard_NapcoPanelArea_GetALL" nodelay="False">ScriptWizard_NapcoPanelArea_GetALL3</table>
        <table source="ScriptWizard_NapcoPanelRelays_GetALL" nodelay="False">ScriptWizard_NapcoPanelRelays_GetALL3</table>
        <table source="ScriptWizard_NapcoPanelZones_GetALL" nodelay="False">ScriptWizard_NapcoPanelZones_GetALL3</table>
        <table source="ScriptWizard_Panel_GetALL" nodelay="False">ScriptWizard_Panel_GetALL3</table>
        <table source="ScriptWizard_ContinentalPanel_GetALL" nodelay="False">ScriptWizard_ContinentalPanel_GetALL3</table>
        <table source="ScriptWizard_LockPanel_GetALL" nodelay="False">ScriptWizard_LockPanel_GetALL3</table>
        <table source="ScriptWizard_Reader_GetALL" nodelay="False">ScriptWizard_Reader_GetALL3</table>
        <table source="ScriptWizard_Relay_GetALL" nodelay="False">ScriptWizard_Relay_GetALL3</table>
        <table source="ScriptWizard_ScriptTypes_GetALL" nodelay="False">ScriptWizard_ScriptTypes_GetALL2</table>
        <table source="ScriptWizard_ScriptTypeStatus_GetALL" nodelay="False">ScriptWizard_ScriptTypeStatus_GetALL2</table>
      </lookups>
    </ScriptScheduler>
    <ScriptWizard maintable="alarmLink_scripts" childtable="alarmLink_ScriptLinks" hostcallback="False" sendtoallpanels="False" operation="0">
      <tables>
        <table>alarmLink_ScriptLinks</table>
        <table>alarmLink_scripts</table>
      </tables>
      <lookups>
        <table source="panellookup" nodelay="False">panellookup6</table>
        <table source="scriptLookup" nodelay="False">scriptLookup1</table>
        <table source="scriptServerLookup" nodelay="False">scriptServerLookup1</table>
        <table source="ScriptTypeLookup" nodelay="False">ScriptTypeLookup2</table>
        <table source="ScriptTypeStatusLookup" nodelay="False">ScriptTypeStatusLookup1</table>
        <table source="ScriptWizard_ActivityLink_GetALL" nodelay="False">ScriptWizard_ActivityLink_GetALL1</table>
        <table source="ScriptWizard_APBAreas_GetALL" nodelay="False">ScriptWizard_APBAreas_GetALL1</table>
        <table source="ScriptWizard_CategoryCounters_GetALL" nodelay="False">ScriptWizard_CategoryCounters_GetALL1</table>
        <table source="ScriptWizard_Input_GetALL" nodelay="False">ScriptWizard_Input_GetALL1</table>
        <table source="ScriptWizard_Link_GetALL" nodelay="False">ScriptWizard_Link_GetALL1</table>
        <table source="ScriptWizard_LockDownAreas_GetALL" nodelay="False">ScriptWizard_LockDownAreas_GetALL1</table>
        <table source="ScriptWizard_MessageTemplate_GetALL" nodelay="False">ScriptWizard_MessageTemplate_GetALL1</table>
        <table source="ScriptWizard_NapcoEventDef_GetALL" nodelay="False">ScriptWizard_NapcoEventDef_GetALL1</table>
        <table source="ScriptWizard_NapcoPanel_GetALL" nodelay="False">ScriptWizard_NapcoPanel_GetALL1</table>
        <table source="ScriptWizard_NapcoPanelArea_GetALL" nodelay="False">ScriptWizard_NapcoPanelArea_GetALL1</table>
        <table source="ScriptWizard_NapcoPanelRelays_GetALL" nodelay="False">ScriptWizard_NapcoPanelRelays_GetALL1</table>
        <table source="ScriptWizard_NapcoPanelZones_GetALL" nodelay="False">ScriptWizard_NapcoPanelZones_GetALL1</table>
        <table source="ScriptWizard_Operator_GetALL" nodelay="False">ScriptWizard_Operator_GetALL1</table>
        <table source="ScriptWizard_Panel_GetALL" nodelay="False">ScriptWizard_Panel_GetALL1</table>
        <table source="ScriptWizard_ContinentalPanel_GetALL" nodelay="False">ScriptWizard_ContinentalPanel_GetALL1</table>
        <table source="ScriptWizard_LockPanel_GetALL" nodelay="False">ScriptWizard_LockPanel_GetALL1</table>
        <table source="ScriptWizard_Privilage_GetALL" nodelay="False">ScriptWizard_Privilage_GetALL1</table>
        <table source="ScriptWizard_Reader_GetALL" nodelay="False">ScriptWizard_Reader_GetALL1</table>
        <table source="ScriptWizard_Relay_GetALL" nodelay="False">ScriptWizard_Relay_GetALL1</table>
        <table source="rolelookup" nodelay="False">ScriptWizard_rolelookup1</table>
        <table source="ScriptWizard_ScriptServer_GetALL" nodelay="False">ScriptWizard_ScriptServer_GetALL1</table>
        <table source="ScriptWizard_ScriptTypes_GetALL" nodelay="False">ScriptWizard_ScriptTypes_GetALL1</table>
        <table source="ScriptWizard_ScriptTypeStatus_GetALL" nodelay="False">ScriptWizard_ScriptTypeStatus_GetALL1</table>
        <table source="ScriptWizard_ThreatLevel_GetALL" nodelay="False">ScriptWizard_ThreatLevel_GetALL</table>
      </lookups>
    </ScriptWizard>
    <Shunt maintable="MShunt" hostcallback="false" sendtoallpanels="false" deleteprocname="ca_sp_DeleteShunts" operation="0">
      <tables>
        <table>MShunt</table>
        <table>Shunt</table>
      </tables>
      <lookups>
        <table source="allinputlookup" nodelay="False">allinputlookup1</table>
      </lookups>
    </Shunt>
    <SystemScreen maintable="SystemSettings" hostcallback="True" sendtoallpanels="False" key1name="SysId" operation="19">
      <tables>
        <table>OperatorSettings</table>
        <table>SystemSettings</table>
        <table>WorkstationSettings</table>
      </tables>
      <lookups>
        <table source="centralstationserver0" nodelay="False">centralstationserver1</table>
        <table source="CustomMenuSettings" nodelay="False">CustomMenuSettings1</table>
        <table source="MessageTemplatesList" nodelay="True">MessageTemplatesList1</table>
        <table source="napcoworkstation" nodelay="False">napcoworkstation1</table>
        <table source="ScriptingServersList" nodelay="True">ScriptingServersList2</table>
        <table source="smsProvidersList" nodelay="True">smsProvidersList1</table>
        <table source="snppProvidersList" nodelay="True">snppProvidersList1</table>
        <table source="timeschedulelookupsettings" nodelay="False">timeschedulelookup1</table>
        <table source="timeschedulelookup" nodelay="False">timeschedulelookup3</table>
      </lookups>
      <listlookups>
        <table source="KeypadOptionList">KeypadOptionList1</table>
        <table source="maxaccessgroups">maxaccessgroups1</table>
        <table source="maxbadgelength">maxbadgelength1</table>
        <table source="vechileTrack">vechileTrack1</table>
        <table source="APBResetList">APBResetList1</table>
    </listlookups>
    </SystemScreen>
    <ThreatLevel maintable="MActiveThreatLevel" hostcallback="false" sendtoallpanels="false" operation="0">
      <tables>
        <table>MActiveThreatLevel</table>
      </tables>
      <lookups>
        <table source="lockoutarealookup" nodelay="True">lockoutarealookup1</table>
      </lookups>
    </ThreatLevel>
    <ElevatorFloors maintable="ElevFloors" hostcallback="false" sendtoallpanels="false" operation="0">
      <tables>
        <table>ElevFloors</table>
      </tables>
      <lookups>
        <table source="elevatorfacilitylookup" nodelay="True">elevatorfacilitylookup1</table>
      </lookups>
    </ElevatorFloors>
    <ElevatorServers maintable="ElevServers" hostcallback="false" sendtoallpanels="false" operation="0">
      <tables>
        <table>ElevServers</table>
      </tables>
      <lookups>
        <table source="elevatorfacilitylookup" nodelay="True">elevatorfacilitylookup1</table>
      </lookups>
    </ElevatorServers>
    <ElevatorFacilities maintable="ElevFacilities" hostcallback="false" sendtoallpanels="false" operation="0">
      <tables>
        <table>ElevFacilities</table>
      </tables>
    </ElevatorFacilities>
  </screens>
  <tables>
    <AccGrp>
      <primarykeyfields>
        <primarykeyfield type="String">Agno</primarykeyfield>
        <primarykeyfield type="Int32">PnlRef</primarykeyfield>
      </primarykeyfields>
      <keyfields>
        <keyfield type="Int32">Agno</keyfield>
      </keyfields>
      <datafields>
        <datafield type="Int32" null="false">Agno</datafield>
        <datafield type="Guid" null="false" RequireDownload="false">caObjectID</datafield>
        <datafield type="Guid" RequireDownload="false">LastOperator</datafield>
        <datafield type="DateTime" RequireDownload="false">LastUpdated</datafield>
        <datafield type="String" RequireDownload="false">LastWorkStation</datafield>
        <datafield type="Int32" null="false">PnlRef</datafield>
        <datafield type="Int32">Tz1</datafield>
        <datafield type="Int32">Tz10</datafield>
        <datafield type="Int32">Tz11</datafield>
        <datafield type="Int32">Tz12</datafield>
        <datafield type="Int32">Tz13</datafield>
        <datafield type="Int32">Tz14</datafield>
        <datafield type="Int32">Tz15</datafield>
        <datafield type="Int32">Tz16</datafield>
        <datafield type="Int32">Tz2</datafield>
        <datafield type="Int32">Tz3</datafield>
        <datafield type="Int32">Tz4</datafield>
        <datafield type="Int32">Tz5</datafield>
        <datafield type="Int32">Tz6</datafield>
        <datafield type="Int32">Tz7</datafield>
        <datafield type="Int32">Tz8</datafield>
        <datafield type="Int32">Tz9</datafield>
        <datafield type="Int32" RequireDownload="false">UTCOffset</datafield>
      </datafields>
    </AccGrp>
    <ActiveLinks>
      <primarykeyfields>
        <primarykeyfield type="Int32">CatNo</primarykeyfield>
        <primarykeyfield type="Int32">InpNo</primarykeyfield>
        <primarykeyfield type="Int32">PnlNo</primarykeyfield>
        <primarykeyfield type="Int32">PnlRef</primarykeyfield>
        <primarykeyfield type="Int32">ProgNo</primarykeyfield>
        <primarykeyfield type="Int32">RdrNo</primarykeyfield>
        <primarykeyfield type="Int32">RelNo</primarykeyfield>
      </primarykeyfields>
      <keyfields>
        <keyfield type="Int32">PnlRef</keyfield>
        <keyfield type="Int32">ProgNo</keyfield>
      </keyfields>
      <datafields>
        <datafield type="Guid" null="false" RequireDownload="false">caObjectId</datafield>
        <datafield type="Int32" null="false" listsource="categorycounterlookup2" listquery="categorycounterlookup">CatNo</datafield>
        <datafield type="Int32">CatReader</datafield>
        <datafield type="String" listsource="controllist1" listquery="controllist">Control</datafield>
        <datafield type="Int32" null="false" listsource="inputlookup7" listquery="inputlookup">InpNo</datafield>
        <datafield type="Guid" RequireDownload="false">LastOperator</datafield>
        <datafield type="String" RequireDownload="false">LastWorkStation</datafield>
        <datafield type="Int32" null="false">PnlNo</datafield>
        <datafield type="Int32">PnlRef</datafield>
        <datafield type="Int32">ProgNo</datafield>
        <datafield type="Int32" null="false" listsource="readerlookup2" listquery="readerlookup">RdrNo</datafield>
        <datafield type="Int32" listsource="relaylookup17" listquery="relaylookup">RelNo</datafield>

        <datafield type="Int32" null="false" identity="true">ALPId</datafield>
        <datafield type="Boolean" null="true">Active</datafield>
      </datafields>
    </ActiveLinks>
    <AlarmLink_Schedule orderby="ScheduleID" ismaster="False">
      <primarykeyfields>
        <primarykeyfield type="Int32">ScheduleID</primarykeyfield>
      </primarykeyfields>
      <keyfields>
        <keyfield type="Guid">caObjectID</keyfield>
      </keyfields>
      <datafields>
        <datafield type="Int64" null="false">Badge</datafield>
        <datafield type="Guid" null="false" RequireDownload="false">caObjectId</datafield>
        <datafield type="Int32" null="false" listsource="ScriptWizard_ScriptTypes_GetALL2" listquery="ScriptWizard_ScriptTypes_GetALL">cat</datafield>
        <datafield type="Int32" null="false">DeviceNo</datafield>
        <datafield type="Int32" null="false">EventClassID</datafield>
        <datafield type="Int32" null="false" min="0" max="32768">Facility</datafield>
        <datafield type="Boolean" null="false" default="False">IsScheduleEventDependent</datafield>
        <datafield type="Guid" RequireDownload="false">LastOperator</datafield>
        <datafield type="DateTime" null="false" RequireDownload="false">LastUpdated</datafield>
        <datafield type="String" RequireDownload="false">LastWorkStation</datafield>
        <datafield type="Int32" null="false">pnlNo</datafield>
        <datafield type="Boolean" null="false" default="False">RunIfOperatorLoggedOn</datafield>
        <datafield type="DateTime" null="false">ScheduleDateTime</datafield>
        <datafield type="Boolean" null="false" default="True">ScheduleEnabled</datafield>
        <datafield type="Int32" null="false">ScheduleID</datafield>
        <datafield type="String" RequireDownload="false">ScheduleName</datafield>
        <datafield type="Int32" null="false" listsource="ScheduleTypeLookup1" listquery="ScheduleTypeLookup">ScheduleTypeID</datafield>
        <datafield type="Int32" null="false" listsource="scriptLookup2" listquery="scriptLookup">ScriptID</datafield>
        <datafield type="Int32" null="false">status</datafield>
        <datafield type="Int32" null="false" listsource="scriptServerLookup2" listquery="scriptServerLookup">workstationID</datafield>
      </datafields>
    </AlarmLink_Schedule>
    <AlarmLink_ScheduleDetail orderby="ScheduleID" ismaster="False">
      <primarykeyfields>
        <primarykeyfield type="Int32">ScheduleDetailID</primarykeyfield>
      </primarykeyfields>
      <keyfields>
        <keyfield type="Int32">ScheduleID</keyfield>
      </keyfields>
      <datafields>
        <datafield type="Guid" null="false" RequireDownload="false">caObjectId</datafield>
        <datafield type="Guid" RequireDownload="false">LastOperator</datafield>
        <datafield type="DateTime" null="false" RequireDownload="false">LastUpdated</datafield>
        <datafield type="String" RequireDownload="false">LastWorkStation</datafield>
        <datafield type="Int32" identity="true">ScheduleDetailID</datafield>
        <datafield type="Int32">ScheduleExtraData</datafield>
        <datafield type="Int32" null="false" listsource="ScheduleLookup1" listquery="ScheduleLookup">ScheduleID</datafield>
      </datafields>
    </AlarmLink_ScheduleDetail>
    <AlarmLink_ScheduleType orderby="ID" ismaster="False">
      <primarykeyfields>
        <primarykeyfield type="Int32">ID</primarykeyfield>
      </primarykeyfields>
      <datafields>
        <datafield type="Int32" null="false">ID</datafield>
        <datafield type="String" null="false">TypeName</datafield>
      </datafields>
    </AlarmLink_ScheduleType>
    <alarmLink_ScriptLinks ismaster="False">
      <primarykeyfields>
        <primarykeyfield type="Int64">badge</primarykeyfield>
        <primarykeyfield type="Int32">cat</primarykeyfield>
        <primarykeyfield type="Int32">DeviceNo</primarykeyfield>
        <primarykeyfield type="Int32">facility</primarykeyfield>
        <primarykeyfield type="Int32">pnlNo</primarykeyfield>
        <primarykeyfield type="Int32">status</primarykeyfield>
        <primarykeyfield type="Int32">workstationID</primarykeyfield>
      </primarykeyfields>
      <keyfields>
        <keyfield type="Guid">caObjectID</keyfield>
      </keyfields>
      <datafields>
        <datafield type="Int64" null="false">badge</datafield>
        <datafield type="Guid" null="false" RequireDownload="false">caObjectId</datafield>
        <datafield type="Int32" null="false" listsource="ScriptTypeLookup2" listquery="ScriptTypeLookup">cat</datafield>
        <datafield type="Int32" null="false">DeviceNo</datafield>
        <datafield type="Int32" null="false">EventClassID</datafield>
        <datafield type="Int32" null="false" min="0" max="32768">Facility</datafield>
        <datafield type="Guid" RequireDownload="false">LastOperator</datafield>
        <datafield type="DateTime" null="false" RequireDownload="false">LastUpdated</datafield>
        <datafield type="String" RequireDownload="false">LastWorkStation</datafield>
        <datafield type="Int32" null="false" listsource="panellookup6" listquery="panellookup">pnlNo</datafield>
        <datafield type="Int32" null="false" listsource="scriptLookup1" listquery="scriptLookup">scriptID</datafield>
        <datafield type="Boolean" null="false" default="True">scriptLinkEnabled</datafield>
        <datafield type="String" null="false" RequireDownload="false">scriptLinkName</datafield>
        <datafield type="Int32" null="false" listsource="ScriptTypeStatusLookup1" listquery="ScriptTypeStatusLookup">status</datafield>
        <datafield type="Int32" null="false" listsource="scriptServerLookup1" listquery="scriptServerLookup">workstationID</datafield>
      </datafields>
    </alarmLink_ScriptLinks>
    <alarmLink_scripts orderby="ScriptID" ismaster="True">
      <primarykeyfields>
        <primarykeyfield type="Int32">scriptID</primarykeyfield>
      </primarykeyfields>
      <keyfields>
        <keyfield type="Guid">caObjectID</keyfield>
      </keyfields>
      <datafields>
        <datafield type="Guid" null="false" RequireDownload="false">caObjectId</datafield>
        <datafield type="String">compiledScript</datafield>
        <datafield type="Int32" null="false" min="0" max="99">executeEventPriority</datafield>
        <datafield type="Boolean" null="false" default="True">generateEvent</datafield>
        <datafield type="Guid" RequireDownload="false">LastOperator</datafield>
        <datafield type="DateTime" null="false" RequireDownload="false">LastUpdated</datafield>
        <datafield type="String" RequireDownload="false">LastWorkStation</datafield>
        <datafield type="String" null="false">procName</datafield>
        <datafield type="Int32" null="false">scriptID</datafield>
        <datafield type="String" readonly="true" null="false">scriptLanguage</datafield>
        <datafield type="String">scriptName</datafield>
        <datafield type="String">scriptText</datafield>
      </datafields>
    </alarmLink_scripts>
    <APBAreas>
      <keyfields>
        <keyfield type="Guid">caObjectID</keyfield>
      </keyfields>
      <datafields>
        <datafield type="Boolean" default="False">Active</datafield>
        <datafield type="Boolean" null="false" default="false">AlertOn</datafield>
        <datafield type="Int32" min="0" max="65535">AreaCountDown</datafield>
        <datafield type="Int32" min="0" max="65535">AreaCountUp</datafield>
        <datafield type="Int32" null="false">AreaNo</datafield>
        <datafield type="Guid" null="false" RequireDownload="false">caObjectId</datafield>
        <datafield type="String" length="41" RequireDownload="false">Description</datafield>
        <datafield type="Guid" RequireDownload="false">LastOperator</datafield>
        <datafield type="DateTime" null="false" RequireDownload="false">LastUpdated</datafield>
        <datafield type="String" RequireDownload="false">LastWorkStation</datafield>
        <datafield type="Int32" listsource="APBAreaLinkLookup1" listquery="APBAreaLinkLookup" min="0" max="2147483647">LinkOccupied</datafield>
        <datafield type="Int32" listsource="APBAreaLinkLookup2" listquery="APBAreaLinkLookup" min="0" max="2147483647">LinkOnCountDown</datafield>
        <datafield type="Int32" listsource="APBAreaLinkLookup3" listquery="APBAreaLinkLookup" min="0" max="2147483647">LinkOnCountUp</datafield>
        <datafield type="Int32" listsource="APBAreaLinkLookup4" listquery="APBAreaLinkLookup" min="0" max="2147483647">LinkVacant</datafield>
        <datafield type="Int32" null="true">ParentArea</datafield>
      </datafields>
    </APBAreas>
    <Badge>
      <keyfields>
        <keyfield type="Int64">Badge</keyfield>
        <keyfield type="Int32">Facility</keyfield>
        <keyfield type="Guid">PersonID</keyfield>
      </keyfields>
      <datafields>
        <datafield type="Int32" min="0" max="255">AccessTime</datafield>
        <datafield type="DateTime" RequireDownload="false">ActvDate</datafield>
        <datafield type="Int32">AgencyCode</datafield>
        <datafield type="Int32" listsource="apbareaswithsetnextlookup1" listquery="apbareaswithsetnextlookup">APBArea</datafield>
        <datafield type="Int32">APBSet</datafield>
        <datafield type="Int64" null="false">Badge</datafield>
        <datafield type="String" null="True">PIVI</datafield>
        <datafield type="Int32">BadgeType</datafield>
        <datafield type="Guid" null="false" RequireDownload="false">caObjectID</datafield>
        <datafield type="Boolean" default="False">DurUse</datafield>
        <datafield type="Int32">Embossed</datafield>
        <datafield type="Boolean" default="True">Enabled</datafield>
        <datafield type="String" RequireDownload="false">EPI_BadgeID</datafield>
        <datafield type="String" RequireDownload="false">EPI_FORMAT_ID</datafield>
        <datafield type="Boolean" default="False">Escort</datafield>
        <datafield type="DateTime" RequireDownload="false">ExprDate</datafield>
        <datafield type="Int32" null="false" min="0" max="10">Facility</datafield>
        <datafield type="Boolean" default="False">FirstInControl</datafield>
        <datafield type="Int32" listsource="mholidaylookup2" listquery="mholidaylookup">HolidayCalendar</datafield>
        <datafield type="Boolean" default="True">InitLoad</datafield>
        <datafield type="Int32" min="0" max="99">Issue</datafield>
        <datafield type="Guid" RequireDownload="false">LastOperator</datafield>
        <datafield type="DateTime" null="false" RequireDownload="false">LastUpdated</datafield>
        <datafield type="String" RequireDownload="false">LastWorkStation</datafield>
        <datafield type="Boolean" default="False">MApbExempt</datafield>
        <datafield type="Int32" listsource="persorglist1" listquery="persorglist">OrgAssoc</datafield>
        <datafield type="Int32" listsource="orgcatlist1" listquery="orgcatlist">OrgCategory</datafield>
        <datafield type="Int32" min="0" max="65535">OrgId</datafield>
        <datafield type="Guid" null="false">PersonID</datafield>
        <datafield type="Int64">PersPIVId</datafield>
        <datafield type="Int32">Pin</datafield>
        <datafield type="Boolean" default="True">Resident</datafield>
        <datafield type="DateTime">SDate</datafield>
        <datafield type="Int32" min="0" max="65535">Series</datafield>
        <datafield type="Boolean" default="False">Shunt</datafield>
        <datafield type="Int32" listsource="mshuntlookup1" listquery="mshuntlookup">ShuntId</datafield>
        <datafield type="Int32">SiteNo</datafield>
        <datafield type="Boolean" default="False">Track</datafield>
        <datafield type="Int32" RequireDownload="false" min="0" max="10000">UseCount</datafield>
        <datafield type="Int32" RequireDownload="false">UTCOffset</datafield>
        <datafield type="Boolean" default="False">VehicleTag</datafield>
        <datafield type="Int32" null="false" listsource="napcompermissionslookup1" listquery="napcompermissionslookup">NAPCOPermissionId</datafield>
      </datafields>
    </Badge>
    <BadgeAccess orderby="AGSeq">
      <primarykeyfields>
        <primarykeyfield type="Int32">AGroupNo</primarykeyfield>
        <primarykeyfield type="Int32">AGSeq</primarykeyfield>
        <primarykeyfield type="Int64">Badge</primarykeyfield>
        <primarykeyfield type="Int32">Facility</primarykeyfield>
      </primarykeyfields>
      <keyfields>
        <keyfield type="Int64">Badge</keyfield>
        <keyfield type="Int32">Facility</keyfield>
      </keyfields>
      <datafields>
        <datafield type="DateTime" displaylabel="Access Group Activation Date">AGroupActivationDate</datafield>
        <datafield type="DateTime" displaylabel="Access Group Expiration Date">AGroupExpirationDate</datafield>
        <datafield type="Int32" null="false" listsource="accessgroupslookup1" listquery="accessgroupsPartitionlookup" displaylabel="Access Group ">AGroupNo</datafield>
        <datafield type="Int32">AGSeq</datafield>
        <datafield type="Int64" null="false">Badge</datafield>
        <datafield type="Guid" null="false" RequireDownload="false">caObjectId</datafield>
        <datafield type="Int32" null="false">Facility</datafield>
        <datafield type="Guid" RequireDownload="false">LastOperator</datafield>
        <datafield type="DateTime" null="false" RequireDownload="false">LastUpdated</datafield>
        <datafield type="String" RequireDownload="false">LastWorkStation</datafield>
        <datafield type="Boolean" default="False">PointAccess</datafield>
        <datafield type="Int32" RequireDownload="false">UTCOffset</datafield>
      </datafields>
    </BadgeAccess>
    <BadgeCategories ismaster="False">
      <primarykeyfields>
        <primarykeyfield type="Int64">Badge</primarykeyfield>
        <primarykeyfield type="Int32">CatNumber</primarykeyfield>
        <primarykeyfield type="Int32">Facility</primarykeyfield>
      </primarykeyfields>
      <keyfields>
        <keyfield type="Int64">Badge</keyfield>
        <keyfield type="Int32">Facility</keyfield>
      </keyfields>
      <datafields>
        <datafield type="Int64" null="false">Badge</datafield>
        <datafield type="Int32" null="false">CatNumber</datafield>
        <datafield type="Int32" null="false">Facility</datafield>
        <datafield type="DateTime" null="false" RequireDownload="false">LastUpdated</datafield>
        <datafield type="String" RequireDownload="false">LastWorkStation</datafield>
      </datafields>
    </BadgeCategories>
    <CategoryCounters>
      <primarykeyfields>
        <primarykeyfield type="Int32">CatNo</primarykeyfield>
        <primarykeyfield type="Int32">PnlNo</primarykeyfield>
      </primarykeyfields>
      <keyfields>
        <keyfield type="Int32">PnlNo</keyfield>
      </keyfields>
      <datafields>
        <datafield type="Guid" null="false" RequireDownload="false">caObjectId</datafield>
        <datafield type="Int32" readonly="true">CatNo</datafield>
        <datafield type="String" length="50" RequireDownload="false">Description</datafield>
        <datafield type="Boolean" default="False">EventMsg</datafield>
        <datafield type="Int32" min="0" max="65000">HiWater</datafield>
        <datafield type="Guid" RequireDownload="false">LastOperator</datafield>
        <datafield type="DateTime" null="false" RequireDownload="false">LastUpdated</datafield>
        <datafield type="String" RequireDownload="false">LastWorkStation</datafield>
        <datafield type="Int32" min="0" max="65000">LowWater</datafield>
        <datafield type="Int32" null="false">PnlNo</datafield>
        <datafield type="Int32" min="1" max="99">Priority</datafield>
        <datafield type="Boolean" default="False">RespReq</datafield>
        <datafield type="Int32">UTCOffset</datafield>
      </datafields>
    </CategoryCounters>
    <CentralStationLinks ismaster="False">
      <keyfields>
        <keyfield type="Int64">badge</keyfield>
        <keyfield type="Int32">cat</keyfield>
        <keyfield type="Guid">centralStationId</keyfield>
        <keyfield type="Int32">facility</keyfield>
        <keyfield type="Int32">Number</keyfield>
        <keyfield type="Int32">pnlNo</keyfield>
        <keyfield type="Int32">status</keyfield>
        <keyfield type="Int32">workstationId</keyfield>
      </keyfields>
      <datafields>
        <datafield type="Int32" null="false" min="0" max="255">areaNum</datafield>
        <datafield type="Int64" null="false">badge</datafield>
        <datafield type="Guid" null="false" RequireDownload="false">caObjectId</datafield>
        <datafield type="Int32" null="false" min="0" max="99999">cat</datafield>
        <datafield type="Guid" null="false" listsource="centralstationserver2" listquery="centralstationserver">centralStationId</datafield>
        <datafield type="Int32" null="false" min="0" max="255">codeToReport</datafield>
        <datafield type="Int32" null="false" min="0" max="10">facility</datafield>
        <datafield type="Guid" RequireDownload="false">LastOperator</datafield>
        <datafield type="String" RequireDownload="false">LastWorkStation</datafield>
        <datafield type="Int32" null="false" min="0" max="99999">Number</datafield>
        <datafield type="Int32" null="false" min="0" max="99999">pnlNo</datafield>
        <datafield type="Boolean" null="false" default="True">shouldReport</datafield>
        <datafield type="Int32" null="false" min="0" max="99999">status</datafield>
        <datafield type="Int32" null="false" min="0" max="99999">workstationId</datafield>
        <datafield type="Int32" null="false" min="0" max="255">zoneNum</datafield>
      </datafields>
    </CentralStationLinks>
    <Com>
      <primarykeyfields>
        <primarykeyfield type="Int32">ComPort</primarykeyfield>
        <primarykeyfield type="Int32">HCSNo</primarykeyfield>
      </primarykeyfields>
      <keyfields>
        <keyfield type="Int32">HCSNo</keyfield>
      </keyfields>
      <datafields>
        <datafield type="Int32">Authentication</datafield>
        <datafield type="Int32" listsource="baudlist1" listquery="baudlist">Baud</datafield>
        <datafield type="Boolean" default="False">BinaryMode</datafield>
        <datafield type="Guid" null="false" RequireDownload="false">caObjectId</datafield>
        <datafield type="Int32" readonly="true">ComPort</datafield>
        <datafield type="String">DHCPName</datafield>
        <datafield type="Int32">GatewayEncryption</datafield>
        <datafield type="String">GatewayIPAddress</datafield>
        <datafield type="Int32" readonly="true" min="0" max="100">HCSNo</datafield>
        <datafield type="String" editmask="000.000.000.000">IPAddress</datafield>
        <datafield type="Int32">IPPort</datafield>
        <datafield type="String">Key1Value</datafield>
        <datafield type="Int32">KeyType</datafield>
        <datafield type="Guid" RequireDownload="false">LastOperator</datafield>
        <datafield type="DateTime" null="false" RequireDownload="false">LastUpdated</datafield>
        <datafield type="String" RequireDownload="false">LastWorkStation</datafield>
        <datafield type="String">MACAddress</datafield>
        <datafield type="Int32">NetworkType</datafield>
        <datafield type="Boolean" default="False">NoPolling</datafield>
        <datafield type="String" length="50">Passwrd</datafield>
        <datafield type="Int32">RFChannel</datafield>
        <datafield type="Int32">RFGroup</datafield>
        <datafield type="Int32">SecurityType</datafield>
        <datafield type="String">SSIDName</datafield>
        <datafield type="String">SubNetMask</datafield>
        <datafield type="Int32">SyncWordLower</datafield>
        <datafield type="Int32">SyncWordUpper</datafield>
        <datafield type="Int32" listsource="typelist1" listquery="typelist">Type</datafield>
        <datafield type="Boolean" default="False">UseDHCP</datafield>
        <datafield type="Int32">WifiChannelNo</datafield>
        <datafield type="Int32">WirelessMode</datafield>
        <datafield type="Int32" null="false" listsource="zonelookup1" listquery="zonelookup">ZoneId</datafield>
      </datafields>
    </Com>
    <DBAudit ismaster="False">
      <datafields>
        <datafield type="String">Actions</datafield>
        <datafield type="Int32" null="false">AuditId</datafield>
        <datafield type="Guid">caObjectID</datafield>
        <datafield type="String">ChangedColumns</datafield>
        <datafield type="String">Description</datafield>
        <datafield type="Guid" RequireDownload="false">LastOperator</datafield>
        <datafield type="String">NewData</datafield>
        <datafield type="String">OldData</datafield>
        <datafield type="String">OperatorName</datafield>
        <datafield type="DateTime">RevisionStamp</datafield>
        <datafield type="String">StationName</datafield>
        <datafield type="String">TableName</datafield>
        <datafield type="Int32">UTCOffset</datafield>
      </datafields>
    </DBAudit>
    <DvrCamera>
      <primarykeyfields>
        <primarykeyfield type="Int32">DvrCameraID</primarykeyfield>
        <primarykeyfield type="Guid">DvrServerID</primarykeyfield>
      </primarykeyfields>
      <keyfields>
        <keyfield type="Guid">DvrServerID</keyfield>
      </keyfields>
      <datafields>
        <datafield type="String" null="false" RequireDownload="false">CameraName</datafield>
        <datafield type="Guid" null="false" RequireDownload="false">caObjectId</datafield>
        <datafield type="Int32" null="false" RequireDownload="false">DvrCameraID</datafield>
        <datafield type="Guid" null="false" RequireDownload="false">DvrServerID</datafield>
        <datafield type="Boolean" default="False" RequireDownload="false">EnableNotification</datafield>
        <datafield type="Guid" RequireDownload="false">LastOperator</datafield>
        <datafield type="DateTime" RequireDownload="false">LastUpdated</datafield>
        <datafield type="String" RequireDownload="false">LastWorkStation</datafield>
        <datafield type="Int32" min="1" max="99" increment="1" RequireDownload="false">Priority</datafield>
        <datafield type="Int32" listsource="mtimezonlookup17" listquery="mtimezonlookup" RequireDownload="false">Tzno</datafield>
        <datafield type="String" default="" RequireDownload="false">VendorCameraID</datafield>
      </datafields>
    </DvrCamera>
    <DvrConfig>
      <keyfields>
        <keyfield type="Guid">DvrID</keyfield>
      </keyfields>
      <datafields>
        <datafield type="Boolean" null="false" default="False" RequireDownload="false">Active</datafield>
        <datafield type="Guid" null="false" RequireDownload="false">DvrID</datafield>
        <datafield type="Int32" listsource="dvrtypelist1" listquery="dvrtypelist" RequireDownload="false">DVRVendor</datafield>
        <datafield type="Boolean" default="False" RequireDownload="false">EnableNotification</datafield>
        <datafield type="Guid" RequireDownload="false">LastOperator</datafield>
        <datafield type="DateTime" RequireDownload="false">LastUpdated</datafield>
        <datafield type="String" RequireDownload="false">LastWorkStation</datafield>
        <datafield type="String" null="false" RequireDownload="false">Password</datafield>
        <datafield type="String" null="false" RequireDownload="false">ServerIP</datafield>
        <datafield type="String" null="false" RequireDownload="false">ServerName</datafield>
        <datafield type="String" null="false" RequireDownload="false">UserName</datafield>
        <datafield type="Int32" RequireDownload="false">UserType</datafield>
        <datafield type="Int32" listsource="zonelookup2" listquery="zonelookup" RequireDownload="false">ZoneID</datafield>
      </datafields>
    </DvrConfig>
    <ElevAg>
      <primarykeyfields>
        <primarykeyfield type="Int32">AccGroup</primarykeyfield>
        <primarykeyfield type="Int32">PnlRef</primarykeyfield>
        <primarykeyfield type="Int32">RdrRef</primarykeyfield>
        <primarykeyfield type="Int32">RelayNumber</primarykeyfield>
      </primarykeyfields>
      <keyfields>
        <keyfield type="Int32">PnlRef</keyfield>
        <keyfield type="Int32">RdrRef</keyfield>
      </keyfields>
      <datafields>
        <datafield type="Int32">AccGroup</datafield>
        <datafield type="Guid" RequireDownload="false">LastOperator</datafield>
        <datafield type="String" RequireDownload="false">LastWorkStation</datafield>
        <datafield type="Int32">PnlRef</datafield>
        <datafield type="Int32">RdrRef</datafield>
        <datafield type="Int32">RelayNumber</datafield>
      </datafields>
    </ElevAg>
    <ElevAgFloors>
      <primarykeyfields>
        <primarykeyfield type="Int32">AccGroup</primarykeyfield>
        <primarykeyfield type="Int32">PnlRef</primarykeyfield>
        <primarykeyfield type="Int32">RdrRef</primarykeyfield>
        <primarykeyfield type="Int32">FloorNumber</primarykeyfield>
      </primarykeyfields>
      <keyfields>
        <keyfield type="Int32">PnlRef</keyfield>
        <keyfield type="Int32">RdrRef</keyfield>
      </keyfields>
      <datafields>
        <datafield type="Int32">AccGroup</datafield>
        <datafield type="Guid" RequireDownload="false">LastOperator</datafield>
        <datafield type="String" RequireDownload="false">LastWorkStation</datafield>
        <datafield type="Int32">PnlRef</datafield>
        <datafield type="Int32">RdrRef</datafield>
        <datafield type="Int32">FloorNumber</datafield>
        <datafield type="DateTime" null="false" RequireDownload="false">LastUpdated</datafield>
      </datafields>
    </ElevAgFloors>
    <Facility ismaster="False">
      <keyfields>
        <keyfield type="Guid">caObjectID</keyfield>
      </keyfields>
      <datafields>
        <datafield type="Guid" null="false" RequireDownload="false">caObjectId</datafield>
        <datafield type="Int32" min="0" max="65535">Facil1</datafield>
        <datafield type="Int32" min="0" max="65535">Facil10</datafield>
        <datafield type="Int32" min="0" max="65535">Facil2</datafield>
        <datafield type="Int32" min="0" max="65535">Facil3</datafield>
        <datafield type="Int32" min="0" max="65535">Facil4</datafield>
        <datafield type="Int32" min="0" max="65535">Facil5</datafield>
        <datafield type="Int32" min="0" max="65535">Facil6</datafield>
        <datafield type="Int32" min="0" max="65535">Facil7</datafield>
        <datafield type="Int32" min="0" max="65535">Facil8</datafield>
        <datafield type="Int32" min="0" max="65535">Facil9</datafield>
        <datafield type="Guid" RequireDownload="false">LastOperator</datafield>
        <datafield type="DateTime" null="false" RequireDownload="false">LastUpdated</datafield>
        <datafield type="String" RequireDownload="false">LastWorkStation</datafield>
        <datafield type="Int32" readonly="true" null="false" listsource="panellookup5" listquery="allpanellookup">PnlRef</datafield>
        <datafield type="Int32" RequireDownload="false">UTCOffset</datafield>
      </datafields>
    </Facility>
    <FacilityMap ismaster="True">
      <primarykeyfields>
        <primarykeyfield type="Int32">MapId</primarykeyfield>
      </primarykeyfields>
      <keyfields>
        <keyfield type="Int32">MapId</keyfield>
      </keyfields>
      <datafields>
        <datafield type="Guid" null="false" RequireDownload="false">caObjectId</datafield>
        <datafield type="Guid" RequireDownload="false">LastOperator</datafield>
        <datafield type="DateTime" null="false" RequireDownload="false">LastUpdated</datafield>
        <datafield type="String" RequireDownload="false">LastWorkStation</datafield>
        <datafield type="String" RequireDownload="false">MapDescription</datafield>
        <datafield type="Int32" null="false" RequireDownload="false">MapId</datafield>
        <datafield type="Binary" RequireDownload="false">MapImage</datafield>
        <datafield type="String" null="false" RequireDownload="false">MapName</datafield>
      </datafields>
    </FacilityMap>
    <FacilityMapPoints ismaster="False">
      <primarykeyfields>
        <primarykeyfield type="Int32">MapPointId</primarykeyfield>
      </primarykeyfields>
      <keyfields>
        <keyfield type="Int32">MapId</keyfield>
      </keyfields>
      <datafields>
        <datafield type="Int32" RequireDownload="false">DevNo</datafield>
        <datafield type="Int32" null="false" RequireDownload="false">MapId</datafield>
        <datafield type="Int32" null="false" RequireDownload="false">MapPointId</datafield>
        <datafield type="Int32" RequireDownload="false">PanelNo</datafield>
        <datafield type="Single" RequireDownload="false">PtX</datafield>
        <datafield type="Single" RequireDownload="false">PtY</datafield>
        <datafield type="Int32" null="false" RequireDownload="false">Type</datafield>
      </datafields>
    </FacilityMapPoints>
    <Format ismaster="False">
      <keyfields>
        <keyfield type="Guid">caObjectID</keyfield>
      </keyfields>
      <datafields>
        <datafield type="Guid" null="false" RequireDownload="false">caObjectID</datafield>
        <datafield type="String" length="50" null="false" RequireDownload="false">Description</datafield>
        <datafield type="Int32" min="0" max="9999">FmtCLen</datafield>
        <datafield type="Int32" min="0" max="9999">FmtCOff</datafield>
        <datafield type="Int32" min="0" max="999">FmtCSLen</datafield>
        <datafield type="Int32" min="0" max="999">FmtCSOff</datafield>
        <datafield type="Int32" min="0" max="999">FmtDLen</datafield>
        <datafield type="Int32" min="0" max="999">FmtDOff</datafield>
        <datafield type="Int32" min="0" max="9999">FmtES</datafield>
        <datafield type="Int32" min="0" max="9999">FmtESO</datafield>
        <datafield type="Int32" min="0" max="9999">FmtFLen</datafield>
        <datafield type="Int32" min="0" max="9999">FmtFOff</datafield>
        <datafield type="Int32" min="0" max="9999">FmtFS</datafield>
        <datafield type="Int32" min="0" max="9999">FmtFSO</datafield>
        <datafield type="Int32" min="0" max="999">FmtILen</datafield>
        <datafield type="Int32" min="0" max="9999">FmtIOff</datafield>
        <datafield type="Int32" min="3" max="255">FmtLength</datafield>
        <datafield type="Int32" readonly="true" null="false" min="0" max="9999">FmtNo</datafield>
        <datafield type="Int32" min="0" max="999">FmtOCLen</datafield>
        <datafield type="Int32" min="0" max="999">FmtOCOff</datafield>
        <datafield type="Int32" min="0" max="999">FmtOILen</datafield>
        <datafield type="Int32" min="0" max="999">FmtOIOff</datafield>
        <datafield type="Int32" min="0" max="999">FmtPILen</datafield>
        <datafield type="Int32" min="0" max="999">FmtPIOff</datafield>
        <datafield type="Int32" min="0" max="999">FmtPOALen</datafield>
        <datafield type="Int32" min="0" max="999">FmtPOAOff</datafield>
        <datafield type="Int32" min="0" max="9999">FmtSS</datafield>
        <datafield type="Int32" min="0" max="9999">FmtSSO</datafield>
        <datafield type="Int32" null="false" listsource="badgeformatlist1" listquery="badgeformatlist">FmtType</datafield>
        <datafield type="Guid" RequireDownload="false">LastOperator</datafield>
        <datafield type="DateTime" null="false" RequireDownload="false">LastUpdated</datafield>
        <datafield type="String" RequireDownload="false">LastWorkStation</datafield>
        <datafield type="Boolean" default="False">PivStatus</datafield>
      </datafields>
    </Format>
    <globalVariables ismaster="False">
      <primarykeyfields>
        <primarykeyfield type="String">variableName</primarykeyfield>
      </primarykeyfields>
      <datafields>
        <datafield type="String" length="50" null="false">variableName</datafield>
        <datafield type="String" length="512">variableValue</datafield>
      </datafields>
    </globalVariables>
    <Holiday>
      <primarykeyfields>
        <primarykeyfield type="Int32">CalendarNo</primarykeyfield>
        <primarykeyfield type="Int32">HolNo</primarykeyfield>
      </primarykeyfields>
      <keyfields>
        <keyfield type="Int32">CalendarNo</keyfield>
      </keyfields>
      <datafields>
        <datafield type="Int32" null="false">CalendarNo</datafield>
        <datafield type="Guid" null="false" RequireDownload="false">caObjectId</datafield>
        <datafield type="Int32">EndHr</datafield>
        <datafield type="Int32">EndMin</datafield>
        <datafield type="Int32">FrHr</datafield>
        <datafield type="Int32">FrMin</datafield>
        <datafield type="DateTime">FromTime</datafield>
        <datafield type="Int32" null="false">HolNo</datafield>
        <datafield type="Guid" RequireDownload="false">LastOperator</datafield>
        <datafield type="String" RequireDownload="false">LastWorkStation</datafield>
        <datafield type="DateTime">SDate</datafield>
        <datafield type="DateTime">ToTime</datafield>
      </datafields>
    </Holiday>
    <Input>
      <keyfields>
        <keyfield type="Guid">caObjectID</keyfield>
      </keyfields>
      <datafields>
        <datafield type="Boolean" default="False">AbnormDial</datafield>
        <datafield type="Int32" min="0" max="255">AlertLimit</datafield>
        <datafield type="Guid" RequireDownload="false">caObjectID</datafield>
        <datafield type="Int32" displaylabel="Cat Code">CatCode</datafield>
        <datafield type="Int32">Categories</datafield>
        <datafield type="Int32">CatReader</datafield>
        <datafield type="Int32" listsource="mtimezonlookup16" listquery="mtimezonlookup" displaylabel="Cat Schedule">CatSchedule</datafield>
        <datafield type="Boolean" default="False">ConRelay</datafield>
        <datafield type="String" length="50" RequireDownload="false">Description</datafield>
        <datafield type="Int32" listsource="dvrcameralookup3" listquery="dvrcameralookup" RequireDownload="false">DvrCameraID</datafield>
        <datafield type="Guid" listsource="dvrconfiglookup3" listquery="dvrconfiglookup" RequireDownload="false">DvrServerID</datafield>
        <datafield type="Boolean" default="False">Enabled</datafield>
        <datafield type="Boolean" default="False" RequireDownload="false">EnablePTZPreset</datafield>
        <datafield type="Boolean" default="False" RequireDownload="false">EnableRecording</datafield>
        <datafield type="Int32" min="0" max="15300">InpDelay</datafield>
        <datafield type="Int32" readonly="true" min="1" max="82" displaylabel="Input No.">InpNo</datafield>
        <datafield type="Int32" min="0" max="255">InpReset</datafield>
        <datafield type="Int32" listsource="mtimezonlookup10" listquery="mtimezonlookup">InpTz</datafield>
        <datafield type="String" length="100" null="false" RequireDownload="false">InputName</datafield>
        <datafield type="Guid" RequireDownload="false">LastOperator</datafield>
        <datafield type="DateTime" null="false" RequireDownload="false">LastUpdated</datafield>
        <datafield type="String" RequireDownload="false">LastWorkStation</datafield>
        <datafield type="Int32" listsource="mtimezonlookup11" listquery="mtimezonlookup">LimitSchedule</datafield>
        <datafield type="String" length="50" RequireDownload="false">Location</datafield>
        <datafield type="Int32" min="0" max="9999" increment="10">NoofSecsToRecord</datafield>
        <datafield type="Boolean" default="False">NormDial</datafield>
        <datafield type="Boolean" default="False">NormOpen</datafield>
        <datafield type="Boolean" default="False">NoXact</datafield>
        <datafield type="Int32" readonly="true" listsource="panellookupwithoutlock2" listquery="panellookupwithoutlock">PnlRef</datafield>
        <datafield type="Int32" min="1" max="99" RequireDownload="false">Priority</datafield>
        <datafield type="Int32" listsource="ptzpresetlist3" listquery="ptzpresetlist" RequireDownload="false">PTZPresetNo</datafield>
        <datafield type="Int32" listsource="timeschedulelookup4" listquery="timeschedulelookup" RequireDownload="false">RecordingSchedule</datafield>
        <datafield type="String" RequireDownload="false">Remark</datafield>
        <datafield type="Boolean" default="False" RequireDownload="false">RespReq</datafield>
        <datafield type="Boolean" default="False">Supervised</datafield>
        <datafield type="Int32" RequireDownload="false">UTCOffset</datafield>
        <datafield type="Int32" min="0" max="9999" RequireDownload="false">VideoEndTime</datafield>
        <datafield type="Int32" listsource="videoeventtypelist1" listquery="videoeventtypelist" RequireDownload="false">VideoEventType</datafield>
        <datafield type="Int32" min="0" max="9999" RequireDownload="false">VideoStartTime</datafield>
      </datafields>
    </Input>
    <InputCategories ismaster="False">
      <primarykeyfields>
        <primarykeyfield type="Int32">CatNumber</primarykeyfield>
        <primarykeyfield type="Int32">InpNo</primarykeyfield>
        <primarykeyfield type="Int32">PnlRef</primarykeyfield>
      </primarykeyfields>
      <keyfields>
        <keyfield type="Int32">InpNo</keyfield>
        <keyfield type="Int32">PnlRef</keyfield>
      </keyfields>
      <datafields>
        <datafield type="Int32" null="false">CatNumber</datafield>
        <datafield type="Int32" null="false">InpNo</datafield>
        <datafield type="DateTime" null="false" RequireDownload="false">LastUpdated</datafield>
        <datafield type="String" RequireDownload="false">LastWorkStation</datafield>
        <datafield type="Int32" null="false">PnlRef</datafield>
      </datafields>
    </InputCategories>
    <Link>
      <keyfields>
        <keyfield type="Guid">caObjectID</keyfield>
      </keyfields>
      <datafields>
        <datafield type="Guid" null="false" RequireDownload="false">caObjectId</datafield>
        <datafield type="String" RequireDownload="false">Description</datafield>
        <datafield type="Boolean" default="False">Dialup</datafield>
        <datafield type="Boolean" default="True">Enabled</datafield>
        <datafield type="Int32" listsource="mtimezonlookup13" listquery="mtimezonlookup">ETz</datafield>
        <datafield type="Int32" listsource="inputlookup1" listquery="inputlookup">Inp1</datafield>
        <datafield type="Int32" listsource="inputlookup2" listquery="inputlookup">Inp2</datafield>
        <datafield type="Int32" listsource="inputlookup3" listquery="inputlookup">Inp3</datafield>
        <datafield type="Int32" listsource="inputlookup4" listquery="inputlookup">Inp4</datafield>
        <datafield type="Int32" listsource="inputlookup5" listquery="inputlookup">Inp5</datafield>
        <datafield type="Guid" RequireDownload="false">LastOperator</datafield>
        <datafield type="DateTime" null="false" RequireDownload="false">LastUpdated</datafield>
        <datafield type="String" RequireDownload="false">LastWorkStation</datafield>
        <datafield type="String" length="100" null="false" RequireDownload="false">LinkName</datafield>
        <datafield type="Int32">LnkPnl</datafield>
        <datafield type="Int32">LnkProg</datafield>
        <datafield type="String" length="50" RequireDownload="false">Location</datafield>
        <datafield type="Int32" listsource="manprivlookup5" listquery="manprivlist" RequireDownload="false">ManualPriv</datafield>
        <datafield type="Int32" readonly="true" min="0" max="2147483647" RequireDownload="false">MapId</datafield>
        <datafield type="Int32" listsource="relaylookup2" listquery="relaylookup">Off1</datafield>
        <datafield type="Int32" listsource="relaylookup3" listquery="relaylookup">Off2</datafield>
        <datafield type="Int32" listsource="relaylookup4" listquery="relaylookup">Off3</datafield>
        <datafield type="Int32" listsource="relaylookup5" listquery="relaylookup">Off4</datafield>
        <datafield type="Int32" listsource="relaylookup6" listquery="relaylookup">Off5</datafield>
        <datafield type="Int32" listsource="relaylookup7" listquery="relaylookup">On1</datafield>
        <datafield type="Int32" listsource="relaylookup8" listquery="relaylookup">On2</datafield>
        <datafield type="Int32" listsource="relaylookup9" listquery="relaylookup">On3</datafield>
        <datafield type="Int32" listsource="relaylookup10" listquery="relaylookup">On4</datafield>
        <datafield type="Int32" listsource="relaylookup11" listquery="relaylookup">On5</datafield>
        <datafield type="Int32" readonly="true" null="false" listsource="panellookupwithoutlock1" listquery="panellookupwithoutlock">PnlRef</datafield>
        <datafield type="Int32" min="1" max="99" RequireDownload="false">Priority</datafield>
        <datafield type="Int32" readonly="true" null="false" min="1" max="64" increment="1">ProgNo</datafield>
        <datafield type="String" RequireDownload="false">Remarks</datafield>
        <datafield type="Boolean" default="False" RequireDownload="false">RespReq</datafield>
        <datafield type="Boolean" default="True">RptXact</datafield>
        <datafield type="Int32" listsource="relaylookup12" listquery="relaylookup">Trk1</datafield>
        <datafield type="Int32" listsource="relaylookup13" listquery="relaylookup">Trk2</datafield>
        <datafield type="Int32" listsource="relaylookup14" listquery="relaylookup">Trk3</datafield>
        <datafield type="Int32" listsource="relaylookup15" listquery="relaylookup">Trk4</datafield>
        <datafield type="Int32" listsource="relaylookup16" listquery="relaylookup">Trk5</datafield>
        <datafield type="Int32" listsource="mtimezonlookup9" listquery="mtimezonlookup">TrkTZ</datafield>
        <datafield type="Int32" RequireDownload="false">UTCOffset</datafield>
      </datafields>
    </Link>
    <LockdownAreas orderby="PnlRef,RdrNo" ismaster="False">
      <primarykeyfields>
        <primarykeyfield type="Int32">AreaNo</primarykeyfield>
        <primarykeyfield type="Int32">PnlRef</primarykeyfield>
        <primarykeyfield type="Int32">RdrNo</primarykeyfield>
      </primarykeyfields>
      <keyfields>
        <keyfield type="Int32">AreaNo</keyfield>
      </keyfields>
      <datafields>
        <datafield type="Int32" null="false">AreaNo</datafield>
        <datafield type="Guid" RequireDownload="false">caObjectID</datafield>
        <datafield type="Guid" RequireDownload="false">LastOperator</datafield>
        <datafield type="DateTime" RequireDownload="false">LastUpdated</datafield>
        <datafield type="String" RequireDownload="false">LastWorkStation</datafield>
        <datafield type="Int32" null="false">PnlRef</datafield>
        <datafield type="Int32" null="false">RdrNo</datafield>
      </datafields>
    </LockdownAreas>
    <MAccGrp ismaster="True">
      <keyfields>
        <keyfield type="Guid">caObjectID</keyfield>
      </keyfields>
      <datafields>
        <datafield type="Int32" null="false" min="0" max="32000">AgrpNo</datafield>
        <datafield type="Guid" null="false" RequireDownload="false">caObjectId</datafield>
        <datafield type="String" length="50" RequireDownload="false">Description</datafield>
        <datafield type="Guid" RequireDownload="false">LastOperator</datafield>
        <datafield type="DateTime" null="false" RequireDownload="false">LastUpdated</datafield>
        <datafield type="String" RequireDownload="false">LastWorkStation</datafield>
        <datafield type="Boolean" default="False">PointAccess</datafield>
        <datafield type="Int32" RequireDownload="false">UTCOffset</datafield>
      </datafields>
    </MAccGrp>
    <MActiveLinks ismaster="True">
      <keyfields>
        <keyfield type="Guid">caObjectID</keyfield>
      </keyfields>
      <datafields>
        <datafield type="Guid" null="false" RequireDownload="false">caObjectId</datafield>
        <datafield type="Int32" min="0" max="16">Category</datafield>
        <datafield type="String" length="50" null="false" RequireDownload="false">Description</datafield>
        <datafield type="Int32" listsource="devicelookup1" listquery="devicelookup">Device</datafield>
        <datafield type="Boolean" default="True">Enabled</datafield>
        <datafield type="Int32" null="false" listsource="eventlookup1" listquery="eventlookup">EventCode</datafield>
        <datafield type="Guid" RequireDownload="false">LastOperator</datafield>
        <datafield type="DateTime" null="false" RequireDownload="false">LastUpdated</datafield>
        <datafield type="String" RequireDownload="false">LastWorkStation</datafield>
        <datafield type="Int32" listsource="manprivlist5" listquery="manprivlist" displaylabel="Manual Priv"  RequireDownload="false">ManualPriv</datafield>
        <datafield type="Int32" readonly="true" null="false" listsource="newgenpanellookup1" listquery="panellookupwithoutlock">PnlRef</datafield>
        <datafield type="Int32" min="1" max="99" RequireDownload="false">Priority</datafield>
        <datafield type="Int32" readonly="true" null="false" min="1" max="227">ProgNo</datafield>
        <datafield type="Boolean" default="False" RequireDownload="false">RespReq</datafield>
        <datafield type="Int32" listsource="mtimezonlookup15" listquery="mtimezonlookup">Schedule</datafield>
        <datafield type="Boolean" default="False">UnDO</datafield>
        <datafield type="Int32" listsource="alplookup1" listquery="alplookup">UnDoProgNo</datafield>
        <datafield type="Int32" RequireDownload="false">UTCOffset</datafield>
      </datafields>
    </MActiveLinks>
    <MActiveThreatLevel ismaster="True">
      <keyfields>
        <keyfield type="Guid">caObjectID</keyfield>
      </keyfields>
      <datafields>
        <datafield type="Boolean" null="false" default="False">Active</datafield>
        <datafield type="Guid" null="false" RequireDownload="false">caObjectId</datafield>
        <datafield type="Boolean" default="False">DenyAccess</datafield>
        <datafield type="String" length="50" null="false" RequireDownload="false">Description</datafield>
        <datafield type="Guid" null="false" RequireDownload="false">LastOperator</datafield>
        <datafield type="DateTime" null="false" RequireDownload="false">LastUpdated</datafield>
        <datafield type="String" RequireDownload="false">LastWorkStation</datafield>
        <datafield type="String" null="false">LockdownColor</datafield>
        <datafield type="Int32" null="false" min="1" max="200">LockdownID</datafield>
        <datafield type="Int32" listsource="lockoutarealookup1" listquery="lockoutarealookup" displaylabel="Lockout Area">LockoutArea</datafield>
      </datafields>
    </MActiveThreatLevel>
    <ManualPrivilege ismaster="False">
      <primarykeyfields>
        <primarykeyfield type="Int32">ManualPrivilege</primarykeyfield>
        <primarykeyfield type="Guid">OperatorID</primarykeyfield>
      </primarykeyfields>
      <keyfields>
        <keyfield type="Guid">OperatorID</keyfield>
      </keyfields>
      <datafields>
        <datafield type="Int32" null="false" RequireDownload="false">ManualPrivilege</datafield>
        <datafield type="Guid" null="false" RequireDownload="false">OperatorID</datafield>
      </datafields>
    </ManualPrivilege>
    <Map>
      <primarykeyfields>
        <primarykeyfield type="Guid">MapUID</primarykeyfield>
      </primarykeyfields>
      <keyfields>
        <keyfield type="Guid">MapUID</keyfield>
      </keyfields>
      <datafields>
        <datafield type="Guid" null="false" RequireDownload="false">caObjectId</datafield>
        <datafield type="Guid" RequireDownload="false">LastOperator</datafield>
        <datafield type="DateTime" null="false" RequireDownload="false">LastUpdated</datafield>
        <datafield type="String" RequireDownload="false">LastWorkStation</datafield>
        <datafield type="String" RequireDownload="false">MapDescription</datafield>
        <datafield type="Int32" RequireDownload="false">MapHeight</datafield>
        <datafield type="Int32" null="false" RequireDownload="false">MapID</datafield>
        <datafield type="Byte" RequireDownload="false">MapImage</datafield>
        <datafield type="String" RequireDownload="false">MapName</datafield>
        <datafield type="Guid" null="false" RequireDownload="false">MapUID</datafield>
        <datafield type="Int32" RequireDownload="false">MapWidth</datafield>
        <datafield type="Byte" RequireDownload="false">Snapshot</datafield>
      </datafields>
    </Map>
    <MapAPBArea>
      <primarykeyfields>
        <primarykeyfield type="Guid">MapAPBAreaUID</primarykeyfield>
      </primarykeyfields>
      <keyfields>
        <keyfield type="Guid">MapUID</keyfield>
      </keyfields>
      <datafields>
        <datafield type="Int32" null="false" RequireDownload="false">APBAreasID</datafield>
        <datafield type="String" null="false" RequireDownload="false">DrawingCode</datafield>
        <datafield type="Guid" null="false" RequireDownload="false">MapAPBAreaUID</datafield>
        <datafield type="Guid" null="false" RequireDownload="false">MapUID</datafield>
      </datafields>
    </MapAPBArea>
    <MapEventFilter>
      <primarykeyfields>
        <primarykeyfield type="Int64">MapEventFilterID</primarykeyfield>
      </primarykeyfields>
      <keyfields>
        <keyfield type="Guid">MapUID</keyfield>
      </keyfields>
      <datafields>
        <datafield type="Int32" null="false" RequireDownload="false">EventCode</datafield>
        <datafield type="Boolean" null="false" default="False" RequireDownload="false">IsEnable</datafield>
        <datafield type="Int64" null="false" RequireDownload="false">MapEventFilterID</datafield>
        <datafield type="Guid" null="false" RequireDownload="false">MapUID</datafield>
      </datafields>
    </MapEventFilter>
    <MapPoints>
      <primarykeyfields>
        <primarykeyfield type="Guid">MapPointsUID</primarykeyfield>
      </primarykeyfields>
      <keyfields>
        <keyfield type="Guid">MapUID</keyfield>
      </keyfields>
      <datafields>
        <datafield type="Guid" null="false" RequireDownload="false">DeviceObjectID</datafield>
        <datafield type="Int32" null="false" RequireDownload="false">DeviceType</datafield>
        <datafield type="Int32" RequireDownload="false">DvrCameraID</datafield>
        <datafield type="Guid" RequireDownload="false">DvrServerID</datafield>
        <datafield type="Guid" RequireDownload="false">MapAPBAreaUID</datafield>
        <datafield type="Guid" null="false" RequireDownload="false">MapPointsUID</datafield>
        <datafield type="Guid" null="false" RequireDownload="false">MapUID</datafield>
        <datafield type="Int32" RequireDownload="false">PanelType</datafield>
        <datafield type="String" null="false" RequireDownload="false">PointX</datafield>
        <datafield type="String" null="false" RequireDownload="false">PointY</datafield>
      </datafields>
    </MapPoints>
    <MapPointsEventFilter>
      <keyfields>
        <keyfield type="Guid">MapUID</keyfield>
      </keyfields>
      <datafields>
        <datafield type="Int32" null="false" RequireDownload="false">EventCode</datafield>
        <datafield type="Boolean" null="false" default="False" RequireDownload="false">IsEnable</datafield>
        <datafield type="Int64" null="false" RequireDownload="false">MapPointsEventFilterID</datafield>
        <datafield type="Guid" null="false" RequireDownload="false">MapPointsUID</datafield>
        <datafield type="Guid" null="false" RequireDownload="false">MapUID</datafield>
      </datafields>
    </MapPointsEventFilter>
    <MCom>
      <keyfields>
        <keyfield type="Int32">HCSNo</keyfield>
      </keyfields>
      <datafields>
        <datafield type="Guid" null="false" RequireDownload="false">caObjectId</datafield>
        <datafield type="String" length="41" null="false" RequireDownload="false">Description</datafield>
        <datafield type="Int32" null="false" min="1" max="100" increment="1">HCSNo</datafield>
        <datafield type="Boolean" null="false" default="False">IsAssigned</datafield>
        <datafield type="Guid" RequireDownload="false">LastOperator</datafield>
        <datafield type="DateTime" null="false" RequireDownload="false">LastUpdated</datafield>
        <datafield type="String" RequireDownload="false">LastWorkStation</datafield>
        <datafield type="String" length="50" null="false">UNCName</datafield>
      </datafields>
    </MCom>
    <MessageTemplates ismaster="False">
      <primarykeyfields>
        <primarykeyfield type="Int32">templateID</primarykeyfield>
      </primarykeyfields>
      <datafields>
        <datafield type="Int32" null="false" >include</datafield>
        <datafield type="Boolean" null="false" default="False" RequireDownload="false">allowSMS</datafield>
        <datafield type="Boolean" null="false" default="False" RequireDownload="false">allowEmail</datafield>
        <datafield type="Boolean" null="false" default="False" RequireDownload="false">allowSNPP</datafield>
        <datafield type="String" RequireDownload="false">body</datafield>
        <datafield type="String" length="50" null="false" RequireDownload="false">subject</datafield>
        <datafield type="Int32" RequireDownload="false">templateID</datafield>
      </datafields>
    </MessageTemplates>
    <MHoliday>
      <keyfields>
        <keyfield type="Guid">caObjectID</keyfield>
      </keyfields>
      <datafields>
        <datafield type="Int32" null="false">CalendarNo</datafield>
        <datafield type="Guid" null="false" RequireDownload="false">caObjectId</datafield>
        <datafield type="String" length="50" null="false" RequireDownload="false">Description</datafield>
        <datafield type="Guid" RequireDownload="false">LastOperator</datafield>
        <datafield type="DateTime" null="false" RequireDownload="false">LastUpdated</datafield>
        <datafield type="String" RequireDownload="false">LastWorkStation</datafield>
        <datafield type="Int32" RequireDownload="false">UTCOffset</datafield>
      </datafields>
    </MHoliday>
    <MLockdownAreas orderby="AreaNo" ismaster="True">
      <keyfields>
        <keyfield type="Guid">caObjectID</keyfield>
      </keyfields>
      <datafields>
        <datafield type="Boolean" default="False">Active</datafield>
        <datafield type="Boolean" default="False">ActiveByOper</datafield>
        <datafield type="String" length="50" RequireDownload="false">AreaName</datafield>
        <datafield type="Int32" null="false">AreaNo</datafield>
        <datafield type="Guid" RequireDownload="false">caObjectID</datafield>
        <datafield type="Int32">Categories</datafield>
        <datafield type="Boolean" default="False">DenyCategory</datafield>
        <datafield type="Guid" RequireDownload="false">LastOperator</datafield>
        <datafield type="DateTime" RequireDownload="false">LastUpdated</datafield>
        <datafield type="String" RequireDownload="false">LastWorkStation</datafield>
      </datafields>
    </MLockdownAreas>
    <MShunt>
      <keyfields>
        <keyfield type="Guid">caObjectID</keyfield>
      </keyfields>
      <datafields>
        <datafield type="Boolean" default="False">Active</datafield>
        <datafield type="Guid" null="false" RequireDownload="false">caObjectId</datafield>
        <datafield type="String" RequireDownload="false">Description</datafield>
        <datafield type="Guid" RequireDownload="false">LastOperator</datafield>
        <datafield type="DateTime" null="false" RequireDownload="false">LastUpdated</datafield>
        <datafield type="String" RequireDownload="false">LastWorkStation</datafield>
        <datafield type="Int32" null="false">ShuntId</datafield>
        <datafield type="String" length="100" null="false" RequireDownload="false">ShuntName</datafield>
      </datafields>
    </MShunt>
    <MTimezon>
      <keyfields>
        <keyfield type="Guid">caObjectID</keyfield>
      </keyfields>
      <datafields>
        <datafield type="Guid" null="false" RequireDownload="false">caObjectId</datafield>
        <datafield type="String" length="41" RequireDownload="false">Description</datafield>
        <datafield type="Int32">HolGroups</datafield>
        <datafield type="Guid" RequireDownload="false">LastOperator</datafield>
        <datafield type="DateTime" null="false" RequireDownload="false">LastUpdated</datafield>
        <datafield type="String" RequireDownload="false">LastWorkStation</datafield>
        <datafield type="Int32" readonly="true" null="false" min="1" max="254">TzNum</datafield>
        <datafield type="Int32" RequireDownload="false">UTCOffset</datafield>
      </datafields>
    </MTimezon>
    <napcoMPermissions ismaster="False">
      <keyfields>
        <keyfield type="Guid">caObjectID</keyfield>
      </keyfields>
      <datafields>
        <datafield type="Guid" null="false" RequireDownload="false">caObjectId</datafield>
        <datafield type="Guid" RequireDownload="false">LastOperator</datafield>
        <datafield type="DateTime" null="false" RequireDownload="false">LastUpdated</datafield>
        <datafield type="String" RequireDownload="false">LastWorkStation</datafield>
        <datafield type="Int32" null="false" min="1" max="128">PermissionID</datafield>
        <datafield type="String" null="false" RequireDownload="false">PermissionName</datafield>
      </datafields>
    </napcoMPermissions>
    <napcoPanelAreaEventDef>
      <primarykeyfields>
        <primarykeyfield type="Int32">AlarmPanelID</primarykeyfield>
        <primarykeyfield type="Int32">AreaNumber</primarykeyfield>
        <primarykeyfield type="String">statusCode</primarykeyfield>
      </primarykeyfields>
      <keyfields>
        <keyfield type="Int32">AlarmPanelID</keyfield>
        <keyfield type="Int32">AreaNumber</keyfield>
      </keyfields>
      <datafields>
        <datafield type="Int32" readonly="true">AlarmPanelID</datafield>
        <datafield type="Int32" readonly="true" RequireDownload="false">AreaNumber</datafield>
        <datafield type="Int32" null="false" min="0" max="99" RequireDownload="false">EventPriority</datafield>
        <datafield type="Boolean" default="False">GenerateEvent</datafield>
        <datafield type="Int32" listsource="relaycontrollist1" listquery="relaycontrollist">RelayControlAction</datafield>
        <datafield type="Boolean" default="False" RequireDownload="false">ResponseRequired</datafield>
        <datafield type="String" readonly="true" listsource="napcoeventdeflookup4" listquery="napcoeventdeflookup">statusCode</datafield>
      </datafields>
    </napcoPanelAreaEventDef>
    <napcoPanelAreas ismaster="True">
      <keyfields>
        <keyfield type="Int32">AlarmPanelID</keyfield>
        <keyfield type="Int32">AreaNumber</keyfield>
      </keyfields>
      <datafields>
        <datafield type="Int32" null="false" listsource="napcoareatypelookup1" listquery="napcoareatypelookup">alarmAreaType</datafield>
        <datafield type="Int32" readonly="true" listsource="napcopanellookup1" listquery="napcopanellookup">AlarmPanelID</datafield>
        <datafield type="Boolean" default="False">AreaConfigured</datafield>
        <datafield type="String" length="50" RequireDownload="false">AreaName</datafield>
        <datafield type="Int32" readonly="true" min="1" max="8">AreaNumber</datafield>
        <datafield type="Guid" null="false" RequireDownload="false">caObjectId</datafield>
        <datafield type="Boolean" default="False">IsAccessControlPanel</datafield>
        <datafield type="Guid" RequireDownload="false">LastOperator</datafield>
        <datafield type="DateTime" null="false" RequireDownload="false">LastUpdated</datafield>
        <datafield type="String" RequireDownload="false">LastWorkStation</datafield>
        <datafield type="Int32" null="false" listsource="manprivlist3" listquery="manprivlist">ManualPriv</datafield>
        <datafield type="Int32">RelayControlPanel</datafield>
        <datafield type="Int32">RelayControlRelay</datafield>
        <datafield type="Boolean" default="False">UseRelayControl</datafield>
      </datafields>
    </napcoPanelAreas>
    <napcoPanelEventDef>
      <primarykeyfields>
        <primarykeyfield type="Int32">AlarmPanelID</primarykeyfield>
        <primarykeyfield type="String">statusCode</primarykeyfield>
      </primarykeyfields>
      <keyfields>
        <keyfield type="Int32">AlarmPanelID</keyfield>
      </keyfields>
      <datafields>
        <datafield type="Int32" readonly="true">AlarmPanelID</datafield>
        <datafield type="Int32" min="0" max="99" RequireDownload="false">EventPriority</datafield>
        <datafield type="Boolean" default="False">GenerateEvent</datafield>
        <datafield type="Boolean" default="False" RequireDownload="false">ResponseRequired</datafield>
        <datafield type="String" readonly="true" listsource="napcoeventdeflookup3" listquery="napcoeventdeflookup">statusCode</datafield>
      </datafields>
    </napcoPanelEventDef>
    <napcoPanelRelayEventDef>
      <primarykeyfields>
        <primarykeyfield type="Int32">AlarmPanelID</primarykeyfield>
        <primarykeyfield type="Int32">RelayNumber</primarykeyfield>
        <primarykeyfield type="String">statusCode</primarykeyfield>
      </primarykeyfields>
      <keyfields>
        <keyfield type="Int32">AlarmPanelID</keyfield>
        <keyfield type="Int32">RelayNumber</keyfield>
      </keyfields>
      <datafields>
        <datafield type="Int32" readonly="true">AlarmPanelID</datafield>
        <datafield type="Int32" null="false" min="0" max="99" RequireDownload="false">EventPriority</datafield>
        <datafield type="Boolean" default="False">GenerateEvent</datafield>
        <datafield type="Int32" readonly="true">RelayNumber</datafield>
        <datafield type="Boolean" default="False" RequireDownload="false">ResponseRequired</datafield>
        <datafield type="String" readonly="true" listsource="napcoeventdeflookup2" listquery="napcoeventdeflookup">statusCode</datafield>
      </datafields>
    </napcoPanelRelayEventDef>
    <napcoPanelRelays ismaster="True">
      <keyfields>
        <keyfield type="Int32">AlarmPanelID</keyfield>
        <keyfield type="Int32">RelayNumber</keyfield>
      </keyfields>
      <datafields>
        <datafield type="Int32" readonly="true" listsource="napcopanellookup4" listquery="napcopanellookup">AlarmPanelID</datafield>
        <datafield type="Guid" null="false" RequireDownload="false">caObjectId</datafield>
        <datafield type="Guid" RequireDownload="false">LastOperator</datafield>
        <datafield type="DateTime" null="false" RequireDownload="false">LastUpdated</datafield>
        <datafield type="String" RequireDownload="false">LastWorkStation</datafield>
        <datafield type="Boolean" null="false" default="False">RelayConfigured</datafield>
        <datafield type="String" length="50" RequireDownload="false">RelayName</datafield>
        <datafield type="Int32" min="1" max="96">RelayNumber</datafield>
      </datafields>
    </napcoPanelRelays>
    <napcoPanels>
      <keyfields>
        <keyfield type="Int32">AlarmPanelID</keyfield>
      </keyfields>
      <datafields>
        <datafield type="Int32" readonly="true">AlarmPanelID</datafield>
        <datafield type="Guid" null="false" RequireDownload="false">caObjectId</datafield>
        <datafield type="Int32" null="false" listsource="napcoconnectiontypeslookup1" listquery="napcoconnectiontypeslookup">ConnectionType</datafield>
        <datafield type="Boolean" null="false" default="True">Enabled</datafield>
        <datafield type="Guid" RequireDownload="false">LastOperator</datafield>
        <datafield type="DateTime" null="false" RequireDownload="false">LastUpdated</datafield>
        <datafield type="String" RequireDownload="false">LastWorkStation</datafield>
        <datafield type="String" length="6" null="false">MasterProgramCode</datafield>
        <datafield type="String" length="50" RequireDownload="false">PanelName</datafield>
        <datafield type="Int32" listsource="napcopaneltypelookup1" listquery="napcopaneltypelookup">PanelType</datafield>
        <datafield type="Int32" min="0" max="255">PCSecurityCode_1</datafield>
        <datafield type="Int32" min="0" max="255">PCSecurityCode_2</datafield>
        <datafield type="Int32" min="0" max="255">PCSecurityCode_3</datafield>
        <datafield type="Int32" null="false" min="0" max="65535">PortNumber</datafield>
        <datafield type="String" length="50">SocketAddress</datafield>
        <datafield type="Int32" null="false" listsource="napcoworkstationlookup1" listquery="napcoworkstationlookup">workstationID</datafield>
      </datafields>
    </napcoPanels>
    <napcoPanelUsers ismaster="False">
      <primarykeyfields>
        <primarykeyfield type="Int32">AlarmPanelID</primarykeyfield>
        <primarykeyfield type="Int32">UserNumber</primarykeyfield>
      </primarykeyfields>
      <keyfields>
        <keyfield type="Int32">AlarmPanelID</keyfield>
      </keyfields>
      <datafields>
        <datafield type="Int32" null="false">AlarmPanelID</datafield>
        <datafield type="Int64">Badge</datafield>
        <datafield type="Guid" null="false" RequireDownload="false">caObjectId</datafield>
        <datafield type="Int32">Facility</datafield>
        <datafield type="DateTime" null="false" RequireDownload="false">LastUpdated</datafield>
        <datafield type="Boolean" null="false" default="False">LinkToBadge</datafield>
        <datafield type="Boolean" null="false" default="False">UserConfigured</datafield>
        <datafield type="String">Username</datafield>
        <datafield type="Int32" null="false">UserNumber</datafield>
      </datafields>
    </napcoPanelUsers>
    <napcoPanelZoneEventDef>
      <primarykeyfields>
        <primarykeyfield type="Int32">AlarmPanelID</primarykeyfield>
        <primarykeyfield type="String">statusCode</primarykeyfield>
        <primarykeyfield type="Int32">ZoneNumber</primarykeyfield>
      </primarykeyfields>
      <keyfields>
        <keyfield type="Int32">AlarmPanelID</keyfield>
        <keyfield type="Int32">ZoneNumber</keyfield>
      </keyfields>
      <datafields>
        <datafield type="Int32" readonly="true">AlarmPanelID</datafield>
        <datafield type="Int32" null="false" min="0" max="99" RequireDownload="false">EventPriority</datafield>
        <datafield type="Boolean" default="False">GenerateEvent</datafield>
        <datafield type="Boolean" default="False" RequireDownload="false">ResponseRequired</datafield>
        <datafield type="String" readonly="true" listsource="napcoeventdeflookup1" listquery="napcoeventdeflookup">statusCode</datafield>
        <datafield type="Int32" readonly="true">ZoneNumber</datafield>
      </datafields>
    </napcoPanelZoneEventDef>
    <napcoPanelZones ismaster="True">
      <keyfields>
        <keyfield type="Int32">AlarmPanelID</keyfield>
        <keyfield type="Int32">ZoneNumber</keyfield>
      </keyfields>
      <datafields>
        <datafield type="Int32" listsource="napcopanellookup5" listquery="napcopanellookup">AlarmPanelID</datafield>
        <datafield type="Int32" null="false" listsource="napcopanelareaslookup1" listquery="napcopanelareaslookup">AreaNumber</datafield>
        <datafield type="Guid" null="false" RequireDownload="false">caObjectId</datafield>
        <datafield type="Int32" listsource="dvrcameralookup1" listquery="dvrcameralookup" RequireDownload="false">DvrCameraID</datafield>
        <datafield type="Guid" RequireDownload="false">DvrServerID</datafield>
        <datafield type="Boolean" default="False" RequireDownload="false">EnableRecording</datafield>
        <datafield type="Guid" RequireDownload="false">LastOperator</datafield>
        <datafield type="DateTime" null="false" RequireDownload="false">LastUpdated</datafield>
        <datafield type="String" RequireDownload="false">LastWorkStation</datafield>
        <datafield type="Int32" min="0" max="32767">NoofSecsToRecord</datafield>
        <datafield type="Int32" listsource="mtimezonlookup18" listquery="mtimezonlookup" RequireDownload="false">RecordingSchedule</datafield>
        <datafield type="Int32" min="1" max="32768" RequireDownload="false">VideoEndTime</datafield>
        <datafield type="Int32" min="1" max="99" RequireDownload="false">VideoPriorityFrom</datafield>
        <datafield type="Int32" min="1" max="99" RequireDownload="false">VideoPriorityTo</datafield>
        <datafield type="Int32" min="1" max="32768" RequireDownload="false">VideoStartTime</datafield>
        <datafield type="Boolean" null="false" default="False">ZoneConfigured</datafield>
        <datafield type="String" length="50">ZoneName</datafield>
        <datafield type="Int32" readonly="true" min="1" max="255">ZoneNumber</datafield>
      </datafields>
    </napcoPanelZones>
    <napcoPermissions ismaster="False">
      <primarykeyfields>
        <primarykeyfield type="Int32">AlarmPanelID</primarykeyfield>
        <primarykeyfield type="Int32">AreaNumber</primarykeyfield>
        <primarykeyfield type="Int32">PermissionID</primarykeyfield>
      </primarykeyfields>
      <keyfields>
        <keyfield type="Int32">PermissionID</keyfield>
      </keyfields>
      <datafields>
        <datafield type="Int32" null="false">AlarmPanelID</datafield>
        <datafield type="Int32" null="false">AreaNumber</datafield>
        <datafield type="Boolean" null="false" default="False">CanArm</datafield>
        <datafield type="Boolean" null="false" default="False">CanDisarm</datafield>
        <datafield type="Int32" null="false">PermissionID</datafield>
      </datafields>
    </napcoPermissions>
    <Nodes ismaster="False">
      <keyfields>
        <keyfield type="Guid">caObjectId</keyfield>
      </keyfields>
      <datafields>
        <datafield type="Guid" null="false" RequireDownload="false">caObjectId</datafield>
        <datafield type="String" RequireDownload="false">Description</datafield>
        <datafield type="Int32">DevIdIn</datafield>
        <datafield type="Int32">DevIdOut</datafield>
        <datafield type="Int32">Frequency</datafield>
        <datafield type="Int32" listsource="mcomlookup2" listquery="mcomlookup">HCSNo</datafield>
        <datafield type="String" length="40">HostPhone1</datafield>
        <datafield type="String" length="40">HostPhone2</datafield>
        <datafield type="Guid" RequireDownload="false">LastOperator</datafield>
        <datafield type="DateTime" null="false" RequireDownload="false">LastUpdated</datafield>
        <datafield type="String" RequireDownload="false">LastWorkStation</datafield>
        <datafield type="Int32" readonly="true" null="false" min="1" max="512">NodeId</datafield>
        <datafield type="String" length="100" null="false" RequireDownload="false">NodeName</datafield>
        <datafield type="String" length="32">Phone</datafield>
        <datafield type="Int32" listsource="mtimezonlookup14" listquery="mtimezonlookup">Schedule</datafield>
        <datafield type="String" length="25">Setup1</datafield>
        <datafield type="String" length="25">Setup2</datafield>
        <datafield type="Int32">Status</datafield>
        <datafield type="Int32" RequireDownload="false">UTCOffset</datafield>
      </datafields>
    </Nodes>
    <operatorInstructions>
      <keyfields>
        <keyfield type="Guid">instructionID</keyfield>
      </keyfields>
      <datafields>
        <datafield type="Guid" RequireDownload="false">caObjectId</datafield>
        <datafield type="Guid" null="false">instructionID</datafield>
        <datafield type="String">instructionMsg</datafield>
        <datafield type="String" length="50" null="false" RequireDownload="false">instructionName</datafield>
        <datafield type="Guid" RequireDownload="false">LastOperator</datafield>
        <datafield type="DateTime" RequireDownload="false">LastUpdated</datafield>
        <datafield type="String" RequireDownload="false">LastWorkStation</datafield>
      </datafields>
    </operatorInstructions>
    <operatorInstructLink>
      <keyfields>
        <keyfield type="Int32">cat</keyfield>
        <keyfield type="Int32">DeviceNo</keyfield>
        <keyfield type="Int32">pnlNo</keyfield>
        <keyfield type="Int32">status</keyfield>
      </keyfields>
      <datafields>
        <datafield type="String" null="false">AlertNotifySound</datafield>
        <datafield type="Guid" null="false" RequireDownload="false">caObjectId</datafield>
        <datafield type="String" null="false">cat</datafield>
        <datafield type="String" null="false">DeviceNo</datafield>
        <datafield type="Guid" listsource="operatorinstructionlookup1" listquery="operatorinstructionlookup">instructionID</datafield>
        <datafield type="Boolean" null="false" default="False">instructionsEnabled</datafield>
        <datafield type="Guid" RequireDownload="false">LastOperator</datafield>
        <datafield type="DateTime" RequireDownload="false">LastUpdated</datafield>
        <datafield type="String" RequireDownload="false">LastWorkStation</datafield>
        <datafield type="String" null="false">pnlNo</datafield>
        <datafield type="Boolean" null="false" default="False">SoundEnabled</datafield>
        <datafield type="Int32" min="0" max="99">SoundInterval</datafield>
        <datafield type="String" null="false">status</datafield>
      </datafields>
    </operatorInstructLink>
    <OperatorPartitions>
      <datafields>
        <datafield type="DateTime" null="false" RequireDownload="false">LastUpdated</datafield>
        <datafield type="Int32" null="false">OperatorID</datafield>
        <datafield type="Guid" null="false">PartitionID</datafield>
      </datafields>
    </OperatorPartitions>
    <OperatorPrivileges ismaster="False">
      <keyfields>
        <keyfield type="Guid">OperatorID</keyfield>
        <keyfield type="Int32">ScreenID</keyfield>
        <keyfield type="Int32">ScreenObjectID</keyfield>
      </keyfields>
      <datafields>
        <datafield type="Guid" null="false">OperatorID</datafield>
        <datafield type="Int32" null="false">ScreenID</datafield>
        <datafield type="Int32" null="false">ScreenObjectID</datafield>
        <datafield type="Int32" null="false">SecurityLevel</datafield>
      </datafields>
    </OperatorPrivileges>
    <RolePrivileges ismaster="False">
      <keyfields>
        <keyfield type="Guid">RoleID</keyfield>
        <keyfield type="Int32">ScreenID</keyfield>
        <keyfield type="Int32">ScreenObjectID</keyfield>
      </keyfields>
      <datafields>
        <datafield type="Guid" null="false">RoleID</datafield>
        <datafield type="Int32" null="false">ScreenID</datafield>
        <datafield type="Int32" null="false">ScreenObjectID</datafield>
        <datafield type="Int32" null="false">SecurityLevel</datafield>
      </datafields>
    </RolePrivileges>
    <Operators>
      <keyfields>
        <keyfield type="Guid">OperatorID</keyfield>
      </keyfields>
      <datafields>
        <datafield type="Int32" min="1" max="9999" RequireDownload="false">AutoAckTime</datafield>
        <datafield type="Boolean" default="False" RequireDownload="false">CanChangeThreatLevel</datafield>
        <datafield type="Boolean" default="False" RequireDownload="false">DisableLogoff</datafield>
        <datafield type="String" length="40" RequireDownload="false">EmailID</datafield>
        <datafield type="Boolean" null="false" default="False" RequireDownload="false">Enabled</datafield>
        <datafield type="Int32" min="1" max="300" RequireDownload="false">EventCount</datafield>
        <datafield type="Boolean" null="false" default="False" RequireDownload="false">IsGlobalAdministrator</datafield>
        <datafield type="DateTime" null="false" RequireDownload="false">LastLoggedIn</datafield>
        <datafield type="Guid" RequireDownload="false">LastOperator</datafield>
        <datafield type="DateTime" null="false" RequireDownload="false">LastUpdated</datafield>
        <datafield type="String" RequireDownload="false">LastWorkStation</datafield>
        <datafield type="Int32" min="1" max="9999" RequireDownload="false">LogoffTime</datafield>
        <datafield type="Int32" listsource="operatormanprivlist1" listquery="operatormanprivlist" RequireDownload="false">ManualPrivileges</datafield>
        <datafield type="Int32" RequireDownload="false">MaxThreatLevelAllowed</datafield>
        <datafield type="Guid" RequireDownload="false">OperatorID</datafield>
        <datafield type="String" length="50" null="false" displaylabel="Operator First Name" RequireDownload="false">OperFName</datafield>
        <datafield type="String" length="50" null="false" displaylabel="Operator Last Name" RequireDownload="false">OperLName</datafield>
        <datafield type="String" length="50" null="false" RequireDownload="false">OperLoginName</datafield>
        <datafield type="String" length="50" null="false" RequireDownload="false">OperPassword</datafield>
        <datafield type="Int32" listsource="smsproviderslookup1" listquery="smsproviderslookup" RequireDownload="false">OperSMSHostID</datafield>
        <datafield type="Int32" listsource="snppproviderslookup1" listquery="snppproviderslookup" RequireDownload="false">OperSNPPHostID</datafield>
        <datafield type="Boolean" null="false" default="False" RequireDownload="false">OperUseEmail</datafield>
        <datafield type="Boolean" null="false" default="False" RequireDownload="false">OperUseSMS</datafield>
        <datafield type="Boolean" null="false" default="False" RequireDownload="false">OperUseSNPP</datafield>
        <datafield type="String" length="20" RequireDownload="false">PagerID</datafield>
        <datafield type="String" length="51" RequireDownload="false">PhoneNo</datafield>
        <datafield type="Guid" null="false" listsource="rolelookup1" listquery="rolelookup" displaylabel="Role" RequireDownload="false">RoleID</datafield>
        <datafield type="Boolean" null="false" default="False" RequireDownload="false">UseLegacyDisplay</datafield>
        <datafield type="Int32" RequireDownload="false">UTCOffset</datafield>
      </datafields>
    </Operators>
    <OperatorSettings ismaster="False">
      <keyfields>
        <keyfield type="Guid">OperatorID</keyfield>
      </keyfields>
      <datafields>
        <datafield type="Guid" null="false" RequireDownload="false">caObjectId</datafield>
        <datafield type="Int32" RequireDownload="false">GUIViewMode</datafield>
        <datafield type="Int32" RequireDownload="false">LanguageID</datafield>
        <datafield type="Guid" RequireDownload="false">LastOperator</datafield>
        <datafield type="DateTime" null="false" RequireDownload="false">LastUpdated</datafield>
        <datafield type="String" RequireDownload="false">LastWorkStation</datafield>
        <datafield type="Boolean" default="False" RequireDownload="false">MapCloseAlert</datafield>
        <datafield type="Boolean" default="False" RequireDownload="false">MapManualControlDblClick</datafield>
        <datafield type="String" RequireDownload="false">MapTheme</datafield>
        <datafield type="String" RequireDownload="false">MapToolTipInterval</datafield>
        <datafield type="Guid" null="false" RequireDownload="false">OperatorID</datafield>
        <datafield type="Int32" RequireDownload="false">StatusUpdateInterval</datafield>
        <datafield type="Int32" RequireDownload="false">UIViewStyle</datafield>
      </datafields>
    </OperatorSettings>
    <Panel>
      <keyfields>
        <keyfield type="Guid">caObjectID</keyfield>
      </keyfields>
      <datafields>
        <datafield type="Int32" null="false" min="1" max="63">Address</datafield>
        <datafield type="Int32" min="10" max="1000" displaylabel="AG Size">AGSize</datafield>
        <datafield type="Boolean" default="False">AperioType</datafield>
        <datafield type="Guid">caObjectID</datafield>
        <datafield type="Int32" min="1" max="99" displaylabel="Comm Prior" RequireDownload="false">CommPrior</datafield>
        <datafield type="Int32" listsource="comlookup1" listquery="comlookup" min="1" max="9984" displaylabel="Com Port">ComPort</datafield>
        <datafield type="Int32" displaylabel="Current Pwd">CurrentPwd</datafield>
        <datafield type="Int32" listsource="mholidaylookup1" listquery="mholidaylookup" displaylabel="Default Calendar">DefaultCalendar</datafield>
        <datafield type="Boolean" displaylabel="Degrade Mode" default="False">DegradeMode</datafield>
        <datafield type="String"  RequireDownload="false">Description</datafield>
        <datafield type="Int32" min="1" max="99" displaylabel="Download Prior" RequireDownload="false">DwnLoadPrior</datafield>
        <datafield type="Boolean" null="false" displaylabel="Is Elevator" default="False">Elevators</datafield>
        <datafield type="Boolean" default="False">Enabled</datafield>
        <datafield type="Int32" listsource="mcomlookup1" listquery="mcomlookup" displaylabel="Com Server">HCSNo</datafield>
        <datafield type="Boolean" default="False">Interactive</datafield>
        <datafield type="Guid" RequireDownload="false">LastOperator</datafield>
        <datafield type="DateTime" null="false" displaylabel="Last Edit" RequireDownload="false">LastUpdated</datafield>
        <datafield type="String" RequireDownload="false">LastWorkStation</datafield>
        <datafield type="String" length="50" RequireDownload="false">Location</datafield>
        <datafield type="Int32">LockAssigned</datafield>
        <datafield type="Int32">LockExpAddress</datafield>
        <datafield type="Boolean" default="False">LockChanged</datafield>
        <datafield type="String">LockId</datafield>
        <datafield type="Int32">LockType</datafield>
        <datafield type="Int32">LockUpdateSchedule</datafield>
        <datafield type="Int32" min="0" max="99" displaylabel="Low Battery Prior" RequireDownload="false">LowBatPrior</datafield>
        <datafield type="Int32" min="0" max="10000" displaylabel="Max Alp">MaxAlp</datafield>
        <datafield type="Int32" displaylabel="Max Evt">MaxEvt</datafield>
        <datafield type="Int32" min="1" max="99" displaylabel="Modem Prior" RequireDownload="false">ModemPrior</datafield>
        <datafield type="Int32" listsource="NapcoPanelNoneLookup1" listquery="NapcoPanelNoneLookup" displaylabel="NAPCO Panel">NAPCOPanel</datafield>
        <datafield type="Int32">Node</datafield>
        <datafield type="Boolean" displaylabel="No Fail" default="False">NoFail</datafield>
        <datafield type="Boolean" displaylabel="Non-Polled" default="True">NoPolling</datafield>
        <datafield type="String" length="50" null="false" RequireDownload="false">PanelName</datafield>
        <datafield type="Int32" listsource="paneltypelookup1" listquery="paneltypelookup" displaylabel="Panel Type">PanelType</datafield>
        <datafield type="Boolean" displaylabel="Password" default="False">Passwrd</datafield>
        <datafield type="Int32" readonly="true" null="false" min="1" max="10000" displaylabel="Panel No.">PnlNo</datafield>
        <datafield type="Int32" min="1" max="99" displaylabel="Pwr Prior"  RequireDownload="false">PwrPrior</datafield>
        <datafield type="String" RequireDownload="false">Remarks</datafield>
        <datafield type="Boolean" default="False">RemoteDevice</datafield>
        <datafield type="Boolean" default="False" RequireDownload="false">RespACPowerFail</datafield>
        <datafield type="Boolean" default="False" RequireDownload="false">RespDownloads</datafield>
        <datafield type="Boolean" default="False"  RequireDownload="false">RespLowBattery</datafield>
        <datafield type="Boolean" default="False"  RequireDownload="false">RespModemActivity</datafield>
        <datafield type="Boolean" default="False"  RequireDownload="false">RespOffOnLine</datafield>
        <datafield type="Int32">RetrievalSchedule</datafield>
        <datafield type="Int32" min="50" max="2540">Schedules</datafield>
        <datafield type="Int32" RequireDownload="false">UTCOffset</datafield>
        <datafield type="Int32" min="50" max="10000" increment="50" displaylabel="Xact Size">XactSize</datafield>
        <datafield type="Int32" null="false">ZoneId</datafield>
        <datafield type="Int32">EleControlType</datafield>
      </datafields>
    </Panel>
    <Partition>
      <keyfields>
        <keyfield type="Guid">PartitionID</keyfield>
      </keyfields>
      <datafields>
        <datafield type="Int32" null="false" RequireDownload="false">DeviceType</datafield>
        <datafield type="DateTime" null="false" RequireDownload="false">LastUpdated</datafield>
        <datafield type="Guid" null="false" RequireDownload="false">PartitionID</datafield>
        <datafield type="String" null="false" RequireDownload="false">PartitionName</datafield>
      </datafields>
    </Partition>
    <Person>
      <keyfields>
        <keyfield type="Guid">PersonID</keyfield>
      </keyfields>
      <datafields>
        <datafield type="Guid" null="false" RequireDownload="false">caObjectID</datafield>
        <datafield type="Int32" listsource="companyidlookup1" listquery="companyidlookup" RequireDownload="false">CompanyID</datafield>
        <datafield type="String" length="30" displaylabel="Phone" RequireDownload="false">ContPhone</datafield>
        <datafield type="DateTime" RequireDownload="false">DateOfBirth</datafield>
        <datafield type="Int32" listsource="departmentlookup1" listquery="departmentlookup" RequireDownload="false">DeptID</datafield>
        <datafield type="Boolean" default="True">Enabled</datafield>
        <datafield type="String" length="50" displaylabel="First Name" RequireDownload="false">FrstName</datafield>
        <datafield type="String" listsource="genderlist1" listquery="genderlist" RequireDownload="false">Gender</datafield>
        <datafield type="String" length="50" null="false" RequireDownload="false">LastName</datafield>
        <datafield type="Guid" RequireDownload="false">LastOperator</datafield>
        <datafield type="DateTime" null="false" RequireDownload="false" >LastUpdated</datafield>
        <datafield type="String" RequireDownload="false">LastWorkStation</datafield>
        <datafield type="String" length="20" RequireDownload="false">License</datafield>
        <datafield type="Int32" listsource="locationlookup1" listquery="locationlookup">LocationID</datafield>
        <datafield type="String" length="30" RequireDownload="false">MiddleName</datafield>
        <datafield type="Guid" null="false" RequireDownload="false">PersonID</datafield>
        <datafield type="String" length="30" displaylabel="Extension" RequireDownload="false">Phone</datafield>
        <datafield type="String" RequireDownload="false">Remarks</datafield>
        <datafield type="String" RequireDownload="false">SSN</datafield>
        <datafield type="Boolean" default="False">Supervisor</datafield>
        <datafield type="Guid" listsource="supervisorlookup1" listquery="supervisorlookup">SupervisorID</datafield>
        <datafield type="String" length="50">Vehicle</datafield>
      </datafields>
    </Person>
    <Reader ismaster="True">
      <keyfields>
        <keyfield type="Guid">caObjectID</keyfield>
      </keyfields>
      <datafields>
        <datafield type="Boolean" default="False">AckBypass</datafield>
        <datafield type="Boolean" default="False">AckCommonCode</datafield>
        <datafield type="Boolean" default="False">AckFreeAccess</datafield>
        <datafield type="Boolean" default="False">AckManualDoorCtrl</datafield>
        <datafield type="Boolean" default="False">AckValidAccess</datafield>
        <datafield type="Int32" listsource="apbareaslookup1" listquery="apbareaslookup" displaylabel="APB Entry">APBEntry</datafield>
        <datafield type="Int32" listsource="apbareaslookup2" listquery="apbareaslookup" displaylabel="APB Exit">APBExit</datafield>
        <datafield type="Boolean" displaylabel="APB Override" default="False">APBOvr</datafield>
        <datafield type="Int32" listsource="apbtypelist1" listquery="apbtypelist" displaylabel="APB Type">APBType</datafield>
        <datafield type="Int32" min="0" max="255" increment="1">AperioAddr</datafield>
        <datafield type="Boolean" displaylabel="Badge Use Register" default="True">BadgeUseRegister</datafield>
        <datafield type="Int32" min="0" max="81">Bypass</datafield>
        <datafield type="Boolean" default="False">BypassLocks</datafield>
        <datafield type="Boolean" default="False">RexOption</datafield>
        <datafield type="Boolean" default="False">UseLedBar</datafield>
        <datafield type="Int32" min="0" max="255">ElevServerId</datafield>
        <datafield type="Boolean" default="False">GenerateAlert</datafield>
        <datafield type="Boolean" default="False">BypCatControl</datafield>
        <datafield type="Boolean" displaylabel="Byp Unlocks" default="True">BypUnlock</datafield>
        <datafield type="Guid" null="false" RequireDownload="false">caObjectId</datafield>
        <datafield type="Int32" displaylabel="Cat Code">CatCode</datafield>
        <datafield type="Int32" min="0" max="2">CatFilter</datafield>
        <datafield type="Int32" listsource="mtimezonlookup16" listquery="mtimezonlookup" displaylabel="Cat Schedule">CatSchedule</datafield>
        <datafield type="Int32" listsource="mtimezonlookup4" listquery="mtimezonlookup" displaylabel="Card/Code Tz">Cctz</datafield>
        <datafield type="Boolean" displaylabel="CR Apb" default="False">CRApb</datafield>
        <datafield type="Boolean" displaylabel="CR Denied" default="False">CRDenied</datafield>
        <datafield type="Boolean" displaylabel="CR Duress" default="False">CRDuress</datafield>
        <datafield type="Boolean" displaylabel="CR Forced" default="False">CRForced</datafield>
        <datafield type="Boolean" displaylabel="CR Otl" default="False">CROtl</datafield>
        <datafield type="Boolean" displaylabel="CR Track" default="False">CRTrack</datafield>
        <datafield type="Boolean" displaylabel="CR Void" default="False">CRVoid</datafield>
        <datafield type="Int32" listsource="mtimezonlookup1" listquery="mtimezonlookup" displaylabel="Card Tz">Ctz</datafield>
        <datafield type="Int32" min="0" max="65535" displaylabel="Cypher">Cyph</datafield>
        <datafield type="Int32" listsource="mtimezonlookup5" listquery="mtimezonlookup" displaylabel="PIN Tz">Cytz</datafield>
        <datafield type="Int32" listsource="mtimezonlookup3" listquery="mtimezonlookup" displaylabel="Degr Schedule">DegrSchedule</datafield>
        <datafield type="Boolean" default="False">DoubleReadFA</datafield>
        <datafield type="Int32" min="0" max="255" displaylabel="Door Strike Time">Dst</datafield>
        <datafield type="Int32" min="0" max="2700" displaylabel="Dur Use">DurUse</datafield>
        <datafield type="Int32" listsource="dvrcameralookup2" listquery="dvrcameralookup"  RequireDownload="false">DvrCameraID</datafield>
        <datafield type="Guid" listsource="dvrconfiglookup2" listquery="dvrconfiglookup"  RequireDownload="false">DvrServerID</datafield>
        <datafield type="Boolean" default="True">Enabled</datafield>
        <datafield type="Boolean" null="false" default="False" RequireDownload="false">EnablePTZPreset</datafield>
        <datafield type="Boolean" default="False" RequireDownload="false">EnableRecording</datafield>
        <datafield type="Boolean" default="False">Escort</datafield>
        <datafield type="Boolean" displaylabel="Ext Shunt" default="False">ExtShunt</datafield>
        <datafield type="Int32" listsource="mtimezonlookup2" listquery="mtimezonlookup" displaylabel="FA Tz">Fatz</datafield>
        <datafield type="Int32" min="0" max="255" displaylabel="Forced Door Delay">Fdd</datafield>
        <datafield type="Boolean" default="False">Keypad</datafield>
        <datafield type="Guid" RequireDownload="false">LastOperator</datafield>
        <datafield type="DateTime" null="false" displaylabel="Last Edit" RequireDownload="false">LastUpdated</datafield>
        <datafield type="String" RequireDownload="false">LastWorkStation</datafield>
        <datafield type="String" length="50" RequireDownload="false">Location</datafield>
        <datafield type="Int32" listsource="lockcontrollist1" listquery="lockcontrollist" displaylabel="Lock Ctrl">LockCtl</datafield>
        <datafield type="Int32" listsource="twopersonreadertypelist1" listquery="twopersonreadertypelist" displaylabel="2 Man Rule">ManRule</datafield>
        <datafield type="Int32" listsource="manprivlist1" listquery="manprivlist" displaylabel="Manual Priv">ManualPriv</datafield>
        <datafield type="Int32" displaylabel="NAPCO Areas">NAPCOAreas</datafield>
        <datafield type="Boolean" displaylabel="No Duress" default="False">NoDuress</datafield>
        <datafield type="Int32" min="0" max="9999">NoofSecsToRecord</datafield>
        <datafield type="Int32" min="0" max="9999">NoOTL</datafield>
        <datafield type="Boolean" default="False">NoSound</datafield>
        <datafield type="Boolean" displaylabel="No Xact" default="False">NoXact</datafield>
        <datafield type="Boolean" displaylabel="Report after open" default="False">OpnWait</datafield>
        <datafield type="Int32" min="0" max="255" displaylabel="Open too Long">Otl</datafield>
        <datafield type="Int32" listsource="mtimezonlookup6" listquery="mtimezonlookup" displaylabel="OTL Schedule">OTLSchedule</datafield>
        <datafield type="Int32" readonly="true" null="false" listsource="panellookup1" listquery="panellookupwithoutlock">PnlRef</datafield>
        <datafield type="Int32" listsource="ptzpresetlist1" listquery="ptzpresetlist" RequireDownload="false">PTZPresetNo</datafield>
        <datafield type="Int32" readonly="true" null="false" min="1" max="16">RdrNo</datafield>
        <datafield type="String" length="100" null="false" RequireDownload="false">ReaderName</datafield>
        <datafield type="Int32" listsource="mtimezonlookup19" listquery="mtimezonlookup" RequireDownload="false">RecordingSchedule</datafield>
        <datafield type="String" RequireDownload="false">Remarks</datafield>
        <datafield type="Int32" min="0" max="255" displaylabel="Repeat OTL">RepeatOTL</datafield>
        <datafield type="Boolean" default="False" RequireDownload="false">RespAPBViolate</datafield>
        <datafield type="Boolean" default="False" RequireDownload="false">RespBypass</datafield>
        <datafield type="Boolean" default="False" RequireDownload="false">RespCommonCode</datafield>
        <datafield type="Boolean" default="False" RequireDownload="false">RespDuress</datafield>
        <datafield type="Boolean" default="False" RequireDownload="false">RespForcedDoor</datafield>
        <datafield type="Boolean" default="False" RequireDownload="false">RespFreeAccess</datafield>
        <datafield type="Boolean" default="False" RequireDownload="false">RespManualDoorCtrl</datafield>
        <datafield type="Boolean" default="False" RequireDownload="false">RespOtherDenied</datafield>
        <datafield type="Boolean" default="False" RequireDownload="false">RespOTL</datafield>
        <datafield type="Boolean" default="False" RequireDownload="false">RespTrackedBadge</datafield>
        <datafield type="Boolean" default="False" RequireDownload="false">RespValidAccess</datafield>
        <datafield type="Boolean" default="False" RequireDownload="false">RespVoidBadge</datafield>
        <datafield type="Boolean" displaylabel="Rpt Bypass" default="False">RptByp</datafield>
        <datafield type="Int32" min="0" max="81">Sensor</datafield>
        <datafield type="Int32" min="0" max="73">Shunt</datafield>
        <datafield type="Int32" min="0" max="255" displaylabel="Extended Shunt Time">ShuntTime</datafield>
        <datafield type="Int32" min="0" max="73">Strike</datafield>
        <datafield type="Int32" listsource="taapbtypelist1" listquery="taapbtypelist">TAAPBType</datafield>
        <datafield type="Int32" min="0" max="255" displaylabel="Tag Timeout">TagTimeout</datafield>
        <datafield type="Int32" listsource="vehicletagreaderlookup1" listquery="vehicletagreaderlookup" displaylabel="TA Type">TAType</datafield>
        <datafield type="Int32" min="0" max="3" displaylabel="Reader Type">Type</datafield>
        <datafield type="Boolean" displaylabel="TZ Override" default="False">TZOvr</datafield>
        <datafield type="Int32" RequireDownload="false">UTCOffset</datafield>
        <datafield type="Int32" min="0" max="9999" RequireDownload="false">VideoEndTime</datafield>
        <datafield type="Int32" min="1" max="32767" RequireDownload="false">VideoPriorityFrom</datafield>
        <datafield type="Int32" min="1" max="32767" RequireDownload="false">VideoPriorityTo</datafield>
        <datafield type="Int32" min="0" max="9999" RequireDownload="false">VideoStartTime</datafield>
      </datafields>
    </Reader>
    <ReaderCategories ismaster="False">
      <primarykeyfields>
        <primarykeyfield type="Int32">CatNumber</primarykeyfield>
        <primarykeyfield type="Int32">PnlRef</primarykeyfield>
        <primarykeyfield type="Int32">RdrNo</primarykeyfield>
      </primarykeyfields>
      <keyfields>
        <keyfield type="Int32">PnlRef</keyfield>
        <keyfield type="Int32">RdrNo</keyfield>
      </keyfields>
      <datafields>
        <datafield type="Int32" null="false">CatNumber</datafield>
        <datafield type="DateTime" null="false" RequireDownload="false">LastUpdated</datafield>
        <datafield type="String" RequireDownload="false">LastWorkStation</datafield>
        <datafield type="Int32" null="false">PnlRef</datafield>
        <datafield type="Int32" null="false">RdrNo</datafield>
      </datafields>
    </ReaderCategories>
    <ReaderPriority>
      <keyfields>
        <keyfield type="Int32">PnlRef</keyfield>
        <keyfield type="Int32">RdrNo</keyfield>
      </keyfields>
      <datafields>
        <datafield type="Int32" min="1" max="99"  RequireDownload="false">APBPrior</datafield>
        <datafield type="Int32" min="1" max="99" RequireDownload="false">BypPrior</datafield>
        <datafield type="Guid" null="false" RequireDownload="false">caObjectId</datafield>
        <datafield type="Int32" min="1" max="99" RequireDownload="false">DuPrior</datafield>
        <datafield type="Int32" min="1" max="99" RequireDownload="false">FDPrior</datafield>
        <datafield type="Int32" min="1" max="99" RequireDownload="false">FreePrior</datafield>
        <datafield type="Guid" RequireDownload="false">LastOperator</datafield>
        <datafield type="DateTime" null="false" RequireDownload="false">LastUpdated</datafield>
        <datafield type="String" RequireDownload="false">LastWorkStation</datafield>
        <datafield type="Int32" min="1" max="99" RequireDownload="false">ManPrior</datafield>
        <datafield type="Int32" min="1" max="99" RequireDownload="false">OTHPrior</datafield>
        <datafield type="Int32" min="1" max="99" RequireDownload="false">OTLPrior</datafield>
        <datafield type="Int32" min="1" max="65535" RequireDownload="false">PINPrior</datafield>
        <datafield type="Int32" null="false">PnlRef</datafield>
        <datafield type="Int32" null="false">RdrNo</datafield>
        <datafield type="Int32" min="1" max="99" RequireDownload="false">TrkPrior</datafield>
        <datafield type="Int32" min="1" max="99" RequireDownload="false">ValidPrior</datafield>
        <datafield type="Int32" min="1" max="99" RequireDownload="false">VPrior</datafield>
      </datafields>
    </ReaderPriority>
    <Relay>
      <keyfields>
        <keyfield type="Guid">caObjectID</keyfield>
      </keyfields>
      <datafields>
        <datafield type="Guid" RequireDownload="false">caObjectID</datafield>
        <datafield type="String" length="50" RequireDownload="false">Description</datafield>
        <datafield type="Boolean" default="False">Dialup</datafield>
        <datafield type="Boolean" default="False">Enabled</datafield>
        <datafield type="Guid" RequireDownload="false">LastOperator</datafield>
        <datafield type="DateTime" null="false" RequireDownload="false">LastUpdated</datafield>
        <datafield type="String" RequireDownload="false">LastWorkStation</datafield>
        <datafield type="String" length="50" RequireDownload="false">Location</datafield>
        <datafield type="Int32" listsource="manprivlist2" listquery="manprivlist">ManualPriv</datafield>
        <datafield type="Boolean" default="False">NormOn</datafield>
        <datafield type="Int32" readonly="true" null="false" listsource="allpanellookupwithcondition1" listquery="allpanellookupwithcondition">PnlRef</datafield>
        <datafield type="Int32" min="1" max="99" RequireDownload="false">Priority</datafield>
        <datafield type="String" length="100" null="false" RequireDownload="false">RelayName</datafield>
        <datafield type="Int32" readonly="true" null="false" min="1" max="73">RelNo</datafield>
        <datafield type="Int32" min="0" max="30000">RelTime</datafield>
        <datafield type="String"  RequireDownload="false">Remarks</datafield>
        <datafield type="Boolean" default="False" RequireDownload="false">RespReq</datafield>
        <datafield type="Int32" listsource="mtimezonlookup7" listquery="mtimezonlookup">TrackTz</datafield>
        <datafield type="Int32" RequireDownload="false">UTCOffset</datafield>
        <datafield type="Boolean" default="False">XactRpt</datafield>
      </datafields>
    </Relay>
    <Resp ismaster="False">
      <keyfields>
        <keyfield type="Guid">caObjectID</keyfield>
      </keyfields>
      <datafields>
        <datafield type="Guid" RequireDownload="false">caObjectID</datafield>
        <datafield type="String" length="65" RequireDownload="false">Description</datafield>
        <datafield type="Guid" RequireDownload="false">LastOperator</datafield>
        <datafield type="DateTime" null="false" RequireDownload="false">LastUpdated</datafield>
        <datafield type="String" RequireDownload="false">LastWorkStation</datafield>
      </datafields>
    </Resp>
    <RolePlugins ismaster="False">
      <primarykeyfields>
        <primarykeyfield type="Guid">pluginId</primarykeyfield>
        <primarykeyfield type="Guid">RoleID</primarykeyfield>
      </primarykeyfields>
      <keyfields>
        <keyfield type="Guid">RoleID</keyfield>
      </keyfields>
      <datafields>
        <datafield type="DateTime" null="false" RequireDownload="false">LastUpdated</datafield>
        <datafield type="Guid" null="false" RequireDownload="false">pluginId</datafield>
        <datafield type="Guid" null="false" RequireDownload="false">RoleID</datafield>
      </datafields>
    </RolePlugins>
    <Roles ismaster="False">
      <keyfields>
        <keyfield type="Guid">RoleID</keyfield>
      </keyfields>
      <datafields>
        <datafield type="Guid" RequireDownload="false">caObjectID</datafield>
        <datafield type="Guid" RequireDownload="false">LastOperator</datafield>
        <datafield type="DateTime" null="false" RequireDownload="false">LastUpdated</datafield>
        <datafield type="String" RequireDownload="false">LastWorkStation</datafield>
        <datafield type="Guid" null="false" RequireDownload="false">RoleID</datafield>
        <datafield type="String" length="200" null="false" RequireDownload="false">RoleName</datafield>
      </datafields>
    </Roles>
    <SchedEvent ismaster="False">
      <keyfields>
        <keyfield type="Guid">caObjectId</keyfield>
      </keyfields>
      <datafields>
        <datafield type="Int64">BadgeFrom</datafield>
        <datafield type="Int64">BadgeTo</datafield>
        <datafield type="Guid" null="false" RequireDownload="false">caObjectId</datafield>
        <datafield type="String" length="50" null="false" RequireDownload="false">Description</datafield>
        <datafield type="Int32">Device</datafield>
        <datafield type="Int32">DeviceNo</datafield>
        <datafield type="DateTime">EndDate</datafield>
        <datafield type="String">FieldIn</datafield>
        <datafield type="Int32">FieldNo</datafield>
        <datafield type="String">FieldOut</datafield>
        <datafield type="String">GroupName</datafield>
        <datafield type="Int32">GroupNo</datafield>
        <datafield type="Boolean" default="False">IsActive</datafield>
        <datafield type="Guid" RequireDownload="false">LastOperator</datafield>
        <datafield type="DateTime" RequireDownload="false">LastUpdated</datafield>
        <datafield type="String" RequireDownload="false">LastWorkStation</datafield>
        <datafield type="Int32">PnlNo</datafield>
        <datafield type="Int32" listsource="timeschedulelookup2" listquery="timeschedulelookup">Schedule</datafield>
        <datafield type="Int32" identity="true">SchId</datafield>
        <datafield type="DateTime" null="false">StartDate</datafield>
        <datafield type="Int32">Status</datafield>
        <datafield type="String">ValueIn</datafield>
        <datafield type="String">ValueOut</datafield>
        <datafield type="Int32" RequireDownload="false">UTCOffset</datafield>
      </datafields>
    </SchedEvent>
    <scriptingServers ismaster="False">
      <primarykeyfields>
        <primarykeyfield type="Int32">workstationID</primarykeyfield>
      </primarykeyfields>
      <datafields>
        <datafield type="Guid" RequireDownload="false">LastOperator</datafield>
        <datafield type="String" RequireDownload="false">LastWorkStation</datafield>
        <datafield type="String" length="255" null="false">pollingUNCName</datafield>
        <datafield type="Int32" null="false">workstationID</datafield>
      </datafields>
    </scriptingServers>
    <Shunt>
      <primarykeyfields>
        <primarykeyfield type="Int32">InpRef</primarykeyfield>
        <primarykeyfield type="Int32">PnlRef</primarykeyfield>
        <primarykeyfield type="Int32">ShuntId</primarykeyfield>
      </primarykeyfields>
      <keyfields>
        <keyfield type="Int32">ShuntId</keyfield>
      </keyfields>
      <datafields>
        <datafield type="Guid" null="false" RequireDownload="false">caObjectId</datafield>
        <datafield type="Int32" null="false">InpRef</datafield>
        <datafield type="Guid" RequireDownload="false">LastOperator</datafield>
        <datafield type="DateTime" null="false" RequireDownload="false">LastUpdated</datafield>
        <datafield type="String" RequireDownload="false">LastWorkStation</datafield>
        <datafield type="Int32" null="false">PnlRef</datafield>
        <datafield type="Int32" null="false">ShuntId</datafield>
      </datafields>
    </Shunt>
    <smsProviders ismaster="False">
      <primarykeyfields>
        <primarykeyfield type="Int32">smsHostID</primarykeyfield>
      </primarykeyfields>
      <datafields>
        <datafield type="Guid" RequireDownload="false">LastOperator</datafield>
        <datafield type="String" RequireDownload="false">LastWorkStation</datafield>
        <datafield type="Int32" RequireDownload="false">smsHostID</datafield>
        <datafield type="String" length="50" null="false" RequireDownload="false">smsHostName</datafield>
        <datafield type="String" length="255" RequireDownload="false">smsParams</datafield>
        <datafield type="String" length="50" RequireDownload="false">smsPassword</datafield>
        <datafield type="String" length="255" RequireDownload="false">smsServer</datafield>
        <datafield type="Int32" RequireDownload="false">smsType</datafield>
      </datafields>
    </smsProviders>
    <snppProviders ismaster="False">
      <primarykeyfields>
        <primarykeyfield type="Int32">snppHostID</primarykeyfield>
      </primarykeyfields>
      <datafields>
        <datafield type="Guid" RequireDownload="false">LastOperator</datafield>
        <datafield type="String" RequireDownload="false">LastWorkStation</datafield>
        <datafield type="Int32" RequireDownload="false">snppHostID</datafield>
        <datafield type="String" length="50" null="false" RequireDownload="false">snppHostName</datafield>
        <datafield type="Int32" RequireDownload="false">snppPort</datafield>
        <datafield type="String" length="255" RequireDownload="false">snppServer</datafield>
      </datafields>
    </snppProviders>
    <SystemSettings ismaster="False">
      <keyfields>
        <keyfield type="Int32">SysId</keyfield>
      </keyfields>
      <datafields>
        <datafield type="Int32" listsource="maxaccessgroups1" listquery="maxaccessgroups">AGCountPerBadge</datafield>
        <datafield type="Int32" listsource="APBResetList1" listquery="APBResetList" RequireDownload="false">APBResetArea</datafield>
        <datafield type="DateTime" RequireDownload="false">APBResetTime</datafield>
        <datafield type="Int32" min="5" max="99" RequireDownload="false">AutoAckPriority</datafield>
        <datafield type="Boolean" default="False" RequireDownload="false">AutoCreateDevice</datafield>
        <datafield type="Int32">BadgeReIssueLevel</datafield>
        <datafield type="Boolean" default="False" RequireDownload="false">EnforceGroups</datafield>
        <datafield type="Boolean" default="False" RequireDownload="false">HidePinCode</datafield>
        <datafield type="Boolean" default="False" RequireDownload="false">HideSSN</datafield>
        <datafield type="Int32" listsource="KeypadOptionList1" listquery="KeypadOptionList">KeypadOption</datafield>
        <datafield type="Guid" RequireDownload="false">LastOperator</datafield>
        <datafield type="DateTime" null="false" RequireDownload="false">LastUpdated</datafield>
        <datafield type="String" RequireDownload="false">LastWorkStation</datafield>
        <datafield type="String" RequireDownload="false">LDAPPath</datafield>
        <datafield type="Int32" RequireDownload="false">LockDown</datafield>
        <datafield type="Int32" min="0" max="30" RequireDownload="false">PasswordMaxLength</datafield>
        <datafield type="Int32" min="0" max="30" RequireDownload="false">PasswordMinLength</datafield>
        <datafield type="Int32" min="0" max="30" RequireDownload="false">PasswordMinNonAlphaChars</datafield>
        <datafield type="String" RequireDownload="false">PasswordRegEx</datafield>
        <datafield type="Int32" listsource="timeschedulelookup3" listquery="timeschedulelookup" RequireDownload="false">PrintBySchedule</datafield>
        <datafield type="Int32" min="0" max="99" RequireDownload="false">PrintPriority</datafield>
        <datafield type="Int32" listsource="timeschedulelookup1" listquery="timeschedulelookupsettings" RequireDownload="false">RespReqTz</datafield>
        <datafield type="Int32" listsource="maxbadgelength1" listquery="maxbadgelength">SysBadgeLen</datafield>
        <datafield type="Int32" null="false">SysId</datafield>
        <datafield type="Int32" listsource="vechileTrack1" listquery="vechileTrack">TagType</datafield>
        <datafield type="Boolean" default="False" RequireDownload="false">UseALP</datafield>
        <datafield type="Boolean" default="False" RequireDownload="false">UseAPBAreas</datafield>
        <datafield type="Boolean" default="False" RequireDownload="false">UseAutoAck</datafield>
        <datafield type="Boolean" default="False" RequireDownload="false">UseCatCounters</datafield>
        <datafield type="Boolean" default="False" RequireDownload="false">UseCustomMenu</datafield>
        <datafield type="Boolean" default="False">UseFacBadge</datafield>
        <datafield type="Boolean" default="False" RequireDownload="false">UseFacilityMaps</datafield>
        <datafield type="Boolean" default="False">UseHoliday</datafield>
        <datafield type="Boolean" default="False">UseHostTz</datafield>
        <datafield type="Int32" default="False">BroadcastValue</datafield>
        <datafield type="Guid" RequireDownload="false">APBResetPartition</datafield>
        <datafield type="Boolean" default="False" RequireDownload="false">UseLDAPAuthentication</datafield>
        <datafield type="Boolean" default="False" RequireDownload="false">UseLDAPAuthorization</datafield>
        <datafield type="Boolean" default="False">UseNAPCO</datafield>
        <datafield type="Boolean" default="False">UseNAPCOPermissions</datafield>
        <datafield type="Boolean" default="False">UseScripting</datafield>
        <datafield type="Boolean" default="False" RequireDownload="false">UseStrongPasswords</datafield>
        <datafield type="Boolean" default="False" RequireDownload="false">UseVideo</datafield>
        <datafield type="Int32" RequireDownload="false">UTCOffset</datafield>
      </datafields>
    </SystemSettings>
    <Timezone>
      <primarykeyfields>
        <primarykeyfield type="Int32">TzId</primarykeyfield>
        <primarykeyfield type="Int32">TzNo</primarykeyfield>
      </primarykeyfields>
      <keyfields>
        <keyfield type="Int32">TzNo</keyfield>
      </keyfields>
      <datafields>
        <datafield type="Guid" null="false" RequireDownload="false">caObjectId</datafield>
        <datafield type="Int32" listsource="daylist1" listquery="daylist">DayFrom</datafield>
        <datafield type="Int32" listsource="daylist2" listquery="daylist">DayTo</datafield>
        <datafield type="Int32">FrHr</datafield>
        <datafield type="Int32">FrMin</datafield>
        <datafield type="Guid" RequireDownload="false">LastOperator</datafield>
        <datafield type="DateTime" null="false" RequireDownload="false">LastUpdated</datafield>
        <datafield type="String" RequireDownload="false">LastWorkStation</datafield>
        <datafield type="DateTime">TimeFrom</datafield>
        <datafield type="DateTime">TimeTo</datafield>
        <datafield type="Int32">ToHr</datafield>
        <datafield type="Int32">ToMin</datafield>
        <datafield type="Boolean" identity="true" default="False">TzId</datafield>
        <datafield type="Int32">TzNo</datafield>
        <datafield type="Int32" RequireDownload="false">UTCOffset</datafield>
      </datafields>
    </Timezone>
    <UserFieldDef ismaster="False">
      <datafields>
        <datafield type="Guid" null="false" RequireDownload="false">caObjectId</datafield>
        <datafield type="Guid" RequireDownload="false">LastOperator</datafield>
        <datafield type="DateTime" RequireDownload="false">LastUpdated</datafield>
        <datafield type="String" RequireDownload="false">LastWorkStation</datafield>
        <datafield type="Int32" null="false">UserFieldID</datafield>
        <datafield type="Int32">UserFieldLength</datafield>
        <datafield type="String" null="false" RequireDownload="false">UserFieldName</datafield>
        <datafield type="Int32">UserFieldTabId</datafield>
        <datafield type="Int32">UserFieldType</datafield>
      </datafields>
    </UserFieldDef>
    <UserFields>
      <primarykeyfields>
        <primarykeyfield type="Int64">Badge</primarykeyfield>
        <primarykeyfield type="Int32">Facility</primarykeyfield>
        <primarykeyfield type="Guid">PersonID</primarykeyfield>
        <primarykeyfield type="Int32">UserFieldID</primarykeyfield>
      </primarykeyfields>
      <keyfields>
        <keyfield type="Int64">Badge</keyfield>
        <keyfield type="Int32">Facility</keyfield>
        <keyfield type="Guid">PersonID</keyfield>
      </keyfields>
      <datafields>
        <datafield type="Int64" null="false">Badge</datafield>
        <datafield type="Guid" null="false" RequireDownload="false">caObjectId</datafield>
        <datafield type="Int32" null="false">Facility</datafield>
        <datafield type="Guid" RequireDownload="false">LastOperator</datafield>
        <datafield type="DateTime" null="false" RequireDownload="false">LastUpdated</datafield>
        <datafield type="String" RequireDownload="false">LastWorkStation</datafield>
        <datafield type="Guid" null="false">PersonID</datafield>
        <datafield type="Int32" null="false">UserFieldID</datafield>
        <datafield type="String">UserFieldValue</datafield>
      </datafields>
    </UserFields>
    <UserFieldTabs ismaster="False">
      <datafields>
        <datafield type="Guid" RequireDownload="false">caObjectId</datafield>
        <datafield type="Guid" RequireDownload="false">LastOperator</datafield>
        <datafield type="DateTime" RequireDownload="false">LastUpdated</datafield>
        <datafield type="String" RequireDownload="false">LastWorkStation</datafield>
        <datafield type="Int32" null="false">UserFieldTabID</datafield>
        <datafield type="String" RequireDownload="false">UserFieldTabName</datafield>
      </datafields>
    </UserFieldTabs>
    <WorkstationSettings ismaster="False">
      <keyfields>
        <keyfield type="String">WorkstationName</keyfield>
      </keyfields>
      <datafields>
        <datafield type="String" RequireDownload="false">AlertColor1</datafield>
        <datafield type="String" RequireDownload="false">AlertColor2</datafield>
        <datafield type="String" RequireDownload="false">AlertColor3</datafield>
        <datafield type="String" RequireDownload="false">AlertColor4</datafield>
        <datafield type="Int32" min="0" max="90" RequireDownload="false">AlertSoundInterval1</datafield>
        <datafield type="Int32" min="0" max="90" RequireDownload="false">AlertSoundInterval2</datafield>
        <datafield type="Int32" min="0" max="90" RequireDownload="false">AlertSoundInterval3</datafield>
        <datafield type="Int32" min="0" max="90" RequireDownload="false">AlertSoundInterval4</datafield>
        <datafield type="String" RequireDownload="false">AlertSoundName1</datafield>
        <datafield type="String" RequireDownload="false">AlertSoundName2</datafield>
        <datafield type="String" RequireDownload="false">AlertSoundName3</datafield>
        <datafield type="String" RequireDownload="false">AlertSoundName4</datafield>
        <datafield type="Int32" min="1" max="98" RequireDownload="false">AlertSoundPriority1</datafield>
        <datafield type="Int32" min="1" max="98" RequireDownload="false">AlertSoundPriority2</datafield>
        <datafield type="Int32" min="1" max="98" RequireDownload="false">AlertSoundPriority3</datafield>
        <datafield type="Int32" min="1" max="98" RequireDownload="false">AlertSoundPriority4</datafield>
        <datafield type="Int32" RequireDownload="false">Badgingoption</datafield>
        <datafield type="String" RequireDownload="false">BadgingPrn</datafield>
        <datafield type="Guid" null="false" RequireDownload="false">caObjectId</datafield>
        <datafield type="Boolean" default="False" RequireDownload="false">CCTVSocket</datafield>
        <datafield type="Boolean" default="False" RequireDownload="false">EnableVideoService</datafield>
        <datafield type="String" RequireDownload="false">EventPrinter</datafield>
        <datafield type="String" RequireDownload="false">EventPrn</datafield>
        <datafield type="Guid" RequireDownload="false">LastOperator</datafield>
        <datafield type="DateTime" null="false" RequireDownload="false">LastUpdated</datafield>
        <datafield type="String" RequireDownload="false">LastWorkStation</datafield>
        <datafield type="Int32" min="0" max="90" RequireDownload="false">ResponseSoundInterval</datafield>
        <datafield type="String" RequireDownload="false">ResponseSoundName</datafield>
        <datafield type="String">TapiId1</datafield>
        <datafield type="String">TapiId2</datafield>
        <datafield type="String">TapiPhone1</datafield>
        <datafield type="String">TapiPhone2</datafield>
        <datafield type="Boolean" default="False" RequireDownload="false">UseAlertSound</datafield>
        <datafield type="Boolean" default="False" RequireDownload="false">UseBadging</datafield>
        <datafield type="Boolean" default="False" RequireDownload="false">UseLinePrinterMode</datafield>
        <datafield type="Boolean" default="False" RequireDownload="false">UsePrinting</datafield>
        <datafield type="Boolean" default="False" RequireDownload="false">UseWirelessLocks</datafield>
        <datafield type="String">WorkstationName</datafield>
        <datafield type="Boolean" default="False" RequireDownload="false">SoftwareElevCtrl</datafield>
      </datafields>
    </WorkstationSettings>
    <ElevFloors ismaster="False">
      <keyfields>
        <keyfield type="Guid">caObjectID</keyfield>
      </keyfields>
      <datafields>
        <datafield type="Guid" RequireDownload="false">caObjectID</datafield>
        <datafield type="Int32" min="-127" max="127">FloorNumber</datafield>
        <datafield type="String" length="65" RequireDownload="false">FloorName</datafield>
        <datafield type="Guid" RequireDownload="false">LastOperator</datafield>
        <datafield type="DateTime" null="false" RequireDownload="false">LastUpdated</datafield>
        <datafield type="String" RequireDownload="false">LastWorkStation</datafield>
        <datafield type="Int32" RequireDownload="false">UTCOffset</datafield>
        <datafield type="Int32" listsource="elevatorfacilitylookup1" listquery="elevatorfacilitylookup" displaylabel="Elevator Facility">ElevFacilityId</datafield>
      </datafields>
    </ElevFloors>
    <ElevServers ismaster="False">
      <primarykeyfields>
        <primarykeyfield type="Int32">ServerId</primarykeyfield>
      </primarykeyfields>
      <keyfields>
        <keyfield type="Guid">caObjectID</keyfield>
      </keyfields>
      <datafields>
        <datafield type="Guid" RequireDownload="false">caObjectID</datafield>
        <datafield type="Int32" RequireDownload="false">ServerId</datafield>
        <datafield type="Int32" RequireDownload="false">ServerType</datafield>
        <datafield type="Int32" RequireDownload="false">ServerPort</datafield>
        <datafield type="String" length="15" RequireDownload="false" null="false">ServerIP</datafield>
        <datafield type="String" length="100" RequireDownload="false">ServerName</datafield>
        <datafield type="String" length="100" RequireDownload="false">WorkstationName</datafield>
        <datafield type="String" length="200" RequireDownload="false">ServerParam</datafield>
        <datafield type="Guid" RequireDownload="false">LastOperator</datafield>
        <datafield type="DateTime" null="false" RequireDownload="false">LastUpdated</datafield>
        <datafield type="String" RequireDownload="false">LastWorkStation</datafield>
        <datafield type="Int32" RequireDownload="false">UTCOffset</datafield>
        <datafield type="Int32" listsource="elevatorfacilitylookup1" listquery="elevatorfacilitylookup" displaylabel="Elevator Facility">ElevFacilityId</datafield>
      </datafields>
    </ElevServers>
    <ElevFacilities ismaster="False">
      <primarykeyfields>
        <primarykeyfield type="Int32">ElevFacilityId</primarykeyfield>
      </primarykeyfields>
      <keyfields>
        <keyfield type="Guid">caObjectID</keyfield>
      </keyfields>
      <datafields>
        <datafield type="Guid" RequireDownload="false">caObjectID</datafield>
        <datafield type="Int32" RequireDownload="false">ElevFacilityId</datafield>
        <datafield type="String" length="100" RequireDownload="false">ElevFacilityName</datafield>
        <datafield type="Guid" RequireDownload="false">LastOperator</datafield>
        <datafield type="DateTime" null="false" RequireDownload="false">LastUpdated</datafield>
        <datafield type="String" RequireDownload="false">LastWorkStation</datafield>
        <datafield type="Int32" RequireDownload="false">UTCOffset</datafield>
      </datafields>
    </ElevFacilities>
  </tables>
  <queries>
    <ABPAreaDownload partitioned="False">
      SELECT 0 as ValueMember, 'One or All' as DisplayMember
      union
      SELECT AreaNo as ValueMember,Description as DisplayMember FROM APBAreas WHERE AreaNo BETWEEN 1 AND 254
      AND caObjectID IN (SELECT DP.caObjectID FROM OperatorPartitions OP
      JOIN Devicepartitions DP ON OP.PartitionID = DP.PartitionID
      WHERE OperatorID = @OperatorID)
    </ABPAreaDownload>
    <accessgroupdetailsgrid partitioned="False">
      select p.PanelName as Panel
      , p.pnlNo
      , r.readername as Reader
      , r.rdrNo
      , 0 as "TimeZone"
      from reader r
      inner join panel p
      on r.pnlref = p.pnlno
      where (not (p.PanelType = 102 and r.RdrNo > 1)) and r.caObjectID in (
      SELECT devicepartitions.caObjectID FROM OperatorPartitions inner join  devicepartitions on devicepartitions.PartitionId = OperatorPartitions.Partitionid where OperatorPartitions.OperatorID = @OperatorID)
      order by p.pnlno,r.rdrno
    </accessgroupdetailsgrid>
    <accessgroupdetailbyobjectid>
      SELECT a.[PnlRef]
      ,a.[Agno]
      ,a.[Tz1]
      ,a.[Tz2]
      ,a.[Tz3]
      ,a.[Tz4]
      ,a.[Tz5]
      ,a.[Tz6]
      ,a.[Tz7]
      ,a.[Tz8]
      ,a.[Tz9]
      ,a.[Tz10]
      ,a.[Tz11]
      ,a.[Tz12]
      ,a.[Tz13]
      ,a.[Tz14]
      ,a.[Tz15]
      ,a.[Tz16]
      ,a.[caObjectID]
      ,a.[LastUpdated]
      ,a.[LastOperator]
      ,a.[LastWorkStation]
      ,a.[UTCOffset]
      FROM [AccGrp] a
      Inner JOin MAccGrp m On a.Agno = m.AgrpNo
      where m.caObjectID = @caObjectID
    </accessgroupdetailbyobjectid>
    <GetBadgeFacility partitioned="False">SELECT MAX(Facility) AS Facility FROM Badge WHERE Badge=@Badge</GetBadgeFacility>
    <AccessGroupList partitioned="False" notificationtable="MAccGrp">select AgrpNo as ValueMember, Description as DisplayMember from mAccGrp</AccessGroupList>
    <accessgroupquery partitioned="False" notificationtable="AccGrp">
        select
        PnlRef
        ,Agno
        ,tz1
        ,tz2
        ,tz3
        ,tz4
        ,tz5
        ,tz6
        ,tz7
        ,tz8
        ,tz9
        ,tz10
        ,tz11
        ,tz12
        ,tz13
        ,tz14
        ,tz15
        ,tz16
        from accgrp
        where agno = @agno
    </accessgroupquery>
    <accessgroupsgrid partitioned="False">
      select
      AgrpNo as "AG No."
      ,Description as "Description Text"
      ,LastUpdated as "Last Edit"
      ,caObjectID
      from mAccGrp
      where isnull(pointaccess,0)=0
    </accessgroupsgrid>
    <accessgroupslookup partitioned="True" notificationtable="MAccGrp">
      select 0 as ValueMember,  'No Access' as DisplayMember, 'AAAA' as OrderCol
      union
      select
      AgrpNo as ValueMember, Description as DisplayMember  ,  Description as OrderCol
      from MAccGrp
      where (isnull(PointAccess,0)=0)
      Order by OrderCol
    </accessgroupslookup>
    <ApiAccessgroupsgrid partitioned="True" notificationtable="MAccGrp">
      select 0 as ValueMember,  'No Access' as DisplayMember
      union
      select
      AgrpNo as ValueMember, Description as DisplayMember
      from MAccGrp
      where (isnull(PointAccess,0)=0)
      Order by ValueMember
    </ApiAccessgroupsgrid>
    <ApiAccessgroupsforschedule partitioned="True" notificationtable="MAccGrp">
      select
      AgrpNo as ValueMember, Description as DisplayMember
      from MAccGrp
      where (isnull(PointAccess,0)=0) and AgrpNo &lt;&gt; 0
      Order by ValueMember
    </ApiAccessgroupsforschedule>
    <accessgroupsnofilterlookup partitioned="True" notificationtable="MAccGrp">
      select -1 as ValueMember,  '&lt;No Filter&gt;' as DisplayMember
      union
      select 0 as ValueMember,  'No Access' as DisplayMember
      union
      select
      AgrpNo as ValueMember, Description as DisplayMember
      from MAccGrp
      where (isnull(PointAccess,0)=0)
    </accessgroupsnofilterlookup>
    <accessgroupsPartitionlookup partitioned="False" notificationtable="MAccGrp">
      Select ValueMember, DisplayMember, OrderCol FROM
      (
      select 0 as ValueMember,  'No Access' as DisplayMember, 'No Access' as OrderCol
      union
      SELECT  MAccGrp.AgrpNo as ValueMember, MAccGrp.Description as DisplayMember, MAccGrp.Description as OrderCol
      FROM    BadgeAccess INNER JOIN MAccGrp ON BadgeAccess.AGroupNo = MAccGrp.AgrpNo
      where (isnull(MAccGrp.PointAccess,0)=0) and BadgeAccess.Badge=@Badge and BadgeAccess.Facility=@Facility
      union
      select
      AgrpNo as ValueMember, Description as DisplayMember  ,  Description as OrderCol
      from MAccGrp
      where (isnull(PointAccess,0)=0)  and caObjectID in (SELECT devicepartitions.caObjectID FROM OperatorPartitions inner join  devicepartitions on devicepartitions.PartitionId = OperatorPartitions.Partitionid where OperatorPartitions.OperatorID = @OperatorID)
      ) as TAB
      ORDER BY CASE WHEN DisplayMember = 'No Access' THEN 1 ELSE 2 END, DisplayMember
    </accessgroupsPartitionlookup>
    <accessGroupUnused partitioned="False" notificationtable="MAccGrp">
      select AgrpNo as [Acc Grp No], Description
      from MAccGrp M
      where  NOT EXISTS(SELECT A.AGroupNo FROM BadgeAccess A WHERE A.AGroupNo  = M.AgrpNo)
      and caObjectID in (
      SELECT devicepartitions.caObjectID FROM OperatorPartitions inner join  devicepartitions on devicepartitions.PartitionId = OperatorPartitions.Partitionid where OperatorPartitions.OperatorID = @OperatorID)
    </accessGroupUnused>
    <accessGroupUsagesByAccessGroupID partitioned="False">
      SELECT (SELECT Badge FROM dbo.Badge WHERE Badge.PersonID= Person.PersonID) AS Badge, FrstName +', '+ LastName as "Name" FROM dbo.Person WHERE PersonID IN (SELECT PersonID FROM dbo.Badge WHERE EXISTS (SELECT Badge FROM BadgeAccess where AGroupNo = @AccessGroupID  AND BadgeAccess.Badge = Badge.Badge)
      and PersonID in (SELECT devicepartitions.caObjectID
      FROM OperatorPartitions inner join  devicepartitions on devicepartitions.PartitionId = OperatorPartitions.Partitionid
      where OperatorPartitions.OperatorID = @OperatorID))
    </accessGroupUsagesByAccessGroupID>
    <APIaccessGroupUsagesByAccessGroupID partitioned="False">
      SELECT (SELECT Badge FROM dbo.Badge WHERE Badge.PersonID= Person.PersonID) AS Badge, FrstName +', '+ LastName as "Name" FROM dbo.Person WHERE PersonID IN (SELECT PersonID FROM dbo.Badge WHERE EXISTS (SELECT Badge FROM BadgeAccess where AGroupNo = @AccessGroupID  AND BadgeAccess.Badge = Badge.Badge)
      and PersonID in (SELECT devicepartitions.caObjectID
      FROM OperatorPartitions inner join  devicepartitions on devicepartitions.PartitionId = OperatorPartitions.Partitionid
      where OperatorPartitions.OperatorID = @OperatorID))
    </APIaccessGroupUsagesByAccessGroupID>
    <aclinkinputgrid partitioned="False">
      select
      r.InpNo,
      r.InputName,
      isnull(a.Control, 0) as Control,
      r.PnlRef,
      a.ProgNo,
      isnull(a.pnlNo, r.PnlRef) as pnlNo,
      r.caObjectID
      from Input r
      left join ActiveLinks a ON
      r.PnlRef = a.PnlNo and
      r.InpNo=a.InpNo and
      a.ProgNo=@ProgNo and
      a.PnlRef=@PnlRef
      where
      r.InpNo &lt; 65
      and
      r.caObjectID in (SELECT devicepartitions.caObjectID FROM OperatorPartitions inner join  devicepartitions on devicepartitions.PartitionId = OperatorPartitions.Partitionid where OperatorPartitions.OperatorID = @OperatorID)
      order by r.InpNo

    </aclinkinputgrid>
    <aclinkpanelgrid partitioned="False">
      select distinct
      P.PnlNo,
      P.PanelName,
      P.PanelType
      ,P.caObjectID
      ,A.CatReader
      from Panel P
      join ActiveLinks A on
      A.PnlNo = P.PnlNo
      where
      P.PanelType in (3,5,6,7,8,9,10,11,12,13,14,15,16,17,101,102) and
      A.ProgNo = @ProgNo and
      A.PnlRef = @PnlRef and
      A.PnlNo &lt;&gt; @PnlRef
      union
      select distinct
      P.PnlNo,
      P.PanelName,
      P.PanelType,
      P.caObjectID
      ,A.CatReader
      from Panel P
      join ActiveLinks A on
      A.PnlNo = P.PnlNo
      where
      P.PnlNo = @PnlRef
    </aclinkpanelgrid>
    <APIaclinkpersonnelgrid partitioned="False">
      select
      c.CatNo,
      c.Description,
      isnull(a.Control, 0) as Control,
      c.PnlNo,
      a.ProgNo,
      isnull(a.pnlNo, c.PnlNo) as pnlNo
      ,      c.caObjectID
      from CategoryCounters c
      left join ActiveLinks a ON
      c.PnlNo = a.PnlNo and
      c.CatNo=a.CatNo and
      a.ProgNo=@ProgNo and
      a.PnlRef=@PnlRef
      order by c.CatNo
    </APIaclinkpersonnelgrid>
    <aclinkpersonnelgrid partitioned="False">
      select
      c.CatNo,
      c.Description,
      isnull(a.Control, 0) as Control,
      c.PnlNo,
      a.ProgNo,
      isnull(a.pnlNo, c.PnlNo) as pnlNo
      ,      c.caObjectID
      from CategoryCounters c
      left join ActiveLinks a ON
      c.PnlNo = a.PnlNo and
      c.CatNo=a.CatNo and
      a.ProgNo=@ProgNo and
      a.PnlRef=@PnlRef
      order by c.CatNo
    </aclinkpersonnelgrid>
    <aclinkreadergrid partitioned="False">
      select
      r.RdrNo,
      r.ReaderName,
      isnull(a.Control, 0) as Control,
      r.PnlRef,
      a.ProgNo,
      isnull(a.pnlNo, r.PnlRef) as pnlNo
      ,      r.caObjectID
      from reader r
      left join ActiveLinks a ON
      r.PnlRef = a.PnlNo and
      r.RdrNo=a.RdrNo and
      a.ProgNo=@ProgNo and
      a.PnlRef=@PnlRef
      where
      r.caObjectID in (SELECT devicepartitions.caObjectID FROM OperatorPartitions inner join  devicepartitions on devicepartitions.PartitionId = OperatorPartitions.Partitionid where OperatorPartitions.OperatorID = @OperatorID)
      order by r.RdrNo
    </aclinkreadergrid>
    <aclinkrelaygrid partitioned="False">
      select
      r.RelNo,
      r.RelayName,
      isnull(a.Control, 0) as Control,
      r.PnlRef,
      a.ProgNo,
      isnull(a.pnlNo, r.PnlRef) as pnlNo
      ,      r.caObjectID
      from Relay r
      left join ActiveLinks a ON
      r.PnlRef = a.PnlNo and
      r.RelNo=a.RelNo and
      a.ProgNo=@ProgNo and
      a.PnlRef=@PnlRef
      where
      r.RelNo &lt; 65
      and
      r.caObjectID in (SELECT devicepartitions.caObjectID FROM OperatorPartitions inner join  devicepartitions on devicepartitions.PartitionId = OperatorPartitions.Partitionid where OperatorPartitions.OperatorID = @OperatorID)
      order by r.RelNo
    </aclinkrelaygrid>
    <ActiveThreadLevelByLockdownArea partitioned="False" notificationtable="ActiveThreatLevel">
      Select LockdownID,Description,LockdownColor,Active,LockoutArea,caObjectID,LastUpdated From MActiveThreatLevel where active = 1 and lockoutarea = @LockoutArea
    </ActiveThreadLevelByLockdownArea>
    <activethreatlevel partitioned="True">Select LockdownID,Description,LockdownColor,Active,LockoutArea,caObjectID,LastUpdated From MActiveThreatLevel where active = 1</activethreatlevel>
    <activethreatlevels partitioned="False" notificationtable="ActiveThreatLevel">
      SELECT LockdownID, CatNumber, 0 as Active FROM ActiveThreatLevel
      union select LockdownID, 0 as CatNumber, Active from MActiveThreatLevel WHERE Active = 1
    </activethreatlevels>
    <activitylinklookup partitioned="False">
      select l.pnlref,l.description,l.progno
      ,p.paneltype from MActivelinks l
      inner join panel p on p.pnlno = l.pnlref
    </activitylinklookup>
    <getactivitylinkenabled partitioned="False">
      select 1 as Cnt from MActiveLinks where Enabled= 1 and ProgNo=@ProgNo and PnlRef=@PnlRef
    </getactivitylinkenabled> 
    <activitylinkprivenabledlookup partitioned="False">
      select l.pnlref,l.description,l.progno
      ,p.paneltype from MActivelinks l
      inner join panel p on p.pnlno = l.pnlref
      where l.enabled = 1
      and ( (isnull(l.ManualPriv,0) = 0)
      or   (l.ManualPriv in (
      select ManualPrivilege from manualprivilege where OperatorID = @OperatorID )))
      and l.caObjectID in (
      SELECT devicepartitions.caObjectID FROM OperatorPartitions inner join  devicepartitions on devicepartitions.PartitionId = OperatorPartitions.Partitionid where OperatorPartitions.OperatorID = @OperatorID)
    </activitylinkprivenabledlookup>
    <activitylinkprivPartitionenabledlookup partitioned="False">
      select l.pnlref,l.description,l.progno
      ,p.paneltype from MActivelinks l
      inner join panel p on p.pnlno = l.pnlref
      where l.enabled = 1
      and ( (isnull(l.ManualPriv,0) = 0)
      or   (l.ManualPriv in (
      select ManualPrivilege from manualprivilege where OperatorID = @OperatorID )))
      and l.caObjectID in (SELECT caObjectID FROM devicepartitions  where PartitionID = @PartitionID)
    </activitylinkprivPartitionenabledlookup>
    <activitylinks partitioned="False" notificationtable="MActiveLinks">
      SELECT
      m.PnlRef,
      m.ProgNo,
      m.Description AS [ALP Description],
      m.Priority,
      m.ManualPriv,
      m.Device,
      m.EventCode,
      m.Category,
      m.UnDO,
      m.Schedule,
      m.UnDoProgNo,
      m.RespReq,
      m.LastUpdated,
      m.caObjectID,
      (CAST(m.PnlRef AS varchar(6))+'-'+CAST(m.ProgNo AS varchar(6))) AS [Pnl/Prog],
      p.Description AS [Panel Name]
      FROM  dbo.MActiveLinks m
      LEFT OUTER JOIN
      dbo.Panel p ON p.PnlNo = m.PnlRef
      WHERE
      m.caObjectID = @caObjectID
    </activitylinks>
    <activitylinksgrid partitioned="False">
      SELECT
      m.PnlRef,
      m.ProgNo,
      Convert(Char(6),PnlRef) + '- ' + Convert(Char(6),ProgNo) as "Pnl/Prog" ,
      m.Description as "ALP Description",
      p.PanelName as Panel,
      m.LastUpdated as "Last Edit",
      m.caObjectID
      FROM  MActiveLinks m
      inner join panel p on m.pnlref = p.pnlno
      where
      m.caObjectID in (SELECT devicepartitions.caObjectID FROM OperatorPartitions inner join  devicepartitions on devicepartitions.PartitionId = OperatorPartitions.Partitionid where OperatorPartitions.OperatorID = @OperatorID)
      order by pnlref,progno
    </activitylinksgrid>
    <APIactivitylinksgrid partitioned="False">
      SELECT
      m.PnlRef,
      m.ProgNo,
      Convert(Char(6),PnlRef) + '- ' + Convert(Char(6),ProgNo) as "PnlProg" ,
      m.Description as "ALP Description",
      p.PanelName as Panel,
      m.LastUpdated as "Last Edit",
      m.caObjectID
      FROM  MActiveLinks m
      inner join panel p on m.pnlref = p.pnlno
      where
      m.caObjectID in (SELECT devicepartitions.caObjectID FROM OperatorPartitions inner join  devicepartitions on devicepartitions.PartitionId = OperatorPartitions.Partitionid where OperatorPartitions.OperatorID = @OperatorID)
      order by pnlref,progno
    </APIactivitylinksgrid>
    <activitylinkslookupjoin partitioned="False">
      select
      m.PnlRef
      ,p.panelname as PnlRefText
      ,m.schedule
      ,t.description  as scheduleText
      ,m.ManualPriv
      , CASE m.ManualPriv
      WHEN (0) THEN 'All'
      WHEN (1) THEN 'Priv 1'
      WHEN (2) THEN 'Priv 2'
      WHEN (3) THEN 'Priv 3'
      WHEN (4) THEN 'Priv 4'
      WHEN (5) THEN 'Priv 5'
      WHEN (6) THEN 'Priv 6'
      WHEN (7) THEN 'Priv 7'
      WHEN (8) THEN 'Priv 8'
      END AS ManualPrivText
      from MActiveLinks m
      inner join panel p on m.pnlref = p.pnlno
      left outer join MTimezon t on m.schedule = t.tznum
      where pnlref = @PnlRef and progno = @ProgNo

    </activitylinkslookupjoin>
    <GetPertitionDeviceObjectID partitioned="False">SELECT caObjectID FROM DevicePartitions where PartitionID=@PartitionID</GetPertitionDeviceObjectID>
    <InsertDefaultValuesToAllPartition partitioned="False">
      INSERT INTO DevicePartitions
      SELECT PartitionID, '971B59B1-B15B-4880-B056-1D7D83337ACF' as caObjectID
      FROM Partition
      WHERE NOT EXISTS(SELECT 1 FROM DevicePartitions WHERE DevicePartitions.PartitionID = Partition.PartitionID AND DevicePartitions.caObjectID = '971B59B1-B15B-4880-B056-1D7D83337ACF')
    </InsertDefaultValuesToAllPartition>
    <addapbnestedarea partitioned="False">
      insert into APBNestedAreas VALUES(@Node,@AreaNo,@NestName,@Level,@Parent,@caObjectId,@lastUpdated,
      @LastOperator,@LastWorkstation)
    </addapbnestedarea>
    <AddNewLock partitioned="False">
      Insert into Panel (PnlNo,HCSNo,Enabled,ComPort,Address,LockType,PanelType,LockId
      ,PanelName,Interactive,NoFail,Elevators,Passwrd,DegradeMode
      ,XactSize,Schedules,CommPrior,DwnloadPrior,PwrPrior,ModemPrior,RespOffOnLine,RespDownloads,RespACPowerFail,RespModemActivity,MaxAlp,MaxEvt,ZoneId,LockAssigned
      ,DefaultCalendar,RetrievalSchedule,LockExpAddress,LastOperator,LastUpdated)
      VALUES(@PnlNo,@HCSNo,1,@ComPort,@Address,@LockType,@PanelType
      ,@LockId,@PanelName,@Interactive,@NoFail,@Elevators,@Passwrd,@DegradeMode,
      @XactSize,@Schedules,@CommPrior,@DwnloadPrior,@PwrPrior,@ModemPrior,@RespOffOnLine,@RespDownloads,@RespACPowerFail,@RespModemActivity,@MaxAlp,@MaxEvt,@ZoneId
      ,@LockAssigned,@DefaultCalendar,@RetrievalSchedule,@LockExpAddress,@LastOperator,@LastUpdated)</AddNewLock>
    <agbybadgefacility partitioned="False">select 0 as ValueMember,  'No Access' as DisplayMember union select AgrpNo as ValueMember, Description as DisplayMember from MAccGrp where (isnull(PointAccess,0)=0) and AgrpNo in (select distinct AGroupNo from BadgeAccess where badge = @Badge and facility = @Facility)</agbybadgefacility>
    <allapbarealookup partitioned="True" notificationtable="APBAreas">
      SELECT apbArea.AreaNo, apbArea.Description, apbArea.caObjectID, apbArea.AlertOn, apbArea.AreaCountUp, apbArea.AreaCountDown, apbArea.LastUpdated
      FROM APBAreas AS apbArea INNER JOIN APBAreas AS apbTmp ON apbArea.AreaNo = apbTmp.AreaNo AND apbArea.areano IN (0, 1)
      UNION
      SELECT AreaNo, Description, caObjectID, AlertOn, AreaCountUp, AreaCountDown, LastUpdated FROM APBAreas
      WHERE AreaNo  &gt; 1 AND areano &lt; 255
      Order by Description
    </allapbarealookup>
    <allapbareaallPartitionlookup partitioned="False" notificationtable="APBAreas">
      SELECT apbArea.AreaNo, apbArea.Description, apbArea.caObjectID, apbArea.AlertOn, apbArea.AreaCountUp, apbArea.AreaCountDown, apbArea.LastUpdated
      FROM APBAreas AS apbArea INNER JOIN APBAreas AS apbTmp ON apbArea.AreaNo = apbTmp.AreaNo AND apbArea.areano IN (0, 1)
      UNION
      SELECT AreaNo, Description, caObjectID, AlertOn, AreaCountUp, AreaCountDown, LastUpdated FROM APBAreas
      WHERE AreaNo  &gt; 1 AND areano &lt; 255
      Order by Description
    </allapbareaallPartitionlookup>
    <allapblookup partitioned="False" notificationtable="APBAreas">
      SELECT  AreaNo as ValueMember, Description as DisplayMember
      FROM APBAreas
      WHERE AreaNo &lt; 255
      ORDER BY Description
    </allapblookup>
    <inputprivenabledlookup partitioned="False" >
      select 0 as pnlref, 0 as ValueMember, 'None' as DisplayMember
      union
      select  PnlRef, InpNo as ValueMember, InputName as DisplayMember
      from Input
      where caObjectid in(SELECT devicepartitions.caObjectID FROM OperatorPartitions inner join  devicepartitions on devicepartitions.PartitionId = OperatorPartitions.Partitionid where OperatorPartitions.OperatorID = @OperatorID)
    </inputprivenabledlookup>
    <inputprivenabledPartitionlookup partitioned="False">
      select 0 as pnlref, 0 as ValueMember, 'None' as DisplayMember
      union
      select  PnlRef, InpNo as ValueMember, InputName as DisplayMember
      from Input
      where caObjectid in(SELECT caObjectID FROM devicepartitions  where PartitionID = @PartitionID)
    </inputprivenabledPartitionlookup>
    <AllGuiPlugins partitioned="False">
      select g.pluginId, g.displayName, g.pluginAssembly, g.availPartGroups from guiPlugins g
    </AllGuiPlugins>
    <AllGuiPluginsAdmin partitioned="False">
      select g.pluginId, g.displayName, g.pluginAssembly from guiPlugins g
    </AllGuiPluginsAdmin>
    <allinputlookup partitioned="True" notificationtable="Input">
      select 0 as PnlRef, 0 as ValueMember, 'None'  as DisplayMember
      union
      select  PnlRef, InpNo as ValueMember, InputName as DisplayMember
      from Input
    </allinputlookup>
    <alllinklookup partitioned="True" notificationtable="Link">
      select 0 as PnlRef, 0 as ValueMember,  'None' as DisplayMember
      union
      select pnlRef, ProgNo as ValueMember, LinkName as DisplayMember
      from Link
    </alllinklookup>
    <APIalllinklookup partitioned="False" notificationtable="Link">
      select 0 as PnlRef, 0 as ValueMember,  'None' as DisplayMember
      union
      select pnlRef, ProgNo as ValueMember, LinkName as DisplayMember
      from Link
    </APIalllinklookup>
    <allpanellookup partitioned="True" notificationtable="Panel">
      select pnlno as ValueMember ,panelname as DisplayMember, paneltype,NapcoPanel from panel order by PanelName
    </allpanellookup>
    <allpanellookupwithcondition partitioned="True" notificationtable="Panel">
      SELECT pnlno as ValueMember ,panelname as DisplayMember, paneltype,NapcoPanel FROM panel WHERE PanelType &lt; = 102 AND ISNULL(LockType, 0) NOT IN (164,165,166,167,168,169,183,184,185,192,193,194,195,196,197,198,199,200,201) order by PanelName
    </allpanellookupwithcondition>
    <allreadercolonbasisofpaneltype partitioned="False">SELECT R.* FROM Panel P, Reader R WHERE R.PnlRef = P.PnlNo AND P.PanelType in (3,5,6,7,8,9,10,11,12,13,14,15,16,17,101,102)</allreadercolonbasisofpaneltype>
    <allreaderlookup partitioned="True" notificationtable="Reader">
      select 0 as PnlRef, 0  as ValueMember, 'None' as DisplayMember
      union
      select pnlRef, RdrNo as ValueMember, readerName as DisplayMember
      from Reader
    </allreaderlookup>
    <allreaderwithoutlocklookup partitioned="True">
      select 0 as PnlRef, 0  as ValueMember, 'None' as DisplayMember
      union
      select pnlRef, RdrNo as ValueMember, readerName as DisplayMember
      from Reader r
      inner join panel p on p.pnlno = r.pnlref
      where p.PanelType &lt; 100 and r.enabled = 1
    </allreaderwithoutlocklookup>
    <allreaderonbasisofpaneltype partitioned="True">
      SELECT PnlNo, RdrNo, Reader, APBEntry, APBExit FROM (
      SELECT R.PnlRef AS PnlNo,R.RdrNo AS RdrNo,  ReaderName AS Reader,  APBEntry, APBExit, r.caObjectID FROM Panel P INNER JOIN Reader R ON R.PnlRef = P.PnlNo
      AND P.PanelType in (3,5,6,7,8,9,10,11,12,13,14,15,16,17,101,102)
      ) AS TAB
    </allreaderonbasisofpaneltype>
    <allrelaylookup partitioned="True" notificationtable="Relay">
      select 0 as PnlRef, 0 as ValueMember, 'None' as DisplayMember
      union
      select pnlref,RelNo as ValueMember, RelayName as DisplayMember
      from Relay
    </allrelaylookup>
    <APIallrelaylookup partitioned="false" notificationtable="Relay">
      select 0 as PnlRef, 0 as ValueMember, 'None' as DisplayMember
      union
      select pnlref,RelNo as ValueMember, RelayName as DisplayMember
      from Relay
    </APIallrelaylookup>
    <alplookup partitioned="True" notificationtable="MActiveLinks">
      select
      ProgNo as ValueMember
      ,Description as DisplayMember
      from MActiveLinks
      where
      isnull(UnDoProgNo,0)=0
      AND PnlRef=@PnlRef AND ProgNo&lt;&gt;@ProgNo
      order by description
    </alplookup>
    <alpundocount partitioned="False" notificationtable="MActiveLinks">
      Select Count(*) as undocount
      FROM MActiveLinks
      WHERE UnDoProgNo= @ProgNo
      AND PnlRef = @PnlRef
    </alpundocount>
    <APBAreaLinkLookup partitioned="True" notificationtable="APBAreas">
      SELECT 0 AS PnlRef, 0 AS ValueMember, 'None' AS DisplayMember
      UNION
      SELECT PnlRef, ValueMember, DisplayMember FROM (
      SELECT PnlRef, (PnlRef*65536+ProgNo) AS ValueMember, LinkName AS DisplayMember, caObjectID FROM Link
      UNION
      SELECT PnlRef, (0x40000000+PnlRef*65536+ProgNo) AS ValueMember, '(ALP) '+Description AS DisplayMember, caObjectID FROM MActiveLinks
      ) AS TAB
    </APBAreaLinkLookup>
    <APBAreaSelect partitioned="False">select APBEntry ,APBExit from reader where rdrno = @Rdrno and pnlref = @Pnlref</APBAreaSelect>
    <apbareaslookup partitioned="True" notificationtable="APBAreas">
      SELECT apbArea.AreaNo as ValueMember, apbArea.Description as DisplayMember 
      FROM APBAreas AS apbArea INNER JOIN APBAreas AS apbTmp ON apbArea.AreaNo = apbTmp.AreaNo AND apbArea.areano IN (0, 1)
      UNION
      SELECT AreaNo as ValueMember, Description as DisplayMember FROM APBAreas WHERE areano &gt; 1 AND areano &lt; 255
    </apbareaslookup>
    <apbareasnofilterlookup partitioned="False" notificationtable="APBAreas">
      select -1 as ValueMember,  '&lt;No Filter&gt;' as DisplayMember
      union
      select AreaNo as ValueMember, Description as DisplayMember from APBAreas
      where AreaNo IN (0, 1, 255) OR caObjectID in (SELECT devicepartitions.caObjectID FROM OperatorPartitions inner join  devicepartitions on devicepartitions.PartitionId = OperatorPartitions.Partitionid
      where OperatorPartitions.OperatorID = @OperatorID)
    </apbareasnofilterlookup>
    <apbareaswithsetnextlookup partitioned="True">
      select apbArea.AreaNo as ValueMember, apbArea.Description as DisplayMember
      from APBAreas AS apbArea INNER JOIN APBAreas AS apbTmp ON apbArea.AreaNo = apbTmp.AreaNo AND apbArea.areano IN (0, 1, 255)
      UNION
      select AreaNo as ValueMember, Description as DisplayMember from APBAreas WHERE areano &gt; 1 AND areano &lt; 255
    </apbareaswithsetnextlookup>
    <apbfirstin partitioned="True">
      select areano,description,active from apbareas
      where areano between 239 and 254 ORDER BY Description
    </apbfirstin>
    <updatefirstinapbschedlock>
      update apbareas set  schedlocked = @schedlocked where areano = @areano
    </updatefirstinapbschedlock>
    <getfirstinforschedlock>
      SELECT AreaNo, Description, caObjectID, AlertOn, AreaCountUp, AreaCountDown, LastUpdated, Active, Schedlocked
      FROM APBAreas WHERE areano = @areano
      AND @areano between 239 and 254
    </getfirstinforschedlock>
    <apbfirstinlookup partitioned="False" notificationtable="APBAreas">
      select AreaNo as ValueMember, Description as DisplayMember from APBAreas
      where areano between 239 and 254 order by Description
    </apbfirstinlookup>
    <apblookup partitioned="False" notificationtable="APBAreas">
      SELECT  AreaNo as ValueMember, Description as DisplayMember
      FROM APBAreas
      WHERE AreaNo =1
      OR AreaNo &gt; 254
      ORDER BY Description
    </apblookup>
    <FirstInAreaLockReaders partitioned="False">
      select r.PnlRef,r.RdrNo, a.Areano,a.Description,a.Active,a.AlertOn,
      r.ReaderName, r.APBEntry, r.APBExit, a.caObjectID FROM APBAreas a
      LEFT JOIN Reader r  on a.Areano=r.APBEntry or a.AreaNo=r.APBExit
      INNER JOIN  Panel AS p ON r.PnlRef = p.PnlNo
      where (a.AreaNo BETWEEN 239 and 254) and (a.AreaNo =@AreaNo) and (p.HCSNo =@HCSNo) and (p.PanelType &gt; 100)  ORDER By r.PnlRef
    </FirstInAreaLockReaders>
    <FirstInAreaReaders partitioned="False">
      select r.PnlRef,r.RdrNo, a.Areano,a.Description,a.Active,a.AlertOn,
      r.ReaderName, r.APBEntry, r.APBExit, a.caObjectID FROM APBAreas a
      LEFT JOIN Reader r  on a.Areano=r.APBEntry or a.AreaNo=r.APBExit
      INNER JOIN  Panel AS p ON r.PnlRef = p.PnlNo
      where (a.AreaNo BETWEEN 239 and 254) and (a.AreaNo =@AreaNo) and (p.HCSNo =@HCSNo) and (p.PanelType  &lt; 100)  ORDER By r.PnlRef
    </FirstInAreaReaders>
    <archivesettings partitioned="False">select ArchiveConfigServer,ArchiveConfigDatabase,ArchiveEventsServer, ArchiveEventsDatabase FROM ArchiveSettings</archivesettings>
    <AreaLockdownlookup partitioned="False" notificationtable="MLockdownAreas">
      select AreaNo as ValueMember, AreaName as DisplayMember from MLockdownAreas 
      order by AreaName
    </AreaLockdownlookup>
    <assignagfromreader partitioned="True" notificationtable="Reader">
      select 0 as PnlRef, 0 as RdrNo, '0' as ValueMember, 'None' as DisplayMember, 'AAAA' as ReaderName
      union
      select pnlRef, RdrNo, Convert(Char(6),PnlRef) + '- ' + Convert(Char(3),RdrNo) AS ValueMember, readerName as DisplayMember,ReaderName
      from Reader
      order by readername
    </assignagfromreader>
    <AssignComPort partitioned="False">
      insert into Com ( ComPort,Baud, IPAddress, HCSNo,MACAddress,Passwrd,RFChannel,RFGroup,SyncWordLower,SyncWordUpper,Type,IPPort,
      UseDHCP,DHCPName,WirelessMode,SubNetMask,GatewayIPAddress,SecurityType,Authentication,
      GatewayEncryption,KeyType,NetworkType,WifiChannelNo,ZoneId,HostIPAddress,GatewayPort,LastOperator,LastUpdated)
      VALUES ( @ComPort, @Baud, @IPAddress, @HCSNo,@MACAddress,@Passwrd,@RFChannel,@RFGroup,@SyncWordLower,@SyncWordUpper,@Type,@IPPort,
      @UseDHCP,@DHCPName,@WirelessMode,@SubNetMask,@GatewayIPAddress,@SecurityType,@Authentication,
      @GatewayEncryption,@KeyType,@NetworkType,@WifiChannelNo,@ZoneId,@HostIPAddress,@GatewayPort,@LastOperator,@LastUpdated)
    </AssignComPort>
    <assignedcategories partitioned="False">
      SELECT  CatNo from CategoryCounters
      WHERE (LowWater &lt;&gt; 0 and LowWater &lt;&gt; 2)  or (HiWater &lt;&gt; 0 and HiWater &lt;&gt; 2)
      UNION Select CatNumber as CatNo from ReaderCategories
    </assignedcategories>
    <assignedthreats partitioned="False">select Distinct CatNumber FROM ActiveThreatLevel</assignedthreats>
    <audittrailgrid partitioned="False">
      select
      revisionstamp
      ,TableName
      ,OperatorName
      ,StationName
      ,CASE Actions
      WHEN ('L') THEN 'Log'
      WHEN ('I') THEN 'Insert'
      WHEN ('U') THEN 'Edit'
      WHEN ('D') THEN 'Delete'
      ELSE 'None'
      END as Action
      ,Description
      ,OldData
      ,NewData
      ,ChangedColumns
      ,AuditId
      ,LastOperator
      ,caObjectID
      ,UTCOffset
      from dbaudit
    </audittrailgrid>
    <APIaudittrailgrid partitioned="False">
      select
      revisionstamp
      ,Description
      ,CASE Actions
      WHEN ('L') THEN 'Log'
      WHEN ('I') THEN 'Insert'
      WHEN ('U') THEN 'Edit'
      WHEN ('D') THEN 'Delete'
      ELSE 'None'
      END as Action
      ,TableName
      ,OperatorName
      ,StationName
      ,UTCOffset
      from dbaudit
      where
      CAST(CONVERT(VARCHAR(12), RevisionStamp, 101) AS DATETIME) between CAST(CONVERT(VARCHAR(12), @fromDate, 101) AS DATETIME)  AND  CAST(CONVERT(VARCHAR(12), @toDate, 101) AS DATETIME)
      and caObjectID in (SELECT devicepartitions.caObjectID FROM OperatorPartitions inner join  devicepartitions on devicepartitions.PartitionId = OperatorPartitions.Partitionid
      where OperatorPartitions.OperatorID = @OperatorID)
    </APIaudittrailgrid>
    <audittraildetail partitioned="False">
      select
      revisionstamp
      ,TableName
      ,OperatorName
      ,StationName
      ,CASE Actions
      WHEN ('L') THEN 'Log'
      WHEN ('I') THEN 'Insert'
      WHEN ('U') THEN 'Edit'
      WHEN ('D') THEN 'Delete'
      ELSE 'None'
      END as Action
      ,Description
      ,OldData
      ,NewData
      ,ChangedColumns
      ,AuditId
      ,ParentAuditId
      ,LastOperator
      ,caObjectID
      ,UTCOffset
      from dbaudit
      WHERE ISNULL(ParentAuditId, AuditId) = @ParentAuditId
    </audittraildetail>
    <badgecustom partitioned="False">
      select
      d.UserFieldName
      ,d.UserFieldType
      ,d.UserFieldLength
      ,f.UserFieldValue
      ,d.UserFieldID
      from userfielddef d
      left outer join userfields f on d.userfieldid = f.userfieldid
      and personid = @personid
      and badge = @badge
      and facility = @facility
    </badgecustom>
    <badgeformatgrid partitioned="False">
      select
      Description as "Description Text"
      ,FmtLength as "Format Length"
      ,FmtType as "Fmt Type"
      ,FmtCLen as "Number len"
      ,FmtCOff as "Number Offset"
      ,FmtFLen as "Facility Len"
      ,FmtFOff as "Facility offset"
      ,LastUpdated as "Last Edit"
      ,caObjectId
      from format
    </badgeformatgrid>
    <badgegrid partitioned="False">
      SELECT
      lastname as 'Last Name',
      frstname as 'First Name',
      Badge,
      PIVI,
      aGroupNo,
      Facility,
      Badge as 'Badge No',
      Enabled,
      caObjectId,
      ActvDate as 'Activation Date',
      ExprDate as 'Expiration Date',
      LastUpdated as 'Last Edit',
      PersonId,
      UTCOffset
      FROM ca_vw_Personnel
      where personid = @personid
      and personid in (SELECT devicepartitions.caObjectID FROM OperatorPartitions inner join  devicepartitions on devicepartitions.PartitionId = OperatorPartitions.Partitionid where OperatorPartitions.OperatorID = @OperatorID)
    </badgegrid>
    <badgelookupjoin partitioned="False">
      select
      b.NAPCOPermissionId
      ,CASE b.NAPCOPermissionId WHEN (0) THEN 'None' ELSE n.PermissionName END as NAPCOPermissionIdText,
      b.HolidayCalendar
      ,h.Description as HolidayCalendarText
      ,b.APBArea
      ,CASE b.APBArea WHEN (255) THEN 'Set Next Use' ELSE a.Description END as APBAreaText
      ,b.ShuntId
      ,CASE b.ShuntId WHEN (0) THEN 'None' ELSE s.ShuntName END as ShuntIdText
      ,b.OrgAssoc
      ,CASE b.OrgAssoc
      WHEN (0) THEN 'Not Used'
      WHEN (1) THEN 'Employee(1)'
      WHEN (2) THEN 'Civil(2)'
      WHEN (3) THEN 'Pers/Org 3'
      WHEN (4) THEN 'Pers/Org 4'
      WHEN (5) THEN 'Pers/Org 5'
      WHEN (6) THEN 'Pers/Org 6'
      WHEN (7) THEN 'Pers/Org 7'
      WHEN (8) THEN 'Pers/Org 8'
      WHEN (9) THEN 'Pers/Org 9'
      ELSE 'Undefined'
      END as OrgAssocText
      ,b.Orgcategory
      ,CASE b.OrgCategory
      WHEN (0) THEN 'Not Used'
      WHEN (1) THEN 'Federal Gov''t Agency (1)'
      WHEN (2) THEN 'State Gov''t Agency (2)'
      WHEN (3) THEN 'Commercial Enterprise (3)'
      WHEN (4) THEN 'Foreign Gov''t (4)'
      WHEN (5) THEN 'Category 5'
      WHEN (6) THEN 'Category 6'
      WHEN (7) THEN 'Category 7'
      WHEN (8) THEN 'Category 8'
      WHEN (9) THEN 'Category 9'
      ELSE 'Undefined'
      END as OrgCategoryText
      from badge b
      left outer join napcoMPermissions n on b.NAPCOPermissionId = n.PermissionID
      left outer join MHoliday h on b.HolidayCalendar = h.CalendarNo
      left outer join APBAreas a on b.APBArea = a.AreaNo
      left outer join MShunt s on b.ShuntId = s.ShuntID
      where personid = @personid
      and badge = @badge
      and facility = @facility
    </badgelookupjoin>
    <GetComDbDataBadge>
      SELECT distinct 
      b.PersonID
      ,b.Badge
      ,b.Facility
      ,b.PIVI
      ,b.Enabled
      ,p.LastName
      ,p.FrstName
      ,b.ActvDate
      ,b.ExprDate
      ,b.UseCount
      ,b.APBArea
      ,b.APBSet
      ,b.Shunt
      ,b.ShuntID
      ,b.Track
      , case when bp.PersonID IS NULL THEN 0 ELSE 1 END as HasPhoto
      ,b.BadgeType
      ,b.caObjectID
      FROM Badge b LEFT JOIN Person p ON b.PersonID = p.PersonID
      LEFT JOIN BadgePhoto bp on bp.PersonID = p.PersonID
    </GetComDbDataBadge>
    <GetComDbDataPanel>
      SELECT
      PnlNo
      ,PanelName as Description
      ,CommPrior
      ,DwnLoadPrior
      ,PwrPrior
      ,ModemPrior
      ,RespOffOnLine
      ,RespDownloads
      ,RespACPowerFail
      ,RespModemActivity
      ,ComPort
      ,Enabled
      ,NULL
      ,caObjectID
      ,ZoneId
      ,PanelType
      FROM Panel
      WHERE HCSNo=@HCSNo AND ((@PnlNo &gt; 0 AND PnlNo = @PnlNo) OR (@PnlNo &lt;= 0 AND PnlNo &lt;&gt; @PnlNo))
    </GetComDbDataPanel>
    <GetComDbDataRelay>
      SELECT
      r.PnlRef
      ,r.RelNo
      ,r.RelayName as Description
      ,r.Priority
      ,r.RespReq
      ,r.XactRpt
      ,r.caObjectID
      FROM Relay r
      INNER JOIN Panel p ON p.PnlNo = r.PnlRef
      WHERE p.HCSNo=@HCSNo AND ((@PnlNo &gt; 0 AND r.PnlRef = @PnlNo) OR (@PnlNo &lt;= 0 AND r.PnlRef &lt;&gt; @PnlNo ))
    </GetComDbDataRelay>
    <GetComDbDataReader>
      SELECT
      r.PnlRef
      ,r.RdrNo
      ,r.ReaderName as Description
      ,r.APBEntry
      ,r.APBExit
      ,r.APBType
      ,r.ExtShunt
      ,rp.FDPrior
      ,rp.OTLPrior
      ,rp.DuPrior
      ,rp.TrkPrior
      ,rp.VPrior
      ,rp.APBPrior
      ,rp.OTHPrior
      ,rp.ManPrior
      ,rp.BypPrior
      ,rp.FreePrior
      ,rp.PINPrior
      ,rp.ValidPrior
      ,ISNULL(r.DvrServerId,'00000000-0000-0000-0000-000000000000')
      ,r.VideoPriorityFrom
      ,r.VideoPriorityTo
      ,r.RespForcedDoor
      ,r.RespOTL
      ,r.RespDuress
      ,r.RespTrackedBadge
      ,r.RespVoidBadge
      ,r.RespAPBViolate
      ,r.RespOtherDenied
      ,r.RespBypass
      ,r.RespFreeAccess
      ,r.RespManualDoorCtrl
      ,r.RespCommonCode
      ,r.RespValidAccess
      ,r.AckBypass
      ,r.AckFreeAccess
      ,r.AckManualDoorCtrl
      ,r.AckCommonCode
      ,r.AckValidAccess
      ,r.BadgeUseRegister
      ,r.Type
      ,r.caObjectID
      FROM Reader r
      INNER JOIN Panel p ON p.PnlNo = r.PnlRef
      INNER JOIN ReaderPriority rp ON  rp.pnlref = r.pnlref and rp.rdrno = r.rdrno
      WHERE p.HCSNo=@HCSNo AND ((@PnlNo &gt; 0 AND r.PnlRef = @PnlNo) OR (@PnlNo &lt;= 0 AND r.PnlRef &lt;&gt; @PnlNo ))
    </GetComDbDataReader>
    <GetComDbDataMActiveLinks>
      SELECT 
      PnlRef
      ,ProgNo
      ,m.Description
      ,Priority
      ,m.caObjectID
      ,RespReq
      FROM MActiveLinks m
      INNER JOIN Panel p ON p.PnlNo = m.PnlRef
      WHERE p.HCSNo=@HCSNo AND ((@PnlNo &gt; 0 AND m.PnlRef = @PnlNo) OR (@PnlNo &lt;= 0 AND m.PnlRef &lt;&gt; @PnlNo ))
    </GetComDbDataMActiveLinks>
    <GetComDbDataActiveLinks>
      SELECT 
      ALPId
      ,PnlRef
      ,ProgNo
      ,a.PnlNo
      ,RelNo
      ,InpNo
      ,RdrNo
      ,CatNo
      ,Control
      ,Active
      ,CatReader
      ,a.caObjectID
      FROM ActiveLinks a
      INNER JOIN Panel p ON p.PnlNo = a.PnlRef
      WHERE p.HCSNo=@HCSNo AND ((@PnlNo &gt; 0 AND a.PnlRef = @PnlNo) OR (@PnlNo &lt;= 0 AND a.PnlRef &lt;&gt; @PnlNo ))
    </GetComDbDataActiveLinks>
    <GetComDbDataAPBAreas>
      SELECT 
      AreaNo
      ,Description
      ,ParentArea
      ,AlertOn
      ,LinkVacant
      ,LinkOccupied
      ,AreaCountUp
      ,LinkOnCountUp
      ,AreaCountDown
      ,LinkOnCountDown
      ,Active
      ,caObjectID
      FROM APBAreas
    </GetComDbDataAPBAreas>
    <GetComDbDataLink>
      SELECT
      PnlRef
      ,ProgNo
      ,LinkName as Description
      ,RptXact
      ,LnkPnl
      ,LnkProg
      ,Priority
      ,l.caObjectID
      ,RespReq
      FROM Link l
      INNER JOIN Panel p ON p.PnlNo = l.PnlRef
      WHERE p.HCSNo=@HCSNo AND ((@PnlNo &gt; 0 AND l.PnlRef = @PnlNo) OR (@PnlNo &lt;= 0 AND l.PnlRef &lt;&gt; @PnlNo ))
    </GetComDbDataLink>
    <GetComDbDataInput>
      SELECT  PnlRef
      ,InpNo
      ,InputName as Description
      ,NoXact
      ,Priority
      ,RespReq
      ,DvrServerID
      ,VideoEventType
      ,EnableRecording
      ,I.caObjectID
      FROM Input I
      INNER JOIN Panel p ON p.PnlNo = I.PnlRef
      WHERE p.HCSNo=@HCSNo AND ((@PnlNo &gt; 0 AND I.PnlRef = @PnlNo) OR (@PnlNo &lt;= 0 AND I.PnlRef &lt;&gt; @PnlNo ))
    </GetComDbDataInput>
    <GetComDbDataCategoryCounters>
      SELECT PnlNo
      ,CatNo
      ,Description
      ,Priority
      ,RespReq
      FROM CategoryCounters
      WHERE (@PnlNo &gt; 0 AND PnlNo = @PnlNo) OR (@PnlNo &lt;= 0 AND PnlNo &lt;&gt; @PnlNo)
    </GetComDbDataCategoryCounters>
    <GetComDbDataZones>
      SELECT 
      ZoneId
      ,Description
      ,StandardName
      ,UTCBias
      ,sBias
      ,sMonth
      ,sDay
      ,sHour
      ,sMinute
      ,sSecond
      ,dBias
      ,dMonth
      ,dDay
      ,dHour
      ,dMinute
      ,dSecond
      FROM Zones
    </GetComDbDataZones>
    <GetComDbDataDvrReader>
      SELECT PnlRef, RdrNo FROM Reader
      WHERE Reader.DvrServerID IS NOT NULL AND NOT EXISTS (SELECT 1 FROM DvrConfig WHERE DvrConfig.DvrID = Reader.DvrServerID)
    </GetComDbDataDvrReader>
    <GetComDbDataDvrInput>
      SELECT PnlRef, InpNo FROM Input
      WHERE Input.DvrServerID IS NOT NULL AND NOT EXISTS (SELECT 1 FROM DvrConfig WHERE DvrConfig.DvrID = Input.DvrServerID)
    </GetComDbDataDvrInput>
    <ca_vw_AccessGroup_Rep partitioned="False">
      SELECT
      AgrpNo
      , [Access Group]
      , [Last Edit]
      , Panel
      , [Panel Description]
      ,  Reader
      , [Reader Description]
      , [Time Zone]
      from ca_vw_AccessGroup_Rep
    </ca_vw_AccessGroup_Rep>
    <ca_vw_ActivityLinks_Rep partitioned="False">
      select
      PnlRef
      ,Panel
      ,ProgNo
      ,[Link Program Description]
      ,Event
      ,[Alert Priority]
      ,[Last Edit]
      ,Category
      ,Device
      ,Control
      ,[Relay Description]
      from ca_vw_ActivityLinks_Rep
    </ca_vw_ActivityLinks_Rep>
    <ca_vw_Personnel_Custom_Rep partitioned="False">
      select
      Name
      ,Facility
      ,Badge
      ,UserFieldName
      ,UserFieldValue
      from ca_vw_Personnel_Custom_Rep
    </ca_vw_Personnel_Custom_Rep>
    <ca_vw_Personnel_Rep partitioned="False">
      select
      Name
      ,Facility
      ,Badge
      ,[Access Group]
      ,[Re-Issue]
      ,[Embossed #]
      ,[Access Date]
      ,[Validate On]
      ,[InValidate On]
      ,AccessTime
      ,[Last Edited]
      ,[Last Access]
      ,[Holiday Group]
      ,Dept
      ,Phone
      ,Location
      ,Supervsr
      ,Ext
      ,License
      ,Vehicle
      ,[Hire Date]
      ,SSN
      ,[Company ID]
      ,Remarks
      ,Escorted
      ,Enabled
      ,Tracked
      ,Resident
      ,InitLoad
      ,[Door Shnt]
      ,MApbExempt
      ,[NAPCO Permission]
      ,[FirstInControl]
      from ca_vw_Personnel_Rep
    </ca_vw_Personnel_Rep>
    <ca_vw_system partitioned="False">
      select SysBadgeLen,AutoAckPriority,RespReqTz,TagType,AGCountPerBadge,UseAPBAreas,APBResetTime,UseALP,UseHoliday,UseAutoAck,AutoAckPriority ,RespReqTz,AGCountPerBadge,usePIV, UseHostTz, KeypadOption
      from systemsettings where sysid =0
    </ca_vw_system>
    <categorycounterlookup partitioned="False">select CatNo as ValueMember, Description as DisplayMember from CategoryCounters where pnlno = @pnlno</categorycounterlookup>
    <categorycountersgrid partitioned="False">
      select DISTINCT c.cPnlNo AS pnlNo,
      c.cPnlNo as Panel,
      p.PanelName,
      p.caObjectID
      ,(SELECT CAST(MAX(LastUpdated) AS DATETIME2(0)) FROM CategoryCounters WHERE PnlNo = c.cPnlNo) as 'Last Edit'
      from (select [PnlNo] AS cPnlNo,[CatNo],[Description],[LowWater],[HiWater],[EventMsg],[Priority],[RespReq],
      [LastUpdated],[caObjectID],[LastOperator],[LastWorkStation],[UTCOffset] FROM categorycounters) AS c INNER JOIN 
      (SELECT PnlNo, PanelName, caObjectID FROM Panel) p ON c.cPnlNo=p.PnlNo
      where p.caObjectID in (
      SELECT devicepartitions.caObjectID FROM OperatorPartitions inner join  devicepartitions on devicepartitions.PartitionId = OperatorPartitions.Partitionid
      where OperatorPartitions.OperatorID = @OperatorId)
      order by c.cPnlNo asc
    </categorycountersgrid>
    <centralstationlinks partitioned="False">
      select
      centralStationId,badge,facility
      from centralstationlinks
      where cat=@cat
      and pnlNo=@pnlNo
      and Number     = @Number
      and status = @status
      and workstationId=@workstationId
    </centralstationlinks>
    <getPartitionCount partitioned="False">
      select OperatorID from OperatorPartitions where PartitionID=@PartitionID and OperatorID=@OperatorID
    </getPartitionCount>
    <centralstationAlllinks partitioned="False">
      select
      centralStationId,badge,facility,cat,pnlNo,Number,status,workstationId
      from centralstationlinks
    </centralstationAlllinks>
    <centralstationserver partitioned="False">
      select centralStationId as ValueMember, centralStationName + ' ( '+ accountNumber + ' )' as DisplayMember, ipAddress, accountNumber, macAddress from CentralStationServer
      order by centralStationName
    </centralstationserver>
    <centralstationserver0 partitioned="False">
      select centralStationId as ValueMember, centralStationName as DisplayMember, ipAddress, accountNumber, macAddress from CentralStationServer
      order by centralStationName, macAddress
    </centralstationserver0>
    <centralstationserver1 partitioned="False">
      select centralStationId as ValueMember, centralStationName + ' ( '+ accountNumber + ' )' as DisplayMember, ipAddress, accountNumber, macAddress from CentralStationServer
      where centralStationName=@centralStationName order by centralStationName
    </centralstationserver1>
    <updatecentralstationserver partitioned="False">UPDATE CentralStationServer SET macAddress = @macAddress WHERE centralStationId = @centralStationId</updatecentralstationserver>
    <CheckAnyPanelExists partitioned="False">Select PnlNo from Panel where ComPort=@ComPort and HCSNo=@HcsNo</CheckAnyPanelExists>
    <checkDedicatedAG partitioned="False">select AgrpNo,Description from MAccGrp where Description=@description</checkDedicatedAG>
    <checkforelevator partitioned="False" notificationtable="Panel">SELECT PnlNo FROM Panel WHERE Enabled=1 AND Elevators=1</checkforelevator>
    <checkforholiday partitioned="False" notificationtable="Holiday">
      Select Holno from Holiday WHERE CalendarNo=0 AND DateDiff(dd,SDate,GetDate()) = 0 AND (FrHr&lt; @FrHr  OR (FrHr= @FrHr AND FrMin&lt;= @FrMin )) AND ((EndHr=0 AND EndMin=0) OR (EndHr&gt;@EndHr ) OR (EndHr= @EndHr AND EndMin &gt; @EndMin))
    </checkforholiday>
    <checkforlegacy partitioned="False">exec ca_sp_GetAGForLegacyPanels @facility, @badge</checkforlegacy>
    <checkMapByName partitioned="False">select count(1) from map where MapName = @MapName and MapID != @MapID</checkMapByName>
    <checkpartition partitioned="False" notificationtable="Partition">
      Select PartitionID, PartitionName from [Partition]
      Where PartitionName = @PartitionName
    </checkpartition>
    <ClearComFromMac partitioned="False">delete From Com WHERE MacAddress=@MACAddress</ClearComFromMac>
    <ClearCounterValue partitioned="False">DELETE FROM scriptCounters WHERE counterName =@counterName </ClearCounterValue>
    <ClearLockScheduledChange partitioned="False">
      select PanelName, LockUpdateSchedule From Panel
      where PnlNo=@PnlNo and LockChanged = 1 and LockUpdateSchedule &lt;&gt; 0
    </ClearLockScheduledChange>
    <ComPortCount partitioned="False">select count(*) as cnt from Com</ComPortCount>
    <com partitioned="False" notificationtable="Com">select ComPort,Baud,Type,Pwd,Passwrd,IPAddress,IPPort,ZoneId,BinaryMode,NoPolling from com where HCSNo = @HCSNo</com>
    <GetComByHcsPort partitioned="False">select ComPort,Baud,Type,Pwd,Passwrd,IPAddress,IPPort,ZoneId,BinaryMode,NoPolling from com where HCSNo = @HCSNo AND ComPort = @ComPort</GetComByHcsPort>
    <APIGetComByHcsPort partitioned="False">select ComPort,Baud,Type,Pwd,Passwrd,IPAddress,IPPort,ZoneId,BinaryMode,NoPolling from com where HCSNo = @HCSNo AND ComPort = @ComPort</APIGetComByHcsPort>
    <ComGrid partitioned="true">SELECT HCSNo as 'No:', UNCName, Description as 'Description Text', LastUpdated as 'Last Edit', caObjectID FROM MCom order by HCSNo</ComGrid>
    <comlookup partitioned="False" notificationtable="Com">select ComPort,comport as ValueMember, comport as DisplayMember, HCSNo,zoneid,IPAddress, Type from com order by comport</comlookup>
    <APIcomlookup partitioned="False" notificationtable="Com">select ComPort,comport as ValueMember, comport as DisplayMember, HCSNo,zoneid,IPAddress, Type from com order by comport</APIcomlookup>
    <companyidlookup partitioned="False" notificationtable="Person">
      select CompanyID as ValueMember
      , CompanyName as DisplayMember
      from CompanyInfo
    </companyidlookup>
    <comserver partitioned="False">SELECT ComID, WorkstationID, Record, Val1, Val2, Val3, Val4, Val5, Pkt, LastUpdated FROM ComServer WHERE WorkstationID = @HCSNo</comserver>
    <comxpanelbycluster partitioned="False">Select Distinct c.HCSNo, c.Comport, c.Baud, c.Type, c.PWD, c.IPAddress,c.IPPort, c.BinaryMode, c.NoPolling from COM c INNER JOIN PANEL p ON c.HCSNo = p.HCSNo AND c.ComPort = p.ComPort WHERE p.Enabled = 1 AND c.Type != 0 AND c.HCSNo = @HCSNo</comxpanelbycluster>
    <comxpanelbyclusterpnlno partitioned="False">SELECT c.HCSNo, c.comport, c.baud, c.type, c.pwd, c.IPAddress, c.IPPort, c.binarymode, c.NoPolling FROM COM c INNER JOIN PANEL p ON c.HCSNo= p.HCSNo AND c.ComPort= p.ComPort WHERE p.enabled= 1 AND c.type != 0 AND c.HCSNo= @HCSNo AND p.pnlno = @pnlno</comxpanelbyclusterpnlno>
    <customfields partitioned="False">
      select 'None' as UserFieldName,0 as UserFieldType,0 as UserFieldLength,0 as UserFieldID
      Union
      select d.UserFieldName,d.UserFieldType,d.UserFieldLength,d.UserFieldID from userfielddef d order by UserFieldID
    </customfields>
    <CustomMenuSettings partitioned="False">
      select caObjectID, DisplayName,ApplicationPath,LastOperator, LastUpdate, LastWorkStation from CustomMenuSettings order by DisplayName
    </CustomMenuSettings>
    <databaselist partitioned="False">Select DISTINCT ServerName FROM DatabaseList WHERE DatabaseType&lt;&gt;2</databaselist>
    <databasename partitioned="False">
      Select DatabaseName, DatabaseType FROM DatabaseList 
      WHERE ServerName = @ServerName and DatabaseType = @DatabaseType
    </databasename>
    <dedicatedaccess partitioned="False">
      select m.description,m.caObjectId, m.PointAccess,m.aGrpNo,m.LastUpdated
      from badgeaccess b
      inner join maccgrp m on b.AGroupNo = m.agrpno
      where b.badge = @Badge and b.facility =@Facility
      and b.pointaccess = 1
      and m.aGrpNo &gt; 0
    </dedicatedaccess>
    <dedicatedaccessgrid partitioned="False">
      select p.PanelName as Panel
      , p.pnlNo
      , r.readername as Reader
      , r.rdrNo
      , 0 as "TimeZone"
      from reader r
      inner join panel p
      on r.pnlref = p.pnlno
      where r.caObjectID in (SELECT devicepartitions.caObjectID FROM OperatorPartitions inner join  devicepartitions on devicepartitions.PartitionId = OperatorPartitions.Partitionid where OperatorPartitions.OperatorID = @OperatorID)
      order by p.pnlno,r.rdrno
    </dedicatedaccessgrid>
    <defaultholidaysgrid partitioned="True">
      select
      CalendarNo
      ,Description
      ,LastUpdated as "Last Edit"
      ,caObjectId
      from mholiday where CalendarNo=0
    </defaultholidaysgrid>
    <deleteactivelinks partitioned="False">
      delete ActiveLinks
      where pnlref = @pnlref
      and  progno = @progNo
      and  pnlno = @pnlno
    </deleteactivelinks>
    <DeleteNapcoContintalMapping partitioned="False">
      UPDATE [Panel] SET [NAPCOPanel] = 0;
      UPDATE [Badge] SET [NAPCOPermissionId] = 0;
      UPDATE [Reader] SET [NAPCOAreas] = 0;
    </DeleteNapcoContintalMapping>
    <DeleteElevatorAccessGroups partitioned="False">
      Update [Reader] Set Type = 0 Where Type = 1 And PnlRef=@PnlRef;
      Delete [ElevAg] Where [PnlRef] = @PnlRef;
    </DeleteElevatorAccessGroups>
    <DeleteExpiredCommunCacheCommands> Delete from CommunCache where TimeStamp  &lt; DATEADD(hh,-48,GETUTCDATE())  </DeleteExpiredCommunCacheCommands>
    <getCustomField partitioned="False">SELECT [UserFieldName] ColumnName,[UserFieldName] DisplayName FROM [UserFieldDef]</getCustomField>
    <DeleteAPBNestedAreas partitioned="False">Delete from APBNestedAreas</DeleteAPBNestedAreas>
    <DeleteComPort partitioned="False">Delete from Com WHERE HCSNo=@HcsNo and ComPort=@ComPort</DeleteComPort>
    <deletecomserver partitioned="False">DELETE FROM ComServer WHERE (ComID = @ComID) AND (WorkstationID = @WorkstationID)</deletecomserver>
    <DeleteGatewayStatus partitioned="False">Delete from GatewayStatus where MACAddress=@MACAddress</DeleteGatewayStatus>
    <DeleteLocks partitioned="False">Delete FROM Panel WHERE ComPort=@ComPort and HCSNo=@HCSNo</DeleteLocks>
    <DeleteLockStatus partitioned="False">Delete from LockStatus where PnlRef=@PnlNo</DeleteLockStatus>
    <DeleteRepeaterStatus partitioned="False">
      IF(@Id=N'0')
      BEGIN
        Delete from RepeaterStatus where Cluster=@Cluster and ComPort=@ComPort;
      END
      ELSE
      BEGIN
        Delete from RepeaterStatus where Cluster=@Cluster and ComPort=@ComPort and Id=@Id;
      END
      Update [GatewayStatus] SET RepeaterCount = RepeaterCount-1 Where Comport =@Comport AND RepeaterCount>0;
    </DeleteRepeaterStatus>
    <DeleteRepeaterStatusForCom partitioned="False">Delete from RepeaterStatus where Cluster=@Cluster and ComPort=@ComPort</DeleteRepeaterStatusForCom>
    <DeleteLockStatusByPanel partitioned="False">Delete from LockStatus Where PnlRef=@PnlRef and ComPort=@ComPort</DeleteLockStatusByPanel>
    <DeleteMap partitioned="False">DELETE FROM Map WHERE MapUID=@MapUID</DeleteMap>
    <DeleteNewLock partitioned="False">Delete from Panel where LockId=@LockId</DeleteNewLock>
    <DeleteNewReader partitioned="False">Delete from Reader where PnlRef=@PnlRef and RdrNo=@RdrNo</DeleteNewReader>
    <DeleteReader partitioned="False">Delete from Reader WHERE PnlRef=@PnlRef</DeleteReader>
    <DeleteRelay partitioned="False">Delete From Relay Where PnlRef = @PnlRef</DeleteRelay>
    <customfieldlookup partitioned="False" notificationtable="UserFieldDef">
      select UserFieldID as ValueMember
      , UserFieldName as DisplayMember
      from userfielddef
    </customfieldlookup>
    <departmentlookup partitioned="False" notificationtable="Person">
      select DepartmentID as ValueMember
      , DepartmentName as DisplayMember
      from DepartmentInfo order by DepartmentName
    </departmentlookup>
    <departmentlookupnofilter partitioned="False">
      select -1 as ValueMember,  '&lt;No Filter&gt;' as DisplayMember
      union
      select DepartmentID as ValueMember
      , DepartmentName as DisplayMember
      from DepartmentInfo order by DisplayMember
    </departmentlookupnofilter>
    <DeviceInfoLookup partitioned="True">
      SELECT [IID]
      ,PanelId
      ,DeviceId
      ,Description
      ,DeviceType
      ,MapId
      ,MapName
      ,MapUID
      ,PanelType
      ,DvrServerID
      ,DvrCameraID
      ,caObjectID FROM ca_vw_DeviceInfo
    </DeviceInfoLookup>
    <DeviceList partitioned="False">
      SELECT     IID, PanelId, DeviceId, Description, DeviceType, MapId, MapName
      FROM         ca_vw_DeviceInfo
    </DeviceList>
    <DeviceListForFacilityMaps partitioned="True">
      SELECT  IID, PanelId, DeviceId, Description, DeviceType
      FROM  ca_vw_DeviceInfo
    </DeviceListForFacilityMaps>
    
    <GetFacilityMapPoints partitioned="false">
      SELECT FacilityMapPoints.* , FacilityMap.caObjectID
      FROM FacilityMap INNER JOIN FacilityMapPoints ON FacilityMap.MapId = FacilityMapPoints.MapId
      WHERE PanelNo = @PnlNo and DevNo = @DevNo and Type=@Type
    </GetFacilityMapPoints>
    <GetMapDeviceInfo partitioned="false">
      SELECT  IID, PanelId, DeviceId, Description, DeviceType FROM  ca_vw_DeviceInfo WHERE PanelId = @PnlNo and Deviceid = @DevNo and DeviceType=@Type
    </GetMapDeviceInfo>
    
    <GetMapLocationSize>SELECT LastPosMap FROM Operators WHERE OperatorID = @OperatorID</GetMapLocationSize>
    <GetPhotoLocationSize>SELECT LastPosPhoto FROM Operators WHERE OperatorID = @OperatorID</GetPhotoLocationSize>
    <DeleteUserFields>DELETE FROM [UserFields] WHERE [Badge] = @Badge AND [Facility] = @Facility</DeleteUserFields>
    <DeleteBadgeCategories> DELETE FROM [BadgeCategories] WHERE [Badge] = @Badge AND [Facility] = @Facility</DeleteBadgeCategories>
    <InsertUserFields>
      INSERT INTO UserFields (PersonID, Badge, Facility, UserFieldID, UserFieldValue, LastUpdated, caObjectID, LastOperator, LastWorkStation)
      VALUES(@PersonID, @Badge, @Facility, @UserFieldID, @UserFieldValue, @LastUpdated, @caObjectID, @LastOperator, @LastWorkStation)
    </InsertUserFields>
    <InsertBadgeCategories>
      INSERT INTO BadgeCategories (Badge, Facility, CatNumber, LastUpdated, LastWorkstation)
      VALUES (@Badge, @Facility, @CatNumber, @LastUpdated, @LastWorkstation)
    </InsertBadgeCategories>
    <devicelookup partitioned="False">
      select panel,device,description,type from ca_vw_DeviceLookup
      order by type,panel,device
    </devicelookup>
    <DisableBadge partitioned="False">
      UPDATE badge SET Flag = 1, Enabled = 0, LastUpdated = @LastUpdated , LastWorkstation =@LastWorkstation
      WHERE Facility = @Facility  AND Badge = @Badge
    </DisableBadge>
    <DisablePerson partitioned="False">UPDATE badge SET Enabled = 0,  LastUpdated = @LastUpdated , LastOperator =@LastOperator , LastWorkstation =@LastWorkstation WHERE PersonID = @PersonID </DisablePerson>
    <DisableSchedule partitioned="False">Update AlarmLink_Schedule set ScheduleEnabled = 0, LastUpdated = @LastUpdated where ScheduleID = @ScheduleID</DisableSchedule>
    <downloadaccessgroups partitioned="False" notificationtable="AccGrp">
        SELECT
        PnlRef,Agno,LastUpdated,Tz1,Tz2,Tz3,Tz4,Tz5,Tz6,Tz7,Tz8,Tz9,Tz10,Tz11,Tz12,Tz13,Tz14,Tz15,Tz16,caObjectID
        FROM AccGrp
        WHERE PnlRef= @PnlRef AND AgNo&gt;= @AgNo ORDER BY AgNo
    </downloadaccessgroups>
    <downloadalp partitioned="False" notificationtable="ActiveLinks">
      SELECT A.ProgNo, A.RelNo, A.RdrNo, A.InpNo, A.CatNo, A.Control, A.CatReader, M.Enabled
      FROM  ActiveLinks A INNER JOIN
      MActiveLinks M ON A.PnlRef = M.PnlRef AND A.ProgNo = M.ProgNo
      WHERE A.PnlRef = @PnlRef AND A.PnlRef = A.PnlNo AND A.ProgNo &gt;= @ProgNo
      ORDER BY A.ProgNo
    </downloadalp>
    <downloadbadges partitioned="False">exec ca_sp_GetPanelDownload @PnlNo , @Badge, @Facility, @Method</downloadbadges>
    <downloadcat partitioned="False" notificationtable="CategoryCounters">
      SELECT PnlNo,CatNo,LowWater,hiWater,EventMsg FROM CategoryCounters
      WHERE PnlNo= @PnlNo
    </downloadcat>
    <downloadelevators partitioned="False" notificationtable="ElevAg">
      SELECT PnlRef, RdrRef, AccGroup, RelayNumber
      FROM ElevAg
      WHERE PnlRef= @PnlRef and RdrRef&gt;= @RdrRef
      ORDER BY RdrRef,AccGroup
    </downloadelevators>
    <downloadevt partitioned="False" notificationtable="MActiveLinks">
      SELECT ProgNo,Device,EventCode,Category,UnDo,Schedule,UnDoProgNo,Enabled FROM MActiveLinks WHERE
      PnlRef= @PnlRef AND ProgNo&gt;= @ProgNo ORDER BY ProgNo
    </downloadevt>
    <downloadfacility partitioned="False" notificationtable="Facility">
      SELECT
      PnlRef,Facil1,Facil2,Facil3,Facil4,Facil5,Facil6,Facil7,Facil8,Facil9,Facil10
      FROM Facility
      WHERE PnlRef= @PnlRef ORDER BY PnlRef
    </downloadfacility>
    <downloadformat partitioned="False" notificationtable="Format">
      SELECT
      FmtNo,Description,FmtLength,FmtType,FmtSS,FmtSSO,FmtES,FmtESO,FmtFS,FmtFSO,FmtCLen,FmtCOff,FmtILen,FmtIOff,FmtFLen,FmtFOff,
      FmtDLen,FmtDOff,FmtCSLen,FmtCSOff,FmtPILen,FmtPIOff,FmtOCLen,FmtOCOff,FmtOILen,FmtOIOff,FmtPOALen,FmtPOAOff
      FROM Format
      WHERE FmtNo&gt;= @FmtNo ORDER BY FmtNo

    </downloadformat>
    <downloadinputs partitioned="False" notificationtable="Input">
      SELECT
      PnlRef,InpNo,Enabled,NormOpen,Supervised,NoXact,AbnormDial,NormDial,ConRelay,InpTz,InpDelay,InpReset,AlertLimit,LimitSchedule,catreader,catcode,catschedule,categories
      FROM Input
      WHERE PnlRef=@PnlRef AND InpNo&gt;= @InpNo ORDER BY PnlRef,InpNo
    </downloadinputs>
    <downloadlinks partitioned="False" notificationtable="Link">
      SELECT
      PnlRef,ProgNo,Enabled,Dialup,RptXact,LinkName as Description,Status,LnkPnl,LnkProg,ETz,TrkTZ,Inp1,Inp2,Inp3,Inp4,Inp5,On1,On2,On3,On4,On5,Off1,Off2,Off3,Off4,Off5,Trk1,Trk2,Trk3,Trk4,Trk5
      FROM Link
      WHERE PnlRef= @PnlRef
      AND ProgNo&gt;= @ProgNo
      ORDER BY ProgNo
    </downloadlinks>
    <downloadreaders partitioned="False">
      SELECT
      r.PnlRef,r.RdrNo,Enabled,RptByp,BypUnlock,OpnWait,NoOTL,NoXact,Escort,ManRule,ExtShunt,TZOvr,APBOvr,Keypad,NoDuress,CRForced,CROtl,CRDuress,CRTrack,CRVoid,CRApb,CRDenied,Ctz,Cctz,Cytz,Fatz,Fdd,Otl,Dst,APBType,TAType,LockCtl,Sensor,Strike,Bypass,Shunt,DurUse,Cyph,Type,MapId,DeviceId,DegrSchedule,ShuntTime,ManualPriv,TagTimeout,APBEntry,APBExit,CatCode,CatFilter,RepeatOTL,OTLSchedule,CatSchedule,BypCatControl,NAPCOAreas,TAAPBType,NoSound,AperioAddr,
      p.ValidPrior,p.DUPrior,p.TrkPrior,p.VPrior,p.APBPrior,p.BypPrior,p.FDPrior,p.FreePrior,p.OTLPrior,BadgeUseRegister
      ,r.DoubleReadFA,r.BypassLocks,r.RexOption,r.UseLedBar,r.ElevServerId,(select categories from ca_vw_getReaderCategories as v where v.PnlRef=r.PnlRef and v.RdrNo=r.Rdrno) as Categories
      FROM Reader r
      LEFT JOIN ReaderPriority p ON r.PnlRef = p.PnlRef and r.RdrNo=p.RdrNo
      WHERE r.PnlRef= @PnlRef AND r.RdrNo&gt;=@RdrNo  ORDER BY r.pnlref, r.RdrNo
    </downloadreaders>
    <downloadrelays partitioned="False" notificationtable="Relay">
      SELECT
      PnlRef,RelNo,RelayName as Description,Enabled,XactRpt,Dialup,NormOn,RelTime,TrackTz,Priority,caObjectID,RespReq
      FROM Relay
      WHERE PnlRef= @PnlRef
      AND RelNo&gt;= @RelNo
      ORDER BY PnlRef,RelNo
    </downloadrelays>
    <downloadschedules partitioned="False" notificationtable="MTimezon">
      SELECT TzNo,DayFrom,DayTo,FrHr,FrMin,ToHr,ToMin,m.HolGroups
      FROM Timezone t  LEFT JOIN MTimezon m ON t.TzNo=m.TzNum
      WHERE TzNo = @TzNo
      ORDER BY TzNo
    </downloadschedules>
    <downloadallschedules partitioned="False" notificationtable="MTimezon">
      SELECT TzNo,DayFrom,DayTo,FrHr,FrMin,ToHr,ToMin,m.HolGroups
      FROM Timezone t  LEFT JOIN MTimezon m ON t.TzNo=m.TzNum
      WHERE TzNo&gt;= @TzNo
      ORDER BY TzNo
    </downloadallschedules>
    <DVRCameraDelete partitioned="False">DELETE from DvrCamera WHERE DvrServerID=@DvrServerID</DVRCameraDelete>
    <DVRCameraList partitioned="True">
      SELECT  DvrCameraID, DvrServerID, ServerName, CameraName, C.EnableNotification, Tzno, Priority, DVRVendor, caObjectID, VendorCameraID
      FROM  dbo.DvrCamera C,dbo.DvrConfig D WHERE C.DvrServerID = D.DvrID and D.DvrID = @ServerID
      ORDER BY C.DvrCameraID
    </DVRCameraList>
    <dvrcameralookup partitioned="True" notificationtable="DvrCamera">
      Select DvrCameraID as ValueMember, CameraName as DisplayMember ,EnableNotification,TzNo,Priority,caObjectID,VendorCameraID
      From DvrCamera
      Where DvrServerID = @ServerID
    </dvrcameralookup>
    <APIdvrcameralookup partitioned="True" notificationtable="DvrCamera">
      Select DvrCameraID as ValueMember, CameraName as DisplayMember ,EnableNotification,TzNo,Priority,caObjectID,VendorCameraID
      From DvrCamera
      Where DvrServerID = @ServerID
    </APIdvrcameralookup>
    <DVRCameras partitioned="False">
      SELECT  DvrCameraID, CameraName, EnableNotification, Tzno, Priority, caObjectID, VendorCameraID
      FROM  dbo.DvrCamera WHERE DvrServerID = @ServerID and DvrCameraID = @CameraId
    </DVRCameras>
    <DVRCameraUpdate partitioned="False">exec ca_sp_DVRCameraUpdate @DVRCameraID , @DVRServerID ,@CameraName , @TzNum , @EnabledNotification, @Priority, @caObjectID,@LastOperator,@LastWorkStation,@VendorCameraID </DVRCameraUpdate>
    <DVRConfigCount partitioned="False">Select Count(*) From DVRConfig Where DVRID &lt;&gt;  '00000000-0000-0000-0000-000000000000'</DVRConfigCount>
    <dvrconfiglookup partitioned="False" notificationtable="DvrConfig">
      select DvrID as ValueMember, ServerName as DisplayMember from DvrConfig
      where DvrID in (SELECT DvrCamera.DvrServerID from DvrCamera
      inner join  devicepartitions on DvrCamera.caObjectID=DevicePartitions.caObjectID
      inner join  OperatorPartitions on devicepartitions.PartitionId = OperatorPartitions.Partitionid
      where OperatorPartitions.OperatorID = @OperatorID) OR DvrID='00000000-0000-0000-0000-000000000000'
    </dvrconfiglookup>
    <elevserverlookup partitioned="True" notificationtable="DvrConfig">
      select 0 as ValueMember, 'Not Used' as DisplayMember, 0 as ElevFacilityId from ElevServers
      Union
      select ServerID as ValueMember, ServerName as DisplayMember, ElevFacilityId from ElevServers
    </elevserverlookup>
    <GetAssignedElevServer partitioned="True" notificationtable="DvrConfig"> SELECT PnlRef,RdrNo,ElevServerId,caObjectID FROM Reader WHERE ElevServerId>0 AND ElevServerId=@ElevServerId </GetAssignedElevServer>
    <APIElevserverlookup partitioned="False">
      select ServerID as ValueMember, ServerName as DisplayMember, caObjectID  from ElevServers
    </APIElevserverlookup>
    <DVRDataUpdate partitioned="False">exec ca_sp_DVRDataUpdate 	@ServerIP, @ServerName ,@UID ,@PWD,	@Enabled ,	@NotifyEnabled ,@DVRVendor ,	@Type ,	@DVRID ,@ZoneID, @OperatorID, @LastWorkStation</DVRDataUpdate>
    <dvrvideogrid partitioned="False">
      select
      DVRId,ServerName,ServerIP,UserName,Password,UserType,Active,
      EnableNotification,DVRVendor,LastUpdated
      from dvrconfig
    </dvrvideogrid>
    <APIdvrvideogrid partitioned="False">
      select DVRId,ServerName,ServerIP,UserName,Password,UserType,Active, EnableNotification,DVRVendor,LastUpdated from dvrconfig
    </APIdvrvideogrid>
    <elevaglookup partitioned="False" notificationtable="ElevAg">SELECT PnlRef,RdrRef,AccGroup,RelayNumber FROM ElevAG Where PnlRef = @PnlRef ANd RdrRef=@RdrRef order by AccGroup,RelayNumber</elevaglookup>
    <elevagfloorlookup partitioned="False" notificationtable="ElevAgFloors">
      SELECT PnlRef,RdrRef,AccGroup,FloorNumber FROM ElevAgFloors WHERE PnlRef = @PnlRef ANd RdrRef=@RdrRef ORDER BY AccGroup,FloorNumber
    </elevagfloorlookup>
    <elevDefaultfloorlookup partitioned="False" notificationtable="ElevDefaultFloors">
      SELECT ServerId,FloorNumber,DoorType FROM ElevDefaultFloors WHERE ServerId = @ServerId
    </elevDefaultfloorlookup>
    <elevlookup partitioned="False" notificationtable="MAccGrp">SELECT a.AgNo, m.Description as "Access Group",t.Description as "Time Schedule" from AccGrp a INNER JOIN MAccGrp m ON m.AgrpNo = a.AgNo INNER JOIN MTimezon t ON t.TzNum = a.Tz{0} WHERE a.AgNo BETWEEN 1 AND 4095 AND PnlRef = @PnlRef AND Tz{0} &lt;&gt; 0 ORDER BY m.AGrpNo</elevlookup>
    <elevrelaylookup partitioned="False" notificationtable="Relay">
      select RelNo as ValueMember, Convert(Char(3),RelNo) + '- ' + Relayname as DisplayMember,PnlRef from Relay
      where pnlref = @pnlRef
    </elevrelaylookup>
    <elevfloorlookup partitioned="True" notificationtable="ElevFloors">
      select [FloorNumber] AS ValueMember, [FloorName] AS DisplayMember, ElevFacilityId from [ElevFloors]
    </elevfloorlookup>
    <APIElevfloorlookup partitioned="True" notificationtable="ElevFloors">
      select FloorNumber AS ValueMember, FloorName AS DisplayMember, ElevFacilityId, caObjectID from ElevFloors
    </APIElevfloorlookup>
    <GetElevatorWorkstations partitioned="False">
      select * from [WorkStationSettings] Where [SoftwareElevCtrl] = 1
    </GetElevatorWorkstations>
    <EmptyGatewayStatusTable partitioned="False">Delete from GatewayStatus</EmptyGatewayStatusTable>
    <EmptyLockStatusTable partitioned="False">Delete from LockStatus</EmptyLockStatusTable>
    <EnableBadge partitioned="False">
      UPDATE badge SET Enabled = 1, LastUpdated = @LastUpdated, LastWorkstation =@LastWorkstation
      WHERE Facility = @Facility  AND Badge = @Badge
    </EnableBadge>
    <EnablePerson partitioned="False">UPDATE badge SET Enabled =1,  LastUpdated = @LastUpdated , LastOperator =@LastOperator , LastWorkstation =@LastWorkstation WHERE PersonID = @PersonID</EnablePerson>
    <EnableReader partitioned="False">update reader set Enabled=1, LastUpdated = GetUTCDate()
where pnlref=@PnlRef and RdrNo=@RdrNo</EnableReader>
    <enforcedreaders partitioned="False">
      select 0 as ValueMember , 'All Local Readers' as DisplayMember
      union
      select RdrNo as ValueMember, ReaderName as DisplayMember from Reader where pnlref = @pnlno
    </enforcedreaders>
    <APIenforcedreaders partitioned="False">
      select 0 as ValueMember , 'All Local Readers' as DisplayMember
      union
      select RdrNo as ValueMember, ReaderName as DisplayMember from Reader
    </APIenforcedreaders>
    <eventlookup partitioned="False" notificationtable="ALPEventTypes">select EventCode as ValueMember, LangEventDescription as DisplayMember , EventCat from ALPEventTypes order by Description</eventlookup>
    <APIeventlookup partitioned="False" notificationtable="ALPEventTypes">select EventCode as ValueMember, LangEventDescription as DisplayMember , EventCat, Description from ALPEventTypes order by Description</APIeventlookup>
    <EventPartition partitioned="False">
      SELECT CAST(CAST(0 AS BINARY) AS UNIQUEIDENTIFIER) as PartitionID, 'None' as PartitionName
      UNION
      SELECT DISTINCT PartitionID,PartitionName
      FROM Partition
      WHERE PartitionID in (SELECT devicepartitions.caObjectID FROM OperatorPartitions inner join  devicepartitions ON devicepartitions.PartitionId = OperatorPartitions.PartitionID WHERE OperatorID = @OperatorID)
    </EventPartition>
    <facilitycodegrid partitioned="False">
      select
      PnlRef  as Panel
      ,p.PanelName as 'Panel Name'
      ,CAST(Facil1 as VARCHAR) as "Facility 1"
      ,CAST(Facil2 as VARCHAR) as "Facility 2"
      ,CAST(Facil3 as VARCHAR) as "Facility 3"
      ,CAST(Facil4 as VARCHAR) as "Facility 4"
      ,CAST(Facil5 as VARCHAR) as "Facility 5"
      ,CAST(Facil6 as VARCHAR) as "Facility 6"
      ,CAST(Facil7 as VARCHAR) as "Facility 7"
      ,CAST(Facil8 as VARCHAR) as "Facility 8"
      ,CAST(Facil9 as VARCHAR) as "Facility 9"
      ,CAST(Facil10 as VARCHAR) as "Facility 10"
      , f.LastUpdated as "Last Edit"
      , f.caObjectID
      from facility f
      inner join panel p on f.pnlref = p.pnlno
      where p.caObjectID in (SELECT devicepartitions.caObjectID FROM OperatorPartitions inner join  devicepartitions on devicepartitions.PartitionId = OperatorPartitions.Partitionid where OperatorPartitions.OperatorID = @OperatorID)
    </facilitycodegrid>
    <facilitylookupjoin partitioned="False">
      select
      f.PnlRef
      ,p.PanelName as PnlRefText
      from facility f
      inner join panel p on f.PnlRef = p.PnlNo
      where f.PnlRef = @PnlRef
    </facilitylookupjoin>
    <facilitymapsbyid partitioned="True">
      select MapId
      ,MapName
      ,MapDescription
      ,MapImage
      ,LastUpdated as "Last Edit"
      ,caObjectID
      from  facilitymap where MapId = @MapId
    </facilitymapsbyid>
    <facilitymapsgrid partitioned="True">
      select MapId
      ,MapName
      ,MapDescription
      ,MapImage
      ,LastUpdated as "Last Edit"
      ,caObjectID
      from  facilitymap
    </facilitymapsgrid>
    <apifacilitymapsgrid partitioned="True">
      select MapId
      ,MapName
      ,MapDescription
      ,MapImage
      ,LastUpdated as "Last Edit"
      ,caObjectID
      from  facilitymap
    </apifacilitymapsgrid>
    <facilitymapspoints partitioned="False">
      SELECT MapPointId,MapId,Type,PanelNo,DevNo,PtX,PtY
      FROM FacilityMapPoints
    </facilitymapspoints>
    <facilitymapspointsbydevice partitioned="False">
      SELECT MapPointId,MapId,Type,PanelNo,DevNo,PtX,PtY
      FROM FacilityMapPoints where Type = @Type and PanelNo=@PanelNo and DevNo=@DevNo
    </facilitymapspointsbydevice>
    <FirstInStatusGrid partitioned="False">
      select r.PnlRef,r.RdrNo, a.Areano,a.Description AS AreaName,a.Active,
      r.ReaderName, r.APBEntry, a.caObjectID, r.caObjectID caObjectIDReader FROM APBAreas a
      LEFT JOIN Reader r  on a.Areano=r.APBEntry or a.AreaNo=r.APBExit
      where a.caObjectID in
      (SELECT devicepartitions.caObjectID FROM OperatorPartitions inner join  devicepartitions on devicepartitions.PartitionId = OperatorPartitions.Partitionid  where  OperatorPartitions.OperatorID = @OperatorID)
      and a.AreaNo BETWEEN 239 and 254
      ORDER By a.AreaNo
    </FirstInStatusGrid>
    <formatlookupjoin partitioned="False">
      select
      fmtType
      ,case fmtType
      WHEN (1) THEN 'ABA'
      WHEN (129) THEN 'ABA - No Degrade'
      WHEN (0) THEN 'Non ABA'
      WHEN (128) THEN 'Non ABA - No Degrade'
      WHEN (2) THEN 'Insertion'
      WHEN (130) THEN 'Insertion - No Degrade'
      WHEN (3) THEN 'Key'
      WHEN (131) THEN 'Key - No Degrade'
      WHEN (64) THEN 'FacBadge'
      WHEN (192) THEN 'FacBadge - No Degrade'
      WHEN (23) THEN 'PIV (MSB)'
      WHEN (151) THEN 'PIV (MSB) - No Degrade'
      WHEN (24) THEN 'PIV (LSB)'
      WHEN (152) THEN 'PIV (LSB) - No Degrade'
      WHEN (25) THEN 'PIV200'
      WHEN (153) THEN 'PIV200 - No Degrade'
      END as fmtTypeText
      from format
      where fmtNo = @fmtNo

    </formatlookupjoin>
    <GetActiveThreatLevel partitioned="False">
      SELECT [LockdownID]      ,[CatNumber]      ,[Description]      ,[Active], [LockoutArea]      ,[LastUpdated]      ,[LockdownColor]
      FROM [dbo].[ca_vw_ThreatLevel] Where LockDownId = @LockdownID
    </GetActiveThreatLevel>
    <GetAllDevices partitioned="True">
      SELECT * FROM (
        SELECT 5 AS DeviceType, [PnlRef] AS PanelNo,[RdrNo] AS DeviceNo,[ReaderName] AS DeviceName,[caObjectID] FROM [Reader]
        UNION
        SELECT 2 AS DeviceType,  [PnlRef] AS PanelNo,[RelNo] AS DeviceNo,[RelayName] AS DeviceName,[caObjectID] FROM [Relay]
        UNION
        SELECT 3 AS DeviceType,  [PnlRef] AS PanelNo,[ProgNo] AS DeviceNo,[LinkName] AS DeviceName,[caObjectID] FROM [Link]
        UNION
        SELECT 10 AS DeviceType,  [PnlRef] AS PanelNo,[ProgNo] AS DeviceNo,[Description] AS DeviceName,[caObjectID] FROM [MActiveLinks]
      ) AS TAB
    </GetAllDevices>
    <GetAllDevicesEnable>
      SELECT * FROM (
      (SELECT 5 AS DeviceType, r.[PnlRef] AS PanelNo,r.[RdrNo] AS DeviceNo,r.[ReaderName] AS DeviceName, r.[caObjectID] FROM [Reader] r
      Inner Join Panel on Panel.PnlNo = r.PnlRef
      where Panel.Enabled = 1 and r.Enabled = 1
      and r.caObjectID IN (SELECT DP.caObjectID FROM OperatorPartitions OP JOIN Devicepartitions DP ON OP.PartitionID = DP.PartitionID WHERE OperatorID = @OperatorID)
      )
      UNION
      (SELECT 2 AS DeviceType,  rl.[PnlRef] AS PanelNo, rl.[RelNo] AS DeviceNo, rl.[RelayName] AS DeviceName, rl.[caObjectID] FROM [Relay] rl
      Inner Join Panel on Panel.PnlNo = rl.PnlRef
      where Panel.Enabled = 1 and rl.Enabled = 1
      and rl.caObjectID IN (SELECT DP.caObjectID FROM OperatorPartitions OP JOIN Devicepartitions DP ON OP.PartitionID = DP.PartitionID WHERE OperatorID = @OperatorID)
      )
      UNION
      SELECT 3 AS DeviceType,  [PnlRef] AS PanelNo,[ProgNo] AS DeviceNo,[LinkName] AS DeviceName, [caObjectID] FROM [Link] where Enabled = 1
      and caObjectID IN (SELECT DP.caObjectID FROM OperatorPartitions OP JOIN Devicepartitions DP ON OP.PartitionID = DP.PartitionID WHERE OperatorID = @OperatorID)
      UNION
      SELECT 10 AS DeviceType,  [PnlRef] AS PanelNo,[ProgNo] AS DeviceNo,[Description] AS DeviceName, [caObjectID] FROM [MActiveLinks] where Enabled = 1
      and caObjectID IN (SELECT DP.caObjectID FROM OperatorPartitions OP JOIN Devicepartitions DP ON OP.PartitionID = DP.PartitionID WHERE OperatorID = @OperatorID)
      ) AS TAB order by DeviceName ASC
    </GetAllDevicesEnable>
    <getadmincountnoncurrent partitioned="False">select count(*) from Operators where Enabled = 1 and IsGlobalAdministrator = 1 and OperatorId &lt;&gt; @OperatorId</getadmincountnoncurrent>
    <GetAGForPanel partitioned="False">select AgNo, tz1 FROM AccGrp WHERE PnlRef = @PnlRef</GetAGForPanel>
    <GetAlarmShuntInputs partitioned="False">SELECT S.PnlRef, S.InpRef, P.HCSNo FROM Panel as P INNER JOIN Shunt as S ON P.PnlNo = S.PnlRef WHERE S.ShuntId=@ShuntId</GetAlarmShuntInputs>
    <GetAlarmShuntInputsForHCS partitioned="False">SELECT S.PnlRef, S.InpRef, P.HCSNo FROM Panel as P INNER JOIN Shunt as S ON P.PnlNo = S.PnlRef WHERE S.ShuntId=@ShuntId AND P.HCSNo = @HCSNo</GetAlarmShuntInputsForHCS>
    <GetAllApbLocks partitioned="False">select PnlNo, ComPort, ApbType, ApbEntry FROM ca_vw_GetAPBLockLocks
    WHERE HCSNo=@HCSNo and (APBEntry &gt; 0) or (APBType &lt; 2) ORDER By ComPort, PnlNo</GetAllApbLocks>
    <GetAllBadgesWithPhoto partitioned="False">
      SELECT b.PersonId, b.Badge, b.Facility, p.LastName, p.FrstName, bp.BadgeImage
      FROM BadgePhoto bp INNER JOIN Badge b ON bp.personid = b.personid
      INNER JOIN Person p ON p.Personid = b.Personid
      WHERE bp.ImageTypeID = 0  AND CAST(CONVERT(VARCHAR(10), b.LastUpdated, 110) AS DATETIME) &gt;= CAST(CONVERT(VARCHAR(10), @LastUpdated, 110) AS DATETIME)
      AND b.PersonID IN (SELECT caObjectID FROM DevicePartitions WHERE PartitionID = @PartitionID)
    </GetAllBadgesWithPhoto>
    <getallobjects partitioned="false">exec ca_sp_GetPartitionData @ID,@Type,@OperatorID,@PartitionID</getallobjects>
    <getalloperatorprivileges partitioned="False" notificationtable="OperatorPrivileges">Select SecurityLevel, ScreenID from OperatorPrivileges Where OperatorID = @OperatorID And ScreenObjectID=0</getalloperatorprivileges>
    <getalloperatorprivilegesfieldchanged partitioned="False">Select distinct ScreenID from OperatorPrivileges Where OperatorID = @OperatorID AND SecurityLevel&gt;0 and SecurityLevel&lt;3</getalloperatorprivilegesfieldchanged>
    <getallpartitions partitioned="False">
      Select PartitionID,PartitionName,DeviceType From [Partition] p
      Where PartitionID not in (Select PartitionID From OperatorPartitions Where OperatorID = @OperatorID)
      Order By PartitionID
    </getallpartitions>
    <getoperatorsbyroleid>
      Select OperatorID from Operators where RoleID = @RoleID
    </getoperatorsbyroleid>
    <GetAllTimeSchedules partitioned="False">select TzNo, DayFrom,DayTo,Frhr,FrMin,ToHr,ToMin from Timezone order by TzNo</GetAllTimeSchedules>
    <GetAllWirelessComPorts partitioned="False">
      SELECT C.ComPort, C.HCSNo, C.MACAddress, C.Passwrd, C.IPAddress, C.RFChannel, C.RFGroup, C.SyncWordUpper, C.SyncWordLower,
      C.HostIPAddress, C.GatewayPort, C.ZoneId
      FROM  MCom  MC INNER JOIN Com C ON MC.HCSNo = C.HCSNo
      WHERE C.Type=10 and MC.caObjectID in (SELECT devicepartitions.caObjectID FROM OperatorPartitions inner join  devicepartitions on devicepartitions.PartitionId = OperatorPartitions.Partitionid where OperatorPartitions.OperatorID = @OperatorID)
      order by HCSNo, ComPort
    </GetAllWirelessComPorts>
    <GetApbAreaLocks partitioned="False">
      select PnlNo, ComPort, ApbType, ApbEntry FROM ca_vw_GetAPBLockLocks
      WHERE HCSNo=@HCSNo and APBEntry between 2 and 254 ORDER By ComPort, PnlNo</GetApbAreaLocks>
    <GetAPBAreaName partitioned="False">SELECT Description from APBAreas WHERE AreaNo=@AreaNo</GetAPBAreaName>
    <GetAPBAreaByApbNo partitioned="False">SELECT Description, ParentArea, AlertOn, LinkVacant, LinkOccupied, AreaCountUp, LinkOnCountUp, AreaCountDown, LinkOnCountDown, Active, caObjectID, SchedLocked from APBAreas WHERE AreaNo=@AreaNo</GetAPBAreaByApbNo>
    <GetApbLocks partitioned="False">select PnlNo, ComPort, ApbType, ApbEntry, Active FROM ca_vw_GetAPBLockLocks
      WHERE HCSNo=@HCSNo and APBEntry=@APBEntry ORDER By ComPort, PnlNo</GetApbLocks>
    <getassignedpartitions partitioned="False">
      Select Distinct P.PartitionID,P.PartitionName,P.DeviceType From [Partition] P,OperatorPartitions OP
      Where OP.OperatorID = @OperatorID
      AND P.PartitionID = OP.PartitionID
    </getassignedpartitions>
    <getassignedpartitionsbyroleid partitioned="False">
      Select Distinct P.PartitionID,P.PartitionName,P.DeviceType From [Partition] P,RolePartitions RP
      Where RP.RoleID = @RoleID
      AND P.PartitionID = RP.PartitionID
    </getassignedpartitionsbyroleid>
    <getassignedroles partitioned="False">
      select g.displayName,g.pluginAssembly,g.availPartGroups,r.RoleID,r.pluginId
      from roleplugins r
      inner join guiplugins g on r.pluginid = g.pluginid
      where r.roleid = @roleid
      order by g.displayname
    </getassignedroles>
    <GetAvailableComPort partitioned="False">select ComPort, Type from Com where ComPort=@ComPort and HCSNo = @HCSNo</GetAvailableComPort>
    <GetBadgeEvent partitioned="False">exec ca_sp_GetBadgeEvent @Facility,@Badge,@APBType,@pnl,@rdr,@toggle,@UseCtrl,@WasEnab,@TStamp,@NewArea</GetBadgeEvent>
    <GetBadgeFormatLookup partitioned="False">
      SELECT Format_ID AS ValueMember, Format_Name AS DisplayMember
      FROM EPI_FORMAT
      WHERE
      templateFileID IN (SELECT DP.caObjectID FROM OperatorPartitions OP JOIN Devicepartitions DP ON OP.PartitionID = DP.PartitionID WHERE OperatorID = @OperatorID)
    </GetBadgeFormatLookup>
    <GetBadgeFormats partitioned="False">Select FmtNo, FmtLength,FmtType,FmtSS,FmtSSO,FmtES,FmtESO,FmtFS,FmtFSO,FmtCLen,FmtCOff,FmtILen,FmtIOff,FmtFLen,
      FmtFOff,FmtDLen,FmtDOff,FmtCSLen,FmtCSOff,FmtPILen,FmtPIOff,FmtOCLen,FmtOCOff,FmtOILen,FmtOIOff,FmtPOALen,FmtPOAOff
      From Format
    </GetBadgeFormats>
    <GetBadgeName partitioned="False">
      select LastName+', '+FrstName as Name, b.Track, p.PersonId, b.APBSet from Person as p inner join
      Badge as b on p.PersonID = b.PersonID where
      b.badge = @Badge and b.Facility = @Facility
    </GetBadgeName>
    <GetBadgeTemplate partitioned="False">
      SELECT     EPI_FORMAT.Format_ID, EPI_FORMAT.Format_Name, EPI_FORMAT.Format_Layout, EPI_FORMAT.templateFileID, epiFiles.templateFileData
      FROM         EPI_FORMAT INNER JOIN
      epiFiles ON EPI_FORMAT.templateFileID = epiFiles.templateFileID
      WHERE     (EPI_FORMAT.Format_ID = @Format_ID)
    </GetBadgeTemplate>
    <GetBadgeTemplateName partitioned="False">
      SELECT     EPI_FORMAT.Format_ID, EPI_FORMAT.Format_Name, EPI_FORMAT.Format_Layout, EPI_FORMAT.templateFileID, epiFiles.templateFileData
      FROM         EPI_FORMAT INNER JOIN
      epiFiles ON EPI_FORMAT.templateFileID = epiFiles.templateFileID
      WHERE     (EPI_FORMAT.Format_Name = @Format_Name)
    </GetBadgeTemplateName>
    <GetBadgeTemplates partitioned="False">
      SELECT Format_ID, Format_Name, templateFileID
      FROM EPI_FORMAT
      WHERE
      templateFileID IN (SELECT DP.caObjectID FROM OperatorPartitions OP JOIN Devicepartitions DP ON OP.PartitionID = DP.PartitionID WHERE OperatorID = @OperatorID)
      ORDER BY Format_Name
    </GetBadgeTemplates>
    <GetBadgingFieldList partitioned="False">exec ca_sp_GetBadgingFieldList</GetBadgingFieldList>
    <GetCategoryCounterForAlert partitioned="False">select pnlNo,CatNo, Description, Priority, RespReq, EventMsg FROM CategoryCounters
where PnlNo = @PnlNo and CatNo=@CatNo</GetCategoryCounterForAlert>
    <GetCategoryCounters partitioned="False">select PnlNo,CatNo,LowWater,HiWater From CategoryCounters WHERE PnlNo=@PnlNo</GetCategoryCounters>
    <GetComFromComPort partitioned="False">select IPAddress, IPPort, MACAddress, ZoneId,RFChannel, RFGroup,SyncWordUpper, SyncWordLower, UseDHCP,DHCPName,SubNetMask,WirelessMode,NetworkType,WiFiChannelNo,SecurityType, Authentication, GatewayEncryption, KeyType,key1Value,SSIDName,GatewayIPAddress
From Com WHERE ComPort=@ComPort and HCSNo=@HCSNo and Type=10</GetComFromComPort>
    <GetComPortByCom partitioned="False">
      select HCSNo,ComPort,MACAddress,IPAddress, Passwrd,RFChannel,RFGroup,SyncWordUpper, SyncWordLower,GatewayPort,ZoneId,HostIPAddress,UseDHCP,DHCPName,
      SubNetMask,WirelessMode,NetworkType,WiFiChannelNo,SecurityType, Authentication, GatewayEncryption, KeyType,key1Value,
      SSIDName,GatewayIPAddress From Com WHERE ComPort=@ComPort and HCSNo=@HCSNo and Type=10
    </GetComPortByCom>
    <GetComFromMac partitioned="False">select ComPort,HCSNo, UseDHCP, SubNetMask, GatewayIPAddress, NetworkType, WirelessMode, WiFiChannelNo,SecurityType,Authentication, GatewayEncryption, KeyType, Key1Value, DHCPName,SSIDName  from Com WHERE MACAddress=@MACAddress</GetComFromMac>
    <SaveComFromMac partitioned="False">
      Update Com
      SET	  UseDHCP = @UseDHCP,
            DHCPName = @DHCPName,
            WirelessMode = @WirelessMode,
            IPAddress = @GatewayIPAddress,
            SubNetMask = @SubNetMask,
            GatewayIPAddress = @DnsGatewayIpAddress,
            SecurityType = @SecurityType,
            [Authentication] = @Authentication,
            GatewayEncryption = @GatewayEncryption,
            KeyType = @KeyType,
            Key1Value = @Key1Value,
            SSIDName = @SSIDName,
            NetworkType = @NetworkType,
            WifiChannelNo = @ChannelNumber
      WHERE MACAddress=@MACAddress
    </SaveComFromMac>
    <getcoreobjectdeflist partitioned="False">
      select objectType, objectTypeName, editorFullClassName, quickFullClassName, parentObjectType, treeResultsQuery, parentTreeResultsQuery, showAddNewMenu, allowChildrenIfNew, showChildPlaceholders, showShowUsageMenu
      ,showShowEventMenu, showAsDialog
      from dbo.coreObjectDefs order by parentObjectType, objectType
    </getcoreobjectdeflist>
    <GetCounterValue partitioned="False" notificationtable="scriptCounters">SELECT counterVal FROM ScriptCounters WHERE CounterName = @CounterName </GetCounterValue>
    <GetCustomMenus partitioned="False">SELECT caObjectID, DisplayName, ApplicationPath from CustomMenuSettings ORDER BY DisplayName</GetCustomMenus>
    <getdialupcount partitioned="False" notificationtable="ComServer">
      SELECT Count(*) as count
      FROM ComServer WHERE Record = -25
      AND val1 = @val1
    </getdialupcount>
    <getdialupdevice partitioned="False" notificationtable="Nodes">
      SELECT DevIdOut FROM Nodes WHERE NodeId = @NodeId  AND HCSNo = @HCSNo
    </getdialupdevice>
    <getdialupinfo partitioned="False" notificationtable="Nodes">
      SELECT
      NodeId,NodeName as Description,Phone,HCSNo,Schedule,Frequency,Setup1,Setup2,DevIdIn,DevIdOut,Status,HostPhone1,HostPhone2,LastUpdated
      FROM Nodes
      WHERE NodeId = @NodeId  AND HCSNo = @HCSNo
    </getdialupinfo>
    <getdvrservers partitioned="False">exec ca_sp_DVRConfiguration @IDVRVendor,@CatType,@isActive,@DVRServer,@OperID</getdvrservers>
    <getdvrserverspartitioned partitioned="False">exec ca_sp_DVRConfiguration @IDVRVendor,@CatType,@isActive,@DVRServer,@OperID,@OperatorID</getdvrserverspartitioned>
    <getepibadgedata partitioned="False">exec ca_sp_GetEpiBadgeData @PersonID, @Badge, @Facility</getepibadgedata>
    <GetEpiBadgeFormat partitioned="False">
      SELECT     EPI_FORMAT_ID
      FROM         Badge
      WHERE     (PersonID = @PersonID) AND (Badge = @Badge) AND (Facility = @Facility)
    </GetEpiBadgeFormat>
    <GetEpiBadgeImageData partitioned="False">
      SELECT     PersonID, ImageTypeID, BadgeImage, LastWorkStation, LastOperator, LastUpdates
      FROM         BadgePhoto
      WHERE     (PersonID = @PersonID)
    </GetEpiBadgeImageData>
    <GetEpiImageType partitioned="False" notificationtable="GA_IMAGEINFO">
      SELECT     Image_ID, Image_Name, Image_Format_Scheme, Image_Max_Size, Image_Format, Image_Format_BitDepth, Image_Format_Quality,
      Image_Format_Subsample, Image_Aspect_X, Image_Aspect_Y, Image_Thumbnail_Width, Image_Thumbnail_Height, Image_Storage_Scheme,
      Image_Storage_Path, Image_Storage_AutoSubDirs
      FROM         GA_IMAGEINFO
    </GetEpiImageType>
    <getEventClassCatDefs partitioned="False">Select EventClassCatID,EventClassCatName from eventclasscategorydefs</getEventClassCatDefs>
    <getEventClassNames partitioned="False">Select EventClassName From EventClassDefs where EventClassCategoryID = @CatID</getEventClassNames>
    <GetFacilitys partitioned="False">select PnlRef,Facil1,Facil2,Facil3,Facil4,Facil5,Facil6,Facil7,Facil8,Facil9,Facil10
FROM Facility WHERE PnlRef = @PnlRef</GetFacilitys>
    <APIGetFacilitys partitioned="False">
      select PnlRef,Facil1,Facil2,Facil3,Facil4,Facil5,Facil6,Facil7,Facil8,Facil9,Facil10, caObjectID
      FROM Facility WHERE PnlRef = @PnlRef
    </APIGetFacilitys>
    <GetRepeaterStatus partitioned="False">
      select Cluster,ComPort,rfAddress,Id,RouteIn,RouteOut,State,RSSI,FirmwareMajor,FirmwareMinor,Status from RepeaterStatus WHERE Cluster=@Cluster and ComPort=@ComPort and rfAddress=@rfAddress
    </GetRepeaterStatus>
    <GetAllRepeaterStatus partitioned="False">
      select Cluster,ComPort,rfAddress,Id,RouteIn,RouteOut,State,RSSI,FirmwareMajor,FirmwareMinor,Status from RepeaterStatus WHERE Cluster=@Cluster and ComPort=@ComPort
    </GetAllRepeaterStatus>
    <GetGatewayStatus partitioned="False">select comport,macaddress,ipaddress,version,status,LockCount,HasRepeaters,RepeaterCount,GroupNo,LastUpdated from GatewayStatus WHERE MACAddress=@MACAddress</GetGatewayStatus>
    <GetGlobalActiveLinks partitioned="False" notificationtable="ActiveLinks">
      SELECT a.PnlNo,a.RelNo,a.RdrNo,a.InpNo,a.CatNo,a.Control, p.HCSNo, a.catreader FROM ActiveLinks a
      INNER JOIN Panel p ON p.PnlNo = a.PnlNo
      WHERE a.PnlRef = @PnlRef AND a.ProgNo = @ProgNo AND a.PnlRef &lt;&gt; a.PnlNo
    </GetGlobalActiveLinks>
    <GetGlobalVariables partitioned="False">select variableValue From GlobalVariables Where VariableName = @VariableName</GetGlobalVariables>
    <getholidayinfo partitioned="False">exec ca_sp_GetHoliday @Grp , @Hol</getholidayinfo>
    <GetHolidays partitioned="False">select CalendarNo,HolNo,SDate,FromTime,FrHr,FrMin,EndHr,EndMin From Holiday
WHERE SDate &gt;= GetDate() and SDate &lt; (GetDate() + 62)</GetHolidays>
    <getinputinfo partitioned="False" notificationtable="Input">
      SELECT  InputName as Description,DvrServerID, VideoEventType, EnableRecording

      FROM Input WHERE PnlRef = @PnlRef AND InpNo =@InpNo
    </getinputinfo>
    <GetLinkedServers partitioned="False">SELECT server_id, name FROM sys.servers WHERE is_linked = 1</GetLinkedServers>
    <getlinkinfo partitioned="False" notificationtable="Link">
      SELECT
      RptXact,LinkName as Description
      FROM Link
      WHERE PnlRef= @PnlRef
      AND ProgNo&gt;= @ProgNo
    </getlinkinfo>
    <APIgetlinkinfo partitioned="False" notificationtable="Link">
      SELECT LinkName,caObjectID FROM Link WHERE PnlRef= @PnlRef AND ProgNo = @ProgNo
    </APIgetlinkinfo>
    <getlinkservers partitioned="False">use master select srvname from sysservers</getlinkservers>
    <getlivevideo partitioned="False">
      SELECT     r.DvrServerID,  r.DvrCameraID, d.ServerIP, d.DVRVendor, d.UserName, d.Password,
      r.RecordingSchedule, r.VideoPriorityFrom, r.VideoPriorityTo, r.VideoStartTime,
      r.VideoEndTime, r.EnableRecording, r.NoofSecsToRecord,
      r.EnablePTZPreset, r.PTZPresetNo, r.RecordingSchedule, d.ZoneID, ISNULL(z.UTCBias, 0) UTCBias,z.StandardName, C.VendorCameraID
      FROM       Reader AS r
      INNER JOIN DvrCamera C ON r.DvrCameraID = C.DvrCameraID AND r.DvrServerID = C.DvrServerID
      INNER JOIN DvrConfig AS d ON r.DvrServerID = d.DvrID
      LEFT OUTER JOIN Zones AS Z ON Z.ZoneId = d.ZoneID
      where r.PnlRef = @PanelNo and r.RdrNo = @DeviceNo
    </getlivevideo>
    <getlivevideo2 partitioned="False">
      SELECT     c.DvrServerID,  c.DvrCameraID, d.ServerIP, d.DVRVendor, d.UserName, d.Password,
      0 AS VideoStartTime,z.StandardName,
      50 AS VideoEndTime, ISNULL(Z.UTCBias, 0) UTCBias, VendorCameraID
      FROM       DvrCamera AS c 
      INNER JOIN DvrConfig AS d ON c.DvrServerID = d.DvrID 
      LEFT OUTER JOIN Zones AS Z ON Z.ZoneId = d.ZoneID
      where c.caObjectID = @ObjGUID
    </getlivevideo2>
    <getlivevideoforinput partitioned="False">
      SELECT  I.DvrServerID,  I.DvrCameraID, d.ServerIP, d.DVRVendor, d.UserName, d.Password,
      I.RecordingSchedule, I.VideoStartTime,
      I.VideoEndTime, I.EnableRecording, I.NoofSecsToRecord,
      I.EnablePTZPreset, I.PTZPresetNo, I.RecordingSchedule, d.ZoneID, ISNULL(z.UTCBias, 0) UTCBias,z.StandardName, C.VendorCameraID
      FROM       Input AS I
      INNER JOIN DvrCamera C ON I.DvrCameraID = C.DvrCameraID AND I.DvrServerID = C.DvrServerID
      INNER JOIN DvrConfig AS d ON I.DvrServerID = d.DvrID
      LEFT OUTER JOIN Zones AS Z ON Z.ZoneId = d.ZoneID
      where I.PnlRef = @PanelNo and I.InpNo = @DeviceNo
    </getlivevideoforinput>
    <getlivevideofornapcopanelzone partitioned="False">
      SELECT  NZ.DvrServerID,  NZ.DvrCameraID, d.ServerIP, d.DVRVendor, d.UserName, d.Password,
      NZ.RecordingSchedule, NZ.VideoStartTime,
      NZ.VideoEndTime, NZ.EnableRecording, NZ.NoofSecsToRecord,
      NZ.RecordingSchedule, d.ZoneID, ISNULL(z.UTCBias, 0) UTCBias,z.StandardName, C.VendorCameraID
      FROM  napcoPanelZones AS NZ
      INNER JOIN DvrCamera C ON NZ.DvrCameraID = C.DvrCameraID AND NZ.DvrServerID = C.DvrServerID
      INNER JOIN DvrConfig AS d ON NZ.DvrServerID = d.DvrID
      LEFT OUTER JOIN Zones AS Z ON Z.ZoneId = d.ZoneID
      where NZ.AlarmPanelID = @PanelNo and NZ.ZoneNumber = @DeviceNo
    </getlivevideofornapcopanelzone>
    <GetActiveLockdownArea partitioned="False" notificationtable="MLockdownAreas">
      SELECT MLockdownAreas.AreaNo, MLockdownAreas.AreaName, MLockdownAreas.Categories, MLockdownAreas.DenyCategory, MLockdownAreas.caObjectID
      FROM MLockdownAreas INNER JOIN DevicePartitions ON MLockdownAreas.caObjectID = DevicePartitions.caObjectID
      INNER JOIN OperatorPartitions ON DevicePartitions.PartitionID = OperatorPartitions.PartitionID
      WHERE Active = 1 AND OperatorPartitions.OperatorID=@OperatorID
    </GetActiveLockdownArea>
    <GetLockdownArea partitioned="False" notificationtable="MLockdownAreas">
      SELECT AreaNo, AreaName, Active, Categories, DenyCategory, caObjectID, LastUpdated, LastOperator, LastWorkStation
      FROM MLockdownAreas
      WHERE AreaNo = @AreaNo
    </GetLockdownArea>
    <GetLockdownAreaLocks partitioned="False" notificationtable="LockdownAreas">
      SELECT l.PnlRef, l.RdrNo, m.Active, m.Categories, m.DenyCategory, m.AreaName, m.caObjectID,p.ComPort,p.LockId FROM   LockdownAreas AS l
      INNER JOIN  Panel AS p ON l.PnlRef = p.PnlNo
      INNER JOIN MLockdownAreas m ON l.AreaNo=m.AreaNo
      WHERE p.Enabled = 1 AND (p.HCSNo = @HCSNo) AND (l.AreaNo=@AreaNo) and (p.PanelType &gt; 99)
		  ORDER BY PnlRef
	  </GetLockdownAreaLocks>
    <GetLockdownAreaName partitioned="False" notificationtable="MLockdownAreas">Select AreaName from MLockdownAreas WHERE AreaNo = @AreaNo</GetLockdownAreaName>
    <GetLockdownAreaNames partitioned="True">SELECT AreaNo,AreaName,Active,ActiveByOper from MLockdownAreas ORDER BY AreaNo</GetLockdownAreaNames>
    <GetLockdownAreaPanels partitioned="False" notificationtable="LockdownAreas">
      SELECT l.PnlRef, l.RdrNo, m.Categories, m.DenyCategory, m.AreaName  FROM      LockdownAreas AS l
      INNER JOIN  Panel AS p ON l.PnlRef = p.PnlNo
      INNER JOIN MLockdownAreas m ON l.AreaNo=m.AreaNo
      WHERE p.Enabled = 1 AND (p.HCSNo = @HCSNo) AND (l.AreaNo=@AreaNo) and (p.PanelType &lt; 100)
      ORDER BY PnlRef
    </GetLockdownAreaPanels>
    <GetPanelStatus partitioned="False">select Version,Status MaxCards, UsedCards,MaxAG, UsedAG,MaxXact,SDate  From Status where Panel=@PnlRef and HCSNo=@Hcsno</GetPanelStatus>
    <GetLockForAlert partitioned="False">
      select PnlNo, PanelName, CommPrior,DwnloadPrior,PwrPrior,DegradeMode,LockType,
      RespoffOnLine,RespDownloads,RespACPowerFail,ZoneId,LockId,LockUpdateSchedule, caObjectID FROM Panel WITH (NOLOCK) WHERE LockID = @LockId</GetLockForAlert>
    <GetLockFromId partitioned="False">Select PnlNo From Panel where LockId=@LockId</GetLockFromId>
    <GetLockFromLockId partitioned="False">
      select  PnlNo,HCSNo,ComPort,Address,LockType,PanelType,LockId,
        PanelName,Interactive,NoFail,Elevators,Passwrd,DegradeMode,
        XactSize,Schedules,CommPrior,MaxAlp,MaxEvt,ZoneId,LockAssigned,LockExpAddress,
        DefaultCalendar,RetrievalSchedule,LastUpdated,caObjectId
        from Panel
      where LockId= @Lockid
    </GetLockFromLockId>
    <GetLockIPs partitioned="False">Select ComPort, IPAddress, IPPort,MACAddress FROM Com WHERE Type=10 and HCSNo=@HCSNo and MACAddress like '%[0-9]%' and  IPAddress like '%[0-9]%'
  order by ComPort</GetLockIPs>
    <GetLocksAndThreatCats partitioned="False">select * from ca_vw_PanelThreatlevels where hcsno=@HCSNo AND LockdownID=@LockdownID and (PanelType between 101 and 102) order by comport,pnlno</GetLocksAndThreatCats>
    <GetLocksChanged partitioned="False">
      select PnlNo from Panel WITH (NOLOCK) WHERE (LockChanged = 1) and (PnlNo = @PnlNo)
      and ((LockUpdateSchedule = 2) or ((LockUpdateSchedule = 3) and (@NewWeek = 1)))</GetLocksChanged>
    <GetLocksForCom partitioned="False">select PnlNo from Panel Where comPort=@ComPort and HCSNo=@HCSNo</GetLocksForCom>
    <GetLocksInComPort partitioned="False">
      Select p.PnlNo, p.Address, p.LockID, p.PanelName, p.LockType, ls.RxRSSI, ls.TxRSSI, ls.Version, ls.Assigned, ls.Status, ls.Battery, ls.LastUpdated,
      CASE WHEN p.LastUpdated &gt; ls.LastUpdated      THEN p.LockExpAddress
      WHEN ls.RepeaterAddress&gt;209 AND ls.RepeaterAddress&lt;=231 THEN ls.RepeaterAddress
      ELSE p.LockExpAddress
      END AS [LockExpAddress]
      From Panel p
      Left Outer Join LockStatus ls on p.PnlNo = ls.PnlRef AND p.ComPort = ls.ComPort WHERE p.ComPort=@ComPort and p.HCSNo=@HCSNo</GetLocksInComPort>
    <GetLocksStatusByComPort partitioned="False">select PnlRef, ComPort, RxRSSI, TxRSSI, Version, Assigned, LockType, LockId, Status, LastUpdated From LockStatus where ComPort = @ComPort </GetLocksStatusByComPort>
    <GetLockStatus partitioned="False">select PnlRef, ComPort, RxRSSI, TxRSSI, Version, Assigned, LockType, LockId, Status, LastUpdated  From LockStatus where PnlRef=@PnlRef and ComPort = @ComPort</GetLockStatus>
    <GetLocksWithApbExit partitioned="False">select PnlNo from Panel inner join Reader on PnlNo=PnlRef and 
APBExit=@ApbExit</GetLocksWithApbExit>
    <GetLocksWithAreaEntry partitioned="False">select PnlNo from Panel inner join Reader on PnlNo=PnlRef and 
APBEntry=@ApbEntry</GetLocksWithAreaEntry>
    <getmap partitioned="False">exec ca_sp_GetMap @MapUID, @OperatorID ,@IsPartitioned</getmap>
    <getmcomkey partitioned="False">select caObjectId from MCom WHERE HCSNo=@HCSNo</getmcomkey>
    <APIgetmcomkey partitioned="False">select caObjectId from MCom WHERE HCSNo=@HCSNo</APIgetmcomkey>
    <getmcomname partitioned="False">select Description, UNCName from MCom Where HCSNo=@HCSNo</getmcomname>
    <GetMessageTemplate partitioned="False" notificationtable="MessageTemplates">Select Subject, Body, allowSNPP, allowEmail, allowSMS,include From MessageTemplates where templateID = @templateID</GetMessageTemplate>
    <GetMLockdownAreaLocks partitioned="False" notificationtable="MLockdownAreas">
      SELECT AreaNo, AreaName, Active, Categories, DenyCategory, caObjectID, LastUpdated, LastOperator, LastWorkStation
      FROM MLockdownAreas
      WHERE (p.HCSNo = @HCSNo) AND (l.AreaNo=@AreaNo) and (p.PanelType &gt; 99)
      ORDER BY PnlRef
    </GetMLockdownAreaLocks>
    <GetNapcoUserForBadge partitioned="False" notificationtable="napcoPanelUsers">SELECT UserNumber FROM napcoPanelUsers WHERE AlarmPanelID = @AlarmPanelID  AND Facility = @Facility  AND Badge = @Badge </GetNapcoUserForBadge>
    <GetNewLock partitioned="False">select PnlNo, Address, HCSNo, LockId,Enabled, PanelType, LockType, LockAssigned,LockExpAddress, PanelName  from Panel Where HCSNo=@HCSNo and ComPort=@ComPort and Address = @Address</GetNewLock>
    <GetNextPanel partitioned="False">select MAX(PnlNo)  PnlNo from Panel</GetNextPanel>
    <getnextserver partitioned="False" notificationtable="ComServer">
      SELECT  TOP 1
      ComID,WorkstationID,Record,Val1,Val2,Val3,Val4,Val5,pkt,LastUpdated
      FROM ComServer
      WHERE Record &lt;&gt; 0
    </getnextserver>
    <getnodeinfo partitioned="False" notificationtable="Nodes">
      SELECT
      NodeId,NodeName as Description,Phone,HCSNo,Schedule,Frequency,Setup1,Setup2,DevIdIn,DevIdOut,Status,HostPhone1,HostPhone2,LastUpdated
      FROM Nodes
      WHERE HCSNo = @HCSNo
    </getnodeinfo>
    <getonepartition partitioned="False" notificationtable="Partition">
      Select PartitionID,PartitionName from [Partition]
      Where PartitionID = @PartitionID
    </getonepartition>
    <GetOperatorMessageSettings partitioned="False" notificationtable="Operators">SELECT OperUseSNPP, OperUseEmail, EmailID, OperSNPPHostID, PagerID,OperUseSMS,OperSMSHostID, PhoneNo FROM Operators WHERE OperatorID = @OperatorID</GetOperatorMessageSettings>
    <getoperatorprivileges partitioned="False" notificationtable="OperatorPrivileges">Select SecurityLevel from OperatorPrivileges Where OperatorID = @OperatorID And ScreenID =@ScreenID And ScreenObjectID=@ScreenObjectID</getoperatorprivileges>
    <getallprivilegesbyroleid partitioned="False" notificationtable="RolePrivileges">SELECT RoleID, ScreenID, ScreenObjectID, SecurityLevel FROM RolePrivileges WHERE RoleID = @RoleID</getallprivilegesbyroleid>
    <privilegeexistsbyroleid partitioned="False">SELECT 1 FROM RolePrivileges WHERE RoleID=@RoleID</privilegeexistsbyroleid>
    <deleteroleprivilegesbyroleid partitioned="False">DELETE FROM RolePrivileges WHERE RoleID=@RoleID</deleteroleprivilegesbyroleid>
    <GetPanelDownloadDataByBadge partitioned="False">
      Facility,Badge,Pin,Issue,Enabled,Track,Resident,InitLoad,Shunt,DurUse,Escort,AccessTime,UseCount,AGSeq,Expr1,PnlNo,APBSet,APBArea,Agno,MApbExempt,HolidayCalendar,VehicleTag,AGroupNo,AgencyCode,SiteNo,Series,PersPIVId,OrgCategory,OrgId,OrgAssoc,FirstInControl
      From
      ca_vw_PanelDownload
      Where Badge=@Badge
    </GetPanelDownloadDataByBadge>
    <getpaneldownloaddatadybadge partitioned="False"> select * from ca_vw_PanelDownload where Badge=@Badge</getpaneldownloaddatadybadge>
    <getpanelfornode partitioned="False" notificationtable="Panel">
      select
      PnlNo
      ,PanelName
      ,PanelName as Description
      ,Address
      ,ComPort
      ,HCSNo
      ,Enabled
      ,Interactive
      ,NoFail
      ,XactSize
      ,Node
      ,MapId
      ,DeviceId
      ,CommPrior
      ,DwnLoadPrior
      ,PwrPrior
      ,Schedules
      ,Elevators
      ,ModemPrior
      ,Passwrd
      ,CurrentPwd
      ,DegradeMode
      ,AGSize
      ,Location
      ,Remarks
      ,PanelType
      ,caObjectID
      ,MaxAlp
      ,MaxEvt
      ,DefaultCalendar
      ,NAPCOPanel
      ,NoPolling
      ,RespOffOnLine
      ,RespDownloads
      ,RespACPowerFail
      ,RespModemActivity
      ,LastUpdated
      FROM Panel WHERE Enabled = 1
      AND Node = @Node
    </getpanelfornode>
    <GetPanelFromNumber partitioned="False">
      select PnlNo,PanelName,Address,ComPort,HCSNo,Enabled,NoFail,XactSize,Schedules,Degrademode,PanelType,MaxAlp
      ,MaxEvt,DefaultCalendar,Zoneid,LockId,LockUpdateSchedule,RetrievalSchedule,LockType,LockAssigned,LockExpAddress,LockChanged
      ,RemoteDevice FROM Panel WHERE PnlNo=@PnlNo</GetPanelFromNumber>
    <GetPanelLocalTime partitioned="False">exec ca_sp_GetZoneLocalTime @zoneid</GetPanelLocalTime>
    <GetAllPanelLocalTime partitioned="False">
      SELECT P.PnlNo, P.Enabled, P.PanelName, P.HCSNo, p.ComPort, P.Enabled, P.PanelType, P.LockType, Z.ZoneId, Z.UTCBias,
      CASE
      WHEN DateAdd(mi, Z.UTCBias*-1, GetUTCDate()) &gt; Z.dStart AND DateAdd(mi, Z.UTCBias*-1, GetUTCDate()) &lt; Z.sStart
      THEN CAST(DateAdd(mi, Z.dBias*-1, DateAdd(mi, Z.UTCBias*-1, GetUTCDate()))  AS smalldatetime)
      ELSE CAST(DateAdd(mi, Z.UTCBias*-1, GetUTCDate()) AS smalldatetime)
      END AS PanelLocalTime,
      Z.StandardName
      FROM Zones Z INNER JOIN Panel P ON Z.ZoneId = P.ZoneId
      ORDER BY PanelLocalTime ASC
    </GetAllPanelLocalTime>
    <getpanelsforcom partitioned="False">select PnlNo FROM ca_vw_getpanelsforcom WHERE ComPort=@ComPort and HCSNo=@HCSNo</getpanelsforcom>
      <GetPanelThreatLevels partitioned="False">
          select * from ca_vw_PanelThreatlevels where PnlRef=@Pnlref
          order by pnlref,rdrno
      </GetPanelThreatLevels>
      <GetPanelTypeDetail partitioned="False">
      SELECT pt.* FROM Panel_Types AS pt
      INNER JOIN Panel AS p
      ON p.PanelType=pt.ID
      WHERE p.PnlNo=@PanelNo
    </GetPanelTypeDetail>
    <GetPanelTypes partitioned="False">
      SELECT * FROM Panel_Types where ID &lt; 18
    </GetPanelTypes>
    <getprimarypartitionbyoperator>
      SELECT PartitionID FROM OperatorPartitions WHERE OperatorID = @OperatorID AND IsPrimaryPartition = 1
    </getprimarypartitionbyoperator>
    <AllRoleAssignToAllPartition Partition="False">
      INSERT INTO [DevicePartitions]
      SELECT '3DC78C7B-C9CE-4485-A835-63D577F623E6' AS PartitionID, P.PartitionID
      FROM [Partition] AS P
      WHERE NOT EXISTS(SELECT 1 FROM [DevicePartitions] AS DP WHERE P.PartitionID = DP.caObjectID AND DP.PartitionID = '3DC78C7B-C9CE-4485-A835-63D577F623E6')
      ORDER BY PartitionName

      DELETE from RolePartitions
      WHERE RolePartitions.PartitionID  not in (SELECT PartitionID FROM Partition)

      DECLARE @v_RoleID UNIQUEIDENTIFIER
      DECLARE db_cursor CURSOR FOR SELECT RoleID FROM Roles
      OPEN db_cursor
      FETCH NEXT FROM db_cursor INTO @v_RoleID

      WHILE @@FETCH_STATUS = 0
      BEGIN

      INSERT INTO DevicePartitions
      SELECT distinct TAB.PartitionID, RP.PartitionID FROM RolePartitions RP
      CROSS JOIN (
      SELECT PartitionID, RoleID FROM RolePartitions
      WHERE RoleID = @v_RoleID) AS TAB
      WHERE RP.RoleID = @v_RoleID
      AND @v_RoleID &lt;&gt; '82B19834-4EF0-405B-9AD1-23860AAF4139'
      AND	NOT EXISTS (SELECT 1 FROM DevicePartitions WHERE PartitionID = TAB.PartitionID AND caObjectID = RP.PartitionID)

      FETCH NEXT FROM db_cursor INTO @v_RoleID
      END

      CLOSE db_cursor
      DEALLOCATE db_cursor
    </AllRoleAssignToAllPartition>
    <getpartitions partitioned="False">
      Select PartitionName,PartitionID,DeviceType From [Partition]
      where (PartitionID in
      (
      SELECT dbo.devicepartitions.caObjectID
      FROM dbo.OperatorPartitions  inner join  dbo.devicepartitions
      on dbo.devicepartitions.PartitionId = dbo.OperatorPartitions.Partitionid
      where dbo.OperatorPartitions.OperatorID = @OperatorID
      )
      OR
      PartitionID not in
      (
      SELECT dbo.devicepartitions.caObjectID
      FROM  dbo.devicepartitions
      )
      )
      Order By PartitionName
    </getpartitions>
    <getObjetctList partitioned="False">
      SELECT caObjectID FROM DevicePartitions WHERE PartitionID=@PartitionID
    </getObjetctList>
    <getphones partitioned="False" notificationtable="Nodes">
      SELECT HostPhone1, HostPhone2 FROM Nodes
      WHERE NodeId = @NodeId
      AND HCSNo = @HCSNo
    </getphones>
    <GetPhoto partitioned="False" notificationtable="BadgePhoto">
      SELECT     PersonID, ImageTypeID, BadgeImage, LastWorkStation, LastOperator, LastUpdates
      FROM         BadgePhoto
      WHERE     (ImageTypeID = 0) AND (PersonID = @PersonID)
    </GetPhoto>
    <GetPhotoByBadgeFacility partitioned="False">
      SELECT bp.BadgeImage FROM BadgePhoto bp
      inner join badge b on bp.personid = b.personid
      WHERE bp.ImageTypeID = 0
      AND b.badge = @Badge
      AND b.facility = @Facility
    </GetPhotoByBadgeFacility>
    <GetPhotos partitioned="False">
      SELECT     PersonID, ImageTypeID, BadgeImage, LastWorkStation, LastOperator, LastUpdates
      FROM         BadgePhoto
      WHERE     (ImageTypeID = 0)
    </GetPhotos>
    <getpivtypes partitioned="False">select FmtType from Format where FmtType in (23,24,25,26,151,152,153,154)</getpivtypes>
    <GetReaderCategories partitioned="False" notificationtable="ReaderCategories">select PnlRef,RdrNo,CatNumber
            from ReaderCategories WHERE PnlRef=@PnlRef and RdrNo=@RdrNo
            order by CatNumber</GetReaderCategories>
    <GetReaderForAlert partitioned="False">
      Select r.PnlRef, r.RdrNo,ReaderName,APBType,TAType,ApbEntry,ApbExit,NAPCOAreas,
      RespForcedDoor,RespOtl,RespDuress,RespTrackedBadge,RespVoidBadge,r.caObjectId,
      BadgeUseRegister,RespAPBViolate,RespOtherDenied,RespBypass,RespFreeAccess,RespManualDoorCtrl,RespCommonCode,RespValidAccess,FDPrior,OTLPrior,DuPrior,TrkPrior,VPrior,APBPrior,OthPrior,ManPrior,BypPrior,FreePrior,PinPrior,ValidPrior,AckBypass,AckFreeAccess,AckManualDoorCtrl,AckCommonCode,AckValidAccess,TAAPBType,DvrServerid,DvrCameraId,VideoPriorityFrom,VideoPriorityTo FROM Reader r
      inner join readerpriority p on r.pnlref=p.pnlref and r.rdrno=p.rdrno
      WHERE r.PnlRef=@PnlRef and r.RdrNo=@RdrNo</GetReaderForAlert>
    <GetReaderFromPartition partitioned="False">select r.pnlref, r.rdrno FROM Reader r Inner Join DevicePartitions d on r.caObjectID = d.caObjectID WHERE d.PartitionID = @PartitionId</GetReaderFromPartition>
    <getreaderinfo partitioned="False" notificationtable="Reader">
      SELECT
      r.ReaderName as Description, r.Type, r.APBEntry, r.APBExit, r.APBType
      ,r.RespForcedDoor ,r.RespOTL ,r.RespDuress ,r.RespTrackedBadge ,r.RespVoidBadge ,r.RespAPBViolate ,r.RespOtherDenied ,r.RespBypass
      ,r.RespFreeAccess ,r.RespManualDoorCtrl ,r.RespCommonCode ,r.RespValidAccess
      /*,c.CCTV_ValidAccess ,c.CCTV_VoidBadges ,c.CCTV_Duress ,c.CCTV_ForcedDoor ,c.CCTV_TrackedBadges
      ,c.CCTV_Bypass ,c.DvrServerID  ,c.VideoPriorityFrom ,c.VideoPriorityTo */
      ,p.ValidPrior
      FROM Reader r /*inner join  cctvreader c on r.pnlref= c.pnlref and r.rdrno = c.rdrno*/
      inner join ReaderPriority p on r.pnlref= p.pnlref and r.rdrno = p.rdrno
      WHERE r.PnlRef =  @PnlRef AND r.RdrNo = @RdrNo
    </getreaderinfo>
    <getpanelinfo partitioned="False" notificationtable="Reader">
      SELECT P.* FROM [Panel] AS P WHERE P.PnlNo = @PnlRef
    </getpanelinfo>
    <getelevcontroltype partitioned="False">
      SELECT P.EleControlType FROM [Panel] AS P WHERE P.Elevators = 1 AND P.PnlNo = @PnlNo AND p.EleControlType = @EleControlType
    </getelevcontroltype>
    <getfloorsbyreader partitioned="False">
      SELECT F.[PnlRef], F.[RdrRef], F.[AccGroup], F.[FloorNumber]
      FROM [ElevAgFloors] AS F INNER JOIN [BadgeAccess] AS BA ON F.AccGroup = BA.AGroupNo
      WHERE F.[PnlRef] = @PnlRef AND F.[RdrRef] = @RdrRef AND BA.Badge = @Badge AND BA.Facility = @Facility
    </getfloorsbyreader>
    <getelevatorInfo partitioned="False">
      SELECT E.[ServerType], E.[ServerIP], E.[ServerPort], E.[ServerName], E.[ServerParam], E.WorkstationName, R.[GenerateAlert],R.[ReaderName], E.[caObjectID]
      FROM [ElevServers] AS E INNER JOIN [Reader] AS R ON E.ServerId = R.ElevServerId
      WHERE R.[PnlRef] = @PnlRef AND R.[RdrNo] =  @RdrRef
    </getelevatorInfo>
    <getbadgeinfo partitioned="False">
      SELECT [PersonID], [Badge], [Facility],[Enabled],[PIVI],[ActvDate],[ExprDate],[Escort],[Track] ,[DefaultFloor], [Features], [DoorType]
      FROM [Badge] WHERE Badge.Badge = @Badge AND Badge.Facility = @Facility
    </getbadgeinfo>
    <GetReaderPartitionNamesNOTUSED partitioned="False">select distinct p.PartitionName, p.PartitionID FROM Partition p inner join DevicePartitions d on d.PartitionID=p.PartitionId inner join Reader r on r.caObjectID=d.caObjectID</GetReaderPartitionNamesNOTUSED>
    <GetRelayForAlert partitioned="False">select pnlRef, relno, relayname,priority,respreq,caObjectID from Relay
WHERE PnlRef=@pnlRef and RelNo=@RelNo
</GetRelayForAlert>
    <getrelayinfo partitioned="False" notificationtable="Relay">
      SELECT
      RelayName as Description
      FROM Relay
      WHERE PnlRef= @PnlRef
      AND RelNo&gt;= @RelNo
    </getrelayinfo>
    <getremotelink partitioned="False" notificationtable="Link">
      SELECT
      LnkPnl,LnkProg
      FROM Link
      WHERE PnlRef= @PnlRef
      AND ProgNo&gt;= @ProgNo
    </getremotelink>
    <getroles partitioned="True">select roleid,rolename,lastupdated from roles order by rolename</getroles>
    <getrolebyid partitioned="False">select [RoleName], [caObjectID] from roles WHERE [RoleID] = @RoleID</getrolebyid>
    <getroleidforoperator partitioned="False">SELECT RoleID FROM Operators WHERE OperatorID =  @OperatorID</getroleidforoperator>
    <getschedchgend partitioned="False" notificationtable="SchedEvent">
      SELECT
      StartDate,SchId,EndDate,Device,PnlNo,DeviceNo,GroupNo,Schedule,FieldNo,Description,GroupName,IsActive,BadgeFrom,BadgeTo,FieldIn,ValueIn,FieldOut,ValueOut,Status
      FROM SchedEvent
      WHERE Status &lt; 4 AND EndDate &lt; @EndDate
      ORDER BY StartDate, SchID
    </getschedchgend>
    <getschedchgstart partitioned="False" notificationtable="SchedEvent">
      SELECT
      StartDate,SchId,EndDate,Device,PnlNo,DeviceNo,GroupNo,Schedule,FieldNo,Description,GroupName,IsActive,BadgeFrom,BadgeTo,FieldIn,ValueIn,FieldOut,ValueOut,Status
      FROM SchedEvent
      WHERE Status &lt; 2 and Device &lt; 10 and StartDate &lt;= @StartDate
      ORDER BY StartDate, SchID
    </getschedchgstart>
    <getscreenobjects partitioned="False" notificationtable="ScreenObjects">
      Select ScreenObjectId,ScreenID,ObjectName,LangObjectName From ScreenObjects
      Where ScreenID = @ScreenID and ScreenObjectID &lt;&gt; 0
      Order By ObjectName
    </getscreenobjects>
    <getscreens partitioned="False" notificationtable="Screens">Select ScreenID,ScreenName From Screens Order By ScreenID</getscreens>
    <getscreenxmldata partitioned="False">select xml from ScreenProperties where OperatorId=@OperatorId and Screen=@Screen</getscreenxmldata>
    <GetSelectedLock partitioned="False">select LockId, PanelName, LockType,LockUpdateSchedule,LockChanged,
Interactive,NoFail,Elevators,Passwrd,DegradeMode,XactSize,Node,Schedules,RetrievalSchedule,
CommPrior,DefaultCalendar,Enabled,PanelType,lastUpdated  from Panel where pnlNo=@PnlNo</GetSelectedLock>
    <getservernot16 partitioned="False" notificationtable="ComServer">
      SELECT  TOP 1
      ComID,WorkstationID,Record,Val1,Val2,Val3,Val4,Val5,pkt,LastUpdated
      FROM ComServer
      WHERE Record &lt;&gt; 0 AND Record &lt;&gt; 16
    </getservernot16>
    <getserverval2equal partitioned="False" notificationtable="ComServer">
      SELECT
      ComID,WorkstationID,Record,Val1,Val2,Val3,Val4,Val5,pkt,LastUpdated
      FROM ComServer WHERE Record=0 AND Val1&lt;&gt;0
      AND Val2 = @Val2
    </getserverval2equal>
    <getserverval2notequal partitioned="False" notificationtable="ComServer">
      SELECT
      ComID,WorkstationID,Record,Val1,Val2,Val3,Val4,Val5,pkt,LastUpdated
      FROM ComServer
      WHERE Record=0 AND VAL1&lt;&gt;0 AND Val2 &lt;&gt; @Val2
    </getserverval2notequal>
    <GetSMSDetails partitioned="False" notificationtable="smsProviders">Select smsHostName, smsServer, smsType, smsParams, smsPassword from SMSProviders where smsHostID = @smsHostID</GetSMSDetails>
    <GetSNPPDetails partitioned="False" notificationtable="snppProviders">Select snppHostName, snppServer, snppPort from SNPPProviders where snppHostID = @snppHostID</GetSNPPDetails>
    <GetSystemForAlert partitioned="False">select UseAutoAck,AutoAckPriority, RespReqTz,APBResetTime,APBResetArea,UseHostTz,TagType
FROM SystemSettings</GetSystemForAlert>
    <getsysteminfo partitioned="False">
      SELECT
      SysBadgelen
      --, UseCCTV
      --, CCTVPort
      --, CCTVBaud
      --, CCTVBits
      --, CCTVParity
      --, CCTVStop
      --, CCTVFlow
      , TapiPhone1
      , TapiPhone2
      , TapiId1
      , TapiId2
      --, AlertPrtyLevel
      --, AlertAutoDisp
      , AutoAckPriority
      , RespReqTz
      , TagType
      --, CCTVSocket
      , AGCountPerBadge
      , APBResetTime
      --, PrnEvent1
      , UseALP
      , USEAPBAreas
      , CatEnable
      , APBResetArea
      , UseCatCounters
      , UseHoliday
      , UseHostTz
      ,KeypadOption
      FROM ca_vw_System
      WHERE SysId= @SysId
    </getsysteminfo>
    <GetThreatLevelCategories partitioned="False">SELECT [CatNumber],[Description],[LastUpdated],[caObjectId],[LastOperator]  FROM [dbo].[ThreatLevelCategories] Order By [CatNumber]</GetThreatLevelCategories>
    <GetThreatLevelColor partitioned="False">Select ThreatLevelColor from MActiveThreatLevel where LockdownId = @LockdownId</GetThreatLevelColor>
    <GetThreatLevelName partitioned="False" notificationtable="MActiveThreatLevel">Select Description from MActiveThreatLevel WHERE LockdownID = @LockdownID</GetThreatLevelName>
    <GetThreatLevels partitioned="False">Select LockdownID,Description,LockdownColor,Active,LockoutArea,caObjectID,LastUpdated From MActiveThreatLevel</GetThreatLevels>
    <GetThreatLocksInArea partitioned="False">select PnlNo,Categories from ca_vw_GetThreatLocksInArea where HCSNo=@HCSNo and ThreatNo=@ThreatNo  Order By PnlNo</GetThreatLocksInArea>
    <GetTimeSchedule partitioned="False">select DayFrom,DayTo,Frhr,FrMin,ToHr,ToMin from Timezone
      where TzNo = @TzNo</GetTimeSchedule>
    <GetTimezone partitioned="False">SELECT TzNo,DayFrom,DayTo,FrHr,FrMin,ToHr,ToMin,TimeFrom,TimeTo FROM Timezone WHERE TzNo=@TzNo</GetTimezone>
    <GetTimezone partitioned="False">SELECT TzNo,DayFrom,DayTo,FrHr,FrMin,ToHr,ToMin,TimeFrom,TimeTo FROM Timezone WHERE TzNo=@TzNo</GetTimezone>
    <APIGetMTimezoneLookup partitioned="False">SELECT TzNum AS ValueMember, Description AS DisplayMember, GroupNo, HolGroups, caObjectID, LastUpdated, LastOperator, LastWorkStation, UTCOffset FROM MTimezon</APIGetMTimezoneLookup>
    <APIGetMTimezoneByScheduleNo partitioned="False">SELECT TzNum, Description, GroupNo, HolGroups, caObjectID, LastUpdated, LastOperator, LastWorkStation, UTCOffset FROM MTimezon WHERE TzNum = @TzNum</APIGetMTimezoneByScheduleNo>
    <APIGetTimezoneTimeBlockIndex partitioned="False"> SELECT TzId AS DisplayMember, TzId AS ValueMember FROM Timezone WHERE TzNo = @TzNo </APIGetTimezoneTimeBlockIndex>
    <GetUnAssignedComPorts partitioned="False">exec ca_sp_FindUnusedComPorts @HCSNo</GetUnAssignedComPorts>
    <GetTimeZoneByPanelNo>
      Select c.ZoneId
      FROM Com c
      Inner Join Panel p
      on c.ComPort = p.ComPort
      WHERE p.PnlNo = @PnlNo
    </GetTimeZoneByPanelNo>
    <GetUnAssignedLock partitioned="False">select  *  from Panel where (Type = 101 or Type = 102) and LockAssigned = 0 and HCSNo=@HCSNo</GetUnAssignedLock>
    <getunassignedroles partitioned="False">
      select g.displayName,g.pluginAssembly,g.pluginId,g.availPartGroups from guiplugins g where g.pluginid not in(
      select pluginId from roleplugins where roleid = @roleid
      ) order by g.displayname
    </getunassignedroles>
    <GetWirelessComPorts partitioned="False">
      SELECT C.ComPort, C.HCSNo, C.MACAddress, C.Passwrd, C.IPAddress, C.RFChannel, C.RFGroup, C.SyncWordUpper, C.SyncWordLower,
      C.HostIPAddress, C.GatewayPort, C.ZoneId
      FROM  MCom  MC INNER JOIN Com C ON MC.HCSNo = C.HCSNo
      WHERE C.Type=10 and MC.HCSNo=@HcsNo and
      MC.caObjectID in (SELECT devicepartitions.caObjectID FROM OperatorPartitions inner join  devicepartitions on devicepartitions.PartitionId = OperatorPartitions.Partitionid where OperatorPartitions.OperatorID = @OperatorID)
      order by HCSNo, ComPort
    </GetWirelessComPorts>
    <GetWirelessComPortsByHcs partitioned="False">
      select ComPort, HCSNo, MacAddress,Passwrd,IPAddress,RFChannel,
      RFGroup,SyncWordUpper, SyncWordLower, HostIPAddress,GatewayPort,ZoneId
      from dbo.Com WHERE Type=10 and HCSNo = @HcsNo
    </GetWirelessComPortsByHcs>
    <GetWirelessGatewaysWithStatus partitioned="False">
      select * From
      ( SELECT c.ComPort, c.HCSNo, c.MACAddress, c.Passwrd, c.IPAddress, c.RFChannel, c.RFGroup, c.SyncWordUpper, c.SyncWordLower, c.Type, g.Status, g.Version,g.HasRepeaters,g.RepeaterCount,g.GroupNo, g.LockCount, g.LastUpdated
      FROM  dbo.Com AS c inner join MCom Mc on c.HCSNo=Mc.HCSNo and Mc.caObjectID in (SELECT devicepartitions.caObjectID FROM OperatorPartitions inner join  devicepartitions on devicepartitions.PartitionId = OperatorPartitions.Partitionid where OperatorPartitions.OperatorID = @OperatorID)
      left join dbo.GatewayStatus AS g ON c.ComPort = g.Comport) as gs
      WHERE gs.Type=10
    </GetWirelessGatewaysWithStatus>
    <APIGetWirelessGatewaysWithStatus partitioned="False">
      select * From
      ( SELECT c.ComPort, c.HCSNo, c.MACAddress, c.IPAddress, c.RFChannel, c.RFGroup, c.SyncWordUpper, c.SyncWordLower, c.Type, g.Status, g.Version,g.HasRepeaters,g.RepeaterCount,g.GroupNo, g.LockCount, g.LastUpdated
      FROM  dbo.Com AS c inner join MCom Mc on c.HCSNo=Mc.HCSNo and Mc.caObjectID in (SELECT devicepartitions.caObjectID FROM OperatorPartitions inner join  devicepartitions on devicepartitions.PartitionId = OperatorPartitions.Partitionid where OperatorPartitions.OperatorID = @OperatorID)
      left join dbo.GatewayStatus AS g ON c.ComPort = g.Comport) as gs
      WHERE gs.Type=10
    </APIGetWirelessGatewaysWithStatus>
    <GetWirelessGatewaysStatusWithPartition partitioned="False">
      select * From
      ( SELECT c.ComPort, c.HCSNo, c.MACAddress, c.Passwrd, c.IPAddress, c.RFChannel, c.RFGroup, c.SyncWordUpper, c.SyncWordLower, C.HostIPAddress, C.GatewayPort, C.ZoneId, c.Type, g.Status, g.Version,g.HasRepeaters,g.RepeaterCount,g.GroupNo, g.LockCount, g.LastUpdated
      FROM  dbo.Com AS c inner join MCom Mc on c.HCSNo=Mc.HCSNo and Mc.caObjectID in (SELECT caObjectID FROM devicepartitions  where PartitionID = @PartitionID)
      left join dbo.GatewayStatus AS g ON c.ComPort = g.Comport) as gs
      WHERE gs.Type=10
    </GetWirelessGatewaysStatusWithPartition>
    <GetWorkstationFromPollingUNC partitioned="False" notificationtable="scriptingServers">SELECT WorkstationID FROM scriptingServers WHERE PollingUNCName = @PollingUNCName</GetWorkstationFromPollingUNC>
    <guiPlugins partitioned="False">
      select g.pluginId, g.displayName, g.pluginAssembly, g.availPartGroups from guiPlugins g
      inner join roleplugins r on g.pluginid = r.pluginid
      inner join operators o on o.roleid = r.roleid
      where o.operatorid = @operatorid
      order by loadOrder
    </guiPlugins>
    <guiPluginsAdmin partitioned="False">
      select distinct g.pluginId, g.displayName, g.pluginAssembly,g.loadOrder from guiPlugins g
      inner join roleplugins r on g.pluginid = r.pluginid or NOT Exists (SELECT 1 from roleplugins where r.RoleID =g.pluginid)
      inner join operators o on o.roleid = r.roleid
      order by loadOrder
    </guiPluginsAdmin>
    <Hardware partitioned="False">
      select
      1 as Tag
      ,0 as Parent
      ,null as ComPort
      ,null as HCSNo
      ,null as PnlNo
      ,null as Rdrno
      ,null as Relno
      ,null as Inpno
      ,null as Progno
      ,null as mActLink
      ,null as CatNo
      ,null as "Description"
      ,null as "caObjectID"
      union all select
      2 as Tag
      ,1 as Parent
      ,ComPort
      ,HCSNo
      ,null as PnlNo
      ,null as Rdrno
      ,null as Relno
      ,null as Inpno
      ,null as Progno
      ,null as mActLink
      ,null as CatNo
      ,'Data Channel' + Convert(VarChar,ComPort) as "Description"
      ,null as "caObjectID"
      from com
      union all select
      3 as Tag
      ,2 as Parent
      ,c.ComPort
      ,c.HCSNo
      ,PnlNo
      ,null as Rdrno
      ,null as Relno
      ,null as Inpno
      ,null as Progno
      ,null as mActLink
      ,null as CatNo
      ,p.PanelName as "Description"
      ,p.caObjectID
      from panel p
      inner join com c
      on  p.comport = c.comport
      and p.HCSNo = c.HCSNo
      union all select
      4 as Tag
      ,3 as Parent
      ,c.ComPort
      ,c.HCSNo
      ,PnlNo
      ,Rdrno
      ,null as Relno
      ,null as Inpno
      ,null as Progno
      ,null as mActLink
      ,null as CatNo
      ,r.ReaderName as "Description"
      ,r.caObjectID
      from panel p
      inner join com c
      on  p.comport = c.comport
      and p.HCSNo = c.HCSNo
      inner join reader r on
      r.pnlref = p.pnlno
      union all select
      5 as Tag
      ,4 as Parent
      ,c.ComPort
      ,c.HCSNo
      ,PnlNo
      ,null as Rdrno
      ,Relno
      ,null as Inpno
      ,null as Progno
      ,null as mActLink
      ,null as CatNo
      ,r.RelayName as "Description"
      ,r.caObjectID
      from panel p
      inner join com c
      on  p.comport = c.comport
      and p.HCSNo = c.HCSNo
      inner join relay r on
      r.pnlref = p.pnlno
      union all select
      6 as Tag
      ,5 as Parent
      ,c.ComPort
      ,c.HCSNo
      ,PnlNo
      ,null as Rdrno
      ,null as Relno
      ,Inpno
      ,null as Progno
      ,null as mActLink
      ,null as CatNo
      ,i.InputName as "Description"
      ,i.caObjectID
      from panel p
      inner join com c
      on  p.comport = c.comport
      and p.HCSNo = c.HCSNo
      inner join input i on
      i.pnlref = p.pnlno
      union all select
      7 as Tag
      ,6 as Parent
      ,c.ComPort
      ,c.HCSNo
      ,PnlNo
      ,null as Rdrno
      ,null as Relno
      ,null as Inpno
      ,Progno
      ,null as mActLink
      ,null as CatNo
      ,l.LinkName as "Description"
      ,null as "caObjectID"
      from panel p
      inner join com c
      on  p.comport = c.comport
      and p.HCSNo = c.HCSNo
      inner join link l on
      l.pnlref = p.pnlno
      union all select
      8 as Tag
      ,6 as Parent
      ,c.ComPort
      ,c.HCSNo
      ,PnlNo
      ,null as Rdrno
      ,null as Relno
      ,null as Inpno
      ,null as mActLink
      ,Progno as mActLink
      ,null as CatNo
      ,m.Description as "Description"
      ,null as "caObjectID"
      from panel p
      inner join com c
      on  p.comport = c.comport
      and p.HCSNo = c.HCSNo
      inner join mActivelinks m on
      m.pnlref = p.pnlno
      union all select
      9 as Tag
      ,6 as Parent
      ,c.ComPort
      ,c.HCSNo
      ,p.PnlNo
      ,null as Rdrno
      ,null as Relno
      ,null as Inpno
      ,null as mActLink
      ,null as mActLink
      ,cc.CatNo
      ,cc.Description as "Description"
      ,null as "caObjectID"
      from panel p
      inner join com c
      on  p.comport = c.comport
      and p.HCSNo = c.HCSNo
      inner join CategoryCounters cc on
      cc.pnlno = p.pnlno
      order by comport,pnlno,parent
    </Hardware>
    <hardwareTree_ActivityLink partitioned="False" notificationtable="MActiveLinks">
      select
      PnlRef as PnlNo
      , ProgNo as DevNo
      , MActiveLinks.Description
      , MActiveLinks.LastUpdated
      , MActiveLinks.caObjectID
      , 0 as IsInTrouble
      , 501 as ObjType
      , Panel.HCSNo
      , Panel.comport
      , null as parentObjectID
      from MActiveLinks
      INNER JOIN Panel ON MActiveLinks.PnlRef = Panel.PnlNo
      WHERE MActiveLinks.caObjectID in (SELECT devicepartitions.caObjectID FROM OperatorPartitions inner join  devicepartitions on devicepartitions.PartitionId = OperatorPartitions.Partitionid where OperatorPartitions.OperatorID = @OperatorID)

    </hardwareTree_ActivityLink>
    <hardwareTree_ActivityLink_Parent partitioned="False" notificationtable="MActiveLinks">
      SELECT
      MActiveLinks.PnlRef AS PnlNo
      , MActiveLinks.ProgNo AS DevNo
      , MActiveLinks.Description
      , MActiveLinks.LastUpdated
      , MActiveLinks.caObjectID
      , 0 AS IsInTrouble
      , 501 AS ObjType
      , Panel.HCSNo
      , Panel.comport
      , Panel.caObjectID AS parentObjectID
      FROM         MActiveLinks INNER JOIN
      Panel ON MActiveLinks.PnlRef = Panel.PnlNo
      WHERE Panel.caObjectID = @parentObjectID
      AND MActiveLinks.caObjectID in (SELECT devicepartitions.caObjectID FROM OperatorPartitions inner join  devicepartitions on devicepartitions.PartitionId = OperatorPartitions.Partitionid where OperatorPartitions.OperatorID = @OperatorID)
    </hardwareTree_ActivityLink_Parent>
    <hardwareTree_BadgeFormat partitioned="False" notificationtable="Format">
      select
      fmtNo  as PnlNo
      , 0 as DevNo
      , Description
      , LastUpdated
      , caObjectID
      , 0 as IsInTrouble
      , 507 as ObjType
      ,0 as HCSNo
      ,0 as comport
      , null as parentObjectID
      from format
    </hardwareTree_BadgeFormat>
    <hardwareTree_Com partitioned="False" notificationtable="Com">
      select
      c.HCSNo as PnlNo
      ,c.ComPort as DevNo
      ,CAST(c.ComPort as nvarchar(10)) as Description
      ,c.LastUpdated
      ,c.caObjectID
      ,0 as IsInTrouble
      ,50 as ObjType
      ,c.HCSNo
      ,c.comport
      ,null as parentObjectID
      from Com c
      INNER JOIN
      MCom m ON C.HCSNo= M.HCSNo
    </hardwareTree_Com>
    <hardwareTree_Com_Parent partitioned="False" notificationtable="Com">
      SELECT
      Com.HCSNo AS PnlNo
      ,Com.ComPort AS DevNo
      ,CAST(Com.ComPort AS nvarchar(10)) AS Description
      ,Com.LastUpdated
      ,Com.caObjectID
      ,0 AS IsInTrouble
      ,50 AS ObjType
      ,Com.HCSNo
      ,com.comport
      ,MCom.caObjectID AS parentObjectID
      FROM         Com INNER JOIN
      MCom ON Com.HCSNo= MCom.HCSNo
      WHERE MCom.caObjectID = @parentObjectID
    </hardwareTree_Com_Parent>
    <hardwareTree_Continental partitioned="False" notificationtable="DvrConfig">
      SELECT
      0 as PnlNo
      ,0 as DevNo
      ,ServerName as Description
      ,LastUpdated
      ,DvrID as caObjectID
      ,0 as IsInTrouble
      ,301 as ObjType
      ,0 as HCSNo
      ,0 as comport
      ,null as parentObjectID
      FROM DvrConfig Where DVRVendor = 3
    </hardwareTree_Continental>
    <hardwareTree_FacilityCodes partitioned="False" notificationtable="Facility">
      select
      PnlRef  as PnlNo
      , 0 as DevNo
      , p.PanelName as Description
      , f.LastUpdated
      , f.caObjectID
      , 0 as IsInTrouble
      , 506 as ObjType
      ,0 as HCSNo
      ,0 as comport
      , null as parentObjectID
      from facility f inner join panel p on p.pnlno = f.pnlref

    </hardwareTree_FacilityCodes>
    <hardwareTree_Holidays partitioned="False" notificationtable="MHoliday">
      select
      CalendarNo  as PnlNo
      , 0 as DevNo
      , Description
      , LastUpdated
      , caObjectID
      , 0 as IsInTrouble
      , 504 as ObjType
      ,0 as HCSNo
      ,0 as comport
      , null as parentObjectID
      from mholiday
    </hardwareTree_Holidays>
    <hardwareTree_Input partitioned="False" notificationtable="Input">
      SELECT
      PnlRef
      , InpNo
      , InputName as Description
      , Input.LastUpdated
      , Input.caObjectID
      , 0 AS IsInTrouble
      , 103 AS ObjType
      , Panel.HCSNo
      , Panel.comport
      , null AS parentObjectID
      FROM         Input
      INNER JOIN Panel ON Input.PnlRef = Panel.PnlNo
      WHERE Input.caObjectID in (SELECT devicepartitions.caObjectID FROM OperatorPartitions inner join  devicepartitions on devicepartitions.PartitionId = OperatorPartitions.Partitionid where OperatorPartitions.OperatorID = @OperatorID)

    </hardwareTree_Input>
    <hardwareTree_Input_Parent partitioned="False" notificationtable="Input">
      SELECT
      Input.PnlRef
      , Input.InpNo
      , Input.InputName as Description
      , Input.LastUpdated
      , Input.caObjectID
      , 0 AS IsInTrouble
      , 103 AS ObjType
      ,Panel.HCSNo
      ,Panel.comport
      ,Panel.caObjectID AS parentObjectID
      FROM         Input INNER JOIN
      Panel ON Input.PnlRef = Panel.PnlNo
      WHERE Panel.caObjectID = @parentObjectID
      AND Input.caObjectID in (SELECT devicepartitions.caObjectID FROM OperatorPartitions inner join  devicepartitions on devicepartitions.PartitionId = OperatorPartitions.Partitionid where OperatorPartitions.OperatorID = @OperatorID)
    </hardwareTree_Input_Parent>
    <hardwareTree_Integral partitioned="False" notificationtable="DvrConfig">
      SELECT
      0 as PnlNo
      ,0 as DevNo
      ,ServerName as Description
      , LastUpdated
      ,DvrID as caObjectID
      ,0 as IsInTrouble
      ,301 as ObjType
      ,0 as HCSNo
      ,0 as comport
      ,null as parentObjectID
      FROM DvrConfig Where DVRVendor = 1
    </hardwareTree_Integral>
    <hardwareTree_Link partitioned="False" notificationtable="Link">
      SELECT     PnlRef, ProgNo, LinkName, Link.LastUpdated, Link.caObjectID, 0 AS IsInTrouble, 104 AS ObjType
      , Panel.HCSNo
      , Panel.comport
      ,      null AS parentObjectID
      FROM         Link
      INNER JOIN Panel ON Link.PnlRef = Panel.PnlNo
      WHERE Link.caObjectID in (SELECT devicepartitions.caObjectID FROM OperatorPartitions inner join  devicepartitions on devicepartitions.PartitionId = OperatorPartitions.Partitionid where OperatorPartitions.OperatorID = @OperatorID)

    </hardwareTree_Link>
    <hardwareTree_Link_Parent partitioned="False" notificationtable="Link">
      SELECT     Link.PnlRef, Link.ProgNo, Link.LinkName, Link.LastUpdated, Link.caObjectID, 0 AS IsInTrouble, 104 AS ObjType
      ,Panel.HCSNo
      ,Panel.comport
      , Panel.caObjectID AS parentObjectID
      FROM         Link INNER JOIN
      Panel ON Link.PnlRef = Panel.PnlNo
      WHERE Panel.caObjectID = @parentObjectID
      AND Link.caObjectID in (SELECT devicepartitions.caObjectID FROM OperatorPartitions inner join  devicepartitions on devicepartitions.PartitionId = OperatorPartitions.Partitionid where OperatorPartitions.OperatorID = @OperatorID)
    </hardwareTree_Link_Parent>
    <hardwareTree_MCom partitioned="False" notificationtable="MCom">
      select
      HCSNo as PnlNo
      ,0 as DevNo
      ,Description
      ,LastUpdated
      ,caObjectID
      ,0 as IsInTrouble
      ,40 as ObjType
      ,HCSNo
      ,0 as comport
      ,null as parentObjectID
      from MCom
    </hardwareTree_MCom>
    <hardwareTree_Nodes partitioned="True" notificationtable="Nodes">
      select NodeId as PnlNo, 0 as DevNo, NodeName as Description, LastUpdated, caObjectID, 0 as IsInTrouble, 700 as ObjType
      ,0 as HCSNo
      ,0 as comport
      , null as parentObjectID
      from Nodes
    </hardwareTree_Nodes>
    <hardwareTree_Operator partitioned="False" notificationtable="Operators">
      select 0 as PnlNo, 0 as DevNo, OperLName+', '+OperFName as Description, LastUpdated, OperatorID as caObjectID, 0 as IsInTrouble, 500 as ObjType
      ,0 as HCSNo
      ,0 as comport
      , null as parentObjectID
      from Operators
    </hardwareTree_Operator>
    <hardwareTree_OperatorInstructions partitioned="False" notificationtable="operatorInstructions">
      select 0 as PnlNo, 0 as DevNo, instructionName as Description, LastUpdated, instructionID as caObjectID, 0 as IsInTrouble, 502 as ObjType
      ,0 as HCSNo
      ,0 as comport
      , null as parentObjectID
      from OperatorInstructions
    </hardwareTree_OperatorInstructions>
    <hardwareTree_Panel partitioned="True" notificationtable="Panel">
      select
      PnlNo
      , 0 as DevNo
      , PanelName as Description
      , LastUpdated
      , caObjectID
      , 0 as IsInTrouble
      , 100 as ObjType
      , HCSNo
      , comport
      , null as parentObjectID
      from Panel
    </hardwareTree_Panel>
    <hardwareTree_Panel_Parent partitioned="False" notificationtable="Panel">
      SELECT
      Panel.PnlNo
      , 0 AS DevNo
      , Panel.PanelName as Description
      , Panel.LastUpdated
      , Panel.caObjectID
      , 0 AS IsInTrouble
      , 100 AS ObjType
      , panel.HCSNo
      , panel.comport
      , Com.caObjectID AS parentObjectID
      FROM         Panel INNER JOIN
      Com ON Panel.HCSNo = Com.HCSNo AND Panel.ComPort = Com.ComPort
      WHERE Com.caObjectID = @parentObjectID
      AND Panel.caObjectID in (SELECT devicepartitions.caObjectID FROM OperatorPartitions inner join  devicepartitions on devicepartitions.PartitionId = OperatorPartitions.Partitionid where OperatorPartitions.OperatorID = @OperatorID)
    </hardwareTree_Panel_Parent>
    <hardwareTree_Reader partitioned="False" notificationtable="Reader">
      select
      PnlRef
      , RdrNo
      , ReaderName as Description
      , Reader.LastUpdated
      , Reader.caObjectID
      , 0 as IsInTrouble
      , 101 as ObjType
      , Panel.HCSNo
      , Panel.comport
      , null as parentObjectID
      from Reader
      INNER JOIN Panel ON Reader.PnlRef = Panel.PnlNo
      WHERE Reader.caObjectID in (SELECT devicepartitions.caObjectID FROM OperatorPartitions inner join  devicepartitions on devicepartitions.PartitionId = OperatorPartitions.Partitionid where OperatorPartitions.OperatorID = @OperatorID)

    </hardwareTree_Reader>
    <hardwareTree_Reader_Parent partitioned="False" notificationtable="Reader">
      SELECT
      Reader.PnlRef
      , Reader.RdrNo
      , Reader.ReaderName as Description
      , Reader.LastUpdated
      , Reader.caObjectID
      , 0 AS IsInTrouble
      , 101 AS ObjType
      , Panel.HCSNo
      , Panel.comport
      , Panel.caObjectID AS parentObjectID
      FROM         Reader INNER JOIN
      Panel ON Reader.PnlRef = Panel.PnlNo
      WHERE Panel.caObjectID = @parentObjectID
      AND Reader.caObjectID in (SELECT devicepartitions.caObjectID FROM OperatorPartitions inner join  devicepartitions on devicepartitions.PartitionId = OperatorPartitions.Partitionid where OperatorPartitions.OperatorID = @OperatorID)
    </hardwareTree_Reader_Parent>
    <hardwareTree_Relay partitioned="False" notificationtable="Relay">
      select PnlRef, RelNo, RelayName, Relay.LastUpdated, Relay.caObjectID, 0 as IsInTrouble, 102 as ObjType
      , Panel.HCSNo
      , Panel.comport
      , null as parentObjectID
      from Relay
      INNER JOIN
      Panel ON Relay.PnlRef = Panel.PnlNo
      WHERE  Relay.caObjectID in (SELECT devicepartitions.caObjectID FROM OperatorPartitions inner join  devicepartitions on devicepartitions.PartitionId = OperatorPartitions.Partitionid where OperatorPartitions.OperatorID = @OperatorID)

    </hardwareTree_Relay>
    <hardwareTree_Relay_Parent partitioned="False" notificationtable="Relay">
      SELECT     Relay.PnlRef, Relay.RelNo, Relay.RelayName, Relay.LastUpdated, Relay.caObjectID, 0 AS IsInTrouble, 102 AS ObjType
      ,Panel.HCSNo
      ,Panel.comport
      , Panel.caObjectID AS parentObjectID
      FROM         Relay INNER JOIN
      Panel ON Relay.PnlRef = Panel.PnlNo
      WHERE Panel.caObjectID = @parentObjectID
      AND Relay.caObjectID in (SELECT devicepartitions.caObjectID FROM OperatorPartitions inner join  devicepartitions on devicepartitions.PartitionId = OperatorPartitions.Partitionid where OperatorPartitions.OperatorID = @OperatorID)
    </hardwareTree_Relay_Parent>
    <hardwareTree_Salient partitioned="False" notificationtable="DvrConfig">
      SELECT 0 as PnlNo,0 as DevNo,ServerName as Description, LastUpdated,DvrID as caObjectID,0 as IsInTrouble,301 as ObjType
      ,0 as HCSNo
      ,0 as comport
      ,null as parentObjectID
      FROM DvrConfig Where DVRVendor = 2
    </hardwareTree_Salient>
    <hardwareTree_ScheduledChange partitioned="False" notificationtable="SchedEvent">
      select
      SchId as PnlNo
      , 0 as DevNo
      , Description
      , LastUpdated
      , caObjectID
      , 0 as IsInTrouble
      , 508 as ObjType
      ,0 as HCSNo
      ,0 as comport
      , null as parentObjectID
      from SchedEvent
    </hardwareTree_ScheduledChange>
    <hardwareTree_Schedules partitioned="True" notificationtable="MTimezon">
      select TzNum  as PnlNo, 0 as DevNo, Description, LastUpdated, caObjectID, 0 as IsInTrouble, 503 as ObjType
      ,0 as HCSNo
      ,0 as comport
      , null as parentObjectID
      from mtimezon

    </hardwareTree_Schedules>
    <hardwareTree_ShuntGroups partitioned="False" notificationtable="MShunt">
      select ShuntId as PnlNo, 0 as DevNo, ShuntName as Description, LastUpdated, caObjectID, 0 as IsInTrouble, 505 as ObjType
      ,0 as HCSNo
      ,0 as comport
      , null as parentObjectID
      from MShunt
    </hardwareTree_ShuntGroups>
    <hardwareTree_AccessGroups>
      select AgrpNo as PnlNo, 0 as DevNo, Description as Description, LastUpdated, caObjectID, 0 as IsInTrouble, 805 as ObjType
      ,0 as HCSNo
      ,0 as comport
      , null as parentObjectID
      from MAccGrp
      WHERE AgrpNo > 0
    </hardwareTree_AccessGroups>
    <hardwareTree_APBAreas>
      select AreaNo as PnlNo, 0 as DevNo, Description as Description, LastUpdated, caObjectID, 0 as IsInTrouble, 803 as ObjType
      ,0 as HCSNo
      ,0 as comport
      , null as parentObjectID
      from APBAreas
      WHERE AreaNo NOT IN (0, 1, 255)
    </hardwareTree_APBAreas>
    <hardwareTree_LockdownAreas>
      select AreaNo as PnlNo, 0 as DevNo, AreaName as Description, LastUpdated, caObjectID, 0 as IsInTrouble, 804 as ObjType
      ,0 as HCSNo
      ,0 as comport
      , null as parentObjectID
      from MLockdownAreas
    </hardwareTree_LockdownAreas>
    <hardwareTree_Personnel>
      select 0 as PnlNo, 0 as DevNo, LastName + CASE WHEN LEN(ISNULL(FrstName, '')) > 0 THEN ', ' + FrstName ELSE '' END as Description, LastUpdated, caObjectID, 0 as IsInTrouble, 801 as ObjType
      ,0 as HCSNo
      ,0 as comport
      , null as parentObjectID
      from Person
    </hardwareTree_Personnel>
    <hardwareTree_CategoryCounters>
      select DISTINCT Panel.PnlNo as PnlNo, 0 as DevNo, Panel.PanelName as Description, [CategoryCounters].LastUpdated, Panel.caObjectID, 0 as IsInTrouble, 701 as ObjType
      ,0 as HCSNo
      ,0 as comport
      , null as parentObjectID
      from Panel INNER JOIN [CategoryCounters] on Panel.PnlNo = [CategoryCounters].PnlNo
    </hardwareTree_CategoryCounters>
    <hardwareTree_ScriptsEditors>
      SELECT scriptID as PnlNo,0 as DevNo, scriptName as Description, LastUpdated, caObjectID as caObjectID,0 as IsInTrouble, 7032 as ObjType
      ,0 as HCSNo
      ,0 as comport
      ,null as parentObjectID
      FROM alarmLink_scripts
    </hardwareTree_ScriptsEditors>
    <hardwareTree_ScriptsScheduler>
      SELECT ScheduleID as PnlNo,0 as DevNo, ScheduleName as Description, LastUpdated, caObjectID as caObjectID,0 as IsInTrouble, 7034 as ObjType
      ,0 as HCSNo
      ,0 as comport
      ,null as parentObjectID
      FROM AlarmLink_Schedule
    </hardwareTree_ScriptsScheduler>
    <hardwareTree_OperatorResponse>
      SELECT 0 as PnlNo,0 as DevNo, Description as Description, LastUpdated, caObjectID as caObjectID,0 as IsInTrouble, 27 as ObjType
      ,0 as HCSNo
      ,0 as comport
      ,null as parentObjectID
      FROM Resp
    </hardwareTree_OperatorResponse>
    <hardwareTree_ThreatLevel>
      SELECT LockdownID as PnlNo,0 as DevNo, Description as Description, LastUpdated, caObjectID as caObjectID,0 as IsInTrouble, 29 as ObjType
      ,0 as HCSNo
      ,0 as comport
      ,null as parentObjectID
      FROM MActiveThreatLevel
    </hardwareTree_ThreatLevel>
    <hardwareTree_FacilityMap>
      SELECT MapId as PnlNo,0 as DevNo, MapName as Description, LastUpdated, caObjectID as caObjectID,0 as IsInTrouble, 31 as ObjType
      ,0 as HCSNo
      ,0 as comport
      ,null as parentObjectID
      FROM FacilityMap
    </hardwareTree_FacilityMap>
    <hardwareTree_napcoPanels>
      SELECT AlarmPanelID as PnlNo,0 as DevNo, PanelName as Description, LastUpdated, caObjectID as caObjectID,0 as IsInTrouble, 200 as ObjType
      ,0 as HCSNo
      ,0 as comport
      ,null as parentObjectID
      FROM napcoPanels
    </hardwareTree_napcoPanels>
    <hardwareTree_napcoPanelAreas>
      SELECT AlarmPanelID as PnlNo, AreaNumber as DevNo, AreaName as Description, LastUpdated, caObjectID as caObjectID,0 as IsInTrouble, 201 as ObjType
      ,0 as HCSNo
      ,0 as comport
      ,null as parentObjectID
      FROM napcoPanelAreas
    </hardwareTree_napcoPanelAreas>
    <hardwareTree_napcoPanelZones>
      SELECT AlarmPanelID as PnlNo, ZoneNumber as DevNo, ZoneName as Description, LastUpdated, caObjectID as caObjectID,0 as IsInTrouble, 202 as ObjType
      ,0 as HCSNo
      ,0 as comport
      ,null as parentObjectID
      FROM napcoPanelZones
    </hardwareTree_napcoPanelZones>
    <hardwareTree_napcoPanelRelays>
      SELECT AlarmPanelID as PnlNo, RelayNumber as DevNo, RelayName as Description, LastUpdated, caObjectID as caObjectID,0 as IsInTrouble, 203 as ObjType
      ,0 as HCSNo
      ,0 as comport
      ,null as parentObjectID
      FROM napcoPanelRelays
    </hardwareTree_napcoPanelRelays>
    <hardwareTree_napcoMPermissions>
      SELECT 0 as PnlNo, PermissionID as DevNo, PermissionName as Description, LastUpdated, caObjectID as caObjectID,0 as IsInTrouble, 204 as ObjType
      ,0 as HCSNo
      ,0 as comport
      ,null as parentObjectID
      FROM napcoMPermissions
    </hardwareTree_napcoMPermissions>
    <HcsDatabaseList partitioned="False">Select HcsNo,ServerName FROM DatabaseList WHERE DatabaseType=2 order by HcsNo</HcsDatabaseList>
    <HcsNoFromUNC partitioned="False">select HCSNo,caObjectId from MCom where UNCName = @UNCName</HcsNoFromUNC>
    <holidaysgrid partitioned="True">
      select CalendarNo,Description,LastUpdated as "Last Edit",caObjectId  from mholiday
    </holidaysgrid>
    <APIGetHolidaysByCalendarNo>SELECT HolNo As DisplayMember, HolNo AS ValueMember FROM Holiday WHERE CalendarNo = @CalendarNo</APIGetHolidaysByCalendarNo>
    <APIGetMHolidayByCalendarNo>SELECT CalendarNo, Description, LastUpdated, caObjectID, LastOperator, LastWorkStation, UTCOffset FROM MHoliday WHERE CalendarNo = @CalendarNo</APIGetMHolidayByCalendarNo>
    <InputDVRSelect partitioned="False">SELECT DvrServerID,DvrCameraID ,VideoStartTime ,VideoEndTime FROM Input WHERE PnlRef = @PnlRef AND InpNo = @InpNo</InputDVRSelect>
    <inputGetAll partitioned="False" notificationtable="Input">
      Select PnlRef ,
      InpNo ,
      InputName ,
      Description ,
      Enabled ,
      NormOpen ,
      Supervised ,
      NoXact ,
      AbnormDial ,
      NormDial ,
      ConRelay ,
      InpTz ,
      InpDelay ,
      InpReset ,
      Priority ,
      MapId ,
      DeviceId ,
      RespReq ,
      Remark ,
      Location ,
      DvrServerID ,
      DvrCameraID ,
      VideoStartTime ,
      VideoEndTime ,
      VideoEventType ,
      EnableRecording ,
      NoofSecsToRecord ,
      AlertLimit ,
      LimitSchedule ,
      caObjectID ,
      LastUpdated ,
      LastOperator ,
      LastWorkStation
      From Input
    </inputGetAll>
    <inputgrid partitioned="True">
      select
      caObjectID
      ,PnlRef
      ,InpNo
      ,Convert(Char(6),PnlRef) + '- ' + Convert(Char(3),InpNo) as Input
      ,InputName as 'Device Name'
      ,Enabled
      ,NormOpen
      ,Supervised
      ,NoXact as 'No Xact'
      ,ConRelay as 'Console Relay'
      ,InpTz as 'Enable Tz'
      ,InpDelay as Delay
      ,AbnormDial as Dialup
      ,LastUpdated as 'Last Edit'
      from input
      order by pnlref ,inpno
    </inputgrid>
    <inputlookup partitioned="True" notificationtable="Input">
      select 0 as ValueMember, 'None' as DisplayMember, 0 as PnlRef
      union
      select InpNo as ValueMember,InputName as DisplayMember,PnlRef from Input
    </inputlookup>
     <APIinputlookup partitioned="True" notificationtable="Input">
      select 0 as ValueMember, 'None' as DisplayMember, 0 as PnlRef
      union
      select InpNo as ValueMember,InputName as DisplayMember,PnlRef from Input
    </APIinputlookup>
    <inputlookupbypanel partitioned="True" notificationtable="Input">
      select 0 as ValueMember, 'None' as DisplayMember, 0 as PnlRef, '00000000-0000-0000-0000-000000000000' as caObjectID
      union
      select InpNo as ValueMember,InputName as DisplayMember,PnlRef,caObjectID from Input where pnlref = @pnlref
    </inputlookupbypanel>
    <assignedPartitionLookup partitioned="False">
      Select Distinct P.PartitionID as ValueMember,PartitionName as DisplayMember From [Partition] P,OperatorPartitions OP
      Where OP.OperatorID = @OperatorID AND P.PartitionID = OP.PartitionID
      AND p.DeviceType in (0, @DeviceType)
      ORDER BY PartitionName
    </assignedPartitionLookup>
    <assignedPartitionLookupEventRpt partitioned="False">
      Select Distinct P.PartitionID as ValueMember,PartitionName as DisplayMember From [Partition] P,OperatorPartitions OP
    </assignedPartitionLookupEventRpt>
    <assignedPartitionForDeviceLookup partitioned="False">
      SELECT Distinct P.PartitionID AS ValueMember,PartitionName AS DisplayMember FROM Partition P, DevicePartitions dp,OperatorPartitions OP
      WHERE dp.caObjectID = @caObjectID AND P.PartitionID = dp.PartitionID
      AND p.DeviceType IN (0, @DeviceType)
    </assignedPartitionForDeviceLookup>
    <GetGlobalAdminPartitionLookup partitioned="False">
      Select PartitionID as ValueMember,PartitionName as DisplayMember From [Partition] p
      Where p.DeviceType in (0, @DeviceType)
      ORDER BY PartitionName
    </GetGlobalAdminPartitionLookup>
    <GetGlobalAdminPartitionLookupForEventRpt partitioned="False">
      Select PartitionID as ValueMember,PartitionName as DisplayMember From [Partition] p
    </GetGlobalAdminPartitionLookupForEventRpt>
    <inputlookupjoin partitioned="False">
      select
      i.PnlRef
      ,p.PanelName as PnlRefText
      ,i.InpTz
      ,t1.Description as InpTzText
      ,i.LimitSchedule
      ,t2.Description as LimitScheduleText
      ,i.DvrServerID
      ,f.ServerName        as DvrServerIDtext
      ,i.DvrCameraID
      ,c.CameraName        as DvrCameraIDText
      ,i.VideoEventType
      , CASE i.VideoEventType
      WHEN (0) THEN 'Normal'
      WHEN (1) THEN 'Abnormal'
      WHEN (2) THEN 'Both'
      END AS VideoEventTypeText
      ,i.VideoStartTime
      ,i.VideoEndTime
      ,i.EnableRecording
      ,i.NoofSecsToRecord
      ,i.InpDelay
      ,i.InpReset
      ,i.RecordingSchedule
      ,t3.Description as RecordingScheduleText
      ,i.CatSchedule
      ,t4.Description as CatScheduleText
      from input i
      left outer join Panel p on i.PnlRef = p.PnlNo
      left outer join MTimezon t1 on i.InpTz = t1.TzNum
      left outer join MTimezon t2 on i.LimitSchedule = t2.TzNum
      left outer join MTimezon t3 on i.recordingSchedule = t3.TzNum
      left outer join MTimezon AS t4 on i.CatSchedule = t4.TzNum
      left outer join DvrConfig f on i.DvrServerID =  f.DvrID
      left outer join DvrCamera c on i.DvrCameraID =  c.DvrCameraID AND i.DvrServerID =  c.[DvrServerID]
      Where i.PnlRef = @PnlRef
      and i.InpNo = @InpNo
    </inputlookupjoin>
    <insertactivelinks partitioned="False">
      insert into ActiveLinks(PnlRef,ProgNo,RelNo,Control,PnlNo)
      select @pnlref,@progNo,r.relno,0,@pnlno from relay r where r.pnlref = @pnlno
    </insertactivelinks>
    <InsertActiveThreatLevel partitioned="False">
      INSERT INTO [dbo].[ActiveThreatLevel]           ([LockdownID]           ,[CatNumber]           ,[LastUpdated])
      VALUES (@LockdownId,@catNumber,getutcDate())
    </InsertActiveThreatLevel>
    <ApiDeleteActiveThreatLevelByCat partitioned="False">DELETE ActiveThreatLevel WHERE LockdownID=@LockdownId AND CatNumber=@catNumber</ApiDeleteActiveThreatLevelByCat>
    <ApiDeleteActiveThreatLevelByLockdownID partitioned="False">DELETE ActiveThreatLevel WHERE LockdownID=@LockdownId</ApiDeleteActiveThreatLevelByLockdownID>
    <ApiGetMThreatLevelByLockdownID>SELECT Description, Active, LockoutArea, DenyAccess, caObjectID FROM MActiveThreatLevel WHERE LockdownID=@LockdownID</ApiGetMThreatLevelByLockdownID>
    <insertdevicepartitions partitioned="False">
      INSERT INTO [dbo].[DevicePartitions]
      ([PartitionID]
      ,[caObjectID])
      VALUES
      (@PartitionID,@caObjectID)
    </insertdevicepartitions>
    <insertdialuprequest partitioned="False">
      INSERT INTO ComServer (
      WorkStationID
      ,Record,
      Val1,Val2,
      Val3,Val4,Val5,LastUpdated
      ) Values(
      @WorkStationID,
      -25,
      @Val1,@Val2,
      0,0,0,DateAdd(Day,1,GetDate()))
    </insertdialuprequest>
    <InsertLDAPOperator partitioned="False">
      exec ca_sp_AddLDAPOperator
      @OperatorID,
      @OperFName,
      @OperLName,
      @OperLoginName,
      @Enabled,
      @OperPassword,
      @PhoneNo,
      @EmailID,
      @PagerID,
      @LastLoggedIn,
      @LastLoggedInUncName,
      @LogoffTime,
      @AutoAckTime,
      @LastUpdated,
      @PasswordRequiresUpdate,
      @IsGlobalAdministrator,
      @MaxThreatLevelAllowed,
      @CanChangeThreatLevel,
      @UseLegacyDisplay,
      @ManualPrivileges,
      @OperSNPPHostID,
      @OperUseSNPP,
      @OperUseEmail,
      @ColorScheme,
      @PasswordExpiresIn,
      @LoginAttempts,
      @DisableLogoff,
      @LanguageId,
      @EventCount,
      @LastOperator,
      @LastWorkStation,
      @UTCOffset,
      @UserGroup
    </InsertLDAPOperator>
    <insertlockstatus partitioned="False">
      IF EXISTS (SELECT 1 FROM LockStatus WHERE comport=@comport and pnlref=@pnlref)
      BEGIN
      UPDATE LockStatus SET lockid=@lockid , rxrssi=@rxrssi, txrssi=@txrssi, version=@version, locktype=@locktype, assigned=@assigned, status=@status, RepeaterAddress=@RepeaterAddress, lastupdated=@lastupdated
      WHERE comport=@comport and pnlref=@pnlref
      END
      ELSE
      BEGIN
      INSERT INTO LockStatus (pnlref,comport,lockid,rxrssi,txrssi,version,locktype,assigned,status,RepeaterAddress, lastupdated) VALUES (@pnlref,@comport,@lockid,@rxrssi,@txrssi,@version,@locktype,@assigned,@status,@RepeaterAddress, @lastupdated)
      END
    </insertlockstatus>
    <InsertMap partitioned="False">INSERT INTO Map (MapUID, MapID, MapName, MapDescription, MapImage, caObjectID) VALUES (@MapUID, @MapID, @MapName, @MapDescription, @MapImage, @caObjectID)</InsertMap>
    <insertoperatorprivilege partitioned="False">Insert Into OperatorPrivileges (OperatorID,ScreenID,ScreenObjectID,SecurityLevel) Values(@OperatorID,@ScreenID,@ScreenObjectID,@SecurityLevel)</insertoperatorprivilege>
    <insertscreenobjects partitioned="False">Insert Into ScreenObjects(ScreenObjectID,ScreenID,ObjectName) Values(@ScreenObjectID,@ScreenID,@SecurityKey)</insertscreenobjects>
    <insertscreens partitioned="False">Insert Into Screens (ScreenID,ScreenName) Values(@ScreenID,@ScreenName)</insertscreens>
    <InsertGatewayStatusTable partitioned="False">
      IF EXISTS (SELECT 1 FROM GatewayStatus WHERE Comport = @ComPort)
      BEGIN
      UPDATE GatewayStatus SET MACAddress=@MACAddress, IPAddress=@IPAddress, Version=@Version, Status=@Status, LockCount=@LockCount, HasRepeaters=@HasRepeaters, RepeaterCount=@RepeaterCount, GroupNo=@GroupNo, LastUpdated=@LastUpdated, Cluster=@Cluster WHERE Comport=@ComPort
      END
      ELSE
      BEGIN
      INSERT INTO GatewayStatus(Comport,MACAddress,IPAddress,Version,Status,LockCount,HasRepeaters,RepeaterCount,GroupNo,LastUpdated,Cluster)VALUES(@ComPort,@MACAddress,@IPAddress,@Version,@Status,@LockCount,@HasRepeaters,@RepeaterCount,@GroupNo,@LastUpdated,@Cluster)
      END
    </InsertGatewayStatusTable>
    <InsertRepeaterStatusTable partitioned="False">
      INSERT INTO RepeaterStatus(Cluster, Comport, rfAddress, Id, RouteIn, RouteOut, State, RSSI, FirmwareMajor, FirmwareMinor, Status)
      VALUES(@Cluster, @Comport, @rfAddress, @Id, @RouteIn, @RouteOut, @State, @RSSI, @FirmwareMajor, @FirmwareMinor, @Status);
      Update [GatewayStatus] SET RepeaterCount = RepeaterCount+1 Where Comport =@Comport;
    </InsertRepeaterStatusTable>
    <invalidateOperatorPassword partitioned="False">
      update operators set PasswordRequiresUpdate = 1 where OperatorId = @OperatorId
    </invalidateOperatorPassword>
    <IPFromCom partitioned="False">Select C.IPAddress,C.IPPort,C.ZoneId,Z.Description,Z.UTCBias FROM Com C left join Zones Z on Z.ZoneId=C.ZoneId WHERE C.HCSNo=@HCSNo and C.ComPort=@ComPort</IPFromCom>
    <IsUsingScripting partitioned="False" notificationtable="WorkstationSettings">Select COUNT(*) FROM SystemSettings where UseScripting = @UseScripting  AND SysID = @SysID</IsUsingScripting>
    <IsWirelessLockEnabled>
      if (@UNCName = '')
        select count(*) as Cnt from WorkStationSettings where UseWirelessLocks = 1
      else
        select count(*) as Cnt from WorkStationSettings where UseWirelessLocks = 1 and WorkStationName = @UNCName
    </IsWirelessLockEnabled>
    <lastvalidaccess partitioned="False">
      SELECT   r.ReaderName as Description, b.LVDate
      FROM BadgeUpdate b
      INNER JOIN Reader r
      ON b.LVPnl=r.PnlRef
      AND b.LVRdr=r.RdrNo
      AND b.Badge=@Badge
      AND b.Facility=@Facility
    </lastvalidaccess>
    <linkbypanellookup partitioned="True" notificationtable="Link">
      SELECT 0 as PnlRef ,0 as ProgNo, '0  - 0  ' as ValueMember,  'None' as DisplayMember
      UNION
      select PnlRef,ProgNo,Convert(Char(6),PnlRef) + '- ' + Convert(Char(6),ProgNo) AS ValueMember, linkName as DisplayMember
      from Link

    </linkbypanellookup>
    <LinkEnabledLookUp partitioned="False" notificationtable="Link">
      select l.ManualPriv,l.pnlref,l.LinkName as description,l.progno
      ,p.paneltype from link l
      inner join panel p on p.pnlno = l.pnlref where l.enabled = 1
    </LinkEnabledLookUp>
    <linkgrid partitioned="True">
      select PnlRef, ProgNo, CAST(pnlRef AS VARCHAR(100)) +'-'+ CAST(progNo AS VARCHAR(100)) as [Panel Prog],LinkName as [Device Name], Enabled, DialUp as [Dial on Active], RptXact as [Report Activity], lnkPnl as [Lnk Panel], lnkProg as [Lnk Prog], Etz as [Enable Schedule], TrkTz as [Track Schedule], Priority as [Event Priority] , RespReq as [Resp Req], LastUpdated as 'Last Edit', caObjectID
      FROM Link
      order by pnlref,progno
    </linkgrid>
    <APIlinkgrid partitioned="False">
      select PnlRef, ProgNo, CAST(pnlRef AS VARCHAR(100)) +'-'+ CAST(progNo AS VARCHAR(100)) as [Panel Prog],LinkName as [Device Name], Enabled, DialUp as [Dial on Active], RptXact as [Report Activity], lnkPnl as [Lnk Panel], lnkProg as [Lnk Prog], Etz as [Enable Schedule], TrkTz as [Track Schedule], Priority as [Event Priority] , RespReq as [Resp Req], LastUpdated as 'Last Edit', caObjectID
      FROM Link
      order by pnlref,progno
    </APIlinkgrid>
    <linklookup partitioned="True" notificationtable="Link">select ProgNo as ValueMember, LinkName as DisplayMember, caObjectID  from Link where pnlref = @pnlref</linklookup>
    <linklookupjoin partitioned="False">

      select
      l.PnlRef
      ,p.PanelName as PnlRefText
      ,l.ETz
      ,t1.Description as ETzText
      ,l.ManualPriv
      , CASE l.ManualPriv
      WHEN (0) THEN 'All'
      WHEN (1) THEN 'Priv 1'
      WHEN (2) THEN 'Priv 2'
      WHEN (3) THEN 'Priv 3'
      WHEN (4) THEN 'Priv 4'
      WHEN (5) THEN 'Priv 5'
      WHEN (6) THEN 'Priv 6'
      WHEN (7) THEN 'Priv 7'
      WHEN (8) THEN 'Priv 8'
      END AS ManualPrivText
      ,l.LnkProg
      ,l1.LinkName as LnkProgText
      ,l.inp1
      ,case l.inp1 WHEN(0) THEN 'None' ELSE i1.InputName END as inp1Text
      ,l.inp2
      ,case l.inp2 WHEN(0) THEN 'None' ELSE i2.InputName END as inp2Text
      ,l.inp3
      ,case l.inp3 WHEN(0) THEN 'None' ELSE i3.InputName END as inp3Text
      ,l.inp4
      ,case l.inp4 WHEN(0) THEN 'None' ELSE i4.InputName END as inp4Text
      ,l.inp5
      ,case l.inp5 WHEN(0) THEN 'None' ELSE i5.InputName END as inp5Text
      ,l.TrkTz
      ,t2.Description as TrkTzText
      ,l.off1
      ,case l.off1 WHEN(0) THEN 'None' ELSE off1.RelayName END as off1Text
      ,l.off2
      ,case l.off2 WHEN(0) THEN 'None' ELSE off2.RelayName END as off2Text
      ,l.off3
      ,case l.off3 WHEN(0) THEN 'None' ELSE off3.RelayName END as off3Text
      ,l.off4
      ,case l.off4 WHEN(0) THEN 'None' ELSE off4.RelayName END as off4Text
      ,l.off5
      ,case l.off5 WHEN(0) THEN 'None' ELSE off5.RelayName END as off5Text
      ,l.on1
      ,case l.on1 WHEN(0) THEN 'None' ELSE on1.RelayName END as on1Text
      ,l.on2
      ,case l.on2 WHEN(0) THEN 'None' ELSE on2.RelayName END as on2Text
      ,l.on3
      ,case l.on3 WHEN(0) THEN 'None' ELSE on3.RelayName END as on3Text
      ,l.on4
      ,case l.on4 WHEN(0) THEN 'None' ELSE on4.RelayName END as on4Text
      ,l.on5
      ,case l.on5 WHEN(0) THEN 'None' ELSE on5.RelayName END as on5Text
      ,l.trk1
      ,case l.trk1 WHEN(0) THEN 'None' ELSE trk1.RelayName END as trk1Text
      ,l.trk2
      ,case l.trk2 WHEN(0) THEN 'None' ELSE trk2.RelayName END as trk2Text
      ,l.trk3
      ,case l.trk3 WHEN(0) THEN 'None' ELSE trk3.RelayName END as trk3Text
      ,l.trk4
      ,case l.trk4 WHEN(0) THEN 'None' ELSE trk4.RelayName END as trk4Text
      ,l.trk5
      ,case l.trk5 WHEN(0) THEN 'None' ELSE trk5.RelayName END as trk5Text
      from link l
      left outer join Panel p on l.PnlRef = p.PnlNo
      left outer join MTimezon t1 on l.ETz = t1.TzNum
      left outer join Link l1 on l.LnkProg = l1.ProgNo and l.PnlRef = l1.PnlRef
      left outer join input i1 on l.inp1 = i1.InpNo and l.PnlRef = i1.PnlRef
      left outer join input i2 on l.inp2 = i2.InpNo and l.PnlRef = i2.PnlRef
      left outer join input i3 on l.inp3 = i3.InpNo and l.PnlRef = i3.PnlRef
      left outer join input i4 on l.inp4 = i4.InpNo and l.PnlRef = i4.PnlRef
      left outer join input i5 on l.inp5 = i5.InpNo and l.PnlRef = i5.PnlRef
      left outer join MTimezon t2 on l.TrkTz = t2.TzNum
      left outer join Relay off1 on l.off1 = off1.RelNo and l.PnlRef = off1.PnlRef
      left outer join Relay off2 on l.off2 = off2.RelNo and l.PnlRef = off2.PnlRef
      left outer join Relay off3 on l.off3 = off3.RelNo and l.PnlRef = off3.PnlRef
      left outer join Relay off4 on l.off4 = off4.RelNo and l.PnlRef = off4.PnlRef
      left outer join Relay off5 on l.off5 = off5.RelNo and l.PnlRef = off5.PnlRef
      left outer join Relay on1 on l.on1 = on1.RelNo and l.PnlRef = on1.PnlRef
      left outer join Relay on2 on l.on2 = on2.RelNo and l.PnlRef = on2.PnlRef
      left outer join Relay on3 on l.on3 = on3.RelNo and l.PnlRef = on3.PnlRef
      left outer join Relay on4 on l.on4 = on4.RelNo and l.PnlRef = on4.PnlRef
      left outer join Relay on5 on l.on5 = on5.RelNo and l.PnlRef = on5.PnlRef
      left outer join Relay trk1 on l.trk1 = trk1.RelNo and l.PnlRef = trk1.PnlRef
      left outer join Relay trk2 on l.trk2 = trk2.RelNo and l.PnlRef = trk2.PnlRef
      left outer join Relay trk3 on l.trk3 = trk3.RelNo and l.PnlRef = trk3.PnlRef
      left outer join Relay trk4 on l.trk4 = trk4.RelNo and l.PnlRef = trk4.PnlRef
      left outer join Relay trk5 on l.trk5 = trk5.RelNo and l.PnlRef = trk5.PnlRef
      Where l.PnlRef = @PnlRef
      and l.ProgNo = @ProgNo
    </linklookupjoin>
    <linkprivenabledlookup partitioned="False">
      select l.ManualPriv,l.pnlref,l.LinkName as description,l.progno as deviceno ,p.paneltype
      from link l
      inner join panel p on p.pnlno = l.pnlref
      where l.enabled = 1
      and ( (l.ManualPriv = 0)
      or   (l.ManualPriv in (
      select ManualPrivilege from manualprivilege where OperatorID = @OperatorID )))
      and l.caObjectID in (
      SELECT devicepartitions.caObjectID FROM OperatorPartitions inner join  devicepartitions on devicepartitions.PartitionId = OperatorPartitions.Partitionid where OperatorPartitions.OperatorID = @OperatorID)
    </linkprivenabledlookup>

    <linkscprivenabledlookup partitioned="False">
      select 0 as pnlref, 0 as ValueMember, 'None' as DisplayMember
      union
      select l.pnlref,l.progno as ValueMember,l.LinkName as DisplayMember
      from link l
      inner join panel p on p.pnlno = l.pnlref
      where l.enabled = 1
      and l.caObjectID in (
      SELECT devicepartitions.caObjectID FROM OperatorPartitions inner join  devicepartitions on devicepartitions.PartitionId = OperatorPartitions.Partitionid where OperatorPartitions.OperatorID = @OperatorID)
    </linkscprivenabledlookup>
    
    <linkprivpartitionenabledlookup partitioned="False">
      select l.ManualPriv,l.pnlref,l.LinkName as description,l.progno as deviceno ,p.paneltype
      from link l
      inner join panel p on p.pnlno = l.pnlref
      where l.enabled = 1
      and ( (l.ManualPriv = 0)
      or   (l.ManualPriv in (
      select ManualPrivilege from manualprivilege where OperatorID = @OperatorID )))
      and l.caObjectID in (SELECT caObjectID FROM devicepartitions  where PartitionID = @PartitionID)
    </linkprivpartitionenabledlookup>

    <linkscprivpartitionenabledlookup partitioned="False">
      select 0 as pnlref, 0 as ValueMember, 'None' as DisplayMember
      union
      select l.pnlref,l.progno as ValueMember,l.LinkName as DisplayMember
      from link l
      inner join panel p on p.pnlno = l.pnlref
      where l.enabled = 1
      and l.caObjectID in (SELECT caObjectID FROM devicepartitions  where PartitionID = @PartitionID)
    </linkscprivpartitionenabledlookup>
    
    <locationlookup partitioned="False" notificationtable="Person">
      select 0 as ValueMember, 'None' as DisplayMember
      union
      select LocationID as ValueMember
      , Location as DisplayMember
      from LocationInfo
    </locationlookup>
    <LockAddressAssigned partitioned="False">Select PnlNo from Panel where Address=@Address and ComPort=@ComPort and HCSNo=@HCSNo</LockAddressAssigned>
    <LockAddressForGateway partitioned="False">Select Address FROM Panel Where (PanelType=101 OR PanelType=102) and ComPort=@ComPort and HCSNo=@HCSNo</LockAddressForGateway>
    <LockCountForGateway partitioned="False">Select Count(*) as Cnt from Com where ComPort=@ComPort and Type=10</LockCountForGateway>
    <lockdownareadetailgrid partitioned="True">
      SELECT PnlRef, RdrNo, ReaderName, PanelName, Active FROM (
      SELECT DISTINCT r.PnlRef, r.RdrNo, r.ReaderName, p.PanelName,
      CAST(ISNULL(l.PnlRef, 0) AS bit) AS 'Active', r.caObjectID FROM Reader AS r
      LEFT OUTER JOIN  LockdownAreas AS l ON l.PnlRef = r.PnlRef AND
      l.RdrNo = r.RdrNo  and l.AreaNo = @AreaNo
      INNER JOIN  Panel AS p ON r.PnlRef = p.PnlNo AND p.PanelType  in (3,5,6,7,8,9,10,11,12,13,14,15,16,17,101,102)
      ) AS TAB ORDER BY PnlRef,ReaderName
    </lockdownareadetailgrid>
    <lockdownareagrid partitioned="True">
      SELECT AreaNo AS 'Area No',AreaName AS 'Area Name',Active,caObjectID,
      LastUpdated AS 'Last Edit'  FROM MLockdownAreas
    </lockdownareagrid>
    <ApiLockdownareagrid partitioned="True">
      SELECT AreaNo AS 'Area No',AreaName AS 'Area Name',Active,
      LastUpdated AS 'Last Edit'  FROM MLockdownAreas
    </ApiLockdownareagrid>
    <LockdownStatusGrid partitioned="False">
      select l.PnlRef,l.RdrNo, m.Areano,m.AreaName,m.Active,
      r.ReaderName,r.caObjectID FROM MLockdownAreas m
      LEFT JOIN LockdownAreas l on m.Areano=l.Areano
      LEFT JOIN Reader r on l.PnlRef=r.PnlRef and l.RdrNo=r.RdrNo
      where m.caObjectID in
      (SELECT devicepartitions.caObjectID FROM OperatorPartitions inner join  devicepartitions on devicepartitions.PartitionId = OperatorPartitions.Partitionid  where  OperatorPartitions.OperatorID = @OperatorID)
      order by  m.AreaName
    </LockdownStatusGrid>
    <APILockdownStatusGrid partitioned="False">
      select l.PnlRef,l.RdrNo, m.Areano,m.AreaName,m.Active,
      r.ReaderName,r.caObjectID FROM MLockdownAreas m
      LEFT JOIN LockdownAreas l on m.Areano=l.Areano
      LEFT JOIN Reader r on l.PnlRef=r.PnlRef and l.RdrNo=r.RdrNo
      where m.caObjectID in
      (SELECT devicepartitions.caObjectID FROM OperatorPartitions inner join  devicepartitions on devicepartitions.PartitionId = OperatorPartitions.Partitionid  where  OperatorPartitions.OperatorID = @OperatorID)
      order by  m.AreaName
    </APILockdownStatusGrid>
    <LockExists partitioned="False">Select caObjectId from Panel Where Address = @Address and HCSNo=@HCSNo and ComPort=@ComPort</LockExists>
    <APIPanelExists partitioned="False">Select caObjectId from Panel Where PnlNo = @PnlNo and HCSNo=@HCSNo and ComPort=@ComPort</APIPanelExists>
    <LockGuidExistsByLockId partitioned="False">Select ComPort, caObjectId from Panel Where LockId=@LockId</LockGuidExistsByLockId>
    <LockInLockdownArea partitioned="False">select distinct pnlref from reader where pnlref=@PnlRef and APBEntry = @APBEntry</LockInLockdownArea>
    <lockoutarealookup partitioned="True" notificationtable="MLockdownAreas">
      select 0 as ValueMember, 'None' as DisplayMember
      union
      select areano as ValueMenber, areaname as DisplayMember  from MLockdownAreas order by DisplayMember
    </lockoutarealookup>
    <mlockdownareaslookup partitioned="True">
      select 0 as ValueMember, 'None' as DisplayMember
      union
      select areano as ValueMenber, areaname as DisplayMember  from MLockdownAreas order by DisplayMember
    </mlockdownareaslookup>
    <LockWithStatusByComNo partitioned="False">
      SELECT l.PnlRef, p.LockId, l.LockType, p.PanelName, l.TxRSSI, l.RxRSSI, l.Version, l.Status, l.Battery, l.LastUpdated,l.RepeaterAddress 
      FROM LockStatus AS l CROSS JOIN
      Panel AS p
      WHERE p.LockId= l.LockId AND p.HCSNo=@HCSNo and p.ComPort=@ComNo and p.Enabled=1 and p.PanelType&lt;&gt;0 and P.ComPort=l.ComPort
      and p.caObjectID in
      (SELECT devicepartitions.caObjectID FROM OperatorPartitions inner join  devicepartitions on devicepartitions.PartitionId = OperatorPartitions.Partitionid  where  OperatorPartitions.OperatorID = @OperatorID)
    </LockWithStatusByComNo>
    <APILockWithStatus partitioned="False">
      SELECT l.PnlRef, p.ComPort, p.HCSNo, p.LockId, l.LockType, p.PanelName, l.TxRSSI, l.RxRSSI, l.Version, l.Status, l.Battery, l.LastUpdated,l.RepeaterAddress
      FROM LockStatus AS l CROSS JOIN
      Panel AS p
      WHERE p.LockId= l.LockId AND p.Enabled=1 and p.PanelType&lt;&gt;0 and P.ComPort=l.ComPort
      and p.caObjectID in
      (SELECT devicepartitions.caObjectID FROM OperatorPartitions inner join  devicepartitions on devicepartitions.PartitionId = OperatorPartitions.Partitionid  where  OperatorPartitions.OperatorID = @OperatorID)
    </APILockWithStatus>
    <LockDeviceStatus>
      Select * from ca_vw_WirlessLockStatus
      where caObjectID in (SELECT devicepartitions.caObjectID FROM OperatorPartitions 
      inner join devicepartitions on devicepartitions.PartitionId = OperatorPartitions.Partitionid  where  OperatorPartitions.OperatorID = @OperatorID)
    </LockDeviceStatus>
    <APILockDeviceStatus>
      Select * from ca_vw_WirlessLockStatus
      where caObjectID in (SELECT devicepartitions.caObjectID FROM OperatorPartitions
      inner join devicepartitions on devicepartitions.PartitionId = OperatorPartitions.Partitionid  where  OperatorPartitions.OperatorID = @OperatorID)
    </APILockDeviceStatus>
    <mactivelinkslookup partitioned="True" notificationtable="MActiveLinks">select ProgNo as ValueMember, Description as DisplayMember from MActiveLinks where UnDo=0 and pnlref = @pnlref</mactivelinkslookup>
    <mactivelinksundolookup partitioned="True" notificationtable="MActiveLinks">select ProgNo as ValueMember, Description as DisplayMember from MActiveLinks where UnDo=1 and pnlref = @pnlref</mactivelinksundolookup>
    <MapAPBAreaDelete partitioned="False">DELETE FROM MapAPBArea WHERE MapAPBAreaUID=@MapAPBAreaUID</MapAPBAreaDelete>
    <MapAPBAreaInsert partitioned="False">INSERT INTO MapAPBArea (MapAPBAreaUID, APBAreasID, MapUID, DrawingCode) VALUES (@MapAPBAreaUID, @APBAreasID, @MapUID, @DrawingCode)</MapAPBAreaInsert>
    <MapAPBAreaSelect partitioned="False">SELECT MapAPBAreaUID, APBAreasID, MapUID, DrawingCode FROM MapAPBArea WHERE MapUID=@MapUID</MapAPBAreaSelect>
    <MapAPBAreaUpdate partitioned="False">UPDATE MapAPBArea SET APBAreasID=@APBAreasID, MapUID=@MapUID, DrawingCode=@DrawingCode WHERE MapAPBAreaUID=@MapAPBAreaUID</MapAPBAreaUpdate>
    <MapCameraName partitioned="False">Select CameraName From DVRCamera where DvrCameraID = @DvrCameraID and DvrServerID = @DvrServerID</MapCameraName>
    <MapDelete partitioned="False">DELETE FROM Map Where MapUID=@MapUID</MapDelete>
    <MapDisplayIcon partitioned="False">
      SELECT MapDisplayIconID
      ,EventCode
      ,DefaultIcon
      ,DisplayIcon
      ,LangEventName as EventName
      ,DeviceCode
      FROM MapDisplayIcon
    </MapDisplayIcon>
    <MapDVRConfig partitioned="False">Select DVRID,ServerIP,UserName,Password,DVRVendor,ServerName,EnableNotification  From DVRConfig Where DVRID = @DVRID</MapDVRConfig>
    <MapDVRLocalTime partitioned="False">SELECT UTCBias, dStart, sStart, dBias FROM DVRConfig D, Zones Z WHERE D.DVRID = @DVRID AND Z.ZoneID=D.ZoneID</MapDVRLocalTime>
    <MapEventFilterDelete partitioned="False">DELETE FROM MapEventFilter WHERE MapEventFilterID=@MapEventFilterID</MapEventFilterDelete>
    <MapEventFilterInsert partitioned="False">INSERT INTO MapEventFilter (MapUID, EventCode, IsEnable) VALUES (@MapUID, @EventCode, @IsEnable); SELECT @MapEventFilterID=SCOPE_IDENTITY();</MapEventFilterInsert>
    <MapEventFilterSelect partitioned="False">SELECT MapEventFilterID, MapUID, EventCode, IsEnable FROM MapEventFilter WHERE MapUID=@MapUID</MapEventFilterSelect>
    <MapEventFilterUpdate partitioned="False">UPDATE MapEventFilter SET MapUID=@MapUID, EventCode=@EventCode, IsEnable=@IsEnable WHERE MapEventFilterID=@MapEventFilterID</MapEventFilterUpdate>
    <MapIDSelect partitioned="False" notificationtable="Map">SELECT MapID FROM Map WHERE MapUID=@MapUID</MapIDSelect>
    <MapInsert partitioned="False">
      INSERT INTO Map (MapUID, MapName, MapDescription, MapImage, caObjectID, MapWidth, MapHeight, Snapshot
      ,LastOperator                         ,LastWorkStation
      )
      VALUES (@MapUID, @MapName, @MapDescription, @MapImage, @caObjectID, @MapWidth, @MapHeight, @Snapshot
      ,@LastOperator                         ,@LastWorkStation
      )
    </MapInsert>
    <MapList partitioned="True">SELECT MapUID, MapID, MapName, MapImage, MapDescription, caObjectID, Snapshot FROM Map order by MapName</MapList>
    <maplookup partitioned="False">SELECT m.mapimage,m.mapname, m.mapdescription from MapPoints mp inner join map m on m.mapid = mp.mapno where mp.Type = @Type and mp.PanelNo = @PnlNo and mp.DevNo = @DeviceNo</maplookup>
    <MapPointsDelete partitioned="False">DELETE FROM MapPoints WHERE MapPointsUID=@MapPointsUID</MapPointsDelete>
    <MapPointsEventFilterDelete partitioned="False">DELETE FROM MapPointsEventFilter WHERE MapPointsEventFilterID=@MapPointsEventFilterID</MapPointsEventFilterDelete>
    <MapPointsEventFilterInsert partitioned="False">INSERT INTO MapPointsEventFilter (MapPointsUID, MapUID, EventCode, IsEnable) VALUES (@MapPointsUID, @MapUID, @EventCode, @IsEnable); SELECT @MapPointsEventFilterID=SCOPE_IDENTITY()</MapPointsEventFilterInsert>
    <MapPointsEventFilterSelect partitioned="False">SELECT MapPointsEventFilterID, MapPointsUID, MapUID, EventCode, IsEnable FROM MapPointsEventFilter WHERE MapUID=@MapUID</MapPointsEventFilterSelect>
    <MapPointsEventFilterUpdate partitioned="False">UPDATE MapPointsEventFilter SET MapPointsUID=@MapPointsUID, MapUID=@MapUID, EventCode=@EventCode, IsEnable=@IsEnable WHERE MapPointsEventFilterID=@MapPointsEventFilterID</MapPointsEventFilterUpdate>
    <MapPointsEventFilterIsExists partitioned="False">
      SELECT IsExists = 
        CASE
          WHEN EXISTS (SELECT 1 FROM MapPointsEventFilter WHERE MapUID = @MapUID)
          THEN
            CASE  
              WHEN EXISTS (SELECT 1 FROM MapPointsEventFilter WHERE IsEnable=1 AND MapUID = @MapUID AND EventCode = @EventCode)
              THEN 1
            ELSE 0
          END
        ELSE 1
      END
    </MapPointsEventFilterIsExists>
    <MapPointsInsert partitioned="False">INSERT INTO MapPoints (MapPointsUID, MapUID, DeviceType, DeviceObjectID, PointX, PointY, MapAPBAreaUID, DvrCameraID, DVRServerID, PanelType) VALUES (@MapPointsUID, @MapUID, @DeviceType, @DeviceObjectID, @PointX, @PointY, @MapAPBAreaUID, @DvrCameraID, @DVRServerID, @PanelType)</MapPointsInsert>
    <MapPointsSelect partitioned="False">SELECT MapPointsUID, MapUID, DeviceType, DeviceObjectID, PointX, PointY, MapAPBAreaUID, DvrCameraID, DVRServerID, PanelType FROM MapPoints WHERE MapUID = @MapUID</MapPointsSelect>
    <MapPointsUpdate partitioned="False">UPDATE MapPoints SET MapUID=@MapUID, DeviceType=@DeviceType, DeviceObjectID=@DeviceObjectID, PointX=@PointX, PointY=@PointY, MapAPBAreaUID=@MapAPBAreaUID, DvrCameraID = @DvrCameraID, DVRServerID = @DVRServerID, PanelType = @PanelType WHERE MapPointsUID=@MapPointsUID</MapPointsUpdate>
    <MapRename partitioned="False">UPDATE Map SET MapName=@MapName WHERE MapUID = @MapUID</MapRename>
    <MapSelect partitioned="False" notificationtable="Map">SELECT MapUID, MapID, MapName, MapDescription, MapImage,caObjectID, MapHeight, MapWidth, Snapshot FROM Map WHERE MapUID=@MapUID</MapSelect>
    <MapSettings partitioned="False">SELECT MapToolTipInterval, MapManualControlDblClick, MapCloseAlert, MapTheme, StatusUpdateInterval FROM OperatorSettings WHERE OperatorID = @OperatorID</MapSettings>
    <MapUpdate partitioned="False">
      UPDATE Map SET MapName=@MapName, MapDescription=@MapDescription, MapImage=@MapImage, MapWidth=@MapWidth, MapHeight=@MapHeight, Snapshot=@Snapshot
      ,LastOperator       =@LastOperator
      ,LastWorkStation                 = @LastWorkStation
      WHERE MapUID=@MapUID
    </MapUpdate>
    <maxSystemAG partitioned="False">SELECT DISTINCT(Badge) FROM BadgeAccess WHERE AGSeq&gt;@AGNo</maxSystemAG>
    <mcomCount partitioned="False">select count(*) as cnt from MCom</mcomCount>
    <mcomlookup partitioned="true" notificationtable="MCom">select HCSNo as ValueMember, Description as DisplayMember from MCOM</mcomlookup>
    <APImcomlookup partitioned="true" notificationtable="MCom">select HCSNo as ValueMember, Description as DisplayMember from MCOM</APImcomlookup>
    <MessageTemplatesList partitioned="False" notificationtable="MessageTemplates">Select templateID,subject,body,allowSNPP,allowEmail,allowSMS,include from MessageTemplates</MessageTemplatesList>
    <mholidaylookup partitioned="True" notificationtable="MHoliday">
      select CalendarNo as ValueMember, Description as DisplayMember from MHoliday
    </mholidaylookup>
    <elevatorfacilitylookup partitioned="True" notificationtable="ElevatorFloors">
      select 0 as ValueMember, 'None' as DisplayMember
      union
      select ElevFacilityId as ValueMenber, ElevFacilityName as DisplayMember  from ElevFacilities order by DisplayMember
    </elevatorfacilitylookup>
    <APIelevatorfacilitylookup partitioned="True" notificationtable="ElevatorFloors">
      select 0 as ValueMember, 'None' as DisplayMember, '00000000-0000-0000-0000-000000000000' as caObjectID
      union
      select ElevFacilityId as ValueMenber, ElevFacilityName as DisplayMember, caObjectID  from ElevFacilities order by DisplayMember
    </APIelevatorfacilitylookup>
    <mholidaynofilterlookup partitioned="False" notificationtable="MHoliday">
      select -1 as ValueMember,  '&lt;No Filter&gt;' as DisplayMember
      union
      select CalendarNo as ValueMember, Description as DisplayMember from MHoliday
    </mholidaynofilterlookup>
    <mshuntbyid partitioned="False" notificationtable="MShunt">
      select Active from MShunt
      where ShuntID = @ShuntID
    </mshuntbyid>
    <mshuntlookup partitioned="True" notificationtable="MShunt">
      select 0 as ValueMember, 'None' as DisplayMember
      ,0 as Active
      union
      select ShuntID as ValueMember, ShuntName as DisplayMember
      ,Active
      from MShunt
    </mshuntlookup>
    <ApiShuntGroupsGrid partitioned="True">
      select ShuntId, ShuntName, [Active], LastUpdated AS 'Last Edit' from MShunt
    </ApiShuntGroupsGrid>
    <mshuntupdate partitioned="False">
      UPDATE MShunt SET Active=@Active, LastOperator=@LastOperator, LastWorkStation=@LastWorkStation WHERE ShuntId=@ShuntId
    </mshuntupdate>
    <mtimezonlookup partitioned="True" notificationtable="MTimezon">
      select 0 as ValueMember, 'Not Used' as DisplayMember
      union
      select TzNum as ValueMember, Description as DisplayMember  from MTimezon
    </mtimezonlookup>
    <APImtimezonlookup partitioned="True" notificationtable="MTimezon">
      select 0 as ValueMember, 'Not Used' as DisplayMember
      union
      select TzNum as ValueMember, Description as DisplayMember  from MTimezon
    </APImtimezonlookup>
    <mtimezonnoresults partitioned="False" notificationtable="MTimezon">select 1 from mtimezon where 1=0</mtimezonnoresults>
    <mtimezonPartitionlookup partitioned="False" notificationtable="MTimezon">
      if OBJECT_ID('tempdb..#timezoneTemp') is not null drop table #timezoneTemp
      create table #timezoneTemp( [PanelID] int  ,[AccessGroupID] int  ,[ReaderID] int ,[TimeZoneID]int)
      insert into #timezoneTemp SELECT * FROM   ca_vw_ReaderAccessGroupTimeZone

      select ValueMember, DisplayMember from (
      select 0 as ValueMember, 'Not Used' as DisplayMember
      union
      SELECT MTimezon.TzNum,MTimezon.Description
      FROM   #timezoneTemp inner JOIN MTimezon on #timezoneTemp.TimeZoneID=MTimezon.TzNum
      where  #timezoneTemp.AccessGroupID=@AccessGroupID
      union
      select TzNum as ValueMember, Description as DisplayMember  from MTimezon
      where caObjectID in (SELECT devicepartitions.caObjectID FROM OperatorPartitions inner join  devicepartitions on devicepartitions.PartitionId = OperatorPartitions.Partitionid
      where OperatorPartitions.OperatorID = @OperatorID)
      ) A group by ValueMember, DisplayMember
    </mtimezonPartitionlookup>
    <napcoareaeventdefgrid partitioned="False">
      select
      e.AreaNumber
      , e.statusCode as StatusCode
      , e.GenerateEvent
      , e.EventPriority as Event_Priority
      , e.ResponseRequired
      , e.relayControlAction as RelayControl
      , d.eventMsgText as EventMessage
      ,d.langEventMsgText as LanguEventMessage
      ,e.AlarmPanelID
      from napcoPanelAreaEventDef e
      inner join napcoEventDef d on e.statuscode =  d.statuscode
      where alarmPanelID = @alarmPanelID and areaNumber = @areaNumber


    </napcoareaeventdefgrid>
    <napcoareagrid partitioned="True">
      select
      PanelName as "Alarm Panel"
      ,AreaNumber as "Area Number"
      ,AreaName as "Area Name"
      ,areaTypeName as "Area Type"
      ,AreaConfigured as Configured
      ,AlarmPanelID
      ,caObjectId
      ,LastUpdated as 'Last Edit'
      from ca_vw_napco_areaDisplayGrid
    </napcoareagrid>
    <napcoareagridbyarea partitioned="True">
      select
      PanelName as "Alarm Panel"
      ,AreaNumber as "Area Number"
      ,AreaName as "Area Name"
      ,areaTypeName as "Area Type"
      ,AreaConfigured as Configured
      ,AlarmPanelID
      ,caObjectId
      from ca_vw_napco_areaDisplayGrid where AreaNumber = @AreaNumber and AlarmPanelID = @AlarmPanelID
    </napcoareagridbyarea>
    <napcoareagridbypanel partitioned="True">
      select
      PanelName as "Alarm Panel"
      ,AreaNumber as "Area Number"
      ,AreaName as "Area Name"
      ,areaTypeName as "Area Type"
      ,AreaConfigured as Configured
      ,AlarmPanelID
      ,caObjectId
      from ca_vw_napco_areaDisplayGrid where AlarmPanelID = @AlarmPanelID
    </napcoareagridbypanel>
    <napcoareas partitioned="False" notificationtable="napcoPanelAreas">
      SELECT n.AreaNumber,n.AreaName, n.AreaConfigured FROM napcoPanelAreas n
      INNER JOIN Panel p ON n.AlarmPanelID = p.NAPCOPanel
      WHERE p.PnlNo = @pnlno
    </napcoareas>
    <napcoareasactivepanelslookup partitioned="False">
      select AlarmPanelID, AreaNumber, AreaName, ManualPriv
      from napcoPanelAreas
      where AreaConfigured = 1
      and AlarmPanelID in (select AlarmPanelID from napcoPanels where Enabled = 1)
      order by AlarmPanelID, AreaNumber

    </napcoareasactivepanelslookup>
    <napcoareasonepanelslookup partitioned="False">
      select AlarmPanelID, AreaNumber, AreaName, ManualPriv
      from napcoPanelAreas
      where AreaConfigured = 1 and AlarmPanelID = @AlarmPanelID
      order by AreaNumber
    </napcoareasonepanelslookup>
    <napcoareaspecificlookup partitioned="False">
      select AlarmPanelID, AreaNumber, AreaName, ManualPriv
      from napcoPanelAreas
      where AlarmPanelID = @AlarmPanelID
      and  AreaNumber =@AreaNumber
    </napcoareaspecificlookup>
    <APInapcoareaspecificlookup partitioned="False">
      select AlarmPanelID, AreaNumber, AreaName, ManualPriv
      from napcoPanelAreas
      where AlarmPanelID = @AlarmPanelID
      and  AreaNumber =@AreaNumber
    </APInapcoareaspecificlookup>
    <napcoareasprivactivepanelslookup partitioned="False">
      select AlarmPanelID, AreaNumber, AreaName, ManualPriv
      from napcoPanelAreas n
      where AreaConfigured = 1
      and AlarmPanelID in (select AlarmPanelID from napcoPanels where Enabled = 1 and workstationID is not null)
      and ( (ManualPriv = 0)
      or   (ManualPriv in (
      select ManualPrivilege from manualprivilege where OperatorID = @OperatorID )))
      and n.caObjectID in (
      SELECT devicepartitions.caObjectID FROM OperatorPartitions inner join  devicepartitions on devicepartitions.PartitionId = OperatorPartitions.Partitionid where OperatorPartitions.OperatorID = @OperatorID)
      order by AlarmPanelID, AreaNumber
    </napcoareasprivactivepanelslookup>
    <napcoareasprivonepanelslookup partitioned="False">
      select AlarmPanelID, AreaNumber, AreaName, ManualPriv
      from napcoPanelAreas n
      where AreaConfigured = 1 and AlarmPanelID = @AlarmPanelID
      and ( (ManualPriv = 0)
      or   (ManualPriv in (
      select ManualPrivilege from manualprivilege where OperatorID = @OperatorID )))
      and n.caObjectID in (
      SELECT devicepartitions.caObjectID FROM OperatorPartitions inner join  devicepartitions on devicepartitions.PartitionId = OperatorPartitions.Partitionid where OperatorPartitions.OperatorID = @OperatorID)
      order by AreaNumber
    </napcoareasprivonepanelslookup>

    <APInapcoareasprivonepanelslookup partitioned="False">
      select AlarmPanelID, AreaNumber, AreaName, ManualPriv
      from napcoPanelAreas n
      where AreaConfigured = 1 and AlarmPanelID = @AlarmPanelID
      and ( (ManualPriv = 0)
      or   (ManualPriv in (
      select ManualPrivilege from manualprivilege where OperatorID = @OperatorID )))
      and n.caObjectID in (
      SELECT devicepartitions.caObjectID FROM OperatorPartitions inner join  devicepartitions on devicepartitions.PartitionId = OperatorPartitions.Partitionid where OperatorPartitions.OperatorID = @OperatorID)
      order by AreaNumber
    </APInapcoareasprivonepanelslookup>
    
    <napcoareasprivonePartitionpanelslookup partitioned="False">
      select AlarmPanelID, AreaNumber, AreaName, ManualPriv
      from napcoPanelAreas n
      where AreaConfigured = 1 and AlarmPanelID = @AlarmPanelID
      and ( (ManualPriv = 0)
      or   (ManualPriv in (
      select ManualPrivilege from manualprivilege where OperatorID = @OperatorID )))
      and n.caObjectID in (SELECT caObjectID FROM devicepartitions  where PartitionID = @PartitionID)
      order by AreaNumber
    </napcoareasprivonePartitionpanelslookup>
    <napcoareasprivPartitionactivepanelslookup partitioned="False">
      select AlarmPanelID, AreaNumber, AreaName, ManualPriv
      from napcoPanelAreas n
      where AreaConfigured = 1
      and AlarmPanelID in (select AlarmPanelID from napcoPanels where Enabled = 1 and workstationID is not null)
      and ( (ManualPriv = 0)
      or   (ManualPriv in (
      select ManualPrivilege from manualprivilege where OperatorID = @OperatorID )))
      and n.caObjectID in (SELECT caObjectID FROM devicepartitions  where PartitionID = @PartitionID)
      order by AlarmPanelID, AreaNumber
    </napcoareasprivPartitionactivepanelslookup>
    <napcoareatypelookup partitioned="False">select alarmareatype as ValueMember ,areatypename as DisplayMember from napcoAlarmAreaTypeDef</napcoareatypelookup>
    <APInapcoareatypelookup partitioned="False">select alarmareatype as ValueMember ,areatypename as DisplayMember from napcoAlarmAreaTypeDef</APInapcoareatypelookup>
    <napcoconnectiontypeslookup partitioned="False" notificationtable="napcoConnectionTypes">select connectionType as ValueMember, connectionTypeName as DisplayMember from napcoConnectionTypes order by connectionType</napcoconnectiontypeslookup>
    <napcoeventdefbytypelookup partitioned="False" notificationtable="napcoEventDef">
      select statusCode as ValueMember, langEventMsgText as DisplayMember from napcoeventdef where eventHandlerType=@eventHandlerType
    </napcoeventdefbytypelookup>
    <napcoeventdeflookup partitioned="False" notificationtable="napcoEventDef">select statusCode as ValueMember, eventMsgText as DisplayMember from napcoeventdef</napcoeventdeflookup>
    <NapcoHardware partitioned="False">
      select
      1 as Tag
      ,0 as Parent
      ,null as AlarmPanelID
      ,null as AreaNumber
      ,null as RelayNumber
      ,null as ZoneNumber
      ,null as "Description"
      union all select
      2 as Tag
      ,1 as Parent
      ,AlarmPanelID
      ,null as AreaNumber
      ,null as RelayNumber
      ,null as ZoneNumber
      ,PanelName as "Description"
      from NapcoPanels
      union all select
      3 as Tag
      ,2 as Parent
      ,p.AlarmPanelID
      ,AreaNumber
      ,null as RelayNumber
      ,null as ZoneNumber
      ,AreaName as "Description"
      from NapcoPanels p
      inner join NapcoPanelAreas a on
      p.AlarmPanelID = a.AlarmPanelID
      union all select
      4 as Tag
      ,3 as Parent
      ,p.AlarmPanelID
      ,null as AreaNumber
      ,RelayNumber
      ,null as ZoneNumber
      ,RelayName as "Description"
      from NapcoPanels p
      inner join NapcoPanelRelays r on
      p.AlarmPanelID = r.AlarmPanelID
      union all select
      5 as Tag
      ,4 as Parent
      ,p.AlarmPanelID
      ,null as AreaNumber
      ,null as RelayNumber
      ,ZoneNumber
      ,ZoneName as "Description"
      from NapcoPanels p
      inner join NapcoPanelZones z on
      p.AlarmPanelID = z.AlarmPanelID
      order by AlarmPanelID,parent
    </NapcoHardware>
    <napcompermissionslookup partitioned="True" notificationtable="napcoMPermissions">
      select 0 as ValueMember, 'None' as DisplayMember
      union
      SELECT napcoMPermissions.PermissionID as "ValueMember",napcoMPermissions.PermissionName as "DisplayMember" FROM napcoMPermissions
    </napcompermissionslookup>
    <napcopanelactivelookup partitioned="False">
      select alarmpanelid  as ValueMember ,panelname as DisplayMember
      from napcoPanels where caObjectID in (
      SELECT devicepartitions.caObjectID FROM OperatorPartitions inner join  devicepartitions on devicepartitions.PartitionId = OperatorPartitions.Partitionid where OperatorPartitions.OperatorID = @OperatorID)
    </napcopanelactivelookup>
    <APInapcopanelactivelookup partitioned="False">
      select alarmpanelid  as ValueMember ,panelname as DisplayMember
      from napcoPanels where caObjectID in (
      SELECT devicepartitions.caObjectID FROM OperatorPartitions inner join  devicepartitions on devicepartitions.PartitionId = OperatorPartitions.Partitionid where OperatorPartitions.OperatorID = @OperatorID)
    </APInapcopanelactivelookup>
    <napcopanelactivePartitionlookup partitioned="False">
      select alarmpanelid  as ValueMember ,panelname as DisplayMember
      from napcoPanels where caObjectID in (SELECT caObjectID FROM devicepartitions  where PartitionID = @PartitionID)
    </napcopanelactivePartitionlookup>
    <napcopanelareaslookup partitioned="True" notificationtable="napcoPanelAreas">
      select AreaNumber as ValueMember, AreaName as DisplayMember
      from napcoPanelAreas
      where alarmpanelid = @alarmpanelid
      order by AreaNumber
    </napcopanelareaslookup>
    <napcopanelbypanel partitioned="True" notificationtable="napcoPanels">
      select
      alarmpanelid as "Panel Number"
      ,panelname as "Panel Name"
      ,PanelType as "Panel Type"
      ,PollingUncName as Workstation
      ,ConnectionTypeName as Connection
      ,SocketAddress as Address
      ,PortNumber as Port
      ,Enabled
      ,MasterProgramCode as "Master Program Code"
      ,caObjectId
      ,alarmpanelid
      from ca_vw_napco_panelDisplayGrid where alarmpanelid = @AlarmPanelId
    </napcopanelbypanel>
    <napcopaneleventdefgrid partitioned="False">
      select d.statuscode as StatusCode, isnull(e.generateevent,d.defaultgenerateevent) as GenerateEvent,
      isnull(e.eventpriority,d.defaulteventpriority) as 'Event_Priority',
      isnull(e.responserequired,d.defaultresponserequired) as ResponseRequired
      ,d.eventMsgText as EventMessage,d.langEventMsgText as LanguEventMessage
      from NapcoPanelEventDef e
      right outer join napcoeventdef d on d.statuscode = e.statuscode and e.alarmpanelid = @alarmpanelid
      where d.eventhandlertype=1
    </napcopaneleventdefgrid>
    <napcopanelgrid partitioned="True" notificationtable="napcoPanels">
      select
      alarmpanelid
      ,alarmpanelid as "Panel Number"
      ,panelname as "Panel Name"
      ,PanelType as "Panel Type No"
      ,PanelTypeName as "Panel Type"
      ,PollingUncName as Workstation
      ,ConnectionTypeName as Connection
      ,SocketAddress as Address
      ,PortNumber as Port
      ,Enabled
      ,MasterProgramCode as "Master Program Code"
      ,caObjectId
      ,LastUpdated as 'Last Edit'
      from ca_vw_napco_panelDisplayGrid
    </napcopanelgrid>
    <napcopanellookup partitioned="True" notificationtable="napcoPanels">
      select alarmpanelid  as ValueMember ,panelname as DisplayMember
      ,caObjectId
      from napcoPanels
    </napcopanellookup>
    <APInapcopanellookup partitioned="True" notificationtable="napcoPanels">
      select alarmpanelid  as ValueMember ,panelname as DisplayMember,caObjectId from napcoPanels
    </APInapcopanellookup>
    <NapcoPanelNoneLookup partitioned="true" notificationtable="napcoPanels">
      select
      0 as ValueMember,
      'None' as DisplayMember
      union
      select
      AlarmPanelID as ValueMember,
      PanelName as DisplayMember
      from napcoPanels
    </NapcoPanelNoneLookup>
    <napcopaneltypelookup partitioned="False">select paneltype as ValueMember ,paneltypename as DisplayMember from napcoAlarmPanelDef</napcopaneltypelookup>
    <APInapcopaneltypelookup partitioned="False">select paneltype as ValueMember ,paneltypename as DisplayMember from napcoAlarmPanelDef</APInapcopaneltypelookup>
    <napcopermissiongrid partitioned="True">
      SELECT
      PermissionID
      , PermissionID as "Permission No"
      , PermissionName as "Permission Name"
      , LastUpdated as "Last Edit"
      ,caobjectid
      FROM napcoMPermissions
    </napcopermissiongrid>
    <napcopermissionpartitiontree partitioned="False">
      select
      p.AlarmPanelId
      , a.AreaNumber
      , p.PanelName
      , a.AreaName
      ,np.CanArm
      ,np.CanDisarm
      from napcoPanels p
      inner join napcoPanelAreas a on a.AlarmPanelId = p.AlarmPanelid
      left outer join (select * from napcoPermissions where PermissionID = @PermissionID ) np on np.AlarmPanelId = p.AlarmPanelId and  np.AreaNumber = a.AreaNumber
      where a.AreaConfigured = 1
      and (p.caObjectID in
      (
      SELECT dbo.devicepartitions.caObjectID
      FROM dbo.OperatorPartitions  inner join  dbo.devicepartitions
      on dbo.devicepartitions.PartitionId = dbo.OperatorPartitions.Partitionid
      where dbo.OperatorPartitions.OperatorID = @OperatorID
      )
      OR
      p.caObjectID not in
      (
      SELECT dbo.devicepartitions.caObjectID
      FROM  dbo.devicepartitions
      ))
      order by p.AlarmPanelId,a.AreaNumber
    </napcopermissionpartitiontree>
    <napcopermissiontree partitioned="False">
      select
      p.AlarmPanelId
      , a.AreaNumber
      , p.PanelName
      , a.AreaName
      ,np.CanArm
      ,np.CanDisarm
      from napcoPanels p
      inner join napcoPanelAreas a on a.AlarmPanelId = p.AlarmPanelid
      left outer join (select * from napcoPermissions where PermissionID = @PermissionID ) np on np.AlarmPanelId = p.AlarmPanelId and  np.AreaNumber = a.AreaNumber
      where a.AreaConfigured = 1
      order by p.AlarmPanelId,a.AreaNumber
    </napcopermissiontree>
    <napcorelaybypanellookup partitioned="True" notificationtable="napcoPanelRelays">select relayNumber as ValueMember, RelayName as DisplayMember,AlarmPanelID from ca_vw_napco_relayDisplayGrid  where relayconfigured = 1 and AlarmPanelID = @AlarmPanelID order by relayNumber</napcorelaybypanellookup>
    <napcorelayeventdefgrid partitioned="False">
      select
      e.AlarmPanelID
      , e.RelayNumber
      , e.StatusCode
      , e.GenerateEvent
      , e.EventPriority as Event_Priority
      , e.ResponseRequired
      , d.eventMsgText  as EventMessage
      ,d.langEventMsgText as LanguEventMessage
      from napcoPanelRelayEventDef e
      inner join napcoEventDef d on e.statuscode =  d.statuscode
      where alarmPanelID = @alarmPanelID and RelayNumber = @RelayNumber
    </napcorelayeventdefgrid>
    <napcorelaygrid partitioned="True">
      select
      PanelName as "Alarm Panel"
      ,RelayNumber as "Relay Number"
      ,RelayName as "Relay Name"
      ,RelayConfigured as Configured
      ,AlarmPanelID
      ,caObjectId
      ,LastUpdated as 'Last Edit'
      from ca_vw_napco_RelayDisplayGrid
      order by AlarmPanelID,RelayNumber
    </napcorelaygrid>
    <napcorelaylookup partitioned="True" notificationtable="napcoPanelRelays">select relayNumber as ValueMember, RelayName as DisplayMember,AlarmPanelID from ca_vw_napco_relayDisplayGrid order by relayNumber</napcorelaylookup>
    <napcoworkstation partitioned="False">select workstationID,pollingUNCName,pollingIPAddress,caObjectID from napcoWorkstations order by pollingUNCName</napcoworkstation>
    <napcoworkstationlookup partitioned="False" notificationtable="napcoWorkstations">select workstationID as ValueMember, pollingUNCName as DisplayMember from napcoWorkstations order by workstationID</napcoworkstationlookup>
    <APInapcoworkstationlookup partitioned="False">select workstationID as ValueMember, pollingUNCName as DisplayMember from napcoWorkstations order by workstationID</APInapcoworkstationlookup>
    <napcozoneeventdefgrid partitioned="False">
      select
      e.AlarmPanelID
      , e.ZoneNumber
      , e.StatusCode
      , e.GenerateEvent
      , e.EventPriority as Event_Priority
      , e.ResponseRequired
      , d.eventMsgText as EventMessage
      ,d.langEventMsgText as LanguEventMessage
      from napcoPanelZoneEventDef e
      inner join napcoEventDef d on e.statuscode =  d.statuscode
      where alarmPanelID = @alarmPanelID and ZoneNumber = @ZoneNumber
    </napcozoneeventdefgrid>
    <napcozonegrid partitioned="True">
      select
      PanelName as "Alarm Panel"
      ,ZoneNumber as "Zone Number"
      ,AreaNumber as "Area Number"
      ,ZoneName as "Zone Name"
      ,ZoneConfigured as Configured
      ,AlarmPanelID
      ,caObjectId
      ,LastUpdated as 'Last Edit'
      from ca_vw_napco_zoneDisplayGrid
    </napcozonegrid>
    <napcozonegridbyarea partitioned="True">
      select
      AlarmPanelID as "Alarm Panel"
      ,ZoneNumber as "Zone Number"
      ,AreaNumber as "Area Number"
      ,ZoneName as "Zone Name"
      ,ZoneConfigured as Configured
      ,AlarmPanelID
      ,caObjectId
      from ca_vw_napco_zoneDisplayGrid where AlarmPanelID = @AlarmPanelID AND AreaNumber = @AreaNumber
    </napcozonegridbyarea>
    <napcozonegridbypanel partitioned="True">
      select
      AlarmPanelID as "Alarm Panel"
      ,ZoneNumber as "Zone Number"
      ,AreaNumber as "Area Number"
      ,ZoneName as "Zone Name"
      ,ZoneConfigured as Configured
      ,AlarmPanelID
      ,caObjectId
      from ca_vw_napco_zoneDisplayGrid where AlarmPanelID = @AlarmPanelID
    </napcozonegridbypanel>
    <newgenpanellookup partitioned="True" notificationtable="Panel">
      select pnlno as ValueMember ,panelname as DisplayMember, paneltype,NapcoPanel from panel
      where PanelType in (3,5,6,7,8,9,10,11,12,13,14,15,16,17,101,102)
      order by PanelName

    </newgenpanellookup>
    <newpanellookup partitioned="True" notificationtable="Panel">
      select Pnlno, PanelType, PanelName as Description from panel where Enabled=1 and PanelType in (3,5,6,7,8,9,10,11,12,13,14,15,16,17,101,102)
      and caObjectID in (
      SELECT devicepartitions.caObjectID FROM OperatorPartitions
      inner join  devicepartitions on devicepartitions.PartitionId = OperatorPartitions.Partitionid where OperatorPartitions.OperatorID = @OperatorId)
    </newpanellookup>
    <newpanellookupwithoutlock partitioned="True" notificationtable="Panel">
      select Pnlno, PanelType, PanelName as Description from panel where Enabled=1 and PanelType in (1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17)
      and caObjectID in (
      SELECT devicepartitions.caObjectID FROM OperatorPartitions
      inner join  devicepartitions on devicepartitions.PartitionId = OperatorPartitions.Partitionid where OperatorPartitions.OperatorID = @OperatorId)
    </newpanellookupwithoutlock>

    <downloadpanellookup partitioned="True" notificationtable="Panel">
      select Pnlno, PanelType, PanelName as Description from panel where Enabled=1 and PanelType not in (100)
      and caObjectID in (
      SELECT devicepartitions.caObjectID FROM OperatorPartitions
      inner join  devicepartitions on devicepartitions.PartitionId = OperatorPartitions.Partitionid where OperatorPartitions.OperatorID = @OperatorId)
    </downloadpanellookup>
    
    <downloadHolidaytopanellookup partitioned="false" notificationtable="Panel">
      select Pnlno, PanelType, PanelName as Description from panel where Enabled=1 and PanelType &lt; 100 and HCSNo = @HCSNo
    </downloadHolidaytopanellookup>
    
    <newpanelsunpartlookup partitioned="False" notificationtable="Panel">
      select distinct
      p.Pnlno
      ,  p.Pnlno as ValueMember
      , p.PanelType
      , p.PanelName as Description
      , p.PanelName as DisplayMember
      from panel p  INNER JOIN CategoryCounters c ON p.PnlNo=c.PnlNo
      where p.caObjectID in (
      SELECT devicepartitions.caObjectID FROM OperatorPartitions inner join  devicepartitions on devicepartitions.PartitionId = OperatorPartitions.Partitionid where OperatorPartitions.OperatorID = @OperatorId)
      order by p.pnlno asc
    </newpanelsunpartlookup>
    <noaccesstemplate partitioned="True">
      select pnlno as PnlRef
      ,0 as Agno
      ,0 as tz1
      ,0 as tz2
      ,0 as tz3
      ,0 as tz4
      ,0 as tz5
      ,0 as tz6
      ,0 as tz7
      ,0 as tz8
      ,0 as tz9
      ,0 as tz10
      ,0 as tz11
      ,0 as tz12
      ,0 as tz13
      ,0 as tz14
      ,0 as tz15
      ,0 as tz16
      from panel order by pnlno
    </noaccesstemplate>
    <nodelookupjoin partitioned="False">
      select
      n.HCSNo
      ,c.Description as HCSNoText
      ,n.Schedule
      ,t.Description as ScheduleText
      from nodes n
      left outer join MCOM c on n.HCSNo = c.HCSNo
      left outer join MTimezon t on n.Schedule = t.TzNum
      Where n.nodeid = @nodeid

    </nodelookupjoin>
    <nodesgrid partitioned="True">
      select
      NodeId
      ,NodeName as "Description Text"
      ,Phone as "Panel Phone"
      ,Schedule as "Dial Schedule"
      ,Frequency as  "Dial Frequency"
      ,Setup1 as "Setup Text 1"
      ,Setup2 as "Setup Text 2"
      ,      caObjectId
      from nodes
    </nodesgrid>
    <nodeslookup partitioned="False" notificationtable="Nodes">select 0 as ValueMember, 'All Cluster' as DisplayMember union select NodeId as ValueMember, NodeName as DisplayMember from Nodes</nodeslookup>
    <nodespanellookup partitioned="False" notificationtable="Com">
      SELECT     TOP 100 PERCENT dbo.Panel.PnlNo, dbo.Panel.PanelName, dbo.Panel.HCSNo, dbo.Panel.caObjectId
      FROM         dbo.Panel INNER JOIN
      dbo.Com ON dbo.Panel.HCSNo = dbo.Com.HCSNo AND dbo.Panel.ComPort = dbo.Com.ComPort
      WHERE     (dbo.Com.Type = 2)
      ORDER BY dbo.Panel.PnlNo
    </nodespanellookup>
    <OperatorAssignPartition partitioned="False">
      EXEC ca_sp_GetDevicePartitions @TableName,@DeviceType,@OperatorID
    </OperatorAssignPartition>
    <operatorgrid partitioned="False">
      Select
      OperPassword
      ,      OperLoginName  as 'Screen Name'
      ,      OperFName as 'First Name'
      ,      OperLName as 'Last Name'
      ,      AutoAckTime as AckTimeout
      ,      LastUpdated as 'Last Edit'
      ,OperatorID
      From Operators
      where (OperatorID in
      (
      SELECT dbo.devicepartitions.caObjectID
      FROM dbo.OperatorPartitions  inner join  dbo.devicepartitions
      on dbo.devicepartitions.PartitionId = dbo.OperatorPartitions.Partitionid
      where dbo.OperatorPartitions.OperatorID = @OperatorID
      )
      OR
      OperatorID not in
      (
      SELECT dbo.devicepartitions.caObjectID
      FROM  dbo.devicepartitions
      ))
      Order By OperLoginName
    </operatorgrid>
    <APIoperatorgrid partitioned="False">
      Select
      OperPassword
      ,      OperLoginName  as 'Screen Name'
      ,      OperFName as 'First Name'
      ,      OperLName as 'Last Name'
      ,      AutoAckTime as AckTimeout
      ,      LastUpdated as 'Last Edit'
      ,OperatorID
      From Operators
      where (OperatorID in
      (
      SELECT dbo.devicepartitions.caObjectID
      FROM dbo.OperatorPartitions  inner join  dbo.devicepartitions
      on dbo.devicepartitions.PartitionId = dbo.OperatorPartitions.Partitionid
      )
      OR
      OperatorID not in
      (
      SELECT dbo.devicepartitions.caObjectID
      FROM  dbo.devicepartitions
      ))
      Order By OperLoginName
    </APIoperatorgrid>
    <operatorinstruction partitioned="False">
      select instructionMsg
      from operatorInstructLink l
      inner join operatorinstructions i on i.instructionid = l.instructionid
      where instructionsEnabled = 1
      and cat = @cat
      and  status = @status
      and  pnlNo =@pnlNo
      and  DeviceNo  = @DeviceNo
    </operatorinstruction>
    <operatorinstruction partitioned="False">
      select instructionMsg
      from operatorInstructLink l
      inner join operatorinstructions i on i.instructionid = l.instructionid
      where instructionsEnabled = 1
      and cat = @cat
      and  status = @status
      and  pnlNo =@pnlNo
      and  DeviceNo  = @DeviceNo
    </operatorinstruction>
    <apioperatorinstruction partitioned="False">
      SELECT 
      instructionsEnabled, 
      instructionID, 
      caObjectId, 
      SoundEnabled, 
      AlertNotifySound, 
      SoundInterval FROM operatorInstructLink
      WHERE cat = @cat
      and  status = @status
      and  pnlNo =@pnlNo
      and  DeviceNo  = @DeviceNo
    </apioperatorinstruction>
    <operatorinstructionlinksgrid partitioned="False">
      select
      Cat
      ,PnlNo
      ,DeviceNo
      ,status
      ,InstructionsEnabled
      ,LastUpdated
      ,caObjectId
      ,      InstructionID
      from operatorInstructLink
    </operatorinstructionlinksgrid>
    <operatorinstructionlookup partitioned="False" notificationtable="operatorInstructions">
      select instructionID as ValueMember, instructionName as DisplayMember from operatorInstructions order by instructionName
    </operatorinstructionlookup>
    <operatorinstructions partitioned="False">
      select cat,  status,pnlNo,       DeviceNo    ,instructionMsg, SoundEnabled, AlertNotifySound, SoundInterval
      from operatorInstructLink l
      inner join operatorinstructions i on i.instructionid = l.instructionid
      where instructionsEnabled = 1
    </operatorinstructions>
    <getoperatorinstructionsbyid>SELECT instructionName, instructionMsg, caObjectId FROM operatorInstructions WHERE instructionID=@instructionID</getoperatorinstructionsbyid>
    <operatorinstructionsgrid partitioned="False">
      select instructionName as 'Instruction Name', instructionID
      ,LastUpdated as 'Last Edit'
      from operatorInstructions order by instructionName

    </operatorinstructionsgrid>
    <operatorLoginLookup partitioned="False">
      SELECT  [OperatorID],[RoleID],[OperFName],[OperLName],[OperLoginName],[OperPassword],[LogoffTime],[AutoAckTime]
      ,[PasswordRequiresUpdate],[IsGlobalAdministrator],[MaxThreatLevelAllowed],[CanChangeThreatLevel]
      ,[UseLegacyDisplay],[PasswordExpiresIn],[LoginAttempts],[DisableLogoff],[LanguageId],[EventCount],[RoleId] FROM Operators Where [OperLoginName] = @LoginName AND [Enabled] = 1
    </operatorLoginLookup>
    <OperatorMenuPermissions partitioned="False">
      SELECT dbo.RolePrivileges.SecurityLevel
      FROM dbo.RolePrivileges INNER JOIN
      dbo.Screens ON dbo.RolePrivileges.ScreenID = dbo.Screens.ScreenID INNER JOIN
      dbo.ScreenObjects ON dbo.RolePrivileges.ScreenID = dbo.ScreenObjects.ScreenID AND
      dbo.RolePrivileges.ScreenObjectID = dbo.ScreenObjects.ScreenObjectID
      WHERE RoleID = @roleId and (ObjectLabel = @MenuKey)
    </OperatorMenuPermissions>
    <OperatorResponseExist partitioned="False">SELECT Description FROM dbo.Resp where Description=@Description</OperatorResponseExist>
    <operatorresponsegrid partitioned="False">
      select description as "Response Text"
      ,LastUpdated as 'Last Edit'
      ,caobjectid
      from resp
      order by description
    </operatorresponsegrid>
    <ElevatorFloorsGrid partitioned="True">
      SELECT [FloorNumber], [FloorName], LastUpdated as 'Last Edit', caObjectID FROM [ElevFloors] order by [FloorName]
    </ElevatorFloorsGrid>
    <ElevatorServersGrid partitioned="True">
      SELECT [ServerName],[ServerIP],  LastUpdated as 'Last Edit', caObjectID FROM [ElevServers] order by [ServerName]
    </ElevatorServersGrid>
    <ElevatorFacilitiesGrid partitioned="True">
      SELECT [ElevFacilityName] as "Elevator Facility Name",  LastUpdated as 'Last Edit', caObjectID FROM [ElevFacilities] order by [ElevFacilityName]
    </ElevatorFacilitiesGrid>
    <GetInListForOperator partitioned="False">
      SELECT ALL I.Name,
      I.Reader, I.PanelTime as Time, AA.Description AS APBArea, I.APBIn, TAIn, I.PanelTime as UTCTime , I.UTCOffset, P.PersonID,Badge,Facility,AA.AreaNo,I.PanelTime
      FROM EVENT_DB_NAME..InList AS I
      INNER JOIN APBAreas AS AA ON I.APBArea=AA.AreaNo
      INNER JOIN Person as P ON P.PersonID = I.PersonID
      WHERE ((APBArea BETWEEN 2 AND 254) OR APBIn=1 OR TAIn=1)
      AND EXISTS (SELECT 1 FROM Reader WHERE Reader.PnlRef = I.PnlNo AND Reader.RdrNo = I.RdrNo
      AND Reader.caObjectID in (SELECT devicepartitions.caObjectID FROM OperatorPartitions inner join  devicepartitions on devicepartitions.PartitionId = OperatorPartitions.Partitionid
      where OperatorPartitions.OperatorID = @OperatorID))
    </GetInListForOperator>
    <OperatorScreenPermissions partitioned="False">
      SELECT     dbo.RolePrivileges.RoleID, dbo.Screens.ScreenName, dbo.RolePrivileges.ScreenObjectID, dbo.RolePrivileges.SecurityLevel
      , RTRIM(dbo.ScreenObjects.ObjectName) as ObjectName
      , LTRIM(RTRIM(dbo.ScreenObjects.ObjectLabel)) as ObjectLabel
      FROM         dbo.RolePrivileges INNER JOIN
      dbo.Screens ON dbo.RolePrivileges.ScreenID = dbo.Screens.ScreenID INNER JOIN
      dbo.ScreenObjects ON dbo.RolePrivileges.ScreenID = dbo.ScreenObjects.ScreenID AND
      dbo.RolePrivileges.ScreenObjectID = dbo.ScreenObjects.ScreenObjectID
      WHERE RoleID = @roleId and (ScreenName = @screenName or dbo.ScreenObjects.ScreenObjectID = @ScreenObjectID)
    </OperatorScreenPermissions>
    <operatorsettings partitioned="False">
      select
      GUIViewMode
      ,UIViewStyle
      from operatorsettings
      where operatorid = @operatorid
    </operatorsettings>
    <OtherMenuPlugins partitioned="False">
      SELECT dbo.RolePlugins.RoleID, dbo.RolePlugins.pluginId AS PluginID, dbo.guiPlugins.displayName, dbo.RolePlugins.LastUpdated
      FROM dbo.Operators INNER JOIN
      dbo.RolePlugins ON dbo.Operators.RoleID = dbo.RolePlugins.RoleID INNER JOIN
      dbo.guiPlugins ON dbo.RolePlugins.pluginId = dbo.guiPlugins.pluginId
      WHERE dbo.Operators.OperatorID = @operatorId
    </OtherMenuPlugins>
    <panel partitioned="False" notificationtable="Panel">select PnlNo,Address,ComPort,HCSNo,Enabled,Interactive,Node,NoFail,XactSize, CommPrior,DwnLoadPrior,PwrPrior,LowBatPrior,RespOffOnLine , RespDownloads , RespACPowerFail, RespModemActivity, RespLowBattery,Schedules,Elevators,ModemPrior,Passwrd, CurrentPwd,DegradeMode,AGSize,PanelType,MaxAlp,MaxEvt,DefaultCalendar,NoPolling,ZoneId,RemoteDevice,LockType,RetrievalSchedule from panel where pnlno = @PnlNo</panel>
    <panelbypartition partitioned="false">
      SELECT MIN(P1.PnlNo) AS PnlNo
      FROM PANEL as P1
      WHERE P1.Enabled = 1 AND caObjectID in  (SELECT caObjectID FROM DevicePartitions WHERE PartitionID = @PartitionID)
      GROUP BY P1.ComPort, P1.HCSNo
    </panelbypartition>
    <PanelByComNo partitioned="False">
      select PnlNo from Panel p
      inner join Com c ON p.ComPort = c.ComPort and c.Type&lt;&gt;0
      where p.HCSNo=@HCSNo and p.ComPort=@ComNo and p.Enabled=1
    </PanelByComNo>
    <PanelByHcsNo partitioned="False">
      Select PnlNo,PanelName,Description,Address,ComPort,HCSNo,Enabled,Interactive,NoFail,XactSize,Node,MapId,DeviceId,CommPrior,DwnLoadPrior,PwrPrior,Schedules
      ,Elevators,ModemPrior,Passwrd,CurrentPwd,DegradeMode,AGSize,Location,Remarks,PanelType,MaxAlp,MaxEvt,DefaultCalendar,NAPCOPanel,NoPolling,RespOffOnLine,RespDownloads
      ,RespACPowerFail,RespModemActivity,caObjectID,LastUpdated,LastOperator,LastWorkStation,ZoneId,UTCOffset,LockId,LockUpdateSchedule,LockType,LockAssigned
      ,LockExpAddress,LockChanged,RemoteDevice,CentralStationId,RetrievalSchedule,AperioType
      from Panel
      Where HCSNo=@HCSNo and PanelType&gt;99
    </PanelByHcsNo>
    <PanelCount partitioned="False">select count(*) as cnt from Panel</PanelCount>
    <paneldownloadAgNoInitLoad partitioned="False">
      SELECT
      Facility,Badge,Pin,Issue,Enabled,Track,Resident,InitLoad,Shunt,DurUse,Escort,AccessTime,UseCount,HolidayCalendar,VehicleTag,FirstInControl,PnlNo,APBSet,APBArea,Agno
      FROM ca_vw_PanelDownload
      WHERE Enabled=1
      AND AgNo= @AgNo
      AND PnlNo= @PnlNo
      AND (InitLoad=1)
      ORDER BY Facility,Badge
    </paneldownloadAgNoInitLoad>
    <paneldownloadEnabledBadgeFac partitioned="False">
      SELECT
      distinct Facility,Badge,Pin,Issue,Enabled,Track,Resident,InitLoad,Shunt,DurUse,Escort,AccessTime,UseCount,FirstInControl,HolidayCalendar,VehicleTag,PnlNo,APBSet,APBArea
      ,(select Agroupno from ca_vw_PanelDownload where Enabled=1 AND Facility = @facility and badge =@badge and pnlno = @pnlno AND AGSeq = 1 AND v.badge = badge and v.facility = facility and v.personid = personid) as aGroup1
      ,(select Agroupno from ca_vw_PanelDownload where Enabled=1 AND Facility = @facility and badge =@badge and pnlno = @pnlno AND AGSeq = 2 AND v.badge = badge and v.facility = facility and v.personid = personid) as aGroup2
      ,(select Agroupno from ca_vw_PanelDownload where Enabled=1 AND Facility = @facility and badge =@badge and pnlno = @pnlno AND AGSeq = 3 AND v.badge = badge and v.facility = facility and v.personid = personid) as aGroup3
      ,(select Agroupno from ca_vw_PanelDownload where Enabled=1 AND Facility = @facility and badge =@badge and pnlno = @pnlno AND AGSeq = 4 AND v.badge = badge and v.facility = facility and v.personid = personid) as aGroup4
      ,(select Agroupno from ca_vw_PanelDownload where Enabled=1 AND Facility = @facility and badge =@badge and pnlno = @pnlno AND AGSeq = 5 AND v.badge = badge and v.facility = facility and v.personid = personid) as aGroup5
      ,(select Agroupno from ca_vw_PanelDownload where Enabled=1 AND Facility = @facility and badge =@badge and pnlno = @pnlno AND AGSeq = 6 AND v.badge = badge and v.facility = facility and v.personid = personid) as aGroup6
      FROM ca_vw_PanelDownload v
      WHERE Enabled=1
      AND Facility= @facility
      AND Badge= @badge
      AND PnlNo= @pnlno
    </paneldownloadEnabledBadgeFac>
    <paneldownloadEnabledInitLoad partitioned="False">
      SELECT
      distinct Facility,Badge,Pin,Issue,Enabled,Track,Resident,InitLoad,Shunt,DurUse,Escort,AccessTime,UseCount,FirstInControl,HolidayCalendar,VehicleTag,PnlNo,APBSet,APBArea
      ,(select Agroupno from ca_vw_PanelDownload where enabled = 1 AND InitLoad=1 AND pnlno =@pnlno AND AGSeq = 1 AND v.badge = badge and v.facility = facility and v.personid = personid) as aGroup1
      ,(select Agroupno from ca_vw_PanelDownload where enabled = 1 AND InitLoad=1 AND pnlno =@pnlno AND AGSeq = 2 AND v.badge = badge and v.facility = facility and v.personid = personid) as aGroup2
      ,(select Agroupno from ca_vw_PanelDownload where enabled = 1 AND InitLoad=1 AND pnlno =@pnlno AND AGSeq = 3 AND v.badge = badge and v.facility = facility and v.personid = personid) as aGroup3
      ,(select Agroupno from ca_vw_PanelDownload where enabled = 1 AND InitLoad=1 AND pnlno =@pnlno AND AGSeq = 4 AND v.badge = badge and v.facility = facility and v.personid = personid) as aGroup4
      ,(select Agroupno from ca_vw_PanelDownload where enabled = 1 AND InitLoad=1 AND pnlno =@pnlno AND AGSeq = 5 AND v.badge = badge and v.facility = facility and v.personid = personid) as aGroup5
      ,(select Agroupno from ca_vw_PanelDownload where enabled = 1 AND InitLoad=1 AND pnlno =@pnlno AND AGSeq = 6 AND v.badge = badge and v.facility = facility and v.personid = personid) as aGroup6
      FROM ca_vw_PanelDownload v
      WHERE Enabled=1
      AND PnlNo= @PnlNo
      AND InitLoad=1
      ORDER BY Facility,Badge
    </paneldownloadEnabledInitLoad>
    <PanelExists partitioned="False">select Count(*) as Cnt from Panel where pnlno=@PnlNo</PanelExists>
    <PanelFilterWithPartiion partitioned="False">
      SELECT distinct Panel.PnlNo as PnlNo,Panel.PanelName as 'Device Name',Panel.PanelType
      FROM   Panel INNER JOIN Reader ON Panel.PnlNo = Reader.PnlRef CROSS JOIN APBAreas
      WHERE  (Reader.APBEntry = @APBArea or Reader.APBExit = @APBArea) and Panel.caObjectID in (select caObjectID from DevicePartitions where PartitionID=@PartitionID)
    </PanelFilterWithPartiion>
    <PanelFilterWithOutPartiion partitioned="False">
      SELECT distinct Panel.PnlNo as PnlNo,Panel.PanelName as 'Device Name',Panel.PanelType
      FROM   Panel INNER JOIN Reader ON Panel.PnlNo = Reader.PnlRef CROSS JOIN APBAreas
      WHERE  (Reader.APBEntry = @APBArea or Reader.APBExit = @APBArea)
    </PanelFilterWithOutPartiion>
    <PanelPartitionFilter partitioned="False">
      SELECT distinct Panel.PnlNo as PnlNo,Panel.PanelName as 'Device Name',Panel.PanelType
      FROM   Panel WHERE  Panel.caObjectID in (select caObjectID from DevicePartitions where PartitionID=@PartitionID)
    </PanelPartitionFilter>
    <panelgrid partitioned="True">
      select
      PnlNo
      ,PnlNo as Panel
      ,PanelName as 'Device Name'
      ,Address as 'Pnl Address'
      ,Enabled as Enable
      ,HCSNo as Workstation
      ,ComPort
      ,Interactive as 'Is Interactive'
      ,NoFail as 'No Repeat Fail'
      ,XactSize as 'Buffer Size'
      ,Node as 'Dialup Node'
      ,LastUpdated as 'Last Edit'
      ,caObjectID
      from panel
      order by pnlno
    </panelgrid>
    <ApiPanelgrid partitioned="True">
      select
      PnlNo
      ,PanelName as 'Device Name'
      ,Address as 'Pnl Address'
      ,Enabled as Enable
      ,HCSNo as Workstation
      ,ComPort
      ,LastUpdated as 'Last Edit'
      ,PanelType
      ,caObjectID
      from panel
      order by pnlno
    </ApiPanelgrid>
    <panelgridwithoutlock partitioned="True">
      select
      PnlNo
      ,PnlNo as Panel
      ,PanelName as 'Device Name'
      ,Address as 'Pnl Address'
      ,Enabled as Enable
      ,HCSNo as Workstation
      ,ComPort
      ,Interactive as 'Is Interactive'
      ,NoFail as 'No Repeat Fail'
      ,XactSize as 'Buffer Size'
      ,Node as 'Dialup Node'
      ,LastUpdated as 'Last Edit'
      ,caObjectID
      ,HCSNo
      from panel
      WHERE paneltype &lt; 101
      order by pnlno
    </panelgridwithoutlock>
    <panellookup partitioned="True" notificationtable="Panel">
      select pnlno as ValueMember ,panelname as DisplayMember, paneltype,NapcoPanel from panel order by PanelName
    </panellookup>
    <panellookupwithoutlock partitioned="True" notificationtable="Panel">
      select pnlno as ValueMember ,panelname as DisplayMember, paneltype,NapcoPanel from panel WHERE paneltype &lt; 101 order by PanelName
    </panellookupwithoutlock>
    <panellookupjoin partitioned="False">
      select
      p.PanelType
      ,t.description as PanelTypeText
      ,p.NapcoPanel
      , CASE p.NapcoPanel WHEN (0) THEN 'None'  ELSE n.PanelName END AS NapcoPanelText
      ,p.DefaultCalendar
      ,h.Description as DefaultCalendarText
      ,p.HCSNo
      ,c.description as HCSNoText
      from panel p
      left outer join Panel_Types t on p.paneltype = t.id
      left outer join napcoPanels n on p.NapcoPanel = n.AlarmPanelID
      left outer join MHoliday h on p.DefaultCalendar = h.CalendarNo
      left outer join MCOM c on p.HCSNo = c.HCSNo
      where pnlNo = @PnlNo

    </panellookupjoin>
    <panelnoresults partitioned="False" notificationtable="Panel">select 1 from panel where 1=0</panelnoresults>
    <panelquery partitioned="False">
      select paneltype,NapcoPanel,AperioType from panel
      where pnlno = @pnlNo
    </panelquery>
    <panelsbynode partitioned="False" notificationtable="Panel">select pnlno,node from panel where node = @NodeId</panelsbynode>
    <panelsunpartlookupforCatCntr partitioned="True" notificationtable="Panel">
      select distinct
      Pnlno
      , Pnlno as ValueMember
      , PanelType
      , PanelName as Description
      , PanelName as DisplayMember
      from panel WHERE PnlNo not in (select c.pnlno from CategoryCounters c) AND PanelType in (3,5,6,7,8,9,10,11,12,13,14,15,16,17,101,102)
    </panelsunpartlookupforCatCntr>
    <panelswithcatcounters partitioned="False" notificationtable="CategoryCounters">
      SELECT DISTINCT p.PnlNo,p.PanelName,p.PanelType FROM Panel p
      INNER JOIN CategoryCounters c ON c.PnlNo=p.PnlNo WHERE PanelType in (3,5,6,7,8,9,10,11,12,13,14,15,16,17,101,102)
      and p.caObjectID in (
      SELECT devicepartitions.caObjectID FROM OperatorPartitions inner join  devicepartitions on devicepartitions.PartitionId = OperatorPartitions.Partitionid where OperatorPartitions.OperatorID = @OperatorId)
      order by p.PanelName
    </panelswithcatcounters>
    <paneltypelookup partitioned="False" notificationtable="Panel_Types">select ID as ValueMember, Description as DisplayMember from Panel_types</paneltypelookup>
    <panelUsagesByPanelID partitioned="false">
      select
      (select count(*) from
      (select distinct P.Badge, P.Facility
      from ca_vw_PanelDownload P
      inner join Badge on Badge.Badge=P.Badge and Badge.Facility=P.Facility
      WHERE  P.Enabled = 1 AND Badge.Enabled = 1 AND P.PnlNo =  @PanelID
      and (((P.ActvDate IS NULL) AND (P.ExprDate IS NULL)) OR
      ((P.ExprDate IS NULL) AND ((CASE WHEN UseHostTz = 1 THEN P.ActvDate ELSE DATEADD(MINUTE, P.UTCOffset, P.ActvDate) END) &lt;= (CASE WHEN UseHostTz = 1 THEN GetUTCDate() ELSE (CASE WHEN DATEADD(MINUTE, UTCBias * - 1, GetUTCDate()) > dStart AND DATEADD(MINUTE, UTCBias * - 1, GetUTCDate()) &lt; sStart THEN DateAdd(MINUTE, dBias*-1, DATEADD(MINUTE, UTCBias * - 1, GetUTCDate())) ELSE DATEADD(MINUTE, UTCBias * - 1, GetUTCDate()) END) END))) OR
      ((P.ActvDate IS NULL) AND ((CASE WHEN UseHostTz = 1 THEN P.ExprDate ELSE DATEADD(MINUTE, P.UTCOffset, P.ExprDate) END) &gt;= (CASE WHEN UseHostTz = 1 THEN GetUTCDate() ELSE (CASE WHEN DATEADD(MINUTE, UTCBias * - 1, GetUTCDate()) > dStart AND DATEADD(MINUTE, UTCBias * - 1, GetUTCDate()) &lt; sStart THEN DateAdd(MINUTE, dBias*-1, DATEADD(MINUTE, UTCBias * - 1, GetUTCDate())) ELSE DATEADD(MINUTE, UTCBias * - 1, GetUTCDate()) END)END))) OR
      (((CASE WHEN UseHostTz = 1 THEN P.ActvDate ELSE DATEADD(MINUTE, P.UTCOffset, P.ActvDate) END) &lt;= (CASE WHEN UseHostTz = 1 THEN GetUTCDate() ELSE (CASE WHEN DATEADD(MINUTE, UTCBias * - 1, GetUTCDate()) > dStart AND DATEADD(MINUTE, UTCBias * - 1, GetUTCDate()) &lt; sStart THEN DateAdd(MINUTE, dBias*-1, DATEADD(MINUTE, UTCBias * - 1, GetUTCDate())) ELSE DATEADD(MINUTE, UTCBias * - 1, GetUTCDate()) END)END)) AND 
      ((CASE WHEN UseHostTz = 1 THEN P.ExprDate ELSE DATEADD(MINUTE, P.UTCOffset, P.ExprDate) END) &gt;= (CASE WHEN UseHostTz = 1 THEN GetUTCDate() ELSE (CASE WHEN DATEADD(MINUTE, UTCBias * - 1, GetUTCDate()) > dStart AND DATEADD(MINUTE, UTCBias * - 1, GetUTCDate()) &lt; sStart THEN DateAdd(MINUTE, dBias*-1, DATEADD(MINUTE, UTCBias * - 1, GetUTCDate())) ELSE DATEADD(MINUTE, UTCBias * - 1, GetUTCDate()) END)END)))) 
      AND Badge.PersonID in (
      SELECT devicepartitions.caObjectID FROM OperatorPartitions inner join  devicepartitions on devicepartitions.PartitionId = OperatorPartitions.Partitionid where OperatorPartitions.OperatorID = @OperatorID)
      ) badge_count
      ) TotalBadges,
      (select Count(*) from Accgrp
      Inner Join MAccGrp on MAccGrp.AgrpNo=AccGrp.Agno
      WHERE PnlRef = @PanelID
      AND MAccGrp.caObjectID in (
      SELECT devicepartitions.caObjectID FROM OperatorPartitions inner join  devicepartitions on devicepartitions.PartitionId = OperatorPartitions.Partitionid where OperatorPartitions.OperatorID = @OperatorID)
      ) TotalAccGroups,
      ISNULL((select sum
      (
      case when Tz1 != 0 then 1 else 0 end
      + case when Tz2 != 0 then 1 else 0 end
      + case when Tz3 != 0 then 1 else 0 end
      + case when Tz4 != 0 then 1 else 0 end
      + case when Tz5 != 0 then 1 else 0 end
      + case when Tz6 != 0 then 1 else 0 end
      + case when Tz7 != 0 then 1 else 0 end
      + case when Tz8 != 0 then 1 else 0 end
      + case when Tz9 != 0 then 1 else 0 end
      + case when Tz10 != 0 then 1 else 0 end
      + case when Tz11 != 0 then 1 else 0 end
      + case when Tz12 != 0 then 1 else 0 end
      + case when Tz13 != 0 then 1 else 0 end
      + case when Tz14 != 0 then 1 else 0 end
      + case when Tz15 != 0 then 1 else 0 end
      + case when Tz16 != 0 then 1 else 0 end
      ) as total_0s
      from AccGrp
      Inner Join MAccGrp on MAccGrp.AgrpNo=AccGrp.Agno
      Where PnlRef = @PanelID AND MAccGrp.caObjectID in (
      SELECT devicepartitions.caObjectID FROM OperatorPartitions inner join  devicepartitions on devicepartitions.PartitionId = OperatorPartitions.Partitionid where OperatorPartitions.OperatorID = @OperatorID)
      ),0) TotalAgBlocks
    </panelUsagesByPanelID>
    <APIpanelUsagesByPanelID partitioned="false">
      select
      (select count(*) from (select Distinct b.Badge, b.Facility
      from BadgeAccess B INNER JOIN AccGrp A ON A.Agno = B.AGroupNo INNER JOIN Panel P On P.PnlNo = A.PnlRef INNER JOIN Badge Ba ON Ba.Badge = B.Badge
      WHERE  P.Enabled = 1 AND Ba.Enabled = 1 AND P.PnlNo =  @PanelID
      AND  (
      ba.BadgeType = 0
      OR ba.BadgeType =  CASE WHEN p.PanelType IN (3,11,12,13,14,15,16,17) THEN 1 END
      OR ba.BadgeType =  CASE WHEN p.PanelType IN (3,11,12,13,14,15,16,17) THEN 2 END
      )
      AND(1 = CASE WHEN Ba.Badge > 2147483647 THEN CASE WHEN p.PanelType IN (3,6,8,9,10,11,12,13,14,15,16,17) THEN 1 ELSE 0 END ELSE 1 END)
      AND Ba.PersonID in (
      SELECT devicepartitions.caObjectID FROM OperatorPartitions inner join  devicepartitions on devicepartitions.PartitionId = OperatorPartitions.Partitionid where OperatorPartitions.OperatorID = @OperatorID)
      ) badge_count
      ) 'Total Badges',
      (select Count(*) from Accgrp
      Inner Join MAccGrp on MAccGrp.AgrpNo=AccGrp.Agno
      WHERE PnlRef = @PanelID
      AND MAccGrp.caObjectID in (
      SELECT devicepartitions.caObjectID FROM OperatorPartitions inner join  devicepartitions on devicepartitions.PartitionId = OperatorPartitions.Partitionid where OperatorPartitions.OperatorID = @OperatorID)
      ) 'Total Access Groups',
      ISNULL((select sum
      (
      case when Tz1 != 0 then 1 else 0 end
      + case when Tz2 != 0 then 1 else 0 end
      + case when Tz3 != 0 then 1 else 0 end
      + case when Tz4 != 0 then 1 else 0 end
      + case when Tz5 != 0 then 1 else 0 end
      + case when Tz6 != 0 then 1 else 0 end
      + case when Tz7 != 0 then 1 else 0 end
      + case when Tz8 != 0 then 1 else 0 end
      + case when Tz9 != 0 then 1 else 0 end
      + case when Tz10 != 0 then 1 else 0 end
      + case when Tz11 != 0 then 1 else 0 end
      + case when Tz12 != 0 then 1 else 0 end
      + case when Tz13 != 0 then 1 else 0 end
      + case when Tz14 != 0 then 1 else 0 end
      + case when Tz15 != 0 then 1 else 0 end
      + case when Tz16 != 0 then 1 else 0 end
      ) as total_0s
      from AccGrp
      Inner Join MAccGrp on MAccGrp.AgrpNo=AccGrp.Agno
      Where PnlRef = @PanelID AND MAccGrp.caObjectID in (
      SELECT devicepartitions.caObjectID FROM OperatorPartitions inner join  devicepartitions on devicepartitions.PartitionId = OperatorPartitions.Partitionid where OperatorPartitions.OperatorID = @OperatorID)
      ),0) 'Total Ag Blocks'
    </APIpanelUsagesByPanelID>
    <panelxcombycluster partitioned="False">SELECT p.PnlNo, p.Address, p.ComPort, p.HCSNo, p.Enabled, p.Interactive, p.NoFail, p.XactSize, p.Node, p.CommPrior, p.DwnLoadPrior, p.PwrPrior,p.RespOffOnLine , p.RespDownloads , p.RespACPowerFail, p.RespModemActivity,p.Schedules, p.Elevators, p.ModemPrior, p.Passwrd, p.CurrentPwd, p.DegradeMode, p.AGSize, p.PanelType, p.MaxAlp, p.MaxEvt, p.DefaultCalendar,p.NoPolling, c.type FROM PANEL p INNER JOIN COM c ON p.HCSNo= c.HCSNo AND p.ComPort= c.ComPort WHERE p.HCSNo= @HCSNo AND p.enabled= 1</panelxcombycluster>
    <panelxcombypanelno partitioned="False">SELECT p.PnlNo, p.Address, p.ComPort, p.HCSNo, p.Enabled, p.Interactive, p.NoFail, p.XactSize, p.Node, p.CommPrior, p.DwnLoadPrior, p.PwrPrior,p.RespOffOnLine , p.RespDownloads , p.RespACPowerFail, p.RespModemActivity, p.Schedules, p.Elevators, p.ModemPrior, p.Passwrd, p.CurrentPwd, p.DegradeMode, p.AGSize, p.PanelType, p.MaxAlp, p.MaxEvt, p.DefaultCalendar,p.NoPolling, c.type FROM PANEL p INNER JOIN COM c ON p.HCSNo= c.HCSNo AND p.ComPort= c.ComPort WHERE p.PnlNo= @PnlNo AND p.enabled= 1</panelxcombypanelno>
    <partitionedthreatlevels partitioned="True">
      Select distinct m.LockdownID,m.Description,m.LockdownColor,m.Active, m.LockoutArea,m.caObjectID,m.LastUpdated From MActiveThreatLevel m inner join ActiveThreatLevel a on m.LockdownID = a.LockdownID
      order by LockdownID
    </partitionedthreatlevels>
    <partitionlookup partitioned="False">
    </partitionlookup>
    <GetPersonBySSN partitioned="False">
      Select p.PersonID, p.LastName, p.FrstName, b.Badge, b.Facility, (Select count(*) FROM [Badge] WHERE PersonID = p.PersonID) AS TotalBadgeCount
      , b.Enabled, b.BadgeDisabledDate, b.caObjectID as BadgeCaObjectId FROM Person p INNER JOIN [Badge] b on b.PersonID = p.PersonID
      WHERE p.SSN = @ssn
    </GetPersonBySSN>
    <GetPersonByName partitioned="False">
      Select p.PersonID, p.LastName, p.FrstName, b.Badge, b.Facility, (Select count(*) FROM [Badge] WHERE PersonID = p.PersonID) AS TotalBadgeCount
      , b.Enabled, b.BadgeDisabledDate, b.caObjectID as BadgeCaObjectId FROM Person p INNER JOIN [Badge] b on b.PersonID = p.PersonID
      WHERE p.LastName = @LastName and p.FrstName=@FrstName and p.MiddleName=@MiddleName
    </GetPersonByName>
    <personlookupjoin partitioned="False">
      select
      p.CompanyID
      ,c.CompanyName as CompanyIDText
      ,p.deptid
      ,d.departmentname as deptidText
      ,p.locationid
      ,l.location as locationidText
      ,p.SupervisorId
      ,ISNULL(s.LastName + ', ' + s.FrstName,'None') as SupervisorIdText
      ,p.gender
      ,CASE p.gender WHEN (0) THEN 'Unspecified' WHEN (1) THEN 'Male' WHEN (2) THEN 'Female' ELSE 'Unspecified' END as genderText
      from Person p
      left outer join CompanyInfo c on c.companyid = p.companyid
      left outer join DepartmentInfo d on d.departmentid = p.deptid
      left outer join LocationInfo l on l.Locationid = p.LocationId
      left outer join Person s on s.Personid = p.SupervisorId
      where p.personid = @personid
    </personlookupjoin>
    <personnelgrid partitioned="True">
      SELECT
      lastname as 'Last Name',
      frstname as 'First Name',
      Badge,
      PIVI,
      aGroupNo,
      Facility,
      Badge as 'Badge No',
      Enabled,
      caObjectId,
      ActvDate as 'Activation Date',
      ExprDate as 'Expiration Date',
      LastUpdated as 'Last Edit',
      PersonId
      FROM ca_vw_Personnel
    </personnelgrid>
    <getCA3000UserFields>
      SELECT variableValue
      FROM GlobalVariables
      WHERE variableName='EPIFieldmap'
    </getCA3000UserFields>
    <persontabs partitioned="False">
      select distinct t.userfieldtabname, t.userfieldtabid from UserFieldTabs t
      inner join UserFieldDef d on d.userfieldtabid = t.userfieldtabid
    </persontabs>
    <privilegelookup partitioned="False">
    </privilegelookup>
    <qAccessGroup partitioned="False">
      SELECT 0 as Agno, 'No Filter' as Description
      UNION
      SELECT DISTINCT MAccGrp.AgrpNo Agno, MAccGrp.Description FROM MAccGrp
      LEFT JOIN AccGrp  ON AccGrp.Agno = MAccGrp.AgrpNo
      WHERE MAccGrp.caObjectID IN (SELECT DP.caObjectID FROM OperatorPartitions OP JOIN Devicepartitions DP ON OP.PartitionID = DP.PartitionID WHERE OperatorID = @OperatorID)
    </qAccessGroup>
    <qAccessGroupList partitioned="False">
      SELECT AccessGroupID,BadgeID,LastName,FirstName FROM ca_vw_GetAccessGroupListData 1Sep
      WHERE (1=1) 1Sep
      AND AccessGroupID=@AccessGroupID
    </qAccessGroupList>
    <qAccessGroupReport partitioned="False">
      SELECT MAG.Agrpno AgNo, MAG.Description AgDesc, AG.PnlRef PnlNo, P.PanelName PnlDesc, R.RdrNo RdNo,
      R.ReaderName RdDesc, LASTEDIT, MAG.UTCOffset as UTCOffset,
      CASE WHEN MAG.PointAccess = 1 THEN 'Dedicated' ELSE '' END AS PointAccess,
      AG.Tz1, AG.Tz2, AG.Tz3, AG.Tz4, AG.Tz5, AG.Tz6, AG.Tz7, AG.Tz8, AG.Tz9, AG.Tz10, AG.Tz11, AG.Tz12, AG.Tz13, AG.Tz14, AG.Tz15, AG.Tz16,
      (CASE WHEN (SELECT COUNT(*) FROM AccGrp WHERE Agno = MAG.AgrpNo) &gt;0 THEN 1 ELSE 0 END) AS HasDetail
      FROM MAccGrp AS MAG LEFT JOIN AccGrp AS AG ON MAG.AgrpNo = AG.AGNO
      LEFT JOIN Panel AS P ON AG.PnlRef = P.PnlNo
      LEFT JOIN Reader AS R On AG.PnlRef = R.PnlRef WHERE MAG.AgrpNo &gt; 0 1Sep
      AND MAG.AgrpNo BETWEEN @Agno1 AND  @Agno2 1Sep
      AND MAG.AgrpNo = @Agno1 1Sep
    </qAccessGroupReport>
    <qAccessGroupReport1 partitioned="False">
      SELECT TzNum, Description FROM MTimeZon WHERE TzNum &gt; 0
      AND caObjectID IN (SELECT DP.caObjectID FROM OperatorPartitions OP JOIN Devicepartitions DP ON OP.PartitionID = DP.PartitionID WHERE OperatorID = @OperatorID)
    </qAccessGroupReport1>
    <qAccessGroupsForParam partitioned="False">
      SELECT 0 as AccessGroupNo, 'No Access' as Description
      union
      SELECT ALL AccessGroupNo, Description FROM ca_vw_AccessGroupsGetForParam WHERE caObjectID IN (SELECT DP.caObjectID FROM OperatorPartitions OP JOIN Devicepartitions DP ON OP.PartitionID = DP.PartitionID WHERE OperatorID = @OperatorID)
      ORDER BY Description
    </qAccessGroupsForParam>
    <qActivityLinkReport partitioned="False">
      SELECT caObjectID,Category, LASTUPDATED, Description,Device,DeviceName,EventCode,PnlRef,PnlNo,Priority,
      ProgNo,CASE WHEN UnDO=1 THEN 'Yes' ELSE 'No' END AS UnDO,PanelName,EventName,EventCat,CatName,RelNo,Control, DeviceType, DeviceDescription, Status, UTCOffset,
      CASE
      WHEN PnlRef &lt;&gt; PnlNo THEN 'GLOBAL' END GLOBAL , CASE WHEN Enabled=1 THEN 'Yes' ELSE 'No' END AS Enabled,
      CASE WHEN RespReq=1 THEN 'Yes' ELSE 'No' END AS RespReq, ManualPriv, ControlSchedule
      FROM ca_vw_GetActivityLinkData WHERE 1=1 1Sep
      AND PnlRef = @PnlRef 1Sep
      AND EventCat = @EventCat
    </qActivityLinkReport>
    <qAlertResponseReport partitioned="False">
      SELECT R.Description FROM dbo.Resp R ORDER BY R.Description ASC
    </qAlertResponseReport>
    <qAPBAreas partitioned="False">
      SELECT AreaNo,Description FROM APBAreas WHERE AreaNo BETWEEN 1 AND 254
      AND (AreaNo=1 or caObjectID IN (SELECT DP.caObjectID FROM OperatorPartitions OP JOIN Devicepartitions DP ON OP.PartitionID = DP.PartitionID WHERE OperatorID = @OperatorID))
      ORDER BY Description
    </qAPBAreas>
    <ApiAPBAreasGrid partitioned="True">
      SELECT AreaNo, Description, [Active], LastUpdated AS 'Last Edit' FROM APBAreas WHERE AreaNo BETWEEN 1 AND 254
      AND (AreaNo=1 or caObjectID IN (SELECT DP.caObjectID FROM OperatorPartitions OP JOIN Devicepartitions DP ON OP.PartitionID = DP.PartitionID WHERE OperatorID = @OperatorID))
      ORDER BY Description
    </ApiAPBAreasGrid>
    <ApiLockdownAPBAreas partitioned="True">
      SELECT AreaNo, Description, [Active], LastUpdated AS 'Last Edit' FROM APBAreas WHERE AreaNo BETWEEN 239 AND 254
      AND (AreaNo=1 or caObjectID IN (SELECT DP.caObjectID FROM OperatorPartitions OP JOIN Devicepartitions DP ON OP.PartitionID = DP.PartitionID WHERE OperatorID = @OperatorID))
      ORDER BY Description
    </ApiLockdownAPBAreas>
    <qAPBNestedAreas partitioned="False">
      SELECT NAA.Node, NAA.NestName FROM APBNestedAreas NAA
      JOIN APBAreas AA ON NAA.AreaNo = AA.AreaNo
      WHERE NAA.NestName IS NOT NULL AND len(NAA.NestName) != 0
      AND AA.caObjectID IN (SELECT DP.caObjectID FROM OperatorPartitions OP JOIN Devicepartitions DP ON OP.PartitionID = DP.PartitionID WHERE OperatorID = @OperatorID)
    </qAPBNestedAreas>
    <qAPBReaders partitioned="False">
      SELECT PnlRef,RdrNo,ReaderName Description FROM Reader WHERE APBType = 0 OR TAAPBType = 16 OR TAAPBType = 48 OR APBEntry &gt; 0
      AND caObjectID IN (SELECT DP.caObjectID FROM OperatorPartitions OP JOIN Devicepartitions DP ON OP.PartitionID = DP.PartitionID WHERE OperatorID = @OperatorID) ORDER BY ReaderName
    </qAPBReaders>
    <qAreaAccessListReport partitioned="False">
      select Description as Name,Badge,EVENTDATETIME,Name as Device,CVP.CompanyName as CompanyID,CVP.DepartmentName as Department,CVP.Location,CVP.Supervisor
      from EVENTS_DB_NAME..Event left outer join ca_vw_PersonnelInfo as CVP on Event.Badge=CVP.BadgeID
      Where Badge in(select Badge from Badge where FirstInControl=1)
      and CAST(CONVERT(VARCHAR(12), Edate, 101) AS DATETIME) between @DateFrom and @DateTo
      and DeviceNo in(SELECT Rdr.RdrNo
      FROM APBAreas as Area JOIN Reader as Rdr on Rdr.APBEntry=Area.AreaNo
      WHERE(AREA_NOS))
      and Cat in(0,6)
      order by Description
    </qAreaAccessListReport>
    <qAttendanceReport partitioned="False">
      SELECT EV.[Facno] AS Facility, EV.[Badge], EV.FullName, [E_Date], EV.[UTCOffset], EV.Clock_In, EV.ClockInReader,
      CASE WHEN ClockIn = ClockOut THEN NULL ELSE EV.Clock_Out END AS ClockOut, CASE WHEN ClockIn = ClockOut THEN NULL ELSE ClockOutReader END ClockOutReader
      FROM ( 1Sep
      ) AS EV WHERE EV.ClockIn &gt;= DATEADD(MINUTE, @minutes, CAST(DATEDIFF(DD,0, EV.ClockIn) AS DATETIME)) ORDER BY EV.[EDate] 1Sep
      SELECT DISTINCT [Facno], [Badge], Description AS FullName, CAST(DATEDIFF(DD, 0, DATEADD(MINUTE, {0}, [EDate])) AS DATETIME) as [EDate], [UTCOffset] 1Sep
      FROM EVENT_DB_NAME.[Event] AS E 1Sep
      , (SELECT TOP 1 DATEADD(MINUTE, {0}, [EDate]) AS [EDate] FROM EVENT_DB_NAME.[Event] 1Sep
      WHERE Cat IN (0, 8) AND Status IN (1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26) 1Sep
      AND [EDate] BETWEEN @dateFrom AND @dateTo AND E.Facno = Facno AND E.Badge = Badge 1Sep
      AND CAST(DATEDIFF(DD, 0, E.[EDate]) AS DATETIME) = CAST(DATEDIFF(DD, 0, [EDate]) AS DATETIME) 1Sep
      ORDER BY [EDate] 1Sep
      DESC 1Sep
      ) AS ClockIn 1Sep
      , (SELECT TOP 1 [Name] FROM EVENT_DB_NAME.[Event] 1Sep
      ) AS ClockInReader 1Sep
      ) AS ClockOut 1Sep
      ) AS ClockOutReader 1Sep
      AND E.Badge = CASE WHEN @Badge = -1 THEN E.Badge ELSE @Badge END 1Sep
      AND caObjectID in (SELECT devicepartitions.caObjectID FROM DBO.OperatorPartitions inner join DBO.devicepartitions ON devicepartitions.PartitionId = OperatorPartitions.PartitionID WHERE OperatorID = @OperatorID) 1Sep
    </qAttendanceReport>
    <qAuditTrailReport partitioned="False">
      Select
      OCCUREDON
      ,revisionstamp
      ,Description
      ,CASE Actions
      WHEN ('L') THEN 'Log'
      WHEN ('I') THEN 'Insert'
      WHEN ('U') THEN 'Edit'
      WHEN ('D') THEN 'Delete'
      ELSE 'None'
      END as Action
      ,TableName
      ,OperatorName
      ,StationName
      ,UTCOffset
      ,caObjectID
      from CONFIG_DB_NAME.[dbo].[DBAudit]
      WHERE 1=1
    </qAuditTrailReport>
    <qBadgeAccessReport partitioned="False">
      exec ca_sp_GetBadgeAccessList @whereClause
    </qBadgeAccessReport>
    <qBadgeCustomFieldsReport partitioned="False">
      SELECT UFD.PersonID, UFD.Badge, UFD.Facility, UFD.UserFieldID, UFD.UserFieldName, UF.UserFieldValue
      FROM (
      SELECT  UFD.UserFieldID, UserFieldName
      ,PersonID, Badge, Facility
      FROM UserFieldDef AS UFD CROSS JOIN Badge
      ) AS UFD LEFT OUTER JOIN (
      SELECT UFD.UserFieldID, UFD.UserFieldName, UF.UserFieldValue, UF.Badge, UF.Facility, UF.PersonID
      FROM UserFieldDef AS UFD INNER JOIN UserFields AS UF ON UFD.UserFieldID = UF.UserFieldID
      ) AS UF ON UFD.Badge = UF.Badge AND UFD.Facility = UF.Facility AND UFD.PersonID = UF.PersonID AND UFD.UserFieldID = UF.UserFieldID
      WHERE EXISTS (SELECT 1 FROM ({0} ORDER BY BadgeID,FacilityID) AS TAB WHERE TAB.BadgeID = UFD.Badge AND TAB.FacilityID = UFD.Facility)
      ORDER BY UFD.Badge, UFD.Facility, UFD.UserFieldID
    </qBadgeCustomFieldsReport>
    <qBadgeHolderName partitioned="False">
      SELECT BadgeID,PanelID,ReaderID,ReaderName,TimeZoneName,AccessGroupName,caObjectID FROM ca_vw_GetPersonnelAccessListData 1Sep
      WHERE (1=1) 1Sep
      AND BadgeID=@BadgeID
    </qBadgeHolderName>
    <qBadgeSearchCriteria partitioned="False">
      AND ( BadgeID BETWEEN 1Sep
      AND 1Sep
      AND DoorShunt= 1Sep
      AND DepartmentID= 1Sep
      AND LocationID= 1Sep
      AND ValidateOn&gt;= 1Sep
      AND InvalidateOn&gt;= 1Sep
      AND HireDate&gt;= 1Sep
      AND LastEdited&gt;= 1Sep
      AND LVAccessDate 1Sep
      AND IsEnabled=1 1Sep
      AND IsEnabled=0 1Sep
      AND IsTracked=1 1Sep
      AND IsResident=1 1Sep
      AND IsResident=0 1Sep
      AND IsEscort=1 1Sep
      AND IsDoorShunt=1 1Sep
      AND IsDedicated=1 1Sep
      ORDER BY 1Sep
      AND AccessGroupID= 1Sep
      AND AccessGroupID &lt;&gt;
    </qBadgeSearchCriteria>
    <qBadgesForTimeAndAttendance partitioned="False">
      SELECT ALL P.caObjectID, P.FrstName, P.LastName,
      ISNULL(P.LastName,'')  + ', ' + ISNULL(P.FrstName,'') AS FullName
      FROM dbo.Person P WHERE PersonID IN (SELECT DP.caObjectID FROM OperatorPartitions OP JOIN Devicepartitions DP ON OP.PartitionID = DP.PartitionID WHERE OperatorID = @OperatorID)
    </qBadgesForTimeAndAttendance>
    <qCategoryCountersReport partitioned="False">
      SELECT caObjectID,PanelID,PanelName,CategoryID,CategoryDescription,HighWatermark,
      LowWatermark,GenAlert,Priority,LastEdited FROM dbo.ca_vw_HardwareCategoryCounters WHERE (1=1) 1Sep
      AND PanelID BETWEEN @PanelIDFrom AND @PanelIDTo 1Sep
      AND PanelID = @PanelID
    </qCategoryCountersReport>
    <qDatabaseList partitioned="False">
      SELECT ID, ServerName, DatabaseName, DatabaseType FROM DatabaseList WHERE 1=1
    </qDatabaseList>
    <qDeviceList partitioned="False">
      SELECT PanelId,DeviceId,Description,DeviceType FROM ca_vw_DeviceList
      WHERE 1=1 AND caObjectID IN (SELECT DP.caObjectID FROM OperatorPartitions OP JOIN Devicepartitions DP ON OP.PartitionID = DP.PartitionID WHERE OperatorID = @OperatorID)
    </qDeviceList>
    <qExportEvents partitioned="False">
      SELECT E.Badge,E.Class, CASE WHEN Cat=5 THEN (SELECT TOP 1 R.ReaderName FROM CONFIG_DB_NAME.Reader R WHERE E.PnlNo = R.PnlRef AND E.DeviceNo = R.RdrNo) ELSE E.Description END AS Description, E.Name, EVENTDATE FROM 1Sep
      EVENT_DB_NAME.Event E 1Sep
      WHERE 1Sep
      ( 1Sep
      (E.Cat=0 OR E.Cat=8 OR E.Cat=5) 1Sep
      ) 1Sep
      AND ( 1Sep
      E.Status= 1Sep
      OR 1Sep
      ) 1Sep
      AND ((dbo.ca_fn_UTCDate(E.EDate, {0}, E.UTCOffset, TIMEFORMAT)&gt;=' 1Sep
      :00:00.000' 1Sep
      00:00:00.000' 1Sep
      ) AND (dbo.ca_fn_UTCDate(E.EDate, {0}, E.UTCOffset, TIMEFORMAT) 1Sep
      AND DATEPART(HOUR, dbo.ca_fn_UTCDate(E.EDate, {0}, E.UTCOffset, TIMEFORMAT))&gt;= 1Sep
      AND DATEPART(HOUR, dbo.ca_fn_UTCDate(E.EDate, {0}, E.UTCOffset, TIMEFORMAT)) 1Sep
      All 1Sep
      Panel 1Sep
      AND (Cat=4 1Sep
      AND ( 1Sep
      PnlNo= 1Sep
      OR  1Sep
      E.DeviceNo= 1Sep
      (Cat=  1Sep
      AND ( 1Sep
      Status= 1Sep
      OR  1Sep
      ) 1Sep
      cat&gt;=0 1Sep
      ORDER BY  1Sep
      Name 1Sep
      Eventdate 1Sep
      Badge 1Sep
    </qExportEvents>
    <qFacilityCodeReport partitioned="False">
      SELECT F.PnlRef, P.PanelName Description, CASE WHEN F.Facil1 = '0000' THEN '' ELSE F.Facil1 END Facil1,
      CASE WHEN F.Facil2 = '0000'THEN '' ELSE F.Facil2 END Facil2, CASE WHEN F.Facil3 = '0000' THEN ''
      ELSE F.Facil3 END Facil3, CASE WHEN F.Facil4 = '0000' THEN '' ELSE F.Facil4 END Facil4, CASE
      WHEN F.Facil5 = '0000' THEN '' ELSE F.Facil5 END Facil5, CASE WHEN F.Facil6 = '0000' THEN ''
      ELSE F.Facil6 END Facil6, CASE WHEN F.Facil7 = '0000' THEN '' ELSE F.Facil7 END Facil7,
      CASE WHEN F.Facil8 = '0000' THEN '' ELSE F.Facil8 END Facil8, CASE WHEN F.Facil9 = '0000' THEN ''
      ELSE F.Facil9 END Facil9, CASE WHEN F.Facil10 = '0000' THEN '' ELSE F.Facil10 END Facil10, LastUpdated, F.UTCOffset AS UTCOffset
      FROM dbo.Facility F INNER JOIN dbo.Panel P ON P.PnlNo=F.PnlRef WHERE 1=1 ORDER BY F.PnlRef
    </qFacilityCodeReport>
    <qGeneralEventReport partitioned="False">
      SELECT E.SeqNo,E.Cat, E.DeviceNo, E.PnlNo,EVENTDATE,E.EDate,E.DeviceNo Number,E.Status,E.Facno,E.Badge,E.Class,E.Description,E.Name,E.AckOpr,E.AckTStamp, E.Actions, 1Sep
      E.Actions, 1Sep
      E.Tag,E.HasPhoto, #OprName#, E.EDate as UTCDate, E.AckTStamp as UTCAckDate, ACKDATE, E.UTCOffset  FROM 1Sep
      EVENT_DB_NAME.Event E LEFT OUTER JOIN CONFIG_DB_NAME.Operators O ON E.AckOpr=O.OperatorID 1Sep
      . 1Sep
      .dbo 1Sep
      EVENT_DB_NAME.Event E LEFT OUTER JOIN CONFIG_DB_NAME.Operators O ON E.AckOpr=O.OperatorID 1Sep
      WHERE ( 1Sep
      cat&gt;=0 1Sep
      OR 1Sep
      ((Cat=  1Sep
      AND ( 1Sep
      Status= 1Sep
      OR  1Sep
      ) 1Sep
      AND E.HasPhoto=1 1Sep
      AND ((dbo.ca_fn_UTCDate(E.EDate, {0}, E.UTCOffset, TIMEFORMAT)&gt;=' 1Sep
      :00:00.000' 1Sep
      00:00:00.000' 1Sep
      ) AND (dbo.ca_fn_UTCDate(E.EDate, {0}, E.UTCOffset, TIMEFORMAT) 1Sep
      AND DATEPART(HOUR, dbo.ca_fn_UTCDate(E.EDate, {0}, E.UTCOffset, TIMEFORMAT))&gt;= 1Sep
      AND DATEPART(HOUR, dbo.ca_fn_UTCDate(E.EDate, {0}, E.UTCOffset, TIMEFORMAT)) 1Sep
      All 1Sep
      Panel 1Sep
      AND (Cat=4 1Sep
      AND ( 1Sep
      PnlNo= 1Sep
      OR  1Sep
      E.DeviceNo= 1Sep
      ORDER BY  1Sep
      EDate, Cat, PnlNo, DeviceNo 1Sep
      EDate 1Sep
      AckTStamp 1Sep
      Class, EDate 1Sep
      Description, EDate 1Sep
      Name, EDate 1Sep
      SELECT EP.EventSeqNo, EP.EventResponse, EventResponseDateTime, EP.Operator FROM 1Sep
      INNER JOIN EVENT_DB_NAME.EventResponse EP ON E.Seqno = EP.EventSeqNo 1Sep
      AND CONVERT(VARCHAR(100), EP.EventResponse) NOT IN ('Acknowledged', 'Un-Acked')  1Sep
      Cat=47 1Sep
      AND 1Sep
      PnlNo, DeviceNo, Cat, EDate 1Sep
    </qGeneralEventReport>
    <qGetAllCompanies partitioned="False">
      SELECT CompanyID, CompanyName FROM CompanyInfo
    </qGetAllCompanies>
    <qGetAllDepartments partitioned="False">
      SELECT DepartmentID AS DeptID, DepartmentName FROM DepartmentInfo order by DepartmentName
    </qGetAllDepartments>
    <qGetAllLocations partitioned="False">
      SELECT LocationID, Location FROM LocationInfo order by Location
    </qGetAllLocations>
    <qGetAllSupervisors partitioned="False">
      select LastName + ', ' + FrstName as FullName
      , PersonId   as ValueMember
      from Person
      where supervisor = 1
    </qGetAllSupervisors>
    <qGetBadgesList partitioned="False">
      SELECT P.PersonID, B.Badge, ISNULL(P.LastName, '') AS LastName, ISNULL(P.FrstName, '') AS FirstName, ISNULL(P.LastName, '') + ', '+ ISNULL(P.FrstName, '') AS Name, B.VehicleTag
      FROM dbo.Person AS P INNER JOIN dbo.Badge AS B ON P.PersonID = B.PersonID
      WHERE P.PersonID IN (SELECT DP.caObjectID FROM OperatorPartitions OP JOIN Devicepartitions DP ON OP.PartitionID = DP.PartitionID WHERE OperatorID = @OperatorID)
    </qGetBadgesList>
    <qGetBadgesParameter partitioned="False">
      SELECT PersonID,Badge,LastName,FirstName,LastName+', '+FirstName as Name,APBSet FROM ca_vw_BadgesGetForParam WHERE PersonID IN (SELECT DP.caObjectID FROM OperatorPartitions OP JOIN Devicepartitions DP ON OP.PartitionID = DP.PartitionID WHERE OperatorID = @OperatorID)
      ORDER BY LastName,FirstName
    </qGetBadgesParameter>
    <qGetLinks partitioned="False">
      SELECT PnlRef,ProgNo,Enabled,Dialup,RptXact,LinkName,Description,
      Status,LnkPnl,LnkProg,ETz,TrkTZ,Inp1,Inp2,Inp3,Inp4,Inp5,On1,On2,
      On3,On4,On5,Off1,Off2,Off3,Off4,Off5,Trk1,Trk2,Trk3,Trk4,Trk5,Priority,
      MapId,DeviceId,RespReq,ManualPriv,Location,Remarks,caObjectID,LastUpdated,LastOperator,
      LastWorkStation FROM dbo.Link WHERE 1=1
      AND caObjectID IN (SELECT DP.caObjectID FROM OperatorPartitions OP JOIN Devicepartitions DP ON OP.PartitionID = DP.PartitionID WHERE OperatorID = @OperatorID)
    </qGetLinks>
    <qGetNAPCOPanels partitioned="False">
      SELECT 0 as AlarmPanelID, 'No Filter' as PanelName, null AS caObjectID
      union
      SELECT ALL AlarmPanelID, PanelName, caObjectID FROM napcoPanels WHERE 1=1
      AND caObjectID IN (SELECT DP.caObjectID FROM OperatorPartitions OP JOIN Devicepartitions DP ON OP.PartitionID = DP.PartitionID WHERE OperatorID = @OperatorID)
    </qGetNAPCOPanels>
    <qGetPanels partitioned="False">
      SELECT caObjectID,PanelNo,PanelName,PanelGeneration FROM ca_vw_GetPanels WHERE 1=1
      AND caObjectID IN (SELECT DP.caObjectID FROM OperatorPartitions OP JOIN Devicepartitions DP ON OP.PartitionID = DP.PartitionID WHERE OperatorID = @OperatorID)
    </qGetPanels>
    <qGetPerson partitioned="False">
      SELECT P.PersonID FROM Person AS P
      WHERE P.LastName + RIGHT(P.SSN, 4) = @LastNameSSN
      AND P.PersonID IN (SELECT DP.caObjectID FROM OperatorPartitions OP JOIN Devicepartitions DP ON OP.PartitionID = DP.PartitionID WHERE OperatorID = @OperatorID)
    </qGetPerson>
    <qGetReaders partitioned="False">
      SELECT caObjectID,PanelNo,ReaderNo,ReaderName FROM ca_vw_ReadersGetForParam WHERE caObjectID IN (SELECT DP.caObjectID FROM OperatorPartitions OP JOIN Devicepartitions DP ON OP.PartitionID = DP.PartitionID WHERE OperatorID = @OperatorID)
      ORDER BY PanelNo,ReaderNo
    </qGetReaders>
    <qGetShuntGroup partitioned="false">
      select 0 as ValueMember, 'None' as DisplayMember
      ,0 as Active
      union
      select ShuntID as ValueMember, ShuntName as DisplayMember
      ,ISNULL(Active, 0) AS Active
      from MShunt
      WHERE
      caObjectID IN (SELECT DP.caObjectID FROM OperatorPartitions OP JOIN Devicepartitions DP ON OP.PartitionID = DP.PartitionID WHERE OperatorID = @OperatorID)
      order by DisplayMember
    </qGetShuntGroup>
    <qGetApbFirstInReport partitioned="false">
      select AreaNo as ValueMember, Description as DisplayMember from APBAreas
      where areano between 239 and 254
      and caObjectID IN (SELECT DP.caObjectID FROM OperatorPartitions OP JOIN Devicepartitions DP ON OP.PartitionID = DP.PartitionID WHERE OperatorID = @OperatorID)
      order by Description
    </qGetApbFirstInReport>
    <qGetTemplate partitioned="False">
      SELECT Name,RptType,Period,Previous,Filter,DevList,Data1,Data2,Data3,Data4,
      Data5,Data6,Data7,Data8,Data9,Data10,Data11,Data12,Data13,
      Data14,Data15,Data16,Data17,Data18,Data19,Data20,Data21,Data22,
      Data23,Data24,Data25,Data26,Data27,Data28,Data29,Data30,Data31,
      Data32,Data33,Data34,Data35,Data36,Data37,Data38,Data39,Data40,Data41,Data42,Data43,Data44  FROM dbo.Template T WHERE T.RptType = 2 ORDER BY Name ASC
    </qGetTemplate>
    <qHardwareActivityLinkReport partitioned="False">
      SELECT caObjectID,PanelID,PanelName,ProgNo,ProgDescription,AlertPriority,EventName,Device,
      Category,RelayDescription,RelayControl, LASTEDITED, UTCOffset FROM dbo.ca_vw_HardwareActivityLinks WHERE (1=1) 1Sep
      AND PanelID BETWEEN @PanelIDFrom AND @PanelIDTo 1Sep
      AND PanelID = @PanelID
    </qHardwareActivityLinkReport>
    <qHardwareCategoryCounter partitioned="False">
      select P.PnlNo as PanelID,P.PanelName,CC.CatNo as CategoryID,
      Case when CC.CatNo IN (select distinct catnumber from ActiveThreatLevel)
      then 'In Used by Threat Level Mgmnt' else CC.Description end  as CategoryDescription,
      CC.HiWater as HighWatermark,CC.LowWater as LowWatermark,CC.EventMsg as GenAlert,
      CC.Priority, LASTEDITED, CC.UTCOffset AS UTCOffset from CategoryCounters CC inner join Panel P on P.PnlNo = CC.PnlNo where(1=1) 1Sep
      and CC.PnlNo between @PanelIDFrom and @PanelIDTo 1Sep
      and CC.PnlNo= @PanelID 1Sep
    </qHardwareCategoryCounter>
    <qHolidaysReport partitioned="False">
      SELECT V.CalendarName, V.Schedule, LASTEDIT, UTCOffset, SDate, FromTime, ToTime FROM dbo.ca_vw_HolidayForData V WHERE 1=1
    </qHolidaysReport>
    <qInListReport1 partitioned="False">
      SELECT ALL I.Name,
      I.Reader, I.PanelTime as Time, AA.Description AS APBArea, I.APBIn, TAIn, I.PanelTime as UTCTime , I.UTCOffset, P.PersonID,Badge,Facility,AA.AreaNo,I.PanelTime
      FROM EVENT_DB_NAME..InList AS I
      INNER JOIN APBAreas AS AA ON I.APBArea=AA.AreaNo
      INNER JOIN Person as P ON P.PersonID = I.PersonID
      WHERE ((APBArea BETWEEN 2 AND 254) OR APBIn=1 OR TAIn=1)
    </qInListReport1>
    <qInListReport2 partitioned="False">
      SELECT ALL I.Name,
      I.Reader, I.PanelTime as Time, AA.Description AS APBArea, I.APBIn, TAIn, I.PanelTime as UTCTime , I.UTCOffset, P.PersonID,Badge,Facility,AA.AreaNo,I.PanelTime
      FROM EVENT_DB_NAME..InList AS I
      INNER JOIN APBAreas AS AA ON I.APBArea=AA.AreaNo
      INNER JOIN Person as P ON P.PersonID = I.PersonID
      WHERE 1=1
      AND PnlNo=@fieldOne AND RdrNo=@fieldTwo
    </qInListReport2>
    <qInListReport3 partitioned="False">
      SELECT ALL  I.Name,
      I.Reader, I.PanelTime as Time, AA.Description AS APBArea, I.APBIn, TAIn, I.PanelTime as UTCTime , I.UTCOffset, P.PersonID,Badge,Facility,AA.AreaNo,I.PanelTime
      FROM EVENT_DB_NAME..InList AS I
      INNER JOIN APBAreas AS AA ON I.APBArea=AA.AreaNo
      INNER JOIN Person as P ON P.PersonID = I.PersonID
      WHERE APBArea=@fieldOne
    </qInListReport3>
    <qInListReport4 partitioned="False">
      SELECT ALL I.Name,
      I.Reader, I.PanelTime as Time, AA.Description AS APBArea, I.APBIn, TAIn, I.PanelTime as UTCTime , I.UTCOffset, P.PersonID,Badge,Facility,AA.AreaNo,I.PanelTime
      FROM EVENT_DB_NAME..InList AS I
      INNER JOIN APBAreas AS AA ON I.APBArea=AA.AreaNo
      INNER JOIN Person as P ON P.PersonID = I.PersonID
      WHERE I.APBArea IN (select AreaNo from APBNestedAreas where Node = @fieldOne)
    </qInListReport4>
    <qInListReport5 partitioned="False">
      SELECT ALL I.Name,
      I.Reader, I.PanelTime as Time, AA.Description AS APBArea, I.APBIn, TAIn, I.PanelTime as UTCTime , I.UTCOffset, P.PersonID,Badge,Facility,AA.AreaNo,I.PanelTime,I.PnlNo, I.RdrNo
      FROM EVENT_DB_NAME..InList AS I
      INNER JOIN APBAreas AS AA ON I.APBArea=AA.AreaNo
      INNER JOIN Person as P ON P.PersonID = I.PersonID
      WHERE ((APBArea BETWEEN 2 AND 254) OR APBIn=1 OR TAIn=1)
    </qInListReport5>
    
    <qInputReport partitioned="False">
      SELECT caObjectID,PanelID,PanelName,InputNo,InputName,Enabled,NormalllyOpen,Supervised,DialupOnAbnorm,
      dialupOnNorm,ActivateConsoleRelay,EnabledBySchedule,
      CASE WHEN AlertDelayTime &gt; 59  THEN CAST(AlertDelayTime - 59 AS varchar(5)) + ' Minutes'
      WHEN AlertDelayTime &lt; 60  THEN CAST(AlertDelayTime AS varchar(5)) + ' Seconds' END
      AS AlertDelayTime
      ,AlertResetTime,AlertPriority, LASTEDITED,RepeatIntervalLimit,
      LimitBySchedule,AlarmDelay,AutoResets,NoEventRpt,PanelType, UTCOffset, RespReq FROM dbo.ca_vw_HardwareInput WHERE (1=1) 1Sep
      AND PanelID BETWEEN @PanelIDFrom AND @PanelIDTo 1Sep
      AND PanelID = @PanelID 1Sep
      ORDER BY PanelID, InputNo
    </qInputReport>
    <qLinksReport partitioned="False">
      SELECT caObjectID,PanelID,PanelName,LinkID,LinkName,Enabled,RespReq,Dialup,Priority,LASTUPDATED,RptxAct,
      EnableSchedule,TrackSchedule,RemoteLink,
      CASE WHEN InputOne IS NULL THEN 'N/A' ELSE InputOne END AS InputOne,
      CASE WHEN InputTwo IS NULL THEN 'N/A' ELSE InputTwo END AS InputTwo,
      CASE WHEN InputThree IS NULL THEN 'N/A' ELSE InputThree END AS InputThree,
      CASE WHEN InputFour IS NULL THEN 'N/A' ELSE InputFour END AS InputFour,
      CASE WHEN InputFive IS NULL THEN 'N/A' ELSE InputFive END AS InputFive,
      CASE WHEN OnRelayOne IS NULL THEN 'N/A' ELSE OnRelayOne END AS OnRelayOne,
      CASE WHEN OnRelayTwo IS NULL THEN 'N/A' ELSE OnRelayTwo END AS OnRelayTwo,
      CASE WHEN OnRelayThree IS NULL THEN 'N/A' ELSE OnRelayThree END AS OnRelayThree,
      CASE WHEN OnRelayFour IS NULL THEN 'N/A' ELSE OnRelayFour END AS OnRelayFour,
      CASE WHEN OnRelayFive IS NULL THEN 'N/A' ELSE InputFive END AS OnRelayFive,
      CASE WHEN OffRelayOne IS NULL THEN 'N/A' ELSE OffRelayOne END AS OffRelayOne,
      CASE WHEN OffRelayTwo IS NULL THEN 'N/A' ELSE OffRelayTwo END AS OffRelayTwo,
      CASE WHEN OffRelayThree IS NULL THEN 'N/A' ELSE OffRelayThree END AS OffRelayThree,
      CASE WHEN OffRelayFour IS NULL THEN 'N/A' ELSE OffRelayFour END AS OffRelayFour,
      CASE WHEN OffRelayFive IS NULL THEN 'N/A' ELSE OffRelayFive END AS OffRelayFive,
      CASE WHEN TrackRelayOne IS NULL THEN 'N/A' ELSE TrackRelayOne END AS TrackRelayOne,
      CASE WHEN TrackRelayTwo IS NULL THEN 'N/A' ELSE TrackRelayTwo END AS TrackRelayTwo,
      CASE WHEN TrackRelayThree IS NULL THEN 'N/A' ELSE TrackRelayThree END AS TrackRelayThree,
      CASE WHEN TrackRelayFour IS NULL THEN 'N/A' ELSE TrackRelayFour END AS TrackRelayFour,
      CASE WHEN TrackRelayFive IS NULL THEN 'N/A' ELSE TrackRelayFive END AS TrackRelayFive,
      UTCOffset FROM dbo.ca_vw_LinkGetAllForData V WHERE (1=1) 1Sep
      AND V.PanelID BETWEEN @panelIDFrom AND @panelIDTo 1Sep
      AND V.PanelID = @panelIDFrom 1Sep
      AND V.LinkID BETWEEN @linkIDFrom AND @linkIDTo 1Sep
      AND V.caObjectID = @linkID
    </qLinksReport>
    <qModems partitioned="False">
      SELECT V.NodeID, V.NodeName, V.Phone,
      (case when V.Frequency = 0 then 'Schedule'
      when V.Frequency = 1 then 'Hourly'
      when V.Frequency = 2 then 'Twice Daily'
      when V.Frequency = 3 then 'Daily'
      else 'Unknown' end) as Frequency,
      V.Setup1, V.Setup2, V.LastEdited, V.Schedule,
      (case when V.DialIn=0 then 'Moden Line 1'
      when V.DialIn=1 then 'Moden Line 2'
      when V.DialIn=2 then 'Both Moden Line'
      else 'None' end)as DialIn,
      (case when V.DialOut=0 then 'Moden Line 1'
      when V.DialOut=1 then 'Moden Line 2'
      else 'None' end) as DialOut, V.Panel,V.UTCOffset
      FROM dbo.ca_vw_ModemGetAll AS V 
    </qModems>
    <qNapcoPanelReport partitioned="False">
      SELECT caObjectID,PanelID,PanelName,ConnectionType,PanelType,Enabled,SocketAddress,Workstation,AreaNumber,
      AreaName,AreaType,ManualPriv,AreaConfigured,ZoneNumber,ZoneName,ZoneConfigured
      FROM dbo.ca_vw_HardwareNapcoPanel WHERE (1=1) 1Sep
      AND PanelID = @PanelID
    </qNapcoPanelReport>
    <qNapcoRelayReport partitioned="False">
      SELECT  P.AlarmPanelID AS PanelID, R.RelayNumber AS RelayNumber, R.RelayName AS RelayName, R.RelayConfigured AS RelayConfigured
      FROM dbo.ca_vw_napco_panelDisplayGrid AS P LEFT JOIN dbo.ca_vw_napco_relayDisplayGrid AS R ON R.AlarmPanelID = P.AlarmPanelID AND R.RelayConfigured = 1 WHERE (1=1) 1Sep
      AND P.AlarmPanelID = @PanelID
    </qNapcoRelayReport>
    <qNodes partitioned="False">
      SELECT N.NodeID, N.NodeName AS NodeName FROM dbo.Nodes AS N WHERE
      caObjectID IN (SELECT DP.caObjectID FROM OperatorPartitions OP JOIN Devicepartitions DP ON OP.PartitionID = DP.PartitionID WHERE OperatorID = @OperatorID)
    </qNodes>
    <qOperatorsReport partitioned="False">
      SELECT ALL V.PK, V.ScreenName, V.Name, LASTEDITED, V.AckTime, V.Privilege, UTCOffset FROM dbo.ca_vw_OperatorGetAll V WHERE 1=1
    </qOperatorsReport>
    <qPanelReport partitioned="False">
      SELECT panel.caObjectID,PanelID,PanelName,PanelAddress,COMPort,TransSize,Interactive,StationName,Enabled,LASTEDITED,
      CommunPriority,DataLoadingPriority,TroublePriority,DialupPriority,HasElevator,PanelType,
      MaximumAcitityLinks,DefaultCalendarName,NAPCOPanelLink,RepeatTrouble,DialNode,OnModem,UTCOffset *-1 as UTCOffset, IPAddress, ZoneDescription, DegradeMode, ISNULL(AGSize,0) as AGSize, Schedules
      ,ISNULL([MaxAlp],0) as ActualActivityLinks
      FROM dbo.ca_vw_HardwarePanel as panel left join EVENT_DB_NAME.[Status] as st on st.Panel=PanelID and st.Device=0 WHERE (1=1) 1Sep
      AND PanelID BETWEEN @PanelIDFrom AND @PanelIDTo 1Sep
      AND PanelID = @PanelID 1Sep
      AND COMPort = @COMPort 1Sep
      AND DialNode = @DialNode
    </qPanelReport>
    <qPersonalEventReport partitioned="False">
      SELECT P.CompanyID, P.DeptID, P.LocationID, P.SupervisorID, EVENTDATE , E.EDate as UTCDate, E.AckTStamp as UTCAckDate, E.UTCOffset, E.SeqNo,E.Cat,E.PnlNo,E.EDate,E.DeviceNo Number,E.Status,E.Facno,E.Badge,E.Class, 1Sep
      E.Description + ' ('+ CONVERT(nvarchar, E.Badge) +')' Description,E.Name,E.AckOpr,E.AckTStamp,ACKDATE,E.Tag,E.HasPhoto, #OprName#, E.Actions 1Sep
      ,E.Actions  1Sep
      FROM EVENT_DB_NAME.Event E 1Sep
      LEFT JOIN CONFIG_DB_NAME.Badge B ON (E.Facno=B.Facility AND E.Badge=B.Badge) LEFT JOIN CONFIG_DB_NAME.Person P ON (P.PersonID = B.PersonID) 1Sep
      LEFT OUTER JOIN CONFIG_DB_NAME.Operators O ON E.AckOpr=O.OperatorID 1Sep
      FROM  1Sep
      . 1Sep
      dbo 1Sep
      .Event E 1Sep
      INNER JOIN 1Sep
      .Badge B ON (E.Facno=B.Facility AND E.Badge=B.Badge) 1Sep
      LEFT OUTER JOIN 1Sep
      .Operators O ON E.AckOpr=O.OperatorID  1Sep
      SELECT DISTINCT P.CompanyID, P.DeptID, P.LocationID, P.SupervisorID, E.EDate as UTCDate, E.AckTStamp as UTCAckDate, E.seqno,E.Priority,E.Cat,E.PnlNo,E.EDate,E.DeviceNo Number, 1Sep
      E.Status,E.Facno,E.Badge,E.Class,E.Description,E.Name,E.AckOpr, 1Sep
      E.AckTStamp,E.Tag,R.ReaderName Description, E.HasPhoto', #OprName#, E.Actions 1Sep
      , E.Actions 1Sep
      , E.EDate as UTCDate, E.AckTStamp as UTCAckDate, E.UTCOffset FROM EVENT_DB_NAME.Event E 1Sep
      LEFT OUTER JOIN CONFIG_DB_NAME.Operators O ON E.AckOpr=O.OperatorID 1Sep
      INNER JOIN CONFIG_DB_NAME.Badge B ON (E.Facno=B.Facility AND E.Badge=B.Badge) 1Sep
      1Sep
      LEFT JOIN CONFIG_DB_NAME.Reader R ON (E.PnlNo=R.PnlRef AND E.DeviceNo=R.RdrNo) 1Sep
      FROM 1Sep
      .Event E 1Sep
      LEFT OUTER JOIN 1Sep
      .Operators O ON E.AckOpr=O.OperatorID 1Sep
      INNER JOIN 1Sep
      .Badge B ON (E.Facno=B.Facility AND E.Badge=B.Badge) LEFT JOIN Person P ON (P.PersonID = B.PersonID) 1Sep
      LEFT JOIN 1Sep
      1Sep
      LEFT JOIN 1Sep
      .Reader R ON (E.PnlNo=R.PnlRef AND E.DeviceNo=R.RdrNo) 1Sep
      SELECT P.CompanyID, P.DeptID, P.LocationID, P.SupervisorID, E.EDate as UTCDate, E.AckTStamp as UTCAckDate, E.SeqNo,E.Cat,E.PnlNo,E.EDate,E.DeviceNo Number,E.Status,E.Facno,E.Badge,E.Class, 1Sep
      E.Description,E.Name,E.AckOpr,E.AckTStamp,E.Tag,E.HasPhoto, #OprName#,E.Actions 1Sep
      ,E.Actions 1Sep
      , E.EDate as UTCDate, E.AckTStamp as UTCAckDate, E.UTCOffset FROM EVENT_DB_NAME.Event E 1Sep
      LEFT OUTER JOIN CONFIG_DB_NAME.Badge B ON (E.Facno=B.Facility AND E.Badge=B.Badge) 1Sep
      LEFT OUTER JOIN CONFIG_DB_NAME.Operators O ON E.AckOpr=O.OperatorID 1Sep
      FROM 1Sep
      .Event E 1Sep
      LEFT OUTER JOIN  1Sep
      .Badge B ON (E.Facno=B.Facility AND E.Badge=B.Badge) LEFT JOIN CONFIG_DB_NAME.Person P ON (P.PersonID = B.PersonID) 1Sep
      LEFT OUTER JOIN 1Sep
      .Operators O ON E.AckOpr=O.OperatorID 1Sep
      WHERE 1Sep
      ( 1Sep
      (E.Cat=0 OR E.Cat=8) 1Sep
      (((E.Cat=8) 1Sep
      ) 1Sep
      OR (E.Cat=0)) 1Sep
      AND ( 1Sep
      E.Status= 1Sep
      OR 1Sep
      ) 1Sep
      AND ( 1Sep
      E.Class like '%Trk%' 1Sep
      AND ((dbo.ca_fn_UTCDate(E.EDate, {0}, E.UTCOffset, TIMEFORMAT)&gt;=' 1Sep
      :00:00.000' 1Sep
      00:00:00.000' 1Sep
      ) AND (dbo.ca_fn_UTCDate(E.EDate, {0}, E.UTCOffset, TIMEFORMAT) 1Sep
      AND DATEPART(HOUR, dbo.ca_fn_UTCDate(E.EDate, {0}, E.UTCOffset, TIMEFORMAT))&gt;= 1Sep
      AND DATEPART(HOUR, dbo.ca_fn_UTCDate(E.EDate, {0}, E.UTCOffset, TIMEFORMAT)) 1Sep
      All 1Sep
      Panel 1Sep
      AND (E.Cat=4 1Sep
      AND ( 1Sep
      E.PnlNo= 1Sep
      OR 1Sep
      AND ( 1Sep
      E.DeviceNo= 1Sep
      OR 1Sep
      AND (E.Badge&gt;= 1Sep
      AND E.Badge 1Sep
      AND (E.Description like '% 1Sep
      %' ) 1Sep
      AND (E.Badge= 1Sep
      AND (E.Facno= 1Sep
      1Sep
      AND ( 1Sep
      ORDER BY 1Sep
      EDate 1Sep
      Description, EDate 1Sep
      Badge,EDate 1Sep
      Tag,EDate 1Sep
      Description, EDate 1Sep
      EDate 1Sep
      EDate 1Sep
      Description, EDate 1Sep
      Badge, EDate 1Sep
      PnlNo, Number, EDate 1Sep
      Tag, EDate 1Sep
      SELECT EP.EventSeqNo, EP.EventResponse, EventResponseDateTime, EP.Operator 1Sep
      INNER JOIN EVENT_DB_NAME.EventResponse EP ON E.Seqno = EP.EventSeqNo 1Sep
      AND CONVERT(VARCHAR(100), EP.EventResponse) NOT IN ('Acknowledged', 'Un-Acked')  1Sep
      LEFT JOIN CONFIG_DB_NAME.ca_vw_BadgeAccess AS BA ON (BA.Facility = B.Facility AND BA.Badge = B.Badge) 1Sep
      LEFT JOIN CONFIG_DB_NAME.BadgeUpdate AS BU ON (BU.PersonID = B.PersonID AND BU.Facility = B.Facility AND BU.Badge = B.Badge) 1Sep
    </qPersonalEventReport>
    <qPersonnelBadgeReport partitioned="False">
      SELECT DISTINCT TOP 2000 BP.caObjectID,AccessTime,VALIDATEON,DoorShunt,APBSet,BadgeID, LASTEDITED,Supervisor,Ext,
      CompanyID,DepartmentName,HolidayName,ReaderName,DurUse,InvalidateOn,IsEnabled,Embossed,IsEscort,FacilityID,
      FirstName,IsInitLoad,ReIssue,LastName,License,Location,LVAccessPanelID,LVAccessReaderID,LVACCESSDATE,
      PinCode,IsDedicated,Phone,IsTracked,IsResident,CAST(Remarks AS VARCHAR(500)) AS Remarks,IsDoorShunt,SSN,HireDate,UseCount,FirstInControl,Vehicle,
      BA.accessgroup1, BA.accessgroup2,BA.accessgroup3, BA.accessgroup4,BA.accessgroup5, BA.accessgroup6,
      Category1,Category2,Category3,Category4,Category5,Category6,Category7,Category8,
      Category9,Category10,Category11,Category12,Category13,Category14,Category15,Category16, UTCOffset
      , MShunt.ShuntName, MShunt.Active
      FROM ca_vw_BadgePersonnelForData AS BP LEFT OUTER JOIN ca_vw_BadgeAccess AS BA ON BP.BadgeID = BA.Badge AND BP.FacilityID = BA.Facility
      LEFT OUTER JOIN MShunt ON MShunt.ShuntId = BP.DoorShunt
    </qPersonnelBadgeReport>
    <qBadgeCompressedReport partitioned="False">
      SELECT DISTINCT TOP 2000 BadgeID,LastName,FirstName,FacilityID,IsEnabled,LASTEDITED,UTCOffset
      FROM ca_vw_BadgePersonnelForData AS BP LEFT OUTER JOIN ca_vw_BadgeAccess AS BA ON BP.BadgeID = BA.Badge AND BP.FacilityID = BA.Facility
      LEFT OUTER JOIN MShunt ON MShunt.ShuntId = BP.DoorShunt
    </qBadgeCompressedReport>
    <qPersonnelBadgeReportAll partitioned="False">
      SELECT DISTINCT TOP 2000 BP.caObjectID,AccessTime,VALIDATEON,DoorShunt,APBSet,BadgeID,Category1,
      Category2,Category3,Category4,Category5,Category6,Category7,Category8,Category9,
      Category10,Category11,Category12,Category13,Category14,Category15,Category16,
      LASTEDITED,Supervisor,Ext,CompanyID,DepartmentName,HolidayName,ReaderName,DurUse,
      InvalidateOn,IsEnabled,Embossed,IsEscort,FacilityID,FirstName,IsInitLoad,ReIssue,LastName,
      License,Location,LVAccessPanelID,LVAccessReaderID,LVACCESSDATE,PinCode,IsDedicated,
      Phone,IsTracked,IsResident,CAST(Remarks AS VARCHAR(500)) AS Remarks,IsDoorShunt,SSN,HireDate,UseCount,FirstInControl,Vehicle,
      MApbExempt,PermissionName, BA.accessgroup1, BA.accessgroup2,BA.accessgroup3, BA.accessgroup4,BA.accessgroup5, BA.accessgroup6, UTCOffset
      , MShunt.ShuntName, MShunt.Active
      FROM ca_vw_BadgePersonnelForAllData AS BP LEFT OUTER JOIN ca_vw_BadgeAccess AS BA ON BP.BadgeID = BA.Badge AND BP.FacilityID = BA.Facility
      LEFT OUTER JOIN MShunt ON MShunt.ShuntId = BP.DoorShunt
    </qPersonnelBadgeReportAll>
    <qPersonnelColumnList partitioned="False">
      select 'true' ReportField, 'cast(B.Facility as varchar(15)) Facility' ColumnCast, 'Facility' ColumnName , 'Facility' DisplayName,'false' [null], '0' [min], '32768' [max], '1' [type], '50' length,null TableAlias, 'B.Facility' AS WhereClause
      union all
      select 'true' ReportField, 'cast(B.Badge as varchar(40)) Badge' ColumnCast,'Badge' ColumnName , 'Badge' DisplayName,'false' [null], '0' [min], '32768' [max], '1' [type], '50' length,null TableAlias, 'B.Badge' AS WhereClause
      union all
      select 'true' ReportField, 'isnull(P.LastName, '''') + '','' + isnull(P.FrstName, '''') Name' ColumnCast,'Name' ColumnName , 'Name' DisplayName,'false' [null], '0' [min], '99' [max], '2' [type], '50' length,null TableAlias, 'isnull(P.LastName, '''') + '','' + isnull(P.FrstName, '''')' AS WhereClause
      union all
      select 'true' ReportField, 'isnull(P.LastName, '''') + '','' + isnull(P.MiddleName, '''') + '',''+ isnull(P.FrstName, '''') FullName' ColumnCast,'FullName' ColumnName , 'FullName' DisplayName,'false' [null], '0' [min], '99' [max], '2' [type], '50' length,null TableAlias, 'isnull(P.LastName, '''') + '','' + isnull(P.MiddleName, '''') + '','' + isnull(P.FrstName, '''')' AS WhereClause
      union all
      select 'true' ReportField, 'cast(B.Issue as varchar(15)) Issue' ColumnCast,'Issue' ColumnName , 'Issue' DisplayName,'false' [null], '0' [min], '99' [max], '1' [type], '50' length,null TableAlias, NULL AS WhereClause
      union all
      select 'true' ReportField, null ColumnCast,'Track' ColumnName , 'Track' DisplayName,'false' [null], '0' [min], '16' [max], '3' [type], '50' length,null TableAlias, NULL AS WhereClause
      union all
      select 'true' ReportField, null ColumnCast,'Escort' ColumnName , 'Escort' DisplayName,'false' [null], '0' [min], '16' [max], '3' [type], '50' length,null TableAlias, NULL AS WhereClause
      union all
      select 'true' ReportField, 'CONVERT(CHAR(11), B.ActvDate, {1}) AS ActvDate' ColumnCast,'ActvDate' ColumnName , 'Active Date' DisplayName,'false' [null], '0' [min], '16' [max], '4' [type], '50' length,null TableAlias, NULL AS WhereClause
      union all
      select 'true' ReportField, 'CONVERT(CHAR(11), B.ExprDate, {1}) AS ExprDate' ColumnCast,'ExprDate' ColumnName , 'Expire Date' DisplayName,'false' [null], '0' [min], '16' [max], '4' [type], '50' length,null TableAlias, NULL AS WhereClause
      union all
      select 'true' ReportField, 'cast(B.Embossed as varchar(15)) Embossed' ColumnCast,'Embossed' ColumnName , 'Embossed' DisplayName,'false' [null], '0' [min], '32768' [max], '1' [type], '50' length,null TableAlias, NULL AS WhereClause
      union all
      select 'true' ReportField, 'cast(AA.Description as varchar(50)) APBArea' ColumnCast,'APBArea' ColumnName , 'APB Area' DisplayName,'false' [null], '0' [min], '32768' [max], '6' [type], '50' length,null TableAlias, NULL AS WhereClause
      union all
      select 'true' ReportField, 'cast(MH.Description as varchar(50)) HolidayCalendar' ColumnCast,'HolidayCalendar' ColumnName , 'Holiday Calendar' DisplayName,'false' [null], '0' [min], '32768' [max], '12' [type], '50' length,null TableAlias, 'B.HolidayCalendar' AS WhereClause
      union all
      select 'true' ReportField, 'cast(B.AgencyCode as varchar(15)) AgencyCode' ColumnCast,'AgencyCode' ColumnName , 'Agency Code' DisplayName,'false' [null], '0' [min], '32768' [max], '1' [type], '50' length,null TableAlias, NULL AS WhereClause
      union all
      select 'true' ReportField, 'cast(B.SiteNo as varchar(15)) SiteNo' ColumnCast,'SiteNo' ColumnName , 'Site No' DisplayName,'false' [null], '0' [min], '32768' [max], '1' [type], '50' length,null TableAlias, NULL AS WhereClause
      union all
      select 'true' ReportField, 'cast(B.Series as varchar(15)) Series' ColumnCast,'Series' ColumnName , 'Series' DisplayName,'false' [null], '0' [min], '32768' [max], '1' [type], '50' length,null TableAlias, NULL AS WhereClause
      union all
      select 'true' ReportField, 'CONVERT(CHAR(11), B.SDate, {1}) AS HireDate' ColumnCast,'HireDate' ColumnName , 'Hire Date' DisplayName,'false' [null], '0' [min], '16' [max], '4' [type], '50' length,null TableAlias, 'B.SDate' AS WhereClause
      union all
      select 'true' ReportField, 'CONVERT(char(11), DATEADD(MINUTE, {0}, B.LastUpdated), {1}) + SUBSTRING(CONVERT(CHAR(19), DATEADD(MINUTE, {0}, B.LastUpdated), 100), 12, 19) LastUpdated' ColumnCast,'LastUpdated' ColumnName , 'Last Update' DisplayName,'false' [null], '0' [min], '16' [max], '4' [type], '50' length,null TableAlias, 'B.LastUpdated' AS WhereClause
      union all
      select 'true' ReportField, null ColumnCast,'DepartmentName' ColumnName , 'Department Name' DisplayName,'false' [null], '0' [min], '32768' [max], '11' [type], '50' length,null TableAlias, 'P.DeptID' AS WhereClause
      union all
      select 'true' ReportField, null ColumnCast,'Location' ColumnName , 'Location' DisplayName,'false' [null], '0' [min], '32768' [max], '10' [type], '50' length,null TableAlias, 'P.LocationID' AS WhereClause
      union all
      select 'true' ReportField, 'cast(P.Vehicle as varchar(15)) Vehicle' ColumnCast,'Vehicle' ColumnName , 'Vehicle' DisplayName,'false' [null], '0' [min], '32768' [max], '2' [type], '50' length,null TableAlias, NULL AS WhereClause
      union all
      select 'true' ReportField, 'cast(P.License as varchar(50)) License' ColumnCast,'License' ColumnName , 'License' DisplayName,'false' [null], '0' [min], '32768' [max], '2' [type], '50' length,null TableAlias, NULL AS WhereClause
      union all
      select 'true' ReportField, 'case when P.SupervisorID is not null then isnull(S.LastName, '''') + '','' + '' '' + isnull(S.FrstName, '''') end SupervisorName' ColumnCast,'SupervisorName' ColumnName , 'Supervisor Name' DisplayName,'false' [null], '0' [min], '99' [max], '9' [type], '50' length,null TableAlias, 'P.SupervisorID' AS WhereClause
      union all
      select 'true' ReportField, 'P.Supervisor Supervisor' ColumnCast,'Supervisor' ColumnName , 'Supervisor' DisplayName,'false' [null], '0' [min], '16' [max], '3' [type], '50' length,null TableAlias, 'P.Supervisor' AS WhereClause
      union all
      select 'true' ReportField, 'cast(P.SSN as varchar(15)) SSN' ColumnCast,'SSN' ColumnName , 'Soc Sec No' DisplayName,'false' [null], '0' [min], '99' [max], '1' [type], '50' length,null TableAlias, NULL AS WhereClause
      union all
      select 'true' ReportField, null ColumnCast,'CompanyName' ColumnName , 'Company Name' DisplayName,'false' [null], '0' [min], '32768' [max], '7' [type], '50' length,null TableAlias, 'P.CompanyID' AS WhereClause
      union all
      select 'true' ReportField, 'cast(B.OrgCategory as varchar(15)) OrgCategory' ColumnCast, 'OrgCategory' ColumnName , 'Organization Category' DisplayName,'false' [null], '0' [min], '16' [max], '1' [type], '50' length,null TableAlias, NULL AS WhereClause
      union all
      select 'true' ReportField, 'cast(B.OrgId as varchar(15)) OrgId' ColumnCast, 'OrgId' ColumnName , 'Organization ID' DisplayName,'false' [null], '0' [min], '16' [max], '1' [type], '50' length,null TableAlias, NULL AS WhereClause
      union all
      select 'false' ReportField, null ColumnCast, 'B.AccessTime' ColumnName , 'Access Time' DisplayName, 'false' [null], '0' [min], '16' [max], '1' [type], '16' length,null TableAlias, NULL AS WhereClause
      union all
      select 'false' ReportField, null ColumnCast, 'B.APBSet' ColumnName , 'APB Setting' DisplayName, 'false' [null], '0' [min], '16' [max], '1' [type], '16' length,null TableAlias, NULL AS WhereClause
      union all
      select 'false' ReportField, 'P.DateOfBirth DateOfBirth' ColumnCast, 'P.DateOfBirth' ColumnName , 'Date Of Birth' DisplayName, 'false' [null], '0' [min], '16' [max], '4' [type], '50' length,null TableAlias, NULL AS WhereClause
      union all
      select 'false' ReportField, null ColumnCast, 'B.DurUse' ColumnName , 'Duration Use' DisplayName, 'false' [null], '0' [min], '16' [max], '3' [type], '16' length,null TableAlias, NULL AS WhereClause
      union all
      select 'true' ReportField, 'cast(B.Enabled as varchar(10)) Enabled' ColumnCast, 'Enabled' ColumnName , 'Enabled' DisplayName, 'false' [null], '0' [min], '16' [max], '3' [type], '16' length,null TableAlias, 'B.Enabled' AS WhereClause
      union all
      select 'false' ReportField, null ColumnCast, 'P.PersonID' ColumnName , 'PersonID' DisplayName, 'false' [null], '0' [min], '36' [max], '3' [type], '36' length,null TableAlias, NULL AS WhereClause
      union all
      select 'false' ReportField, null ColumnCast, 'P.Phone' ColumnName , 'Phone No' DisplayName, 'false' [null], '0' [min], '16' [max], '1' [type], '16' length,null TableAlias, NULL AS WhereClause
      union all
      select 'false' ReportField, null ColumnCast, 'P.Gender' ColumnName , 'Gender' DisplayName, 'false' [null], '0' [min], '16' [max], '6' [type], '16' length,null TableAlias, NULL AS WhereClause
      union all
      select 'false' ReportField, null ColumnCast, 'B.Initload' ColumnName , 'Initial Download' DisplayName, 'false' [null], '0' [min], '16' [max], '3' [type], '16' length,null TableAlias, NULL AS WhereClause
      union all
      select 'false' ReportField, null ColumnCast, 'P.LastName' ColumnName , 'Last Name' DisplayName, 'false' [null], '0' [min], '30' [max], '2' [type], '16' length,null TableAlias, NULL AS WhereClause
      union all
      select 'false' ReportField, null ColumnCast, 'P.FrstName' ColumnName , 'First Name' DisplayName, 'false' [null], '0' [min], '30' [max], '2' [type], '16' length,null TableAlias, NULL AS WhereClause
      union all
      select 'false' ReportField, null ColumnCast, 'P.MiddleName' ColumnName , 'Middle Name' DisplayName, 'false' [null], '0' [min], '30' [max], '2' [type], '16' length,null TableAlias, NULL AS WhereClause
      union all
      select 'false' ReportField, null ColumnCast, 'B.Resident' ColumnName , 'Panel Resident' DisplayName, 'false' [null], '0' [min], '16' [max], '3' [type], '16' length,null TableAlias, NULL AS WhereClause
      union all
      select 'false' ReportField, null ColumnCast, 'P.ContPhone' ColumnName , 'Phone Extension' DisplayName, 'false' [null], '0' [min], '16' [max], '2' [type], '16' length,null TableAlias, NULL AS WhereClause
      union all
      select 'false' ReportField, null ColumnCast, 'B.ShuntId' ColumnName , 'Shunt' DisplayName, 'false' [null], '0' [min], '16' [max], '1' [type], '16' length,null TableAlias, NULL AS WhereClause
      union all
      select 'false' ReportField, null ColumnCast, 'PA.PointAccess' ColumnName , 'Dedicated Access' DisplayName, 'false' [null], '0' [min], '16' [max], '2' [type], '16' length,null TableAlias, NULL AS WhereClause
      union all
      select 'false' ReportField, null ColumnCast, 'BA.accessgroup1' ColumnName , 'accessgroup1' DisplayName, 'false' [null], '0' [min], '16' [max], '5' [type], '50' length,null TableAlias, NULL AS WhereClause
      union all
      select 'false' ReportField, null ColumnCast, 'BA.AccGrpActivationDate1' ColumnName , 'AccGrpActivationDate1' DisplayName, 'false' [null], '0' [min], '16' [max], '4' [type], '50' length,null TableAlias, NULL AS WhereClause
      union all
      select 'false' ReportField, null ColumnCast, 'BA.AccGrpExpirationDate1' ColumnName , 'AccGrpExpirationDate1' DisplayName, 'false' [null], '0' [min], '16' [max], '4' [type], '50' length,null TableAlias, NULL AS WhereClause
      union all
      select 'false' ReportField, null ColumnCast, 'BA.accessgroup2' ColumnName , 'accessgroup2' DisplayName, 'false' [null], '0' [min], '16' [max], '5' [type], '50' length,null TableAlias, NULL AS WhereClause
      union all
      select 'false' ReportField, null ColumnCast, 'BA.AccGrpActivationDate2' ColumnName , 'AccGrpActivationDate2' DisplayName, 'false' [null], '0' [min], '16' [max], '4' [type], '50' length,null TableAlias, NULL AS WhereClause
      union all
      select 'false' ReportField, null ColumnCast, 'BA.AccGrpExpirationDate2' ColumnName , 'AccGrpExpirationDate2' DisplayName, 'false' [null], '0' [min], '16' [max], '4' [type], '50' length,null TableAlias, NULL AS WhereClause
      union all
      select 'false' ReportField, null ColumnCast, 'BA.accessgroup3' ColumnName , 'accessgroup3' DisplayName, 'false' [null], '0' [min], '16' [max], '5' [type], '50' length,null TableAlias, NULL AS WhereClause
      union all
      select 'false' ReportField, null ColumnCast, 'BA.AccGrpActivationDate3' ColumnName , 'AccGrpActivationDate3' DisplayName, 'false' [null], '0' [min], '16' [max], '4' [type], '50' length,null TableAlias, NULL AS WhereClause
      union all
      select 'false' ReportField, null ColumnCast, 'BA.AccGrpExpirationDate3' ColumnName , 'AccGrpExpirationDate3' DisplayName, 'false' [null], '0' [min], '16' [max], '4' [type], '50' length,null TableAlias, NULL AS WhereClause
      union all
      select 'false' ReportField, null ColumnCast, 'BA.accessgroup4' ColumnName , 'accessgroup4' DisplayName, 'false' [null], '0' [min], '16' [max], '5' [type], '50' length,null TableAlias, NULL AS WhereClause
      union all
      select 'false' ReportField, null ColumnCast, 'BA.AccGrpActivationDate4' ColumnName , 'AccGrpActivationDate4' DisplayName, 'false' [null], '0' [min], '16' [max], '4' [type], '50' length,null TableAlias, NULL AS WhereClause
      union all
      select 'false' ReportField, null ColumnCast, 'BA.AccGrpExpirationDate4' ColumnName , 'AccGrpExpirationDate4' DisplayName, 'false' [null], '0' [min], '16' [max], '4' [type], '50' length,null TableAlias, NULL AS WhereClause
      union all
      select 'false' ReportField, null ColumnCast, 'BA.accessgroup5' ColumnName , 'accessgroup5' DisplayName, 'false' [null], '0' [min], '16' [max], '5' [type], '50' length,null TableAlias, NULL AS WhereClause
      union all
      select 'false' ReportField, null ColumnCast, 'BA.AccGrpActivationDate5' ColumnName , 'AccGrpActivationDate5' DisplayName, 'false' [null], '0' [min], '16' [max], '4' [type], '50' length,null TableAlias, NULL AS WhereClause
      union all
      select 'false' ReportField, null ColumnCast, 'BA.AccGrpExpirationDate5' ColumnName , 'AccGrpExpirationDate5' DisplayName, 'false' [null], '0' [min], '16' [max], '4' [type], '50' length,null TableAlias, NULL AS WhereClause
      union all
      select 'false' ReportField, null ColumnCast, 'BA.accessgroup6' ColumnName , 'accessgroup6' DisplayName, 'false' [null], '0' [min], '16' [max], '5' [type], '50' length,null TableAlias, NULL AS WhereClause
      union all
      select 'false' ReportField, null ColumnCast, 'BA.AccGrpActivationDate6' ColumnName , 'AccGrpActivationDate6' DisplayName, 'false' [null], '0' [min], '16' [max], '4' [type], '50' length,null TableAlias, NULL AS WhereClause
      union all
      select 'false' ReportField, null ColumnCast, 'BA.AccGrpExpirationDate6' ColumnName , 'AccGrpExpirationDate6' DisplayName, 'false' [null], '0' [min], '16' [max], '4' [type], '50' length,null TableAlias, NULL AS WhereClause
      union all
      select 'false' ReportField, null ColumnCast, 'BA.accessgroup7' ColumnName , 'accessgroup7' DisplayName, 'false' [null], '0' [min], '16' [max], '5' [type], '50' length,null TableAlias, NULL AS WhereClause
      union all
      select 'false' ReportField, null ColumnCast, 'BA.AccGrpActivationDate7' ColumnName , 'AccGrpActivationDate7' DisplayName, 'false' [null], '0' [min], '16' [max], '4' [type], '50' length,null TableAlias, NULL AS WhereClause
      union all
      select 'false' ReportField, null ColumnCast, 'BA.AccGrpExpirationDate7' ColumnName , 'AccGrpExpirationDate7' DisplayName, 'false' [null], '0' [min], '16' [max], '4' [type], '50' length,null TableAlias, NULL AS WhereClause
      union all
      select 'false' ReportField, null ColumnCast, 'BA.accessgroup8' ColumnName , 'accessgroup8' DisplayName, 'false' [null], '0' [min], '16' [max], '5' [type], '50' length,null TableAlias, NULL AS WhereClause
      union all
      select 'false' ReportField, null ColumnCast, 'BA.AccGrpActivationDate8' ColumnName , 'AccGrpActivationDate8' DisplayName, 'false' [null], '0' [min], '16' [max], '4' [type], '50' length,null TableAlias, NULL AS WhereClause
      union all
      select 'false' ReportField, null ColumnCast, 'BA.AccGrpExpirationDate8' ColumnName , 'AccGrpExpirationDate8' DisplayName, 'false' [null], '0' [min], '16' [max], '4' [type], '50' length,null TableAlias, NULL AS WhereClause
      union all
      select 'false' ReportField, null ColumnCast, 'BA.accessgroup9' ColumnName , 'accessgroup9' DisplayName, 'false' [null], '0' [min], '16' [max], '5' [type], '50' length,null TableAlias, NULL AS WhereClause
      union all
      select 'false' ReportField, null ColumnCast, 'BA.AccGrpActivationDate9' ColumnName , 'AccGrpActivationDate9' DisplayName, 'false' [null], '0' [min], '16' [max], '4' [type], '50' length,null TableAlias, NULL AS WhereClause
      union all
      select 'false' ReportField, null ColumnCast, 'BA.AccGrpExpirationDate9' ColumnName , 'AccGrpExpirationDate9' DisplayName, 'false' [null], '0' [min], '16' [max], '4' [type], '50' length,null TableAlias, NULL AS WhereClause
      union all
      select 'false' ReportField, null ColumnCast, 'BA.accessgroup10' ColumnName , 'accessgroup10' DisplayName, 'false' [null], '0' [min], '16' [max], '5' [type], '50' length,null TableAlias, NULL AS WhereClause
      union all
      select 'false' ReportField, null ColumnCast, 'BA.AccGrpActivationDate10' ColumnName , 'AccGrpActivationDate10' DisplayName, 'false' [null], '0' [min], '16' [max], '4' [type], '50' length,null TableAlias, NULL AS WhereClause
      union all
      select 'false' ReportField, null ColumnCast, 'BA.AccGrpExpirationDate10' ColumnName , 'AccGrpExpirationDate10' DisplayName, 'false' [null], '0' [min], '16' [max], '4' [type], '50' length,null TableAlias, NULL AS WhereClause
      union all
      select 'false' ReportField, null ColumnCast, 'BA.accessgroup11' ColumnName , 'accessgroup11' DisplayName, 'false' [null], '0' [min], '16' [max], '5' [type], '50' length,null TableAlias, NULL AS WhereClause
      union all
      select 'false' ReportField, null ColumnCast, 'BA.AccGrpActivationDate11' ColumnName , 'AccGrpActivationDate11' DisplayName, 'false' [null], '0' [min], '16' [max], '4' [type], '50' length,null TableAlias, NULL AS WhereClause
      union all
      select 'false' ReportField, null ColumnCast, 'BA.AccGrpExpirationDate11' ColumnName , 'AccGrpExpirationDate11' DisplayName, 'false' [null], '0' [min], '16' [max], '4' [type], '50' length,null TableAlias, NULL AS WhereClause
      union all
      select 'false' ReportField, null ColumnCast, 'BA.accessgroup12' ColumnName , 'accessgroup12' DisplayName, 'false' [null], '0' [min], '16' [max], '5' [type], '50' length,null TableAlias, NULL AS WhereClause
      union all
      select 'false' ReportField, null ColumnCast, 'BA.AccGrpActivationDate12' ColumnName , 'AccGrpActivationDate12' DisplayName, 'false' [null], '0' [min], '16' [max], '4' [type], '50' length,null TableAlias, NULL AS WhereClause
      union all
      select 'false' ReportField, null ColumnCast, 'BA.AccGrpExpirationDate12' ColumnName , 'AccGrpExpirationDate12' DisplayName, 'false' [null], '0' [min], '16' [max], '4' [type], '50' length,null TableAlias, NULL AS WhereClause
      union all
      select 'false' ReportField, null ColumnCast, 'BA.accessgroup13' ColumnName , 'accessgroup13' DisplayName, 'false' [null], '0' [min], '16' [max], '5' [type], '50' length,null TableAlias, NULL AS WhereClause
      union all
      select 'false' ReportField, null ColumnCast, 'BA.AccGrpActivationDate13' ColumnName , 'AccGrpActivationDate13' DisplayName, 'false' [null], '0' [min], '16' [max], '4' [type], '50' length,null TableAlias, NULL AS WhereClause
      union all
      select 'false' ReportField, null ColumnCast, 'BA.AccGrpExpirationDate13' ColumnName , 'AccGrpExpirationDate13' DisplayName, 'false' [null], '0' [min], '16' [max], '4' [type], '50' length,null TableAlias, NULL AS WhereClause
      union all
      select 'false' ReportField, null ColumnCast, 'BA.accessgroup14' ColumnName , 'accessgroup14' DisplayName, 'false' [null], '0' [min], '16' [max], '5' [type], '50' length,null TableAlias, NULL AS WhereClause
      union all
      select 'false' ReportField, null ColumnCast, 'BA.AccGrpActivationDate14' ColumnName , 'AccGrpActivationDate14' DisplayName, 'false' [null], '0' [min], '16' [max], '4' [type], '50' length,null TableAlias, NULL AS WhereClause
      union all
      select 'false' ReportField, null ColumnCast, 'BA.AccGrpExpirationDate14' ColumnName , 'AccGrpExpirationDate14' DisplayName, 'false' [null], '0' [min], '16' [max], '4' [type], '50' length,null TableAlias, NULL AS WhereClause
      union all
      select 'false' ReportField, null ColumnCast, 'BA.accessgroup15' ColumnName , 'accessgroup15' DisplayName, 'false' [null], '0' [min], '16' [max], '5' [type], '50' length,null TableAlias, NULL AS WhereClause
      union all
      select 'false' ReportField, null ColumnCast, 'BA.AccGrpActivationDate15' ColumnName , 'AccGrpActivationDate15' DisplayName, 'false' [null], '0' [min], '16' [max], '4' [type], '50' length,null TableAlias, NULL AS WhereClause
      union all
      select 'false' ReportField, null ColumnCast, 'BA.AccGrpExpirationDate15' ColumnName , 'AccGrpExpirationDate615' DisplayName, 'false' [null], '0' [min], '16' [max], '4' [type], '50' length,null TableAlias, NULL AS WhereClause
      union all
      select 'false' ReportField, null ColumnCast, 'BA.accessgroup16' ColumnName , 'accessgroup16' DisplayName, 'false' [null], '0' [min], '16' [max], '5' [type], '50' length,null TableAlias, NULL AS WhereClause
      union all
      select 'false' ReportField, null ColumnCast, 'BA.AccGrpActivationDate16' ColumnName , 'AccGrpActivationDate16' DisplayName, 'false' [null], '0' [min], '16' [max], '4' [type], '50' length,null TableAlias, NULL AS WhereClause
      union all
      select 'false' ReportField, null ColumnCast, 'BA.AccGrpExpirationDate16' ColumnName , 'AccGrpExpirationDate16' DisplayName, 'false' [null], '0' [min], '16' [max], '4' [type], '50' length,null TableAlias, NULL AS WhereClause
      union all
      select 'true' ReportField, 'cast(B.PersPIVId as varchar(40)) PersPIVId' ColumnCast,'PersPIVId' ColumnName , 'Person ID' DisplayName,'false' [null], '0' [min], '32768' [max], '1' [type], '50' length,null TableAlias, 'B.Badge' AS WhereClause
      union all
      select 'true' ReportField, 'NULL AS [AG_999]' ColumnCast,'AG_999' ColumnName , 'Access Groups' DisplayName,'' [null], '' [min], '' [max], '999' [type], '' length,null TableAlias, '' AS WhereClause
    </qPersonnelColumnList>
    <qReaderAccessList partitioned="False">
      SELECT BadgeID,LastName,FirstName,AccessGroupID,AccessGroupName,ReaderID,PanelID,TimeZoneName FROM ca_vw_GetReaderAccessListData 1Sep
      WHERE (1=1) 1Sep
      AND PanelID=@PanelID 1Sep
      AND ReaderID=@ReaderID
    </qReaderAccessList>
    <qReaderForTimeAndAttendance partitioned="False">
      SELECT R.PnlRef, R.RdrNo, R.ReaderName Description, R.APBType, R.TAAPBType FROM dbo.Reader R WHERE  R.caObjectID IN (SELECT DP.caObjectID FROM OperatorPartitions OP JOIN Devicepartitions DP ON OP.PartitionID = DP.PartitionID WHERE OperatorID = @OperatorID)
    </qReaderForTimeAndAttendance>
    <qReaderReport partitioned="False">
      SELECT caObjectID,PanelID,PanelName,ReaderID,ReaderName,Enabled,RptByPass,BypUnlock,OpenWait,
      SuppOTL,EscortRdr,TwoManRuleCode,DoorShunting,AlarmShuntReader,TZOvr,APBOver,APBViolateOverride,Keypad,
      NoDuress,CardOnlyTz,CardPINTz,CodeOnlyTz,FreeAccessTz,InTrudDelay,OTLDelay,BadgeUseRegister,StrikeTime,APBTypeTATypeCode,TAAPBType,
      LockCTRL,DoorSensor,StrikeRelay,ByPassInput,ShuntRelay,DurationUseTime,TypeCode,LASTEDITED,DegrModeTz,
      ManualControlPrivilegeCode,APBEntryToArea,APBExitFromArea,MaxShuntTime,NAPCOAreas,CategoryFilterCode,
      CategoryCountControlCode,NapcoAlarmPanelAreaOne,NapcoAlarmPanelAreaTwo,NapcoAlarmPanelAreaThree,NapcoAlarmPanelAreaFour,
      NapcoAlarmPanelAreaFive,NapcoAlarmPanelAreaSix,NapcoAlarmPanelAreaSeven,NapcoAlarmPanelAreaEight,NoRptValid,MultiBadgeReadTimeOut,
      CASE WHEN NAPCOAreas &amp; 1 = 1 THEN 1 ELSE 0 END AS NapcoAlarmPanelArea1State,
      CASE WHEN NAPCOAreas &amp; 2 = 2 THEN 1 ELSE 0 END AS NapcoAlarmPanelArea2State,
      CASE WHEN NAPCOAreas &amp; 4 = 4 THEN 1 ELSE 0 END AS NapcoAlarmPanelArea3State,
      CASE WHEN NAPCOAreas &amp; 8 = 8 THEN 1 ELSE 0 END AS NapcoAlarmPanelArea4State,
      CASE WHEN NAPCOAreas &amp; 16 = 16 THEN 1 ELSE 0 END AS NapcoAlarmPanelArea5State,
      CASE WHEN NAPCOAreas &amp; 32 = 32 THEN 1 ELSE 0 END AS NapcoAlarmPanelArea6State,
      CASE WHEN NAPCOAreas &amp; 64 = 64 THEN 1 ELSE 0 END AS NapcoAlarmPanelArea7State,
      CASE WHEN NAPCOAreas &amp; 128 = 128 THEN 1 ELSE 0 END AS NapcoAlarmPanelArea8State,
      IsElevatorReport,Category1 CategoryOne,Category2 CategoryTwo,Category3 CategoryThree,Category4 CategoryFour,Category5 CategoryFive,
      Category6 CategorySix,Category7 CategorySeven,Category8 CategoryEight,Category9 CategoryNine, Category10 CategoryTen,
      Category11 CategoryEleven, Category12 CategoryTwelve, Category13 CategoryThirteen, Category14 CategoryFourteen,
      Category15 CategoryFifteen,Category16 CategorySixteen,UTCOffset AS UTCOffset, EnableSchedule FROM dbo.ca_vw_HardwareReader WHERE (1=1) 1Sep
      AND PanelID BETWEEN @PanelIDFrom AND @PanelIDTo 1Sep
      AND PanelID = @PanelID 1Sep
      AND IsElevatorReport = @IsElevatorReport 1Sep
      ORDER BY PanelID, ReaderID
    </qReaderReport>
    <qRelayReport partitioned="False">
      SELECT caObjectID,PanelID,PanelName,RelayNo,RelayName,Enabled,ReportActivity,Dialup,NormEnergized,
      OnTime,TrackSched,EventPriority,LASTEDITED,ManualControlPrivilegeCode, UTCOffset AS UTCOffset, AlertRequiresResponse FROM dbo.ca_vw_HardwareRelay WHERE (1=1) 1Sep
      AND PanelID BETWEEN @PanelIDFrom AND @PanelIDTo 1Sep
      AND PanelID = @PanelID
    </qRelayReport>
    <qSystemSettings partitioned="False">
      select AGCountPerBadge from SystemSettings
    </qSystemSettings>
    <qSystemSettingsPartOneGetAll partitioned="False">
      SELECT caObjectID,SystemID,WorkStationName,BadgeSize,VehicleTag,HidePin,HideSSN,UseHostTz,
      ShowIssue,APBResetTime,EnableMultiAPBArea,EnableCategoryCounters,ShowBadgeReIssueInAlertTransaction,
      SetToMultiAPBAreaID,SetToMultiAPBArea,AlertSoundEnabled,PlayIntervalOne,PlayIntervalTwo,
      PlayIntervalThree,PlayIntervalFour,SoundFileOne,SoundFileTwo,SoundFileThree,SoundFileFour,
      VideoBadgingPackage,VideoBadgingPrinter,ReportPrinterName,ModemsLocalDialInPhoneOne,
      ModemsLocalDialInPhoneTwo,ResponseRequiredScheduleID,ResponseRequiredSchedule,
      ArchiveConfigServer,ArchiveConfigDatabase,ArchiveEventsServer,ArchiveEventsDatabase,
      MiscEnableActivityLinking,MiscEnableHolidayCalendars,NapcoPanelServer,ScriptingServer, LASTCHANGED,AccGrpBadges,OperatorID, UTCOffset
      FROM dbo.ca_vw_SystemSettingsPartOneGetAll 
      LEFT JOIN ArchiveSettings ON 1=1
      LEFT OUTER JOIN (SELECT UseAlertSound	AS AlertSoundEnabled
      ,AlertSoundInterval1	AS PlayIntervalOne
      ,AlertSoundInterval2	AS PlayIntervalTwo
      ,AlertSoundInterval3	AS PlayIntervalThree
      ,AlertSoundInterval4	AS PlayIntervalFour
      ,AlertSoundName1	AS SoundFileOne
      ,AlertSoundName2	AS SoundFileTwo
      ,AlertSoundName3	AS SoundFileThree
      ,AlertSoundName4	AS SoundFileFour
      ,CASE WHEN UseBadging = 0 THEN 'Not Used'
      WHEN Badgingoption = 1  THEN 'Photos Only'
      WHEN Badgingoption = 2 THEN 'Badging 4K' END
      AS VideoBadgingPackage
      ,CASE UseBadging
      WHEN 'False' THEN 'Not Used'
      WHEN 'True' THEN BadgingPrn	END
      AS VideoBadgingPrinter
      ,CASE UsePrinting
      WHEN 'False' THEN 'Not Used'
      WHEN 'True' THEN EventPrn	END
      AS ReportPrinterName
      ,TapiPhone1		AS ModemsLocalDialInPhoneOne
      ,TapiPhone2		AS ModemsLocalDialInPhoneTwo
      from  WorkStationSettings where WorkStationName = @WorkStationName
      ) WS ON 1 =1
      WHERE 1=1 AND SystemID = @SystemID and operatorid = @operatorid ORDER BY systemID ASC
    </qSystemSettingsPartOneGetAll>
    <qSystemSettingsPartTwoGetAll partitioned="False">
      SELECT Category, GroupOne, GroupTwo, GroupThree, GroupFour, GroupFive FROM dbo.ca_vw_SystemSettingsPartTwoGetAll
    </qSystemSettingsPartTwoGetAll>
    <qSystemSettingsThreatLevel partitioned="False">
      SELECT [Description],[Cat1],[Cat2],[Cat3],[Cat4],[Cat5],[Cat6],[Cat7],[Cat8],[Cat9],[Cat10],[Cat11]
      ,[Cat12],[Cat13],[Cat14],[Cat15],[Cat16],[AreaName],[TypeControl] FROM [ca_vw_SystemSettingsThreatLevel]
      where caObjectID in (
      SELECT devicepartitions.caObjectID FROM OperatorPartitions inner join  devicepartitions on devicepartitions.PartitionId = OperatorPartitions.Partitionid where OperatorPartitions.OperatorID = @OperatorID)
    </qSystemSettingsThreatLevel>
    <qTemplate partitioned="False">
      SELECT Name,RptType,Period,Previous,Filter,DevList,Data1,Data2,Data3,Data4,
      Data5,Data6,Data7,Data8,Data9,Data10,Data11,Data12,Data13,
      Data14,Data15,Data16,Data17,Data18,Data19,Data20,Data21,Data22,
      Data23,Data24,Data25,Data26,Data27,Data28,Data29,Data30,Data31,
      Data32,Data33,Data34,Data35,Data36,Data37,Data38,Data39,Data40,Data41,Data42,Data43,Data44 FROM dbo.Template T WHERE T.RptType IN ( 1Sep
      ) 1Sep
    </qTemplate>
    <qTimeAndAttendanceReport partitioned="False">
      ORDER BY FacNo, Badge, EDate 1Sep
      AND E.EDate BETWEEN @dateFrom AND @dateTo 1Sep
      FullName  1Sep
      AND P.LastName = @LastName AND P.FrstName = @FrstName 1Sep
      AND P. 1Sep
      AND ( 1Sep
      (PnlNo =  1Sep
      AND DeviceNo =  1Sep
      ) 1Sep
      OR 1Sep
      SELECT B.caObjectID, E.Name AS ReaderName, E.Name, E.FacNo, P.LastName, E.PnlNo, E.DeviceNo, E.EDate, E.Status, P.frstName, B.Badge, B.UTCOffSet FROM  1Sep
      EVENT_DB_NAME.Event E INNER JOIN  CONFIG_DB_NAME.Badge B ON E.Badge = B.Badge AND E.FacNo = B.Facility INNER JOIN CONFIG_DB_NAME.Person P ON P.PersonID = B.PersonID  1Sep
      WHERE E.Cat IN(0,8) 1Sep
      AND ( ( E.Status BETWEEN 5 AND 20 ) or ( E.Status BETWEEN 40 AND 43 ) ) 1Sep
      AND ( E.Status BETWEEN 5 AND 12 ) 1Sep
      AND B.PersonID IN(SELECT UF.PersonID FROM CONFIG_DB_NAME.UserFields UF WHERE UF.UserFieldID=@UserFieldID AND B.PersonID = UF.PersonID) 1Sep
    </qTimeAndAttendanceReport>
    <qTimeSchedulesReport partitioned="False">
      SELECT V.TzNum, V.TimeSchedule, V.DayFrom, V.DayTo, V.TimeFrom, V.TimeTo, LastEdited, UTCOffset FROM dbo.ca_vw_TimeScheduleForData V WHERE 1=1 ORDER BY TzNum
    </qTimeSchedulesReport>
    <qUserDefined partitioned="False">
      select UserFieldID,UserFieldName,UserFieldType,UserFieldLength from UserFieldDef
    </qUserDefined>
    <qUserFieldBadgeReport partitioned="False">
      SELECT DISTINCT TOP 2000 caObjectID,BadgeID,FacilityID,LastName,FirstName,IsEnabled,DoorShunt,
      DepartmentName,Location,IsTracked,IsDedicated,IsEscort,IsResident,IsDoorShunt,
      License,HireDate,ValidateOn,InValidateOn,LASTEDITED,SSN,LVACCESSDATE,
      BA.accessgroup1, BA.accessgroup2,BA.accessgroup3, BA.accessgroup4,BA.accessgroup5, BA.accessgroup6,
      FieldName AS FieldID,FieldValue AS FieldName
      FROM ca_vw_BPUserFieldForData AS BP LEFT OUTER JOIN ca_vw_BadgeAccess AS BA ON BP.BadgeID = BA.Badge AND BP.FacilityID = BA.Facility
    </qUserFieldBadgeReport>
    <qUserFieldDef partitioned="False">
      SELECT UserFieldID, UserFieldName,UserFieldType,UserFieldLength FROM UserFieldDef ORDER BY UserFieldName
    </qUserFieldDef>
    <ReaderAPBDelete partitioned="False">DELETE FROM Reader WHERE RdrNo = @RdrNo AND PnlRef = @PnlRef</ReaderAPBDelete>
    <ReaderAPBInsert partitioned="False">INSERT INTO Reader (APBEntry, APBExit, RdrNo, PnlRef) VALUES (@APBEntry, @APBExit, @RdrNo, @PnlRef)</ReaderAPBInsert>
    <ReaderAPBSelect partitioned="False">SELECT APBEntry ,APBExit, RdrNo, PnlRef FROM Reader</ReaderAPBSelect>
    <ReaderAPBUpdate partitioned="False">UPDATE Reader SET APBEntry = @APBEntry, APBExit = @APBExit WHERE RdrNo = @RdrNo AND PnlRef = @PnlRef</ReaderAPBUpdate>
    <ReaderDVRSelect partitioned="False">SELECT DvrServerID,DvrCameraID ,VideoStartTime ,VideoEndTime FROM Reader WHERE PnlRef = @PnlRef and RdrNo = @RdrNo</ReaderDVRSelect>
    <NapcoZoneDVRSelect partitioned="False">SELECT DvrServerID,DvrCameraID ,VideoStartTime ,VideoEndTime FROM napcoPanelZones select WHERE AlarmPanelID = @PnlRef and ZoneNumber = @ZoneNo</NapcoZoneDVRSelect>
    <readerenabledlookup partitioned="False" notificationtable="Reader">
      select r.ManualPriv, r.pnlref, r.ReaderName as description, r.RdrNo
      , p.paneltype from reader r
      inner join panel p on p.pnlno = r.pnlref where r.enabled = 1
    </readerenabledlookup>
    <ReaderExists partitioned="False">select PnlRef from Reader where PnlRef=@PnlRef and RdrNo=@RdrNo</ReaderExists>
    <FloorExists partitioned="False">
      IF(@addingNew = 1)
      BEGIN
      select [FloorNumber] from [ElevFloors] where [FloorNumber]=@FloorNumber AND [ElevFacilityId]=@ElevFacilityId
      END
      ELSE
      BEGIN
      select [FloorNumber] from [ElevFloors] where [FloorNumber]=@FloorNumber AND [ElevFacilityId]=@ElevFacilityId AND [caObjectId]!=@caObjectId
      END
    </FloorExists>
    <ElevServerExists partitioned="False">select [ServerName] from [ElevServers] where [ServerType]=@ServerType and [ServerIP]=@ServerIP and [WorkstationName]=@WorkstationName</ElevServerExists>
    <ReaderCount partitioned="False">select count(*) as cnt from Reader</ReaderCount>
    <readergrid partitioned="True">
      select
      PnlRef
      ,RdrNo
      ,Convert(Char(6),PnlRef) + '- ' + Convert(Char(3),RdrNo) as Reader
      ,ReaderName as 'Device Name'
      ,Enabled
      ,ExtShunt as 'Ext Shunt'
      ,Escort
      ,RptByp as 'Rpt Bypass'
      ,BypUnlock as 'Byp Unlocks'
      ,OpnWait as 'Rpt After Open'
      ,NoOTL as 'Suppress OTL'
      ,Type
      ,LastUpdated as 'Last Edit'
      ,caObjectID
      from reader
      order by pnlref,rdrno
    </readergrid>
    <ApiReadergrid partitioned="True">
      select
      PnlRef
      ,RdrNo
      ,Convert(Char(6),PnlRef) + '- ' + Convert(Char(3),RdrNo) as Reader
      ,ReaderName as 'Device Name'
      ,Enabled
      ,LastUpdated as 'Last Edit'
      from reader
      order by pnlref,rdrno
    </ApiReadergrid>
    <readerlookup partitioned="True" notificationtable="Reader">select RdrNo as ValueMember, ReaderName as DisplayMember,caobjectid from Reader where pnlref = @pnlref</readerlookup>
    <readerlookupinput partitioned="True" notificationtable="Input">
      select '0' as ValueMember, 'None' as DisplayMember, '00000000-0000-0000-0000-000000000000' as caobjectid
      union
      select RdrNo as ValueMember, ReaderName as DisplayMember,caobjectid from Reader where pnlref = @pnlref
      order by DisplayMember, ValueMember
    </readerlookupinput>
    <readerlookupjoin partitioned="False">
      select
      r.PnlRef
      ,p.PanelName as PnlRefText
      ,r.TAType
      , CASE r.TAType WHEN (0) THEN 'None'  ELSE v.readername END as TATypeText
      ,r.Ctz
      ,t1.Description as CtzText
      ,r.Fatz
      ,t2.Description as FatzText
      ,r.DegrSchedule
      ,t3.Description as DegrScheduleText
      ,r.Cctz
      ,t4.Description as CctzText
      ,r.Cytz
      ,t5.Description as CytzText
      ,r.OTLSchedule
      ,t6.Description as OTLScheduleText
      ,r.CatSchedule
      ,t7.Description as CatScheduleText
      ,r.RecordingSchedule
      ,t8.Description as RecordingScheduleText
      ,r.LockCtl
      , CASE r.LockCtl
      WHEN (0) THEN 'On Open'
      WHEN (1) THEN 'On Close'
      WHEN (2) THEN 'On Timeout'
      END AS LockCtlText
      ,r.TAAPBType
      , CASE r.TAAPBType
      WHEN (0) THEN 'None'
      WHEN (16) THEN 'In'
      WHEN (32) THEN 'Out'
      WHEN (48) THEN 'In/Out'
      WHEN (80) THEN 'In with FMI'
      WHEN (96) THEN 'Out with FMI'
      END AS TAAPBTypeText
      ,r.ManRule
      , CASE r.ManRule
      WHEN (0) THEN 'None'
      WHEN (1) THEN 'In'
      WHEN (2) THEN 'Out'
      WHEN (3) THEN 'Out w/Override'
      WHEN (4) THEN 'Always'
      END AS ManRuleText
      ,r.APBType
      , CASE r.APBType
      WHEN (0) THEN 'IN'
      WHEN (1) THEN 'OUT'
      WHEN (2) THEN 'NEUTRAL'
      END AS APBTypeText
      ,r.APBEntry
      , CASE r.APBEntry WHEN (255) THEN 'IN - Anti-Passback in reader'  ELSE a1.Description END AS APBEntryText
      ,r.APBExit
      , CASE r.APBExit WHEN (255) THEN 'IN - Anti-Passback in reader'  ELSE a2.Description END AS APBExitText
      ,r.ManualPriv
      , CASE r.ManualPriv
      WHEN (0) THEN 'All'
      WHEN (1) THEN 'Priv 1'
      WHEN (2) THEN 'Priv 2'
      WHEN (3) THEN 'Priv 3'
      WHEN (4) THEN 'Priv 4'
      WHEN (5) THEN 'Priv 5'
      WHEN (6) THEN 'Priv 6'
      WHEN (7) THEN 'Priv 7'
      WHEN (8) THEN 'Priv 8'
      END AS ManualPrivText
      ,r.DvrServerID
      ,f.ServerName        as DvrServerIDText
      ,r.DvrCameraID
      ,c.CameraName        as DvrCameraIDText
      ,r.VideoStartTime
      ,r.VideoEndTime
      ,r.VideoPriorityFrom
      ,r.VideoPriorityTo
      ,r.EnableRecording
      ,r.NoofSecsToRecord
      --      ,TypeofRecording
      --      ,RateofRecording
      ,CASE r.PTZPresetNo
      WHEN (0) THEN 'None'
      ELSE CONVERT(VARCHAR, r.PTZPresetNo)
      END as PTZPresetNoText
      ,r.PTZPresetNo
      from reader r
      left outer join Panel p on r.PnlRef = p.PnlNo
      left outer join reader v on r.TAType = v.RdrNo and v.pnlref = @PnlRef
      left outer join MTimezon t1 on r.Ctz = t1.TzNum
      left outer join MTimezon t2 on r.Fatz = t2.TzNum
      left outer join MTimezon t3 on r.DegrSchedule = t3.TzNum
      left outer join MTimezon t4 on r.Cctz = t4.TzNum
      left outer join MTimezon t5 on r.Cytz = t5.TzNum
      left outer join MTimezon t6 on r.OTLSchedule = t6.TzNum
      left outer join MTimezon t7 on r.CatSchedule = t7.TzNum
      left outer join MTimezon t8 on r.RecordingSchedule=t8.TzNum
      left outer join APBAreas a1 on r.APBEntry = a1.AreaNo
      left outer join APBAreas a2 on r.APBExit = a2.AreaNo
      left outer join DvrConfig f on r.DvrServerID =  f.DvrID
      left outer join DvrCamera c on r.DvrCameraID =  c.DvrCameraID AND r.DvrServerID =  c.[DvrServerID]
      where r.PnlRef = @PnlRef
      and r.RdrNo = @RdrNo
    </readerlookupjoin>
    <readernoresults partitioned="False" notificationtable="Reader">select 1 from reader where 1=0</readernoresults>
    <readerprivenabledlookup partitioned="False">
      select r.ManualPriv, r.pnlref, r.ReaderName as description, r.RdrNo as deviceno , p.paneltype
      from reader r
      inner join panel p on p.pnlno = r.pnlref
      where r.enabled = 1
      and ( (r.ManualPriv = 0)
      or   (r.ManualPriv in (
      select ManualPrivilege from manualprivilege where OperatorID = @OperatorID )))
      and r.caObjectID not in (select r.caObjectID from Reader r inner join panel p on r.PnlRef = p.PnlNo where p.AperioType > 0 and  r.AperioAddr > 0)
      and r.caObjectID in (
      SELECT devicepartitions.caObjectID FROM OperatorPartitions inner join  devicepartitions on devicepartitions.PartitionId = OperatorPartitions.Partitionid where OperatorPartitions.OperatorID = @OperatorID)
      and not (p.paneltype = 102 and r.RdrNo = 2)
    </readerprivenabledlookup>
    <readerscprivenabledlookup partitioned="False">
      select 0 as pnlref, 0 as ValueMember, 'None' as DisplayMember
      union
      select r.pnlref, r.RdrNo as ValueMember , r.ReaderName as DisplayMember
      from reader r
      inner join panel p on p.pnlno = r.pnlref
      where r.enabled = 1
      and r.caObjectID in (
      SELECT devicepartitions.caObjectID FROM OperatorPartitions inner join  devicepartitions on devicepartitions.PartitionId = OperatorPartitions.Partitionid where OperatorPartitions.OperatorID = @OperatorID)
    </readerscprivenabledlookup>
    <readerprivenabledPartitionlookup partitioned="False">
      select r.ManualPriv, r.pnlref, r.ReaderName as description, r.RdrNo as deviceno , p.paneltype
      from reader r
      inner join panel p on p.pnlno = r.pnlref
      where r.enabled = 1
      and ( (r.ManualPriv = 0)
      or   (r.ManualPriv in (
      select ManualPrivilege from manualprivilege where OperatorID = @OperatorID )))
      and r.caObjectID in (SELECT caObjectID FROM devicepartitions  where PartitionID = @PartitionID)
      and not (p.paneltype = 102 and r.RdrNo = 2)
    </readerprivenabledPartitionlookup>
    <getabolyreadersbyreaderno>
      select 1 from Reader r
      join panel p on r.PnlRef = @PnlRef
      where p.AperioType > 0 and r.AperioAddr > 0
      and r.RdrNo = @RdrNo
    </getabolyreadersbyreaderno>
    <readerscprivenabledPartitionlookup partitioned="False">
      select 0 as pnlref, 0 as ValueMember, 'None' as DisplayMember
      union
      select r.pnlref, r.RdrNo as ValueMember , r.ReaderName as DisplayMember
      from reader r
      inner join panel p on p.pnlno = r.pnlref
      where r.enabled = 1
      and r.caObjectID in (SELECT caObjectID FROM devicepartitions  where PartitionID = @PartitionID)
    </readerscprivenabledPartitionlookup>
    
    <relayenabledlookup partitioned="False" notificationtable="Relay">
      select r.ManualPriv,r.pnlref,r.relayname as description,r.relno
      ,p.paneltype from relay r
      inner join panel p on p.pnlno = r.pnlref where r.enabled = 1
    </relayenabledlookup>
    <relaygrid partitioned="True">
      select
      PnlRef
      ,RelNo
      ,Convert(Char(6),PnlRef) + '- ' + Convert(Char(3),RelNo) as 'Panel/Relay'
      ,relayname as 'Device Name'
      ,Enabled as Enable
      ,XactRpt as 'Report Activity'
      ,Dialup as 'Dial On Change'
      ,NormOn as 'Normally Energized'
      ,RelTime as 'Energize Time'
      ,TrackTz as 'Track Schedule'
      ,Priority as 'Alert Priority'
      ,LastUpdated as 'Last Edit'
      ,caObjectID
      from relay
      order by pnlref,relno
    </relaygrid>
    <ApiRelaygrid partitioned="True">
      select
      PnlRef
      ,RelNo
      ,Convert(Char(6),PnlRef) + '- ' + Convert(Char(3),RelNo) as 'Panel/Relay'
      ,relayname as 'Device Name'
      ,Enabled as Enable
      ,XactRpt as 'Report Activity'
      ,NormOn as 'Normally Energized'
      ,RelTime as 'Energize Time'
      ,TrackTz as 'Track Schedule'
      ,Priority as 'Alert Priority'
      ,LastUpdated as 'Last Edit'
      from relay
      order by pnlref,relno
    </ApiRelaygrid>
    <relaylookup partitioned="True" notificationtable="Relay">
      select 0 as ValueMember, 'None' as DisplayMember, 0 as PnlRef
      union
      select RelNo as ValueMember, Relayname as DisplayMember,PnlRef from Relay
    </relaylookup>
    <relaylookupbypanel partitioned="True" notificationtable="Relay">
      select 0 as ValueMember, 'None' as DisplayMember, 0 as PnlRef,'00000000-0000-0000-0000-000000000000' as caObjectID
      union
      select RelNo as ValueMember, Relayname as DisplayMember,PnlRef,caObjectID from Relay
      where pnlref = @pnlref
    </relaylookupbypanel>
    <relaylookupjoin partitioned="False">
      select
      r.PnlRef
      ,p.PanelName as PnlRefText
      ,r.TrackTz
      ,t.Description as TrackTzText
      ,r.ManualPriv
      , CASE r.ManualPriv
      WHEN (0) THEN 'All'
      WHEN (1) THEN 'Priv 1'
      WHEN (2) THEN 'Priv 2'
      WHEN (3) THEN 'Priv 3'
      WHEN (4) THEN 'Priv 4'
      WHEN (5) THEN 'Priv 5'
      WHEN (6) THEN 'Priv 6'
      WHEN (7) THEN 'Priv 7'
      WHEN (8) THEN 'Priv 8'
      END AS ManualPrivText
      from relay r
      left outer join Panel p on r.PnlRef = p.PnlNo
      left outer join MTimezon t on r.TrackTz = t.TzNum
      Where r.PnlRef = @PnlRef
      and r.RelNo = @RelNo
    </relaylookupjoin>
    <relayprivenabledlookup partitioned="False">
      select r.ManualPriv,r.pnlref,r.relayname as description,r.relno as deviceno ,p.paneltype
      from relay r
      inner join panel p on p.pnlno = r.pnlref
      where r.enabled = 1
      and ( (r.ManualPriv = 0)
      or   (r.ManualPriv in (
      select ManualPrivilege from manualprivilege where OperatorID = @OperatorID )))
      and r.caObjectID in (
      SELECT devicepartitions.caObjectID FROM OperatorPartitions inner join  devicepartitions on devicepartitions.PartitionId = OperatorPartitions.Partitionid where OperatorPartitions.OperatorID = @OperatorID)
      order by r.pnlref, r.relno
    </relayprivenabledlookup>

    <relayscprivenabledlookup partitioned="False">
      select 0 as pnlref, 0 as ValueMember, 'None' as DisplayMember
      union
      select r.pnlref,r.relno as ValueMember,r.relayname as DisplayMember
      from relay r
      inner join panel p on p.pnlno = r.pnlref
      where r.enabled = 1
      and r.caObjectID in (
      SELECT devicepartitions.caObjectID FROM OperatorPartitions inner join  devicepartitions on devicepartitions.PartitionId = OperatorPartitions.Partitionid where OperatorPartitions.OperatorID = @OperatorID)
    </relayscprivenabledlookup>
    
    <relayprivPartitionenabledlookup partitioned="False">
      select r.ManualPriv,r.pnlref,r.relayname as description,r.relno as deviceno ,p.paneltype
      from relay r
      inner join panel p on p.pnlno = r.pnlref
      where r.enabled = 1
      and ( (r.ManualPriv = 0)
      or   (r.ManualPriv in (
      select ManualPrivilege from manualprivilege where OperatorID = @OperatorID )))
      and r.caObjectID in (SELECT caObjectID FROM devicepartitions  where PartitionID = @PartitionID)
    </relayprivPartitionenabledlookup>

    <relayscprivPartitionenabledlookup partitioned="False">
      select 0 as pnlref, 0 as ValueMember, 'None' as DisplayMember
      union
      select r.pnlref,r.relno as ValueMember ,r.relayname as DisplayMember
      from relay r
      inner join panel p on p.pnlno = r.pnlref
      where r.enabled = 1
      and r.caObjectID in (SELECT caObjectID FROM devicepartitions  where PartitionID = @PartitionID)
    </relayscprivPartitionenabledlookup>
    
    <removefromdatabaselist partitioned="False">DELETE from DatabaseList WHERE ServerName=@ServerName AND DatabaseName=@DatabaseName AND DatabaseType=@dbType</removefromdatabaselist>
    <replacelockrecord partitioned="False">UPDATE Panel Set LockId=@LockId2, PanelType=@PanelType,LockType=@LockType,LockExpAddress=@LockExpAddress,LockAssigned=@LockAssigned, LastUpdated=@LastUpdated, LastOperator=@LastOperator WHERE LockId=@LockId1</replacelockrecord>
    <ResetLockChanged partitioned="False">
      IF EXISTS (SELECT 1 FROM Panel WITH (NOLOCK) WHERE LockChanged = 1 AND PnlNo = @PnlNo)
      BEGIN
      update panel set LockChanged=0 where pnlNo=@PnlNo
      END
    </ResetLockChanged>
    <resetSystemAG partitioned="False">DELETE FROM BadgeAccess WHERE AGSeq&gt;@AGNo</resetSystemAG>
    <rolelookup partitioned="True">
      select  RoleId as ValueMember, RoleName as DisplayMember
      from roles
    </rolelookup>
    <GetRolePlugIn partitioned="False">
      SELECT Screens.ScreenID, Screens.ScreenName, Screens.PluginAssembly
      FROM  guiPlugins INNER JOIN RolePlugins ON guiPlugins.pluginId = RolePlugins.pluginId
      INNER JOIN Roles ON RolePlugins.RoleID = Roles.RoleID
      INNER JOIN Screens ON guiPlugins.pluginAssembly = Screens.PluginAssembly
      WHERE RolePlugins.RoleID = @RoleID
    </GetRolePlugIn>
    <schedeventlookupjoin partitioned="False">
      select
      s.schedule
      ,t.Description as scheduleText
      from schedevent s
      left outer join MTimezon t on s.Schedule = t.TzNum
      Where s.schId = @schId

    </schedeventlookupjoin>
    <scheduledchangegrid partitioned="True">
      select
      Description as "Description Text"
      ,CASE Device
      WHEN (0) THEN 'Doors'
      WHEN (1) THEN 'Inputs'
      WHEN (2) THEN 'Relays'
      WHEN (3) THEN 'Links'
      ELSE 'None' END as "Device Name"
      ,StartDate as "Start Date"
      ,EndDate as "End Date"
      ,IsActive as Active
      ,caObjectID
      from schedevent
    </scheduledchangegrid>
    <APIscheduledchangegrid partitioned="True">
      select
      Description as "Description Text"
      ,CASE Device
      WHEN (0) THEN 'Doors'
      WHEN (1) THEN 'Inputs'
      WHEN (2) THEN 'Relays'
      WHEN (3) THEN 'Links'
      ELSE 'None' END as "Device Name"
      ,StartDate as "Start Date"
      ,EndDate as "End Date"
      ,IsActive as Active
      ,caObjectID
      from schedevent
    </APIscheduledchangegrid>
    <ScheduleLookup partitioned="False" notificationtable="AlarmLink_Schedule">Select ScheduleID as ValueMember, ScheduleName as DisplayMember from AlarmLink_Schedule</ScheduleLookup>
    <schedulesgrid partitioned="True" notificationtable="MTimezon">
      select TzNum as 'No:', Description as 'Description Text'
      ,LastUpdated as 'Last Edit'
      ,caObjectID from mtimezon
      where TzNum &gt; 0
    </schedulesgrid>
    <ScheduleTypeLookup partitioned="False" notificationtable="AlarmLink_ScheduleType">Select ID as ValueMember, TypeName as DisplayMember from AlarmLink_scheduleType </ScheduleTypeLookup>
    <scriptEditorGrid partitioned="True" notificationtable="alarmLink_scripts">
      Select ScriptID,ScriptName as [Script Name], ScriptText, LastUpdated, generateEvent, executeEventPriority, ScriptLanguage, caObjectID
      ,LastUpdated as 'Last Edit'
      From alarmLink_Scripts
    </scriptEditorGrid>
    <ScriptingServersList partitioned="False" notificationtable="scriptingServers">select workstationID, pollingUNCName,LastWorkStation,LastOperator,caObjectID from ScriptingServers</ScriptingServersList>
    <ScriptLink partitioned="False" notificationtable="alarmLink_ScriptLinks">select cat,pnlNo, DeviceNo, status, workstationID, facility, badge, scriptID, scriptLinkName, EventClassID, LastUpdated, scriptLinkEnabled, caObjectID from AlarmLink_ScriptLinks where cat = @cat and pnlNo = @pnlNo and DeviceNo = @DeviceNo and status = @status and workstationID = @workstationID and facility = @facility and badge = @badge and scriptID=@scriptID</ScriptLink>
    <ScriptLink_GetAll partitioned="True" notificationtable="alarmLink_ScriptLinks">select cat,pnlNo, DeviceNo, status, workstationID, facility, badge, scriptID, scriptLinkName, EventClassID, LastUpdated, scriptLinkEnabled, caObjectID from AlarmLink_ScriptLinks</ScriptLink_GetAll>
    <scriptLookup partitioned="False" notificationtable="alarmLink_scripts">select scriptID as ValueMember, scriptName as DisplayMember from alarmLink_scripts</scriptLookup>
    <ApiScriptsGrid partitioned="False">select scriptID, scriptName, LastUpdated AS 'Last Edit' from alarmLink_scripts</ApiScriptsGrid>
    <scriptLookup_WithGUID partitioned="False" notificationtable="alarmLink_scripts">select scriptID as ValueMember, scriptName as DisplayMember, caObjectID from alarmLink_scripts</scriptLookup_WithGUID>
    <scriptScheduleGrid partitioned="True" notificationtable="AlarmLink_Schedule">
      Select
      ScheduleID
      ,ScheduleName,IsScheduleEventDependent,ScriptID,ScheduleEnabled,ScheduleTypeID,ScheduleDateTime,caObjectID,LastUpdated as 'Last Edit',RunIfOperatorLoggedOn,cat,pnlNo,DeviceNo,status,facility,Badge,workstationID,EventClassID
      from AlarmLink_Schedule
    </scriptScheduleGrid>
    <scriptServerLookup partitioned="False" notificationtable="scriptingServers">select workstationID as ValueMember, pollingUNCName as DisplayMember From ScriptingServers</scriptServerLookup>
    <ScriptTypeLookup partitioned="False" notificationtable="scriptWizard_Types">select scriptTypeID as ValueMember, ScriptTypeName as DisplayMember From ScriptWizard_Types</ScriptTypeLookup>
    <ScriptTypeStatusLookup partitioned="False" notificationtable="scriptWizard_TypeStatus">select scriptStatus as ValueMember, ScriptStatusName as DisplayMember From ScriptWizard_TypeStatus</ScriptTypeStatusLookup>
    <ScriptWizard_ActivityLink_GetALL partitioned="True" notificationtable="MActiveLinks">select pnlRef,ProgNo,Description,ProgNo as ValueMember,Description +' ('+CAST(ProgNo as nvarchar)+')' as DisplayMember from MActiveLinks  where Enabled = 1</ScriptWizard_ActivityLink_GetALL>
    <ScriptWizard_APBAreas_GetALL partitioned="True" notificationtable="Input">select AreaNo, Description, AreaNo as ValueMember,Description+' ('+CAST(AreaNo as nvarchar)+')' as DisplayMember FROM APBAreas WHERE AreaNo BETWEEN 2 AND 254</ScriptWizard_APBAreas_GetALL>
    <ScriptWizard_CategoryCounters_GetALL partitioned="False" notificationtable="CategoryCounters">select pnlNo as pnlRef,CatNo,Description,CatNo as ValueMember,Description +' ('+CAST(CatNo as nvarchar)+')' as DisplayMember from CategoryCounters</ScriptWizard_CategoryCounters_GetALL>
    <ScriptWizard_Input_GetALL partitioned="True" notificationtable="Input">select PnlRef,InpNo, InputName, InpNo as ValueMember,InputName+' ('+CAST(InpNo as nvarchar)+')' as DisplayMember,caObjectID from Input order by PnlRef,InpNo</ScriptWizard_Input_GetALL>
    <ScriptWizard_Link_GetALL partitioned="True" notificationtable="Link">select PnlRef, ProgNo, LinkName, ProgNo as ValueMember,LinkName+' ('+CAST(ProgNo as nvarchar)+')' as DisplayMember,caObjectID from Link order by LinkName</ScriptWizard_Link_GetALL>
    <ScriptWizard_LockDownAreas_GetALL partitioned="True" notificationtable="Link">select AreaNo, AreaName, AreaNo as ValueMember,AreaName+' ('+CAST(AreaNo as nvarchar)+')' as DisplayMember from MLockdownAreas</ScriptWizard_LockDownAreas_GetALL>
    <ScriptWizard_MessageTemplate_GetALL partitioned="False" notificationtable="MessageTemplates">Select TemplateID as ValueMember, Subject as DisplayMember, Body, AllowSNPP,AllowEmail,AllowSMS,Include from MessageTemplates</ScriptWizard_MessageTemplate_GetALL>
    <ScriptWizard_NapcoEventDef_GetALL partitioned="False" notificationtable="napcoEventDef">select StatusCode, EventHandlerType, EventMsgText, StatusCode as ValueMember,EventMsgText+' ('+CAST(statusCode as nvarchar)+')' as DisplayMember from NapcoEventdef</ScriptWizard_NapcoEventDef_GetALL>
    <ScriptWizard_NapcoPanel_GetALL partitioned="True" notificationtable="napcoPanels">select AlarmPanelID, WorkstationID, PanelType, PanelName,AlarmPanelID as ValueMember, PanelName+' ('+CAST(AlarmPanelID as nvarchar)+')' DisplayMember,caObjectID from NapcoPanels Where Enabled = 1 order by PanelName</ScriptWizard_NapcoPanel_GetALL>
    <ScriptWizard_NapcoPanelArea_GetALL partitioned="True" notificationtable="napcoPanelAreas">select AlarmPanelID, AreaNumber,AreaConfigured, AreaName,AreaNumber as ValueMember,AREANAME+' ('+ CAST(AreaNumber as nvarchar)+')' as DisplayMember from NapcoPanelAreas where AreaConfigured = 1 order by AreaName</ScriptWizard_NapcoPanelArea_GetALL>
    <ScriptWizard_NapcoPanelRelays_GetALL partitioned="True" notificationtable="napcoPanelRelays">select AlarmPanelID, RelayNumber, RelayName,AlarmPanelID as ValueMember, RelayName+' ('+CAST(AlarmPanelID as nvarchar)+')' as DisplayMember from napcoPanelRelays Where RelayConfigured=1</ScriptWizard_NapcoPanelRelays_GetALL>
    <ScriptWizard_NapcoPanelZones_GetALL partitioned="True" notificationtable="napcoPanelZones">select  AlarmPanelID, ZoneNumber, AreaNumber, ZoneName,ZoneNumber as ValueMember,ZoneName+' ('+ CAST(AlarmPanelID as nvarchar)+')' as DisplayMember from NapcoPanelZones Where ZoneConfigured=1</ScriptWizard_NapcoPanelZones_GetALL>
    <ScriptWizard_Operator_GetALL partitioned="False" notificationtable="Operators">
      select OperatorID, OperLName+' ,' +OperFName as [FullName],EmailID, PagerID,OperLogInName
      from operators where OperUseEmail =1 or OperUseEMail=1
    </ScriptWizard_Operator_GetALL>
    <ScriptWizard_Panel_GetALL partitioned="True" notificationtable="Panel">select PnlNo ,PanelName,PnlNo as ValueMember,PanelName+' ('+CAST(pnlNo as nvarchar)+')' as DisplayMember, caObjectID,PanelType from panel  where Enabled = 1 order by PanelName</ScriptWizard_Panel_GetALL>
    <ScriptWizard_ContinentalPanel_GetALL partitioned="True" notificationtable="Panel">select PnlNo ,PanelName,PnlNo as ValueMember,PanelName+' ('+CAST(pnlNo as nvarchar)+')' as DisplayMember, caObjectID from panel  where Enabled = 1 AND PanelType &lt; 101</ScriptWizard_ContinentalPanel_GetALL>
    <ScriptWizard_LockPanel_GetALL partitioned="True" notificationtable="Panel">select PnlNo ,PanelName,PnlNo as ValueMember,PanelName+' ('+CAST(pnlNo as nvarchar)+')' as DisplayMember, caObjectID from panel  where Enabled = 1 AND PanelType IN  (101, 102)</ScriptWizard_LockPanel_GetALL>
    <ScriptWizard_Privilage_GetALL partitioned="False" notificationtable="Privilege">select privilegeID, PrivilegeName,PrivilegeID as ValueMember,PrivilegeName+' ('+CAST(privilegeID as nvarchar) +')' as DisplayMember from privilege</ScriptWizard_Privilage_GetALL>
    <ScriptWizard_Reader_GetALL partitioned="True" notificationtable="Reader">select pnlRef,RdrNo,ReaderName,RdrNo as ValueMember,ReaderName +' ('+CAST(rdrNo as nvarchar)+')' as DisplayMember, caObjectID from Reader  where Enabled = 1 order by ReaderName</ScriptWizard_Reader_GetALL>
    <ScriptWizard_Relay_GetALL partitioned="True" notificationtable="Relay">select PnlRef, RelNo, RelayName,RelNo as ValueMember, RelayName+' ('+ CAST(RelNo as nvarchar)+')' as DisplayMember,caObjectID from Relay order by RelayName</ScriptWizard_Relay_GetALL>
    <ScriptWizard_ScriptServer_GetALL partitioned="False" notificationtable="scriptingServers">select workstationID as WorkstationID, pollingUNCName, WorkstationID as ValueMember, pollingUNCName+' ('+CAST(workstationID as nvarchar)+')' as DisplayMember From ScriptingServers</ScriptWizard_ScriptServer_GetALL>
    <ScriptWizard_ScriptTypes_GetALL partitioned="False" notificationtable="scriptWizard_Types">select scriptTypeID, ScriptTypeName, scriptTypeID as ValueMember,  ScriptTypeName +' ('+ CAST(scriptTypeID as nvarchar)+')' as DisplayMember From ScriptWizard_Types</ScriptWizard_ScriptTypes_GetALL>
    <ScriptWizard_ScriptTypeStatus_GetALL partitioned="False" notificationtable="scriptCounters">select ScriptTypeID, ScriptStatus, ScriptStatusName, ScriptStatus as ValueMember, ScriptStatusName+' ('+CAST(scriptstatus as nvarchar)+')' as DisplayMember From ScriptWizard_TypeStatus</ScriptWizard_ScriptTypeStatus_GetALL>
    <ScriptWizard_ThreatLevel_GetALL partitioned="True" notificationtable="MActiveThreatLevel">Select 0 as ValueMember, 'None' as DisplayMember union Select LockdownID as ValueMember, Description as DisplayMember from MActiveThreatLevel</ScriptWizard_ThreatLevel_GetALL>
    <selectapbarealookup partitioned="True">
      SELECT AreaNo, Description, caObjectID,
      AlertOn,AreaCountUp,LastUpdated,AreaCountDown,
      LinkVacant.displaymember LinkVacant,
      LinkOccupied.displaymember LinkOccupied,
      LinkOnCountUp.displaymember LinkOnCountUp,
      LinkOnCountDown.displaymember LinkOnCountDown,
      Active
      FROM APBAreas APB LEFT OUTER JOIN ca_vw_APBAreas AS LinkVacant ON APB.LinkVacant = LinkVacant.ValueMember
      LEFT OUTER JOIN ca_vw_APBAreas AS LinkOccupied ON APB.LinkOccupied = LinkOccupied.ValueMember
      LEFT OUTER JOIN ca_vw_APBAreas AS LinkOnCountUp ON APB.LinkOnCountUp = LinkOnCountUp.ValueMember
      LEFT OUTER JOIN ca_vw_APBAreas AS LinkOnCountDown ON APB.LinkOnCountDown = LinkOnCountDown.ValueMember
      WHERE AreaNo BETWEEN 2 AND 254
    </selectapbarealookup>
    <SelectNestedAPBAreas partitioned="True">
      SELECT Node, AreaNo, Description, NestName, Level, Parent, caObjectId, LastUpdated, LastOperator, LastWorkstation FROM (
      Select  n.Node,a.AreaNo,a.Description,n.NestName,ISNULL(n.Level,0) as Level, ISNULL(n.Parent,0) as Parent,a.caObjectId,
      n.LastUpdated,n.LastOperator,n.LastWorkstation
      FROM APBAreas a LEFT JOIN APBNestedAreas n ON n.AreaNo=a.AreaNo
      ) AS TAB
      WHERE AreaNo between 2 and 254
      Order By Node, Level
    </SelectNestedAPBAreas>
    <SetBadgeAPB partitioned="False">
      UPDATE badge SET APBSet = @APBSet ,  LastUpdated = @LastUpdated , LastOperator =@LastOperator, LastWorkstation = @LastWorkstation
      WHERE Facility = @Facility AND Badge = @Badge
    </SetBadgeAPB>
    <UpdateBadgeUpdate partitioned="False">
      IF EXISTS(SELECT 1 FROM [BadgeUpdate] WHERE Badge = @Badge and Facility= @Facility)
      BEGIN
      UPDATE [BadgeUpdate] set Badge = @Badge, Facility = @Facility, LVDate = @LVDate, LVPnl = @LVPnl, LVRdr = @LVRdr, PersonId = @PersonId
      WHERE Badge = @Badge and Facility= @Facility AND LVDate &lt;= @LVDate
      END
      ELSE
      BEGIN
      INSERT INTO [BadgeUpdate]
      (PersonID, Badge, Facility, LVPnl, LVRdr, LVDate) VALUES (@PersonId,@Badge,@Facility,@LVPnl,@LVRdr,@LVDate)
      END
    </UpdateBadgeUpdate>
    <UpdateBadgeForBadgeUpdate partitioned="False">
      IF(EXISTS(SELECT TOP 1 1 FROM [Badge] WITH (NOLOCK) WHERE Badge = @Badge and Facility= @Facility AND ((ISNULL(Flag, 0) = 0  AND Enabled &lt;&gt; @Enabled) OR (APBSet &lt;&gt; @APBSet) OR (APBArea &lt;&gt; @APBArea) OR (UseCount &lt;&gt; @UseCount))))
      BEGIN
      UPDATE [Badge] SET Flag = NULL, Enabled = @Enabled,APBSet = @APBSet,APBArea =@APBArea,UseCount=@UseCount
      WHERE Badge = @Badge and Facility= @Facility
      END
      ELSE
      BEGIN
      IF(EXISTS(SELECT TOP 1 1 FROM [Badge] WITH (NOLOCK) WHERE Badge = @Badge and Facility= @Facility AND Flag IS NOT NULL))
      BEGIN
      UPDATE [Badge] SET Flag = NULL WHERE Badge = @Badge and Facility= @Facility
      END
      END
    </UpdateBadgeForBadgeUpdate>
    <SetCounterValue partitioned="False">INSERT INTO scriptCounters(counterName, counterVal) values(@counterName, @counterVal)</SetCounterValue>
    <SetGlobalVariable partitioned="False">
      if exists(select 1 from GlobalVariables where VariableName = @VarName1)
      update GlobalVariables set VariableValue = @VarValue1 where VariableName = @VarName2
      else
      insert into GlobalVariables (VariableName, VariableValue) values (@VarName3, @VarValue2)
    </SetGlobalVariable>
    <SetLockChanged partitioned="False">Update Panel Set LockChanged = 1 where PnlNo=@PnlNo</SetLockChanged>
    <ShowAccessGroupList partitioned="False">
      select ( cast(r.PnlRef as nvarchar) + '-' + cast(r.RdrNo as nvarchar) + '   '+ r.ReaderName) as COL1, m.Description as COL2,A.Description as Description
      from ca_vw_ReaderAccessGroupTimeZone v
      inner join reader r on r.RdrNo= v.ReaderID and r.PnlRef=v.PanelID
      inner join MAccGrp A on A.AgrpNo=v.AccessGroupID
      inner join MTimezon m on m.TzNum=v.TimeZoneID
      INNER JOIN BadgeAccess AS BA ON BA.AGroupNo = A.AgrpNo AND BA.Badge = @Badge AND BA.Facility = @Facility
      ORDER BY A.AgrpNo, r.PnlRef, r.RdrNo
    </ShowAccessGroupList>
    <ShowAccessList partitioned="False">
      select LastName + ',' + FrstName + ',' + CAST(Badge AS VARCHAR(20)) AS DisplayMember1,
      (SELECT description FROM MTimezon WHERE TzNum = (CASE WHEN @rdrNo = 1 THEN Tz1 WHEN @rdrNo = 2 THEN Tz2 WHEN @rdrNo = 3 THEN Tz3 WHEN @rdrNo = 4 THEN Tz4
      WHEN @rdrNo = 5 THEN Tz5 WHEN @rdrNo = 6 THEN Tz6 WHEN @rdrNo = 7 THEN Tz7 WHEN @rdrNo = 8 THEN Tz8
      WHEN @rdrNo = 9 THEN Tz9 WHEN @rdrNo = 10 THEN Tz10 WHEN @rdrNo = 11 THEN Tz11 WHEN @rdrNo = 12 THEN Tz12
      WHEN @rdrNo = 13 THEN Tz13 WHEN @rdrNo = 14 THEN Tz14 WHEN @rdrNo = 15 THEN Tz15 ELSE Tz16
      END)) AS DisplayMember2,
      BA.Description AS DisplayMember3,
      Enabled
      from ca_vw_BadgeAccessList AS BA INNER JOIN AccGrp AS AG ON BA.AGroupNo = AG.Agno
      WHERE AG.PnlRef = @pnlNo
      AND (CASE WHEN @rdrNo = 1 THEN Tz1 WHEN @rdrNo = 2 THEN Tz2 WHEN @rdrNo = 3 THEN Tz3 WHEN @rdrNo = 4 THEN Tz4
      WHEN @rdrNo = 5 THEN Tz5 WHEN @rdrNo = 6 THEN Tz6 WHEN @rdrNo = 7 THEN Tz7 WHEN @rdrNo = 8 THEN Tz8
      WHEN @rdrNo = 9 THEN Tz9 WHEN @rdrNo = 10 THEN Tz10 WHEN @rdrNo = 11 THEN Tz11 WHEN @rdrNo = 12 THEN Tz12
      WHEN @rdrNo = 13 THEN Tz13 WHEN @rdrNo = 14 THEN Tz14 WHEN @rdrNo = 15 THEN Tz15 ELSE Tz16
      END) > 0
      AND EXISTS (SELECT 1
      FROM OperatorPartitions INNER JOIN devicepartitions on devicepartitions.PartitionId = OperatorPartitions.Partitionid
      WHERE OperatorPartitions.OperatorID = @OperatorID
      AND BA.personid = devicepartitions.caObjectID)
      order by Badge
    </ShowAccessList>
    <ShowAccessList2 partitioned="False">
      select ( cast(r.PnlRef as nvarchar) + '-' + p.PanelName + '   '+ cast(r.RdrNo as nvarchar) + '-' + r.ReaderName) as COL1, m.Description as COL2
      from ca_vw_ReaderAccessGroupTimeZone v
      INNER JOIN Panel AS p ON p.PnlNo = v.PanelID
      inner join reader r on r.RdrNo= v.ReaderID and r.PnlRef=v.PanelID
      inner join MTimezon m on m.TzNum=v.TimeZoneID and v.AccessGroupID=@AccessGroupID
      ORDER BY r.PnlRef, r.RdrNo
    </ShowAccessList2>
    <shuntgroupsgrid partitioned="True">
      select
      ShuntName
      ,ShuntID
      ,caObjectId
      ,LastUpdated as 'Last Edit'
      from mshunt
    </shuntgroupsgrid>
    <singleactivitylinklookup partitioned="False">
      select
      l.pnlref,l.description,l.progno
      ,p.paneltype
      from mactivelinks l
      inner join panel p on p.pnlno = l.pnlref
      where l.PnlRef = @PnlRef
      AND l.progno=@ProgNo
    </singleactivitylinklookup>
    <SingleLinkEnabledLookUp partitioned="False" notificationtable="Link">
      select l.ManualPriv,l.pnlref,l.linkname as description,l.progno
      ,p.paneltype from link l
      inner join panel p on p.pnlno = l.pnlref where l.enabled = 1 and l.PnlRef = @PnlRef AND l.progno=@ProgNo
      and ( (l.ManualPriv = 0) or (l.ManualPriv in (select ManualPrivilege from manualprivilege where OperatorID = @OperatorID )))
    </SingleLinkEnabledLookUp>
    <singlereaderenabledlookup partitioned="False" notificationtable="Reader">
      select r.ManualPriv, r.pnlref, r.readername as description, r.RdrNo as deviceno
      , p.paneltype from reader r
      inner join panel p on p.pnlno = r.pnlref where r.enabled = 1 and r.PnlRef = @PnlRef AND r.RdrNo=@RdrNo
      and ( (r.ManualPriv = 0) or (r.ManualPriv in (select ManualPrivilege from manualprivilege where OperatorID = @OperatorID )))
      and not (p.paneltype = 102 and r.RdrNo = 2)
    </singlereaderenabledlookup>
    <singlerelayenabledlookup partitioned="False" notificationtable="Relay">
      select r.ManualPriv,r.pnlref,r.relayname as description,r.relno as deviceno
      ,p.paneltype from relay r
      inner join panel p on p.pnlno = r.pnlref where r.enabled = 1 and r.pnlref=@PnlRef and r.relno = @RelNo
      and ( (r.ManualPriv = 0) or (r.ManualPriv in (select ManualPrivilege from manualprivilege where OperatorID = @OperatorID )))
    </singlerelayenabledlookup>
    <smsProvidersList partitioned="False" notificationtable="smsProviders">Select smsHostID,smsHostName,smsServer,smsType,smsParams,smsPassword,LastWorkStation,LastOperator,caObjectID  from smsProviders</smsProvidersList>
    <smsproviderslookup partitioned="False" notificationtable="smsProviders">select smsHostID as ValueMember, smsHostName as DisplayMember from smsProviders</smsproviderslookup>
    <snppProvidersList partitioned="False" notificationtable="snppProviders">Select snppHostID,snppHostName,snppServer,snppPort,LastWorkStation,LastOperator,caObjectID  from snppProviders</snppProvidersList>
    <snppproviderslookup partitioned="False" notificationtable="snppProviders">select snppHostID as ValueMember, snppHostName as DisplayMember from snppProviders</snppproviderslookup>
    <StatusForAllGateways partitioned="False">select comport,macaddress,ipaddress,version,status,LastUpdated from GatewayStatus</StatusForAllGateways>
    <StatusInput partitioned="False">
      SELECT InputName as Name,caObjectID, Enabled FROM Input
      WHERE PnlRef=@PnlRef and InpNo=@InpNo
    </StatusInput>
    <APIGetInputObject partitioned="False">
      SELECT InputName as Name,caObjectID, Enabled FROM Input WHERE PnlRef=@PnlRef and InpNo=@InpNo
    </APIGetInputObject>
    <StatusNapcoArea partitioned="False">
      SELECT AreaName as Name,caObjectID FROM napcoPanelAreas
      WHERE AlarmPanelID=@PnlID And AreaNumber=@AreaNumber And AreaConfigured =1
    </StatusNapcoArea>
    <ApiStatusNapcoArea partitioned="False">
      SELECT AreaName as Name,caObjectID FROM napcoPanelAreas
      WHERE AlarmPanelID=@PnlID And AreaNumber=@AreaNumber And AreaConfigured =1
    </ApiStatusNapcoArea>
    <StatusNapcoPanel partitioned="False">
      SELECT PanelName as Name,caObjectID FROM napcoPanels
      WHERE AlarmPanelID=@PnlID And Enabled =1
    </StatusNapcoPanel>
    <APIGetNapcoPanelObject partitioned="False">
      SELECT PanelName as Name,caObjectID FROM napcoPanels WHERE AlarmPanelID=@PnlID
    </APIGetNapcoPanelObject>
    <ApiStatusNapcoPanel partitioned="False">
      SELECT PanelName as Name,caObjectID FROM napcoPanels
      WHERE AlarmPanelID=@PnlID And Enabled =1
    </ApiStatusNapcoPanel>
    <StatusNapcoRelay partitioned="False">
      SELECT RelayName as Name,caObjectID FROM napcoPanelRelays
      WHERE AlarmPanelID=@PnlID And RelayNumber=@RelayNumber And RelayConfigured =1
    </StatusNapcoRelay>
    <APIGetNapcoRelayObject partitioned="False">
      SELECT RelayName as Name,caObjectID FROM napcoPanelRelays WHERE AlarmPanelID=@PnlID And RelayNumber=@RelayNumber
    </APIGetNapcoRelayObject>
    <ApiStatusNapcoRelay partitioned="False">
      SELECT RelayName as Name,caObjectID FROM napcoPanelRelays
      WHERE AlarmPanelID=@PnlID And RelayNumber=@RelayNumber And RelayConfigured =1
    </ApiStatusNapcoRelay>
    <StatusNapcoZone partitioned="False">
      SELECT ZoneName as Name,caObjectID FROM napcoPanelZones
      WHERE AlarmPanelID=@PnlID And ZoneNumber=@ZoneNumber And ZoneConfigured =1
    </StatusNapcoZone>
    <APIGetNapcoZoneObject partitioned="False">
      SELECT ZoneName as Name,caObjectID FROM napcoPanelZones WHERE AlarmPanelID=@PnlID And ZoneNumber=@ZoneNumber
    </APIGetNapcoZoneObject>
    <ApiStatusNapcoZone partitioned="False">
      SELECT ZoneName as Name,caObjectID FROM napcoPanelZones
      WHERE AlarmPanelID=@PnlID And ZoneNumber=@ZoneNumber And ZoneConfigured =1
    </ApiStatusNapcoZone>
    <StatusPanel partitioned="False">
      SELECT PanelName as Name,caObjectID, Enabled FROM Panel
      WHERE PnlNo=@PnlRef And Enabled = 1
    </StatusPanel>
    <StatusReader partitioned="False">
      SELECT ReaderName as Name,caObjectID, Enabled FROM Reader
      WHERE PnlRef=@PnlRef and RdrNo=@RdrNo
    </StatusReader>
    <APIGetReaderObject partitioned="False">
      SELECT ReaderName as Name,caObjectID, Enabled FROM Reader WHERE PnlRef=@PnlRef and RdrNo=@RdrNo
    </APIGetReaderObject>
    <StatusRelay partitioned="False">
      SELECT RelayName as Name,caObjectID, Enabled FROM Relay
      WHERE PnlRef=@PnlRef and RelNo=@RelNo
    </StatusRelay>
    <APIGetRelayObject partitioned="False">
      SELECT RelayName as Name,caObjectID, Enabled FROM Relay WHERE PnlRef=@PnlRef and RelNo=@RelNo
    </APIGetRelayObject>
    <SoftwareElevCtrl>
      SELECT COUNT(*) AS CNT FROM WorkStationSettings where SoftwareElevCtrl = 1
    </SoftwareElevCtrl>
    <GetElevServers>
      SELECT [ServerId], [ServerIP], [ServerName], WorkstationName, [caObjectID],[ElevFacilityId], [DecMode], [EnabledPinSecurity] FROM [ElevServers] WHERE ServerIP = @ServerIP and WorkstationName = @WorkstationName and [ServerType] = 1
    </GetElevServers>
    <GetElevServersByid>
      SELECT [ServerId], [ServerIP], [ServerName], WorkstationName, [caObjectID],[ElevFacilityId], [DecMode], [EnabledPinSecurity] FROM [ElevServers] WHERE ServerId = @ServerId and WorkstationName = @WorkstationName and [ServerType] = 1
    </GetElevServersByid>
    <GetWsElevServers>
      select * from ElevServers WHERE WorkstationName = @WorkstationName and [ServerType] = 1
    </GetWsElevServers>
    <GetElevTerminal>
      SELECT E.[ServerIP],  E.[ServerName], E.WorkstationName, R.[ReaderName],  R.[caObjectID],R.[PnlRef],R.[RdrNo]
      FROM [ElevServers] AS E INNER JOIN [Reader] AS R ON E.ServerId = R.ElevServerId
      WHERE E.ServerIP = @ServerIP and E.WorkstationName = @WorkstationName and E.[ServerType] = 1 and R.[DecReader] = 1
    </GetElevTerminal>
    <GetAllEnabledPanels>
      SELECT PnlNo from Panel WHERE Enabled = 1
    </GetAllEnabledPanels>
    <GetDeviceStatus partitioned="False">
      exec ca_sp_GetDeviceStatus @SvrName, @DBName, @OperatorID, @Type
    </GetDeviceStatus>
    <APIGetDeviceStatus partitioned="False">
      exec ca_sp_GetDeviceStatus @SvrName, @DBName, @OperatorID, @Type
    </APIGetDeviceStatus>
    <supervisorlookup partitioned="False">
      select 'None' as DisplayMember, '00000000-0000-0000-0000-000000000000' as ValueMember
      Union
      select LastName + ', ' + FrstName as DisplayMember
      , PersonId   as ValueMember
      from Person
      where supervisor = 1 and PersonId in (
      SELECT devicepartitions.caObjectID FROM OperatorPartitions inner join  devicepartitions on devicepartitions.PartitionId = OperatorPartitions.Partitionid where OperatorPartitions.OperatorID = @OperatorID)
    </supervisorlookup>
    <systemsettings partitioned="False">
      select
      UseHoliday
      ,UseNAPCOPermissions
      ,UseAlp
      ,SysBadgeLen
      ,TagType
      ,UseAPBAreas
      ,UseCatCounters
      ,AGCountPerBadge
      ,UseFacBadge
      ,HidePinCode
      ,HideSSN
      , AutoAckPriority
      , UseAutoAck
      ,UsePIV
      ,UseScripting
      ,UseNAPCO
      ,BadgeReIssueLevel
      ,RespReqTz
      ,lockdown
      ,UseHostTz
      ,KeypadOption
      ,PrintPriority
      ,PrintBySchedule
      ,AutoCreateDevice
      ,UseStrongPasswords
      ,PasswordMinLength
      ,PasswordMaxLength
      ,PasswordMinNonAlphaChars
      ,PasswordRegEx
      ,UseLDAPAuthentication
      ,UseLDAPAuthorization
      ,UseCustomMenu
      ,LDAPPath
      ,UseFacilityMaps
      ,UseVideo
      ,BroadcastValue
      ,APBResetPartition
      from systemsettings where sysid = 0
    </systemsettings>
    <templateaccessgroupslookup partitioned="True" notificationtable="MAccGrp">
      select
      AgrpNo as ValueMember, Description as DisplayMember  ,  Description as OrderCol
      from MAccGrp
      where (isnull(PointAccess,0)=1)
      Order by OrderCol
    </templateaccessgroupslookup>
    <TestQuery partitioned="False">SELECT server_id, name FROM [LINKEDSERVER].[master].sys.servers</TestQuery>
    <ThreatLevelAreaCheck partitioned="False">select LockoutArea, Active, DenyAccess,
     (SELECT  CatEnable
               FROM   dbo.ca_vw_GetActiveThreatLevelCats where LockdownID=@ThreatLevel) as CatBits
  from MActiveThreatLevel
 where LockdownID=@ThreatLevel</ThreatLevelAreaCheck>
    <threatlevelcategories partitioned="False">select distinct catnumber from ActiveThreatLevel order by catnumber</threatlevelcategories>
    <threatlevelgrid partitioned="True">
      select lockdownid as  Level,Description,Active, LockoutArea,caObjectId
      ,LastUpdated as 'Last Edit'
      from MActiveThreatLevel
    </threatlevelgrid>
    <ApiThreatlevelgrid partitioned="True">
      select lockdownid as  Level,Description,Active, LockoutArea
      ,LastUpdated as 'Last Edit'
      from MActiveThreatLevel
    </ApiThreatlevelgrid>
    <ApiLinkgrid partitioned="True">
      select PnlRef, ProgNo, CAST(pnlRef AS VARCHAR(100)) +'-'+ CAST(progNo AS VARCHAR(100)) as [Panel Prog],LinkName as [Device Name], LastUpdated as 'Last Edit', caObjectID
      FROM Link
      order by pnlref,progno
    </ApiLinkgrid>
    <ThreatLevelReaderList partitioned="False">select PnlRef,RdrNo from ca_vw_ThreatLevelReaderList
where HCSNo=@HCSNo and LockdownID=@ThreatLevel
and PanelType between @low and @high</ThreatLevelReaderList>
    <ThreatLevelSelect partitioned="False">SELECT [CatNumber],[Description],[LastUpdated],[caObjectId],[LastOperator] FROM [dbo].[ThreatLevelCategories] Order By [CatNumber]</ThreatLevelSelect>
    <ThreatLevelUpdate partitioned="False">UPDATE SystemSettings set LockoutItem = @Level where SysId = 0</ThreatLevelUpdate>
    <timescheduleList partitioned="False" notificationtable="MTimezon">select TzNum as ValueMember, Description as DisplayMember  from MTimezon</timescheduleList>
    <timeschedulelookup partitioned="True" notificationtable="MTimezon">
      select 0 as ValueMember, 'Not Used' as DisplayMember
      union
      select TzNum as ValueMember, Description as DisplayMember  from MTimezon
    </timeschedulelookup>
    <timeschedulelookupsettings partitioned="True" notificationtable="MTimezon">
      select 0 as ValueMember, 'Always Enabled' as DisplayMember
      union
      select TzNum as ValueMember, Description as DisplayMember  from MTimezon
    </timeschedulelookupsettings>
    <timeZoneAccessGroupNo partitioned="False">SELECT PanelID,PanelName,AccessGroupID from ca_vw_ReaderAccessGroupTimeZone,Panel WHERE ca_vw_ReaderAccessGroupTimeZone.PanelID=Panel.PnlNo and ca_vw_ReaderAccessGroupTimeZone.TimeZoneID = @TimeZoneID Group By PanelID,PanelName,AccessGroupID</timeZoneAccessGroupNo>
    <timezonegrid partitioned="False" notificationtable="Timezone">
      select
      CASE DayFrom
      WHEN (8) THEN 'HOL'
      WHEN (7) THEN 'SUN'
      WHEN (1) THEN 'MON'
      WHEN (2) THEN 'TUE'
      WHEN (3) THEN 'WED'
      WHEN (4) THEN 'THU'
      WHEN (5) THEN 'FRI'
      WHEN (6) THEN 'SAT'
      ELSE 'None'
      END as "Start Day"
      , CASE DayTo
      WHEN (8) THEN 'HOL'
      WHEN (7) THEN 'SUN'
      WHEN (1) THEN 'MON'
      WHEN (2) THEN 'TUE'
      WHEN (3) THEN 'WED'
      WHEN (4) THEN 'THU'
      WHEN (5) THEN 'FRI'
      WHEN (6) THEN 'SAT'
      ELSE 'None'
      END as "End Day"
      ,TimeFrom as "Time From"
      ,TimeTo as "Time To"
      from timezone where tzno=@tzno
      order by TzID
    </timezonegrid>
    <timeZoneUnused partitioned="False">
      SELECT TzNum as TimeZoneID, Description FROM MTimeZon WHERE TzNum NOT IN(SELECT TzNum FROM MTimeZon where TzNum IN(SELECT TimeZoneID FROM ca_vw_ReaderAccessGroupTimeZone UNION ALL SELECT ETz FROM Link UNION ALL SELECT TrkTz FROM Link UNION ALL SELECT TrackTz FROM Relay UNION ALL SELECT InpTz FROM Input UNION ALL SELECT LimitSchedule FROM Input UNION ALL SELECT RespReqTz FROM SystemSettings UNION ALL  SELECT Fatz FROM Reader UNION ALL SELECT Ctz FROM Reader UNION ALL SELECT Cctz FROM Reader UNION ALL SELECT Cytz FROM Reader UNION ALL SELECT DegrSchedule FROM Reader UNION ALL SELECT PrintBySchedule FROM SystemSettings))
      and caObjectID in (SELECT devicepartitions.caObjectID FROM OperatorPartitions inner join  devicepartitions on devicepartitions.PartitionId = OperatorPartitions.Partitionid where OperatorPartitions.OperatorID = @OperatorID)
    </timeZoneUnused>
    <timeZoneUsagesForInputByTimezoneID partitioned="True">SELECT CAST(PnlRef as nvarchar(20))+'-' +CAST(InpNo as nvarchar(20))+'  '+ inputname as DisplayMember FROM Input  WHERE InpTz =@TimeZoneID OR LimitSchedule = @TimeZoneID</timeZoneUsagesForInputByTimezoneID>
    <timeZoneUsagesForLinkByTimezoneID partitioned="True">SELECT CAST(PnlRef as nvarchar(20))+'-'+ CAST(ProgNo as nvarchar(20))+'  '+ LinkName FROM Link WHERE ETz = @TimeZoneID OR TrkTz = @TimeZoneID</timeZoneUsagesForLinkByTimezoneID>
    <timeZoneUsagesForMAccGrpByTimezoneID partitioned="True">SELECT Description as DisplayMember FROM MAccGrp WHERE AgrpNO IN(SELECT DISTINCT AccessGroupID FROM ca_vw_ReaderAccessGroupTimeZone WHERE TimeZoneID = @TimeZoneID )</timeZoneUsagesForMAccGrpByTimezoneID>
    <timeZoneUsagesForNodeByTimezoneID partitioned="True">SELECT NodeName FROM Nodes WHERE Schedule= @TimeZoneID</timeZoneUsagesForNodeByTimezoneID>
    <timeZoneUsagesForReaderByTimezoneID partitioned="True">SELECT CAST(PnlRef as nvarchar(20))+'-'+ CAST(RdrNo as nvarchar(20))+'  '+  ReaderName as DisplayMember FROM Reader WHERE CTz = @TimeZoneID OR FATz = @TimeZoneID OR CYTz = @TimeZoneID OR DegrSchedule = @TimeZoneID</timeZoneUsagesForReaderByTimezoneID>
    <timeZoneUsagesForRelayByTimezoneID partitioned="True">SELECT CAST(PnlRef as nvarchar(20))+'-'+ CAST(RelNo as nvarchar(20))+'  '+ RelayName as DisplayMember FROM Relay  WHERE TrackTz = @TimeZoneID</timeZoneUsagesForRelayByTimezoneID>
    <timeZoneUsagesForSchedEventByTimezoneID partitioned="True">SELECT Description,GroupName FROM SchedEvent WHERE Schedule=@TimeZoneID</timeZoneUsagesForSchedEventByTimezoneID>
    <timeZoneUsagesForSystemSettingsByTimezoneID partitioned="False">
      SELECT 'Response Required',RespReqTz FROM SystemSettings WHERE RespReqTz =@TimeZoneID
      union
      SELECT 'Print Valid Access',PrintBySchedule  FROM SystemSettings WHERE PrintBySchedule = @TimeZoneID
    </timeZoneUsagesForSystemSettingsByTimezoneID>
    <TrackBadge partitioned="False">
      UPDATE badge SET Track = 1,  LastUpdated = @LastUpdated, LastOperator =@LastOperator, LastWorkstation =@LastWorkstation
      WHERE Facility = @Facility AND Badge = @Badge
    </TrackBadge>
    <TrackPerson partitioned="False">UPDATE badge SET TRACK = 1,  LastUpdated = @LastUpdated , LastOperator =@LastOperator , LastWorkstation =@LastWorkstation WHERE PersonID = @PersonID</TrackPerson>
    <typestatuslookup partitioned="False" notificationtable="scriptWizard_TypeStatus">
      select scriptStatus, scriptStatusName from scriptWizard_TypeStatus
      where scriptTypeID = @scriptTypeID
    </typestatuslookup>
    <apitypestatuslookup partitioned="False"> select scriptStatus as ValueMember, scriptStatusName as DisplayMember, scriptTypeID from scriptWizard_TypeStatus </apitypestatuslookup>
    <uiddefsqry partitioned="False">SELECT [UserFieldID],[UserFieldTabId],[UserFieldName],[UserFieldType],[UserFieldLength],[LastUpdated],[caObjectID],[LastOperator],[LastWorkStation] FROM [dbo].[UserFieldDef]</uiddefsqry>
    <uidtabsqry partitioned="False">SELECT [UserFieldTabID],[UserFieldTabName],[LastUpdated],[caObjectId],[LastOperator],[LastWorkStation] FROM [dbo].[UserFieldTabs]</uidtabsqry>
    <UntrackBadge partitioned="False">
      UPDATE badge SET Track = 0,  LastUpdated = @LastUpdated, LastOperator = @LastOperator, LastWorkstation = @LastWorkstation
      WHERE Facility = @Facility  AND Badge = @Badge
    </UntrackBadge>
    <UntrackPerson partitioned="False">UPDATE badge SET TRACK = 0,  LastUpdated = @LastUpdated , LastOperator =@LastOperator , LastWorkstation =LastWorkstation   WHERE PersonID = @PersonID</UntrackPerson>
    <UpdateBadgeFormatID partitioned="False">
      UPDATE Badge
      Set     EPI_FORMAT_ID = @FormatID

      WHERE     (PersonID = @PersonID) AND (Badge = @Badge) AND (Facility = @Facility)
    </UpdateBadgeFormatID>
    <UpdateBadgeTransactionParms partitioned="False">exec ca_sp_UpdateBadgeTransactionParms @caObjectId,@Enabled,@UseCount,@APBArea,@APBSet,@Shunt</UpdateBadgeTransactionParms>
    <updatecatdescription partitioned="False">update ThreatLevelCategories set Description = @Description where catnumber = @catnumber</updatecatdescription>
    <UpdateThreatLevelAccess partitioned="False">
      update MActiveThreatLevel set DenyAccess = @DenyAccess, LastOperator =@LastOperator,LastWorkstation=@LastWorkstation  where LockdownID = @LockdownID
    </UpdateThreatLevelAccess>
    <updatecomport partitioned="False">
      update com set MACAddress=@MacAddress, IPAddress=@IPAddress
      where HCSNo=@HCSNo and ComPort=@ComPort
    </updatecomport>
    <updatewirelesscomport partitioned="False">
      update com set MACAddress=@MACAddress, IPAddress=@IPAddress, SubNetMask=@SubNetMask, GatewayIPAddress=@GatewayIPAddress,HostIPAddress=@HostIPAddress,GatewayPort=@GatewayPort,
      LastUpdated=@LastUpdated,LastOperator=@LastOperator,ZoneId=@ZoneId  where HCSNo=@HCSNo and ComPort=@ComPort
    </updatewirelesscomport>
    <UpdateIPAddress partitioned="False">UPDATE Com SET IPAddress=@IPAddress WHERE MACAddress=@MACAddress and UseDHCP = 1</UpdateIPAddress>
    <UpdateLockStatus partitioned="False">Update LockStatus set RxRSSI=@RxRSSI,TxRSSI=@TxRSSI,Version=@Version,LockType=@LockType,Assigned=@Assigned,Status=@Status,RepeaterAddress=@RepeaterAddress, LastUpdated=@LastUpdated Where PnlRef=@PnlRef</UpdateLockStatus>
    <UpdateLockStatusBattery partitioned="False">Update LockStatus set Battery=@Battery,LastUpdated=@LastUpdated Where LockId=@LockId</UpdateLockStatusBattery>
    <UpdateMap partitioned="False">UPDATE Map SET MapID=@MapID, MapName=@MapName, MapDescription=@MapDescription, MapImage=@MapImage WHERE MapUID=@MapUID</UpdateMap>
    <UpdateMapSettings partitioned="False">UPDATE OperatorSettings SET MapToolTipInterval = @ToolTipInterval, MapManualControlDblClick = @ManualControlDblClick, MapCloseAlert = @CloseAlert, MapTheme = @Theme, StatusUpdateInterval = @StatusUpdateInterval WHERE OperatorID = @OperatorID</UpdateMapSettings>
    <UpdateNewLock partitioned="False">update panel set LockId=@LockId, Enabled=1,PanelType=@PanelType, LockType=@LockType,PanelName=@PanelName, LockAssigned=@LockAssigned, LockExpAddress=@LockExpAddress, UTCOffset=@UTCOffset,LastOperator=@LastOperator,LastUpdated=@LastUpdated WHERE Pnlno=@PnlNo</UpdateNewLock>
    <updateOperatorPassword partitioned="False">
      update operators set OperPassword = @NewPassword
      ,PasswordRequiresUpdate = 0,LastWorkStation = host_name()
      where OperLoginName = @LoginName and OperPassword = @OldPassword
    </updateOperatorPassword>
    <UpdatePanelType partitioned="False">UPDATE Panel SET PanelType=@PanelType WHERE PnlNo=@PnlNo</UpdatePanelType>
    <UpdateGatewayStatusTable partitioned="False">
      UPDATE GatewayStatus set Version = @Version,Status = @Status,LockCount=@LockCount,HasRepeaters=@HasRepeaters,RepeaterCount=@RepeaterCount,GroupNo=@GroupNo,LastUpdated = @LastUpdated, Cluster =@Cluster
      WHERE MACAddress = @MACAddress
    </UpdateGatewayStatusTable>
    <UpdateRepeaterStatusTable partitioned="False">
      UPDATE RepeaterStatus set Id = @Id,RouteIn = @RouteIn, RouteOut=@RouteOut, State = @State,RSSI =@RSSI, FirmwareMajor =@FirmwareMajor, FirmwareMinor=@FirmwareMinor,Status=@Status
      WHERE Cluster = @Cluster and ComPort = @ComPort and rfAddress = @rfAddress
    </UpdateRepeaterStatusTable>
    <userfielddef partitioned="False">
      select t.UserFieldTabID
      ,t.UserFieldTabName
      ,t.LastUpdated
      ,t.caObjectId
      ,t.LastOperator
      ,t.LastWorkStation
      ,d.UserFieldId,d.UserFieldTabId,d.UserFieldName,d.UserFieldType,d.UserFieldLength,
      d.Lastupdated as LU,d.caobjectId as CO ,d.LastOperator as LO,d.LastWorkStation as LW
      ,' ' as userfieldvalue
      FROM UserfieldTabs as t
      LEFT JOIN UserfieldDef as d on t.UserFieldTabId=d.UserFieldTabId
      --where t.UserFieldTabId = @UserFieldTabId
      ORDER BY t.UserFieldTabId
    </userfielddef>
    <UTCOffsetFromZoneID partitioned="False">SELECT ca_fn_UTCOffsetFromZoneID @zoneid</UTCOffsetFromZoneID>
    <getpanelsfordaylight>
      SELECT
      p.PnlNo,
      c.ComId,
      c.HCSNo,
      c.ComPort,
      z.ZoneId,
      z.UTCBias,
      z.dBias,
      z.dMonth,
      z.dDay,
      z.dHour,
      z.dMinute,
      z.dSecond,
      z.sMonth,
      z.sDay,
      z.sHour,
      z.sMinute,
      z.sSecond,
      CAST(DATEADD(MINUTE, z.UTCBias, z.dStart) AS smalldatetime) AS dStart,
      CAST(DATEADD(MINUTE, z.UTCBias + z.dBias, z.sStart) AS smalldatetime) AS sStart
      FROM Com AS c
      INNER JOIN Panel p ON p.ComPort = c.ComPort AND p.HCSNo = @HCSNo
      INNER JOIN Zones AS z   ON c.ZoneId = z.ZoneId
      WHERE
      CAST(DATEADD(MINUTE, z.UTCBias, z.dStart) AS smalldatetime) = CAST(@UTCCurrentDate AS smalldatetime)
      OR
      CAST(DATEADD(MINUTE, z.UTCBias + z.dBias, z.sStart) AS smalldatetime) = CAST(@UTCCurrentDate  AS smalldatetime)
    </getpanelsfordaylight>
    <vehicletagreaderlookup partitioned="True" notificationtable="Reader">
      select 0 as PnlRef, 0  as ValueMember, 'None' as DisplayMember
      union
      select pnlRef, RdrNo as ValueMember, readerName as DisplayMember
      from Reader
    </vehicletagreaderlookup>
    <workstationsettings partitioned="False">
      select
      [WorkstationName]
      ,[UsePrinting]
      ,[EnableVideoService]
      ,[UseWirelessLocks]
      ,[EventPrn]
      ,[BadgingPrn]
      ,[UseBadging]
      ,[Badgingoption]
      ,[UseAlertSound]
      ,[AlertSoundInterval1]
      ,[AlertSoundInterval2]
      ,[AlertSoundInterval3]
      ,[AlertSoundInterval4]
      ,[ResponseSoundInterval]
      ,[AlertSoundName1]
      ,[AlertSoundName2]
      ,[AlertSoundName3]
      ,[AlertSoundName4]
      ,[ResponseSoundName]
      ,[AlertSoundPriority1]
      ,[AlertSoundPriority2]
      ,[AlertSoundPriority3]
      ,[AlertSoundPriority4]
      ,[AlertColor1]
      ,[AlertColor2]
      ,[AlertColor3]
      ,[AlertColor4]
      ,[TapiPhone1]
      ,[TapiPhone2]
      ,[TapiId1]
      ,[TapiId2]
      ,[caObjectID]
      ,[LastUpdated]
      ,[LastOperator]
      ,[LastWorkStation]
      ,[CCTVSocket]
      ,[UseLinePrinterMode]
      ,[EventPrinter]
      ,[PhotoViewMode]
      ,[VideoView]
      ,[MapView]
      ,ISNULL([SoftwareElevCtrl], 0) AS [SoftwareElevCtrl]
      from workstationsettings
      where workstationname = @workstationname
    </workstationsettings>
    <UpdateWorkstationSettings partitioned="False">
      UPDATE WorkStationSettings SET PhotoViewMode = @PhotoView, VideoView = @VideoView, MapView = @MapView WHERE WorkstationName = @UNCName
    </UpdateWorkstationSettings>
    <zonebyid partitioned="False">Select Description from Zones where ZoneId = @ZoneId</zonebyid>
    <GetConfigZones>
      SELECT ZoneId
      ,Description
      ,StandardName
      ,UTCBias
      ,sBias
      ,sMonth
      ,sDay
      ,sHour
      ,sMinute
      ,sSecond
      ,dBias
      ,dMonth
      ,dDay
      ,dHour
      ,dMinute
      ,dSecond
      ,CAST(DATEADD(MINUTE, UTCBias, dStart) AS smalldatetime) AS dStart
      ,CAST(DATEADD(MINUTE, UTCBias + dBias, sStart) AS smalldatetime) AS sStart
      FROM Zones
    </GetConfigZones>
    <ZonedUtcExecTime partitioned="False">select ca_fn_UTCExecTime(@Start,@Zone,@UtcOffset) asExecTime</ZonedUtcExecTime>
    <zonelookup partitioned="False">select ZoneId as ValueMember     ,Description  as DisplayMember from zones order by description</zonelookup>
    <APIzonelookup partitioned="False">select ZoneId as ValueMember     ,Description  as DisplayMember from zones order by description</APIzonelookup>
    <GetConfiguredSoftwareElevCtrl partitioned="False">SELECT WorkstationName AS DisplayMember, WorkstationName AS ValueMember from [WorkStationSettings]  where SoftwareElevCtrl = 1 order by [WorkstationName]</GetConfiguredSoftwareElevCtrl>
    <GetReaderPriority partitioned="False">SELECT [PnlRef],[RdrNo],[FDPrior],[OTLPrior],[DuPrior],[TrkPrior],[VPrior],[APBPrior],[OTHPrior],[ManPrior],[BypPrior],[FreePrior],[PINPrior],[ValidPrior],[LastUpdated],[LastOperator],[LastWorkStation],[caObjectId] FROM [ReaderPriority] WHERE PnlRef=@PnlRef AND RdrNo=@RdrNo</GetReaderPriority>
    <GetMaxFloorNumbers partitioned="True">SELECT MAX(FloorNumber) AS FloorNumber FROM ElevFloors WHERE LastOperator=@LastOperator AND FloorNumber >= 1</GetMaxFloorNumbers>
    <ApiPersonalReport partitioned="True">
      SELECT * FROM (
      SELECT CAST(B.Facility AS varchar(15)) AS Facility, CAST(B.Badge AS varchar(40)) AS Badge, ISNULL(P.LastName, '') + ', ' + ISNULL(P.FrstName, '') AS Name, CAST(B.Issue AS varchar(15)) AS Issue, B.Track, B.Escort,
      CONVERT(CHAR(11), B.ActvDate, 101) AS ActvDate, CONVERT(CHAR(11), B.ExprDate, 101) AS ExprDate, CAST(B.Embossed AS varchar(15)) AS Embossed, CAST(AA.Description AS varchar(50)) AS APBArea,
      CAST(MH.Description AS varchar(50)) AS HolidayCalendar, CAST(B.AgencyCode AS varchar(15)) AS AgencyCode, CAST(B.SiteNo AS varchar(15)) AS SiteNo, CAST(B.Series AS varchar(15)) AS Series, CONVERT(CHAR(11), B.SDate, 101) AS HireDate,
      CONVERT(char(11), DATEADD(MINUTE, 360, B.LastUpdated), 101) + SUBSTRING(CONVERT(CHAR(19), DATEADD(MINUTE, 360, B.LastUpdated), 100), 12, 19) AS LastUpdated, DI.DepartmentName, LI.Location, CAST(P.Vehicle AS varchar(15)) AS Vehicle,
      CAST(P.License AS varchar(50)) AS License, CASE WHEN P.SupervisorID IS NOT NULL THEN isnull(S.LastName, '') + ',' + ' ' + isnull(S.FrstName, '') END AS SupervisorName, P.Supervisor, CAST(P.SSN AS varchar(15)) AS SSN, CI.CompanyName,
      CAST(B.OrgCategory AS varchar(15)) AS OrgCategory, CAST(B.OrgId AS varchar(15)) AS OrgId, B.AccessTime, B.APBSet, P.DateOfBirth, B.DurUse, P.Enabled, P.PersonID, P.PersonID AS caObjectId, P.Phone, P.Gender, B.InitLoad, P.LastName, P.FrstName, P.MiddleName, B.Resident, P.ContPhone,
      B.ShuntId, PA.PointAccess, BA.accessgroup1, BA.AccGrpActivationDate1, BA.AccGrpExpirationDate1, BA.accessgroup2, BA.AccGrpActivationDate2, BA.AccGrpExpirationDate2, BA.accessgroup3, BA.AccGrpActivationDate3, BA.AccGrpExpirationDate3,
      BA.accessgroup4, BA.AccGrpActivationDate4, BA.AccGrpExpirationDate4, BA.accessgroup5, BA.AccGrpActivationDate5, BA.AccGrpExpirationDate5, BA.accessgroup6, BA.AccGrpActivationDate6, BA.AccGrpExpirationDate6, BA.accessgroup7,
      BA.AccGrpActivationDate7, BA.AccGrpExpirationDate7, BA.accessgroup8, BA.AccGrpActivationDate8, BA.AccGrpExpirationDate8, BA.accessgroup9, BA.AccGrpActivationDate9, BA.AccGrpExpirationDate9, BA.accessgroup10, BA.AccGrpActivationDate10,
      BA.AccGrpExpirationDate10, BA.accessgroup11, BA.AccGrpActivationDate11, BA.AccGrpExpirationDate11, BA.accessgroup12, BA.AccGrpActivationDate12, BA.AccGrpExpirationDate12, BA.accessgroup13, BA.AccGrpActivationDate13, BA.AccGrpExpirationDate13,
      BA.accessgroup14, BA.AccGrpActivationDate14, BA.AccGrpExpirationDate14, BA.accessgroup15, BA.AccGrpActivationDate15, BA.AccGrpExpirationDate15, BA.accessgroup16, BA.AccGrpActivationDate16, BA.AccGrpExpirationDate16,
      CAST(B.PersPIVId AS varchar(40)) AS PersPIVId, BP.BadgeImage, B.UTCOffset
      FROM Person AS P
      LEFT OUTER JOIN Badge AS B ON P.PersonID = B.PersonID
      LEFT OUTER JOIN BadgePhoto AS BP ON (ImageTypeID = 0) AND BP.PersonID = B.PersonID
      LEFT OUTER JOIN DepartmentInfo AS DI ON DI.DepartmentID = P.DeptID
      LEFT OUTER JOIN Person AS S ON P.SupervisorID = S.PersonID
      LEFT OUTER JOIN LocationInfo AS LI ON LI.LocationID = P.LocationID
      LEFT OUTER JOIN CompanyInfo AS CI ON CI.CompanyID = P.CompanyID
      LEFT OUTER JOIN APBAreas AS AA ON AA.AreaNo = B.APBArea
      LEFT OUTER JOIN MHoliday AS MH ON MH.CalendarNo = B.HolidayCalendar
      LEFT OUTER JOIN BadgeAccess AS PA ON (PointAccess = 1) AND PA.Badge = B.Badge AND PA.Facility = B.Facility
      LEFT OUTER JOIN ca_vw_BadgeAccessDetails AS BA ON BA.Badge = B.Badge AND BA.Facility = B.Facility
      ) AS PersonalReportTab
    </ApiPersonalReport>
    <UserFieldsQuery partitioned="False">
      SELECT * FROM [dbo].[UserFields] WHERE Facility = @Facility AND Badge = @Badge
    </UserFieldsQuery>
</queries>
  <lists>
    <apbtypelist>
      <items>
        <item value="2">NEUTRAL</item>
        <item value="0">IN</item>
        <item value="1">OUT</item>
      </items>
    </apbtypelist>
    <badgeformatlist>
      <items>
        <item value="1">ABA</item>
        <item value="129">ABA - No Degrade</item>
        <item value="0">Non ABA</item>
        <item value="128">Non ABA - No Degrade</item>
        <item value="2">Insertion</item>
        <item value="130">Insertion - No Degrade</item>
        <item value="3">Key</item>
        <item value="131">Key - No Degrade</item>
        <item value="64">FacBadge</item>
        <item value="192">FacBadge - No Degrade</item>
        <item value="23">PIV (MSB)</item>
        <item value="151">PIV (MSB) - No Degrade</item>
        <item value="24">PIV (LSB)</item>
        <item value="152">PIV (LSB) - No Degrade</item>
        <item value="25">PIV200</item>
        <item value="153">PIV200 - No Degrade</item>
      </items>
    </badgeformatlist>
    <baudlist>
      <items>
        <item value="921600">921600</item>
        <item value="460800">460800</item>
        <item value="115200">115200</item>
        <item value="57600">57600</item>
        <item value="38400">38400</item>
        <item value="19200">19200</item>
        <item value="9600">9600 - recommended for legacy panels</item>
        <item value="4800">4800</item>
        <item value="2400">2400</item>
        <item value="0">0 - valid only for Ethernet channels</item>
      </items>
    </baudlist>
    <APIbaudlist>
      <items>
        <item value="921600">921600</item>
        <item value="460800">460800</item>
        <item value="115200">115200</item>
        <item value="57600">57600</item>
        <item value="38400">38400</item>
        <item value="19200">19200</item>
        <item value="9600">9600 - recommended for legacy panels</item>
        <item value="4800">4800</item>
        <item value="2400">2400</item>
        <item value="0">0 - valid only for Ethernet channels</item>
      </items>
    </APIbaudlist>
    <catcntrcontrollist>
      <items>
        <item value="1">Category 1</item>
        <item value="2">Category 2</item>
        <item value="3">Category 3</item>
        <item value="4">Category 4</item>
        <item value="5">Category 5</item>
        <item value="6">Category 6</item>
        <item value="7">Category 7</item>
        <item value="8">Category 8</item>
        <item value="9">Category 9</item>
        <item value="10">Category 10</item>
        <item value="11">Category 11</item>
        <item value="12">Category 12</item>
        <item value="13">Category 13</item>
        <item value="14">Category 14</item>
        <item value="15">Category 15</item>
        <item value="16">Category 16</item>
      </items>
    </catcntrcontrollist>
    <categorycontrollist>
      <items>
        <item value="0">None</item>
        <item value="1">Enable</item>
        <item value="2">Disable</item>
      </items>
    </categorycontrollist>
    <catcontrollist>
      <items>
        <item value="0">None</item>
        <item value="1">Cancel Denial</item>
        <item value="2">Deny Access</item>
      </items>
    </catcontrollist>
    <controllist>
      <items>
        <item value="0">None</item>
        <item value="1">Momentary</item>
        <item value="2">ON</item>
        <item value="3">Off</item>
      </items>
    </controllist>
    <daylist>
      <items>
        <item value="1">MON</item>
        <item value="2">TUE</item>
        <item value="3">WED</item>
        <item value="4">THU</item>
        <item value="5">FRI</item>
        <item value="6">SAT</item>
        <item value="7">SUN</item>
        <item value="8">HOL</item>
      </items>
    </daylist>
    <dvrtypelist>
      <items>
        <item value="0">None</item>
        <item value="1">DVR caRemoteView [INTEGRAL]</item>
        <item value="2">DVR caCompleteView [SALIENT]</item>
        <item value="3">DVR VideoView [NAPCO]</item>
      </items>
    </dvrtypelist>
    <genderlist>
      <items>
        <item value="0">Unspecified</item>
        <item value="1">Male</item>
        <item value="2">Female</item>
      </items>
    </genderlist>
    <ElevetorDoorType>
      <items>
        <item value="0">Unspecified</item>
        <item value="1">Front</item>
        <item value="2">Rear</item>
      </items>
    </ElevetorDoorType>
    <DecMode>
      <items>
        <item value="0">Unspecified</item>
        <item value="1">Mode 1 (Default Floor)</item>
        <item value="2">Mode 2 (Authorized Floors)</item>
        <item value="3">Mode 3 (Destination Floor)</item>
        <item value="4">Mode 4 (Default or Authorized Floors)</item>
      </items>
    </DecMode>
    <inputcontrollist>
      <items>
        <item value="0">None</item>
        <item value="1">Enable</item>
        <item value="2">Disable</item>
        <item value="3">Switch Normal State</item>
      </items>
    </inputcontrollist>
    <KeypadOptionList>
      <items>
        <item value="0">Keypads not Used</item>
        <item value="1">4-Digit PIN</item>
        <item value="2">9-Digit PIN</item>
      </items>
    </KeypadOptionList>
    <vechileTrack>
      <items>
        <item value="0">Not Used</item>
        <item value="1">Vehicle Tracking</item>
      </items>
    </vechileTrack>
    <APBResetList>
      <items>
        <item value="255">Set Next Use</item>
        <item value="1">Outside</item>
      </items>
    </APBResetList>
    <maxbadgelength>
      <items>
        <item value="5">5 Digit</item>
        <item value="7">7 Digit</item>
        <item value="9">9 Digit</item>
        <item value="11">11 Digit</item>
        <item value="13">13 Digit</item>
        <item value="15">15 Digit</item>
        <item value="17">17 Digit</item>
        <item value="19">19 Digit</item>
      </items>
    </maxbadgelength>
    <lockcontrollist>
      <items>
        <item value="0">On Open</item>
        <item value="1">On Close</item>
        <item value="2">On Timeout</item>
      </items>
    </lockcontrollist>
    <manprivlist>
      <items>
        <item value="0">All</item>
        <item value="1">Priv 1</item>
        <item value="2">Priv 2</item>
        <item value="3">Priv 3</item>
        <item value="4">Priv 4</item>
        <item value="5">Priv 5</item>
        <item value="6">Priv 6</item>
        <item value="7">Priv 7</item>
        <item value="8">Priv 8</item>
      </items>
    </manprivlist>
    <operatormanprivlist>
      <items>
        <item value="1">Privilege 1</item>
        <item value="2">Privilege 2</item>
        <item value="3">Privilege 3</item>
        <item value="4">Privilege 4</item>
        <item value="5">Privilege 5</item>
        <item value="6">Privilege 6</item>
        <item value="7">Privilege 7</item>
        <item value="8">Privilege 8</item>
      </items>
    </operatormanprivlist>
    <maxaccessgroups>
      <items>
        <item value="2">2</item>
        <item value="3">3</item>
        <item value="4">4</item>
        <item value="5">5</item>
        <item value="6">6</item>
        <item value="7">7</item>
        <item value="8">8</item>
        <item value="9">9</item>
        <item value="10">10</item>
        <item value="11">11</item>
        <item value="12">12</item>
        <item value="13">13</item>
        <item value="14">14</item>
        <item value="15">15</item>
        <item value="16">16</item>
      </items>
    </maxaccessgroups>
    <orgcatlist>
      <items>
        <item value="0">Not Used</item>
        <item value="1">Federal Gov't Agency(1)</item>
        <item value="2">State Gov't Agency(2)</item>
        <item value="3">Commercial Enterprise(3)</item>
        <item value="4">Foreign Gov't(4)</item>
        <item value="5">Category 5</item>
        <item value="6">Category 6</item>
        <item value="7">Category 7</item>
        <item value="8">Category 8</item>
        <item value="9">Category 9</item>
      </items>
    </orgcatlist>
    <persorglist>
      <items>
        <item value="0">Not Used</item>
        <item value="1">Employee(1)</item>
        <item value="2">Civil(2)</item>
        <item value="3">Pers/Org 3</item>
        <item value="4">Pers/Org 4</item>
        <item value="5">Pers/Org 5</item>
        <item value="6">Pers/Org 6</item>
        <item value="7">Pers/Org 7</item>
        <item value="8">Pers/Org 8</item>
        <item value="9">Pers/Org 9</item>
      </items>
    </persorglist>
    <ptzpresetlist>
      <items>
        <item value="0">None</item>
        <item value="1">1</item>
        <item value="2">2</item>
        <item value="3">3</item>
        <item value="4">4</item>
        <item value="5">5</item>
        <item value="6">6</item>
        <item value="7">7</item>
        <item value="8">8</item>
        <item value="9">9</item>
        <item value="10">10</item>
        <item value="11">11</item>
        <item value="12">12</item>
        <item value="13">13</item>
        <item value="14">14</item>
        <item value="15">15</item>
        <item value="16">16</item>
        <item value="17">17</item>
        <item value="18">18</item>
        <item value="19">19</item>
        <item value="20">20</item>
        <item value="21">21</item>
        <item value="22">22</item>
        <item value="23">23</item>
        <item value="24">24</item>
        <item value="25">25</item>
        <item value="26">26</item>
        <item value="27">27</item>
        <item value="28">28</item>
        <item value="29">29</item>
        <item value="30">30</item>
        <item value="31">31</item>
        <item value="32">32</item>
      </items>
    </ptzpresetlist>
    <readercontrollist>
      <items>
        <item value="0">None</item>
        <item value="1">Enable</item>
        <item value="2">Disable</item>
        <item value="3">Lock</item>
        <item value="4">Lock and Enable</item>
        <item value="5">Lock and Disable</item>
        <item value="6">Unlock</item>
        <item value="7">Unlock and Enable</item>
        <item value="8">Unlock and Disable</item>
        <item value="9">Unlock and Hold</item>
        <item value="10">Hold Unlock and Enable</item>
        <item value="11">Hold Unlock and Disable</item>
        <item value="12">Suppress OTL</item>
        <item value="13">Enable OTL</item>
        <item value="14">Disable Bypass</item>
        <item value="15">Enable Bypass</item>
        <item value="16">Incr/Decr Category Counter(s)</item>
      </items>
    </readercontrollist>
    <readerundocontrollist>
      <items>
        <item value="0">None</item>
        <item value="1">Disable</item>
        <item value="2">Enable</item>
        <item value="3">Unlock</item>
        <item value="4">Unlock and Disable</item>
        <item value="5">Unlock and Enable</item>
        <item value="6">Lock</item>
        <item value="7">Lock and Disable</item>
        <item value="8">Lock and Enable</item>
        <item value="9">Lock (Undo Hold)</item>
        <item value="10">Lock and Disable (Undo Hold)</item>
        <item value="11">Lock and Enable (Undo Hold)</item>
        <item value="12">Suppress OTL</item>
        <item value="13">Enable OTL</item>
        <item value="14">Enable Bypass</item>
        <item value="15">Disable Bypass</item>
        <item value="16">Incr/Decr Category Counter(s)</item>
      </items>
    </readerundocontrollist>
    <relaycontrollist>
      <items>
        <item value="0">None</item>
        <item value="1">On</item>
        <item value="2">Off</item>
      </items>
    </relaycontrollist>
    <taapbtypelist>
      <items>
        <item value="0">None</item>
        <item value="16">In</item>
        <item value="32">Out</item>
        <item value="48">In/Out</item>
      </items>
    </taapbtypelist>
    <twopersonreadertypelist>
      <items>
        <item value="0">None</item>
        <item value="1">In</item>
        <item value="2">Out</item>
        <item value="3">Out w/Override</item>
        <item value="4">Always</item>
      </items>
    </twopersonreadertypelist>
    <typelist>
      <items>
        <item value="3">Network - Ethernet connection</item>
        <item value="2">Modem - use Dial Up to connect</item>
        <item value="1">Cable - physical serial port</item>
        <item value="0">Not Used - connection is disabled</item>
        <item value="10">Wireless Gateway</item>
      </items>
    </typelist>
    <APItypelist>
      <items>
        <item value="3">Network - Ethernet connection</item>
        <item value="2">Modem - use Dial Up to connect</item>
        <item value="1">Cable - physical serial port</item>
        <item value="0">Not Used - connection is disabled</item>
        <item value="10">Wireless Gateway</item>
      </items>
    </APItypelist>
    <undocategorycontrollist>
      <items>
        <item value="0">None</item>
        <item value="1">Disable</item>
        <item value="2">Enable</item>
      </items>
    </undocategorycontrollist>
    <undoinputcontrollist>
      <items>
        <item value="0">None</item>
        <item value="1">Disable</item>
        <item value="2">Enable</item>
        <item value="3">Switch Normal State</item>
      </items>
    </undoinputcontrollist>
    <undorelaycontrollist>
      <items>
        <item value="0">None</item>
        <item value="1">Momentary</item>
        <item value="2">Off</item>
        <item value="3">ON</item>
      </items>
    </undorelaycontrollist>
    <videoeventtypelist>
      <items>
        <item value="0">Normal</item>
        <item value="1">Abnormal</item>
        <item value="2">Both</item>
      </items>
    </videoeventtypelist>
  </lists>
  <pagedqueries>
    <accessgroupsgrid partitioned="True" objectidcolumnname="caObjectId">
      <finalorderby>Description</finalorderby>
      <orderby>Description</orderby>
      <select>
        caObjectID , Description, AgrpNo, LastUpdated
      </select>
      <finalselect>
        1
        , caObjectID
        , Description
        , AgrpNo
        , NULL
        , LastUpdated
        , ''
        , 1
        , NULL
        , NULL
        , NULL
        , NULL
        , NULL
        , NULL
        , NULL
        , NULL
        , NULL
        ,NULL
      </finalselect>
      <where>isnull(pointaccess,0)=0 and AgrpNo&lt;&gt;0</where>
      <table>mAccGrp</table>
    </accessgroupsgrid>
    <accessgroupslookup partitioned="True" objectidcolumnname="caObjectId">
      <finalorderby>Description</finalorderby>
      <orderby>Description</orderby>
      <select>AgrpNo , Description </select>
      <finalselect>
        1
        , newid()
        , Description
        , AgrpNo
        , NULL
        , GetDate()
        , ''
        , 1
        , NULL
        , NULL
        , NULL
        , NULL
        , NULL
        , NULL
        , NULL
        , NULL
        , NULL
        ,NULL
      </finalselect>
      <where>(isnull(PointAccess,0)=0) or AgrpNo=0</where>
      <table>MAccGrp</table>
    </accessgroupslookup>
    <accessgroupsnofilterlookup partitioned="True" objectidcolumnname="caObjectId">
      <finalorderby>Description</finalorderby>
      <orderby>Description</orderby>
      <select>AgrpNo , Description </select>
      <finalselect>
        1
        , newid()
        , 'No Access' as Description
        , 0
        , NULL
        , GetDate()
        , null
        , 1
        , NULL
        , NULL
        , NULL
        , NULL
        , NULL
        , NULL
        , NULL
        , NULL
        , NULL
        ,NULL
        ,0 union select
        1
        , newid()
        , '&lt;No Filter&gt;' as Description
        , -1
        , NULL
        , GetDate()
        , null
        , 1
        , NULL
        , NULL
        , NULL
        , NULL
        , NULL
        , NULL
        , NULL
        , NULL
        , NULL
        ,NULL
        ,0 union select
        1
        , newid()
        , Description
        , AgrpNo
        , NULL
        , GetDate()
        , ''
        , 1
        , NULL
        , NULL
        , NULL
        , NULL
        , NULL
        , NULL
        , NULL
        , NULL
        , NULL
        ,NULL
      </finalselect>
      <where>(isnull(PointAccess,0)=0)</where>
      <table>MAccGrp</table>
    </accessgroupsnofilterlookup>
    <apbareaslookup partitioned="True" objectidcolumnname="caObjectId">
      <finalorderby>CASE WHEN AreaNo IN (0, 1) THEN 1 END  DESC, CASE WHEN AreaNo > 1 THEN Description END  ASC</finalorderby>
      <orderby>CASE WHEN AreaNo IN (0, 1) THEN 1 END  DESC, CASE WHEN AreaNo > 1 THEN Description END  ASC</orderby>
      <select>AreaNo,Description</select>
      <finalselect>
        1
        , newid()
        , Description
        , AreaNo
        , NULL
        , GetDate()
        , ''
        , 1
        , NULL
        , NULL
        , NULL
        , NULL
        , NULL
        , NULL
        , NULL
        , NULL
        , NULL
        ,NULL
      </finalselect>
      <where>
        AreaNo &lt;&gt; 255
      </where>
      <table>apbareas</table>
    </apbareaslookup>
    <apbareasnofilterlookup partitioned="True" objectidcolumnname="caObjectId">
      <finalorderby>Description</finalorderby>
      <orderby>Description</orderby>
      <select>AreaNo,Description</select>
      <finalselect>
        1
        , newid()
        , '&lt;No Filter&gt;' as Description
        , -1
        , NULL
        , GetDate()
        , null
        , 1
        , NULL
        , NULL
        , NULL
        , NULL
        , NULL
        , NULL
        , NULL
        , NULL
        , NULL
        ,NULL
        ,0 union select
        1
        , newid()
        , 'Set Next Use' as Description
        , 255
        , NULL
        , GetDate()
        , ''
        , 1
        , NULL
        , NULL
        , NULL
        , NULL
        , NULL
        , NULL
        , NULL
        , NULL
        , NULL
        ,NULL
        ,0 union select
        1
        , newid()
        , Description
        , AreaNo
        , NULL
        , GetDate()
        , ''
        , 1
        , NULL
        , NULL
        , NULL
        , NULL
        , NULL
        , NULL
        , NULL
        , NULL
        , NULL
        ,NULL
      </finalselect>
      <where>
      </where>
      <table>apbareas</table>
    </apbareasnofilterlookup>
    <assignagfromreader partitioned="True" objectidcolumnname="caObjectId">
      <finalorderby>readername</finalorderby>
      <orderby>readername</orderby>
      <select>pnlRef, RdrNo,ReaderName,lastupdated</select>
      <finalselect>
        1, newid() , 'None'  as ReaderName, 0, 0       , GetDate(), null, 1			 , 0   	 , NULL
        , NULL       , NULL       , NULL       , NULL       , NULL       , NULL       , NULL       ,NULL
        ,0 union select
        1, newid()
        , Convert(Char(6),PnlRef) +'- '+Convert(Char(3),RdrNo) + ' ' + ReaderName
        , PnlRef, RdrNo, lastupdated, '', 1, null, null
        , null,NULL ,NULL ,NULL ,NULL ,NULL ,NULL ,NULL
      </finalselect>
      <where>
      </where>
      <table>reader</table>
    </assignagfromreader>
    <audittrailgrid partitioned="False" objectidcolumnname="caObjectID">
      <finalorderby>revisionstamp desc</finalorderby>
      <orderby>revisionstamp desc</orderby>
      <select>
        AuditId,TableName,revisionstamp,OperatorName,StationName,Actions, CASE WHEN TableName = 'SystemSettings' THEN Description + (SELECT CASE WHEN COUNT(1) &gt; 3 THEN ' (Multiple Changed) ' WHEN COUNT(1) = 2 THEN '' ELSE
        ' (' + (CASE WHEN EXISTS(SELECT 1 FROM DBAudit AS scripting WHERE scripting.ParentAuditId = dbaudit.AuditId AND scripting.TableName = 'scriptingServers') THEN 'Scripting'
        WHEN EXISTS(SELECT 1 FROM DBAudit AS scripting WHERE scripting.ParentAuditId = dbaudit.AuditId AND scripting.TableName = 'CentralStationServer') THEN 'Central Station'
        WHEN EXISTS(SELECT 1 FROM DBAudit AS scripting WHERE scripting.ParentAuditId = dbaudit.AuditId AND scripting.TableName = 'napcoWorkstations') THEN 'Napco Workstations'
        WHEN EXISTS(SELECT 1 FROM DBAudit AS scripting WHERE scripting.ParentAuditId = dbaudit.AuditId AND scripting.TableName = 'UserFieldDef') THEN 'User Field'
        ELSE 'Others' END) + ' Changed)' END from DBAudit AS DBA where DBA.ParentAuditId = dbaudit.AuditId) ELSE Description END AS Description,OldData,NewData,ChangedColumns,LastOperator,caObjectID,UTCOffset
      </select>
      <finalselect>
        1
        ,NewId()
        ,TableName
        ,AuditId
        ,NULL
        ,revisionstamp
        ,OperatorName
        ,1
        ,NULL
        ,StationName
        ,CASE Actions
        WHEN ('L') THEN 'Log'
        WHEN ('I') THEN 'Insert'
        WHEN ('U') THEN 'Edit'
        WHEN ('D') THEN 'Delete'
        ELSE 'None'
        END as Action
        ,Description
        ,OldData
        ,NewData
        ,ChangedColumns
        ,LastOperator
        ,caObjectID
        ,UTCOffset
      </finalselect>
      <where>
        (ParentAuditId IS NULL OR AuditId = ParentAuditId)
      </where>
      <table>dbaudit</table>
    </audittrailgrid>
    <companyidlookup partitioned="False" objectidcolumnname="CompanyID">
      <finalorderby>CompanyName</finalorderby>
      <orderby>CompanyName</orderby>
      <select>CompanyName</select>
      <finalselect>
        1
        , newid()
        , CompanyName
        , null
        , NULL
        , GetDate()
        , null
        , 1
        , null
        , NULL
        , NULL       , NULL       , NULL       , NULL       , NULL       , NULL       , NULL       ,NULL
      </finalselect>
      <where>
      </where>
      <table>CompanyInfo</table>
    </companyidlookup>
    <departmentlookup partitioned="False" objectidcolumnname="DepartmentID">
      <finalorderby>DepartmentName</finalorderby>
      <orderby>DepartmentName</orderby>
      <select>DepartmentName</select>
      <finalselect>
        1
        , newid()
        , DepartmentName
        , null
        , NULL
        , GetDate()
        , null
        , 1
        , null
        , NULL
        , NULL       , NULL       , NULL       , NULL       , NULL       , NULL       , NULL       ,NULL

      </finalselect>
      <where>
      </where>
      <table>DepartmentInfo</table>
    </departmentlookup>
    <inputlookup partitioned="True" objectidcolumnname="caObjectId">
      <finalorderby>InputName</finalorderby>
      <orderby>InputName</orderby>
      <select> InpNo ,InputName</select>
      <finalselect>
        1
        , '00000000-0000-0000-0000-000000000000'
        , 'None' as InputName
        , 0 as InpNo
        , NULL
        , GetDate()
        , ''
        , 1
        , NULL
        , NULL
        , NULL
        , NULL
        , NULL
        , NULL
        , NULL
        , NULL
        , NULL
        ,NULL
        ,0 union select
        1
        , newid()
        , InputName
        ,  InpNo
        , NULL
        , GetDate()
        , ''
        , 1
        , NULL
        , NULL
        , NULL
        , NULL
        , NULL
        , NULL
        , NULL
        , NULL
        , NULL
        ,NULL
      </finalselect>
      <where>
      </where>
      <table>Input</table>
    </inputlookup>
    <linkbypanellookup partitioned="False" objectidcolumnname="caObjectid">
      <finalorderby>LinkName</finalorderby>
      <orderby>LinkName</orderby>
      <select>ProgNo, LinkName, PnlRef </select>
      <finalselect>
        1
        , newid()
        , LinkName
        , ProgNo
        , PnlRef
        , GetDate()
        , ''
        , 1
        , NULL
        , NULL
        , NapcoPanel       , NULL       , NULL       , NULL       , NULL       , NULL       , NULL        ,NULL
      </finalselect>
      <where>
      </where>
      <table>Link</table>
    </linkbypanellookup>
    <locationlookup partitioned="False" objectidcolumnname="LocationID">
      <finalorderby>location</finalorderby>
      <orderby>location</orderby>
      <select>location</select>
      <finalselect>
        1
        , newid()
        , location
        , null
        , NULL
        , GetDate()
        , null
        , 1
        , null
        , NULL
        , NULL       , NULL       , NULL       , NULL       , NULL       , NULL       , NULL       ,NULL
      </finalselect>
      <where>
      </where>
      <table>LocationInfo</table>
    </locationlookup>
    <lockoutarealookup partitioned="False" objectidcolumnname="caObjectId">
      <finalorderby>AreaName</finalorderby>
      <orderby>AreaName</orderby>
      <select>AreaNo, AreaName</select>
      <finalselect>1
, newId()</finalselect>
      <where>
      </where>
      <table>MLockdownAreas</table>
    </lockoutarealookup>
    <elevatorfacilitylookup>
      <finalorderby>ElevFacilityName</finalorderby>
      <orderby>ElevFacilityName</orderby>
      <select>ElevFacilityId, ElevFacilityName</select>
      <finalselect>
        1
        , newId()
      </finalselect>
      <where>
      </where>
      <table>ElevFacilities</table>
    </elevatorfacilitylookup>
    <mcomlookup partitioned="False" objectidcolumnname="caObjectId">
      <finalorderby>Description </finalorderby>
      <orderby>Description </orderby>
      <select>HCSNo,Description </select>
      <finalselect>
        1
        , newid()
        , Description
        , HCSNo
        , NULL
        , GetDate()
        , ''
        , 1
        , NULL
        , NULL
        , NULL
        , NULL
        , NULL
        , NULL
        , NULL
        , NULL
        , NULL
        ,NULL
      </finalselect>
      <where>
      </where>
      <table>MCOM</table>
    </mcomlookup>
    <mholidaylookup partitioned="False" objectidcolumnname="caObjectId">
      <finalorderby>Description</finalorderby>
      <orderby>Description</orderby>
      <select>CalendarNo ,Description </select>
      <finalselect>
        1
        , newid()
        , Description
        , CalendarNo
        , NULL
        , GetDate()
        , ''
        , 1
        , NULL
        , NULL
        , NULL
        , NULL
        , NULL
        , NULL
        , NULL
        , NULL
        , NULL
        ,NULL
      </finalselect>
      <where>
      </where>
      <table>MHoliday</table>
    </mholidaylookup>
    <mholidaynofilterlookup partitioned="False" objectidcolumnname="caObjectId">
      <finalorderby>Description</finalorderby>
      <orderby>Description</orderby>
      <select>CalendarNo ,Description </select>
      <finalselect>
        1
        , newid()
        , '&lt;No Filter&gt;' as Description
        , -1
        , NULL
        , GetDate()
        , null
        , 1
        , NULL
        , NULL
        , NULL
        , NULL
        , NULL
        , NULL
        , NULL
        , NULL
        , NULL
        ,NULL
        ,0 union select
        1
        , newid()
        , Description
        , CalendarNo
        , NULL
        , GetDate()
        , ''
        , 1
        , NULL
        , NULL
        , NULL
        , NULL
        , NULL
        , NULL
        , NULL
        , NULL
        , NULL
        ,NULL
      </finalselect>
      <where>
      </where>
      <table>MHoliday</table>
    </mholidaynofilterlookup>
    <mshuntlookup partitioned="True" objectidcolumnname="caObjectId">
      <finalorderby>ShuntName</finalorderby>
      <orderby>ShuntName</orderby>
      <select>ShuntID ,ShuntName,Active</select>
      <finalselect>
        1
        , newid()
        , ShuntName
        , ShuntID
        , NULL
        , GetDate()
        , ''
        , 1
        , Active
        , NULL
        , NULL       
        , NULL       
        , NULL       
        , NULL       
        , NULL       
        , NULL       
        , NULL       
        ,NULL
      </finalselect>
      <where>
        ShuntID &gt; 0 OR ShuntID = 0
      </where>
      <table>MShunt</table>
    </mshuntlookup>
    <mtimezonlookup partitioned="True" objectidcolumnname="caObjectid">
      <finalorderby>CASE WHEN TzNum = 0 THEN TzNum END  DESC, CASE WHEN TzNum > 0 THEN Description END  ASC </finalorderby>
      <orderby>description </orderby>
      <select> TzNum ,description </select>
      <finalselect>
        1
        , newid()
        , Description
        , TzNum
        , NULL
        , GetDate()
        , ''
        , 1
        , NULL
        , NULL
        , NULL
        , NULL
        , NULL
        , NULL
        , NULL
        , NULL
        , NULL
        ,NULL
      </finalselect>
      <where>
      </where>
      <table>MTimezon</table>
    </mtimezonlookup>
    <napcompermissionslookup partitioned="True" objectidcolumnname="caObjectId">
      <finalorderby>PermissionName</finalorderby>
      <orderby>PermissionName</orderby>
      <select>PermissionID,PermissionName</select>
      <finalselect>
        1
        , newid()
        , PermissionName
        , PermissionID
        , NULL
        , GetDate()
        , ''
        , 1
        , NULL
        , NULL
        , NULL
        , NULL
        , NULL
        , NULL
        , NULL
        , NULL
        , NULL
        ,NULL
      </finalselect>
      <where>
      </where>
      <table>napcoMPermissions</table>
    </napcompermissionslookup>
    <newpanelsunpartlookup partitioned="False">
      <finalorderby>p.PanelName </finalorderby>
      <orderby>p.PanelName </orderby>
      <select> distinct p.Pnlno, p.PanelType, p.PanelName</select>
      <finalselect>
        1
        , newid()
        , PanelName
        , Pnlno
        , PanelType
        , GetDate()
        , ''
        , 1
        , NULL
        , NULL
        , NULL       , NULL       , NULL       , NULL       , NULL       , NULL       , NULL        ,NULL
      </finalselect>
      <where>( p.PanelType in (3,5,6,7,8,9,10,11,12,13,14,15,16,17,101,102))</where>
      <table>panel p  INNER JOIN CategoryCounters c ON p.PnlNo=c.PnlNo</table>
    </newpanelsunpartlookup>
    <panellookup partitioned="True" objectidcolumnname="caObjectId">
      <finalorderby>PanelName</finalorderby>
      <orderby>PanelName</orderby>
      <select>pnlno, PanelName, paneltype,NapcoPanel,AperioType</select>
      <finalselect>
        1
        , newid()
        , PanelName
        , Pnlno
        , PanelType
        , GetDate()
        , ''
        , 1
        , NULL
        , NULL
        , NapcoPanel       , NULL       , NULL       , NULL       , NULL       , NULL       , NULL        ,NULL
      </finalselect>
      <where>
      </where>
      <table>panel</table>
    </panellookup>
    <paneltypelookup partitioned="False">
      <finalorderby>Description </finalorderby>
      <orderby>Description </orderby>
      <select>ID, Description </select>
      <finalselect>
        1
        , newid()
        , Description
        , ID
        , NULL
        , GetDate()
        , ''
        , 1
        , NULL
        , NULL
        , NULL
        , NULL
        , NULL
        , NULL
        , NULL
        , NULL
        , NULL
        ,NULL
      </finalselect>
      <where>
      </where>
      <table>Panel_types</table>
    </paneltypelookup>
    <personnelgrid partitioned="True" objectidcolumnname="PersonId">
      <finalorderby>lastName,frstName</finalorderby>
      <orderby>lastName,frstName</orderby>
      <select>lastname,frstname,PersonId,aGroupNo,Facility,Badge,Enabled,caObjectId,ActvDate,ExprDate,LastUpdated,PIVI,contphone</select>
      <finalselect>
        1, PersonId,lastname +', '+frstname, Facility, Badge, LastUpdated,'', 1, Enabled, caObjectId, lastname, frstname,aGroupNo
        , ActvDate, ExprDate
        , CASE Enabled WHEN (1) THEN 'Yes' ELSE 'No' END          AS EnabledText
        ,PIVI
        ,contphone
        ,NULL
      </finalselect>
      <where>
      </where>
      <table>ca_vw_Personnel</table>
    </personnelgrid>
    <personnelReport partitioned="False" objectidcolumnname="p.PersonId">
      <finalorderby>lastname,frstname</finalorderby>
      <orderby>lastname,frstname,b.facility,b.badge</orderby>
      <select>
        P.caObjectID,
        B.Badge,
        lastname,
        frstname,
        B.APBSet
      </select>
      <finalselect>
        caObjectID,
        Badge,
        ISNULL(LastName,'') AS LastName,
        ISNULL(FrstName,'') AS FirstName,
        APBSet
      </finalselect>
      <where>
      </where>
      <table>
        Person P INNER JOIN Badge B ON P.PersonID = B.PersonID
      </table>
    </personnelReport>
    <personnelsearch partitioned="True" objectidcolumnname="p.PersonId">
      <finalorderby>lastname,frstname,facility,badge</finalorderby>
      <orderby>lastname,frstname,b.facility,b.badge</orderby>
      <select>
        lastname
        , frstname
        , p.PersonId
        , b.Facility
        , b.Badge
        , b.Enabled
        , b.caObjectId
        , b.ActvDate
        , b.ExprDate
        , b.LastUpdated
      </select>
      <finalselect>
        1, PersonId,lastname +', '+frstname, Facility, Badge, LastUpdated, '', 1, Enabled, caObjectId, lastname, frstname
        , ActvDate, ExprDate
        , CASE Enabled WHEN (1) THEN 'Yes' ELSE 'No' END          AS EnabledText
        ,NULL
        ,NULL
      </finalselect>
      <where>
      </where>
      <table>
      </table>
    </personnelsearch>
    <readergrid partitioned="True" objectidcolumnname="caObjectID">
      <finalorderby>pnlref,rdrno</finalorderby>
      <orderby>pnlref,rdrno</orderby>
      <select>caObjectID,PnlRef,RdrNo,Enabled,ReaderName,Escort,ExtShunt,NoOTL,RptByp,BypUnlock,OpnWait,Type,LastUpdated</select>
      <finalselect>
        1
        , caObjectID
        ,ReaderName
        , PnlRef
        , RdrNo
        , LastUpdated
        , ''
        , 1
        , Enabled
        , CASE Escort WHEN (1) THEN 'Yes' ELSE 'No' END           AS Escort
        , CASE ExtShunt WHEN (1) THEN 'Yes' ELSE 'No' END         AS ExtShunt
        , NoOTL
        , CASE RptByp WHEN (1) THEN 'Yes' ELSE 'No' END           AS RptByp
        , CASE BypUnlock WHEN (1) THEN 'Yes' ELSE 'No' END        AS BypUnlock
        , CASE OpnWait WHEN (1) THEN 'Yes' ELSE 'No' END          AS OpnWait
        , CASE Type WHEN (0) THEN 'Door'
        WHEN (1) THEN 'Elevator'
        WHEN (2) THEN 'Badge Validator'
        WHEN (3) THEN 'Wireless Lock'
        ELSE 'No' END AS Type
        , Convert(Char(6),PnlRef) + '- ' + Convert(Char(3),RdrNo) AS READER
        , CASE Enabled WHEN (1) THEN 'Yes' ELSE 'No' END          AS EnabledText

      </finalselect>
      <where>
      </where>
      <table>
        reader
      </table>
    </readergrid>
    <relaylookup partitioned="True" objectidcolumnname="caObjectId">
      <finalorderby>Relayname </finalorderby>
      <orderby>Relayname </orderby>
      <select>RelNo,Relayname </select>
      <finalselect>
        1
        , '00000000-0000-0000-0000-000000000000'
        , 'None' as Relayname
        , 0 as RelNo
        , NULL
        , GetDate()
        , ''
        , 1
        , NULL
        , NULL
        , NULL
        , NULL
        , NULL
        , NULL
        , NULL
        , NULL
        , NULL
        , NULL
        , 0 union select
        1
        , newid()
        , Relayname
        , RelNo
        , NULL
        , GetDate()
        , ''
        , 1
        , NULL
        , NULL
        , NULL
        , NULL
        , NULL
        , NULL
        , NULL
        , NULL
        , NULL
        ,NULL
      </finalselect>
      <where>
      </where>
      <table>Relay</table>
    </relaylookup>
    <supervisorlookup partitioned="True" objectidcolumnname="Personid">
      <finalorderby>Personid, Name</finalorderby>
      <orderby>Personid, Name</orderby>
      <select>Name, Personid</select>
      <finalselect>
        1
        , Personid
        , Name
        , null
        , NULL
        , GetDate()
        , null
        , 1
        , null
        , NULL
        , NULL
        , NULL
        , NULL
        , NULL
        , NULL
        , NULL
        , NULL
        ,NULL
      </finalselect>
      <where>isnull(Supervisor ,'0') &lt;&gt; '0'</where>
      <table>
        (	select LastName + ', ' + FrstName as Name, Personid, Supervisor from Person
        UNION
        SELECT 'None' as Name, '00000000-0000-0000-0000-000000000000' as Personid, 1
        ) as Person
      </table>
    </supervisorlookup>
    <timeschedulelookup partitioned="True" objectidcolumnname="caObjectId">
      <finalorderby>Description</finalorderby>
      <orderby>Description</orderby>
      <select>TzNum , Description</select>
      <finalselect>
        1
        , newid()
        , Description
        , TzNum
        , NULL
        , GetDate()
        , ''
        , 1
        , NULL
        , NULL
        , NULL
        , NULL
        , NULL
        , NULL
        , NULL
        , NULL
        , NULL
        ,NULL
      </finalselect>
      <where>
      </where>
      <table>MTimezon</table>
    </timeschedulelookup>
    <vehicletagreaderlookup partitioned="True" objectidcolumnname="caObjectId">
      <finalorderby>readerName</finalorderby>
      <orderby>readerName</orderby>
      <select>pnlRef, RdrNo ,readerName</select>
      <finalselect>
        1, newid() , 'None' as readerName, 0, 0       , GetDate(), null, 1	, 0  , NULL       , NULL       , NULL       , NULL       , NULL
        , NULL       , NULL       , NULL       ,NULL
        ,0 union select    1
        , newid()
        , readerName
        , RdrNo
        , PnlRef
        , GetDate()
        , ''
        , 1
        , NULL
        , NULL
        , Null       , NULL       , NULL       , NULL       , NULL       , NULL       , NULL        ,NULL
      </finalselect>
      <where>
      </where>
      <table>Reader</table>
    </vehicletagreaderlookup>
  </pagedqueries>
  <reports>
    <AccessGroup>
      <listlookup name="accessgroup">
        <table source="qAccessGroup">AccessGroup</table>
        <table source="qAccessGroupReport">qReport1</table>
        <table source="qAccessGroupReport1">qReport2</table>
      </listlookup>
    </AccessGroup>
    <Attendance>
      <listlookup name="attendance">
        <table source="qAttendanceReport">qReport1</table>
      </listlookup>
    </Attendance>
    <TimeAndAttendance>
      <listlookup name="TimeAndAttendance">
        <table source="qReaderForTimeAndAttendance">Readers</table>
        <table source="qGetTemplate">Templates</table>
        <table source="qDatabaseList">AlternetDataSource</table>
        <table source="qUserFieldDef">UserFields</table>
        <table source="qGetAllDepartments">Departments</table>
        <table source="qGetAllLocations">Locations</table>
        <table source="qGetAllCompanies">Companies</table>
        <table source="qGetAllSupervisors">Supervisors</table>
        <table source="qBadgesForTimeAndAttendance">Badges</table>
        <table source="qTimeAndAttendanceReport">qReport1</table>
      </listlookup>
    </TimeAndAttendance>
    <ActivityLink>
      <listlookup name="ActivityLink">
        <table source="qGetPanels">Panels</table>
        <table source="qActivityLinkReport">qReport1</table>
      </listlookup>
    </ActivityLink>
    <AlertResponse>
      <listlookup name="AlertResponse">
        <table source="qAlertResponseReport">qReport1</table>
      </listlookup>
    </AlertResponse>
    <AuditTrail>
      <listlookup name="AuditTrail">
        <table source="qAuditTrailReport">qReport1</table>
        <table source="qDatabaseList">AlternetDataSource</table>
      </listlookup>
    </AuditTrail>
    <FacilityCode>
      <listlookup name="FacilityCode">
        <table source="qFacilityCodeReport">qReport1</table>
      </listlookup>
    </FacilityCode>
    <Hardware>
      <listlookup name="Hardware">
        <table source="qGetPanels">Panels</table>
        <table source="qGetNAPCOPanels">NapcoPanel</table>
        <table source="qNodes">Nodes</table>
        <table source="qPanelReport">qReport1</table>
        <table source="qReaderReport">qReport2</table>
        <table source="qInputReport">qReport3</table>
        <table source="qRelayReport">qReport4</table>
        <table source="qNapcoPanelReport">qReport5</table>
        <table source="qHardwareActivityLinkReport">qReport6</table>
        <table source="qHardwareCategoryCounter">qReport7</table>
        <table source="qNapcoRelayReport">qReport8</table>
      </listlookup>
    </Hardware>
    <Holidays>
      <listlookup name="Holidays">
        <table source="qHolidaysReport">qReport1</table>
      </listlookup>
    </Holidays>
    <Links>
      <listlookup name="Links">
        <table source="qGetPanels">Panels</table>
        <table source="qGetLinks">Links</table>
        <table source="qLinksReport">qReport1</table>
      </listlookup>
    </Links>
    <InList>
      <listlookup name="InList">
        <table source="qAPBReaders">APBReaders</table>
        <table source="qAPBAreas">APBAreas</table>
        <table source="qAPBNestedAreas">APBNestedAreas</table>
        <table source="qUserFieldDef">UserField</table>
        <table source="qInListReport1">qReport1</table>
        <table source="qInListReport2">qReport2</table>
        <table source="qInListReport3">qReport3</table>
        <table source="qInListReport4">qReport4</table>
      </listlookup>
    </InList>
    <Modem>
      <listlookup name="Modem">
        <table source="nodeslookup">Modem</table>
        <table source="qModems">qReport1</table>
      </listlookup>
    </Modem>
    <Operators>
      <listlookup name="Operators">
        <table source="qOperatorsReport">qReport1</table>
      </listlookup>
    </Operators>
    <TimeSchedules>
      <listlookup name="TimeSchedules">
        <table source="qTimeSchedulesReport">qReport1</table>
      </listlookup>
    </TimeSchedules>
    <Events>
      <listlookup name="Events">
        <table source="qAccessGroupsForParam">AccessGroups</table>
        <table source="qDeviceList">DeviceList</table>
        <table source="qDatabaseList">DatabaseList</table>
        <table source="qGetBadgesList">BadgesForParam</table>
        <table source="qGeneralEventReport">qReport1</table>
        <table source="qPersonalEventReport">qReport2</table>
        <table source="qTemplate">qReport3</table>
        <table source="qAreaAccessListReport">qReport4</table>
      </listlookup>
    </Events>
    <ImportExportUtility>
      <listlookup name="ImportExportUtility">
        <table source="qExportEvents">qReport1</table>
      </listlookup>
    </ImportExportUtility>
    <Badge>
      <listlookup name="Badge">
        <table source="qAccessGroupsForParam">AccessGroups</table>
        <table source="qGetBadgesParameter">Badges</table>
        <table source="qGetReaders">Readers</table>
        <table source="qGetAllDepartments">Departments</table>
        <table source="qGetShuntGroup">ShuntGroups</table>
        <table source="qGetAllLocations">Locations</table>
        <table source="qGetAllCompanies">Companies</table>
        <table source="qGetAllSupervisors">Supervisors</table>
        <table source="qReaderAccessList">qReport1</table>
        <table source="qAccessGroupList">qReport2</table>
        <table source="qBadgeHolderName">qReport3</table>
        <table source="qPersonnelBadgeReport">qReport4</table>
        <table source="qBadgeSearchCriteria">qReport5</table>
        <table source="qPersonnelBadgeReportAll">qReport6</table>
        <table source="qUserFieldBadgeReport">qReport7</table>
        <table source="qBadgeAccessReport">qReport8</table>
        <table source="qBadgeCustomFieldsReport">qReport9</table>
        <table source="qGetApbFirstInReport">ApbFirstIn</table>
        <table source="qBadgeCompressedReport">qReportC</table>
      </listlookup>
    </Badge>
    <SystemSettings>
      <listlookup name="SystemSettings">
        <table source="qSystemSettingsPartOneGetAll">qReport1</table>
        <table source="qSystemSettingsPartTwoGetAll">qReport2</table>
        <table source="qSystemSettingsThreatLevel">qReport3</table>
      </listlookup>
    </SystemSettings>
    <PersonnelInfo>
      <listlookup name="PersonnelInfo">
        <table source="qGetAllDepartments">Departments</table>
        <table source="qGetAllLocations">Locations</table>
        <table source="qGetAllCompanies">Companies</table>
        <table source="qGetAllSupervisors">Supervisors</table>
      </listlookup>
    </PersonnelInfo>
    <Personnel>
      <listlookup name="Personnel">
        <table source="qPersonnelColumnList">ColumnList</table>
        <table source="qUserDefined">UserDefined</table>
        <table source="qSystemSettings">SystemSettings</table>
        <table source="mholidaylookup">MHoliday</table>
        <table source="apbareaswithsetnextlookup">APBArea</table>
      </listlookup>
    </Personnel>
    <ColorSettings>
      <color>
        <color1 A="255" R="0" G="128" B="0" />
        <color2 A="255" R="255" G="255" B="255" />
        <color3 A="255" R="0" G="0" B="139" />
      </color>
    </ColorSettings>
  </reports>
</schema>
