Agemni Wiki > Integration And API's > APIs > Agemni CMS Sync

The Agemni CMS Sync web service is an application that runs on Agemni servers that allows Agemni clients to synchronize data from their Agemni database into a local store.  The web service is an XML interface described below.  Access to the XML inteface requires a programmer, however, we have written a tool called CMSDownload that accesses the XML interfaces without the need of a programmer.

The interfaces allow you to get changes made to your Agemni database within a specified time frame.  So you can get a backup of your current database and keep it up to date by syncing in the changes your company makes periodically (hourly, daily, weekly, etc).  It also lets you specify which tables you wish to synchronize (see below for a list of available tables).  Sample code on how to access the interface programatically is available below on this page.

The CMSDownload tool is a command prompt window executable that allows you to perform all of the different operations that the XML interface exposes.  It will also output to the screen, comma seperated value (CSV) file, or XML.  This data can be imported into a database or viewed in spread sheets.  This tool can be downloaded below on this page.  Check back for updates since this is the mechansim we are using to distribute this tool

"

How To Use/Implement

CMS Sync will get all changes, including creations and modifications, between a certain time period.  The way you are supposed to sync is via a sliding window.   For example, if you want changes every 30 minutes you need to sync the last 30 minutes only not the entire day, week, month, year, etc.  I also recommend 5 minutes subtracted from the start and 5 added to the end to provide a little over lap.  So if its noon the starttime = '07/27/2011 11:25:00' and then end time = '07/27/2011 12:05:00' then you will get all of the changes in the last 30 minutes only.  If you do not use CMS Sync in this way you could be seeing degraded performance with your Agemni CMS Site.  This also causes large data usage for Agemni and you.

Training is required to have this feature enabled.  To schedule a training contact Agemni support.

NOTE: We ask that you use discretion while using this API because the more you request the more load it puts on your system which may affect your other employees' ability to do their work.  It is recommended that you do the syncing either early in the morning or later in the evening to reduce the chances of impacting your system's performance.

Click here to sign up for email alerts concerning changes and updates to this service.            

Below describes the web service for syncing data from Agemni CMS to another system. 

Enabling CMS Sync Web Service

To enable the CMS Sync Web Service you must first contact Agemni support who can set this up for you.  CMS Sync is included in the CMS Premium Service option on your contract with Agemni.  Call 801-377-4004 op.1 to enroll. 
Once your site has been enabled there will be a services tab that you can now see on the employee page.  You may need to have permissions to this tab.  Once you have this you can enable any employee to do CMS Sync by going to this tab and checking Enable CMS Sync.  This will also show you your DN for logging and accessing the web services.  The user name and password will be the same ones used by the enabled employee.
***Please refer to this page with all questions regarding CMS Sync. Please email support@agemni.com if you have any questions that can't be addressed using this page.  
Please do not call the support line with questions about the CMS Sync.  It will not be possible for the engineers to talk over the phone.  The best way to receive feedback on your issues is to put all questions in an email.  The engineers will respond as soon as possible. Please be patient and allow time for them to respond to these emails.

CMS Sync Web Service

The CMS Sync Web Service can be located at the following urls:

https://www.agemni.com/_snet/AgemniLogin.asmx

Method Name                                 
Description                                 
agLogin                    
Authenticates a session that that can be used to access the ADBAccess.asmx                               

                                                                                                       

                                                                                                      

Method Name                                 
Description                                 
getCMSData 
  
This method retrieves CMS data from Agemni between a specific date range. It will only retreive a thousand records at a time so to continue to the next set, make the same request specifying the last record ID from the XML element 'ResponseResultSetItem'. The valid list operations are: accounts, appointment, area, campaigns, employee, invoice, invoice_line_item, leads, notes, dnscodes, dnscommissions, roles, promotions, inventoryitem, equipmentitem, equipmentmaster, rmadetails, syncdatastats, basepackage, basepackageprice, basepackageprogramming, customerprogramming, dnsfunding, funding, item, kitconfigreceivers, kitconfigs, kits, programming, programmingcategory, promokits, invoicetypes, accountupgrades, upgradeoptions, emergencycontact, provider, deletedrecords, arearights, "payroll", "receivertype" and transactions. You can specify which fields to retrieve by including an array of column names (replacing spaces by underscores (_). If you set the first item to * you will get all available. available columns.                      
getCMSDataByCondition                                                                      
getCMSDataByID                                                                      
getCMSTables                                                                      
getCMSTableColumns                                                                      

                                                                                                       

CMS Sync Web Service Protocol    

The Agemi CMS Sync web service uses a SOAP or HTTP Post protocol to exchange messages.
The Web Service Description Language (WSDL) info can be located at:
https://www.agemni.com/_snet/AgemniLogin.asmx?WSDL                               
For detailas on each operation go to the following links:
https://www.agemni.com/_snet/AgemniLogin.asmx?op=agLogin                               
Agemni Test Server WSDLs:

Authentication And Permissions                                      

Authentication is done via a regular Agemni CMS username and password.  This user must be given permissions to access the web service.  This is done by going to the emplyee page and selecting the Service tab.  Then checking CMS Sync.  You will also notice a DN value.  This value will be needed to authenticate as well.

Method details

This section describes the input and output of each operations currently supported with the CMS Sync web service.
The AgemniLogin web service performs secure operations.  You may notice a differnt url consisting of a _snet directory.  Any operations performed on this directory must be over SSL or HTTPS.  If not it will fail.
AgemniLogin
agLogin
Authenticates a session that that can be used to access the ADBAccess.asmx.  Once authenticated with this method you will be able to call the the methods in the ADBAccess web service below.  An authenticated session will last approximatley 24 hours. Login failures will be treated like Agemni CMS failures and can lead to the account be locked out.
Input Name                                 
Description                                 
dn                    
The dn is a string value that identifies who is authenticating and for which company.  This can be found in the employee page under the service tab. 
username The username is a string value that is the username of the Agemni CMS employee who is performing the sync functionaltiy.  This user must have the permissions to perform the sync.
password The password is a string value that is the password for the specified username.  This is considered sensitve information and thus agLogin can be performed only over an SSL connection.

                                                                                                       

 ADBAccess
The ADBAcces web service methods retrieves data from CMS.  You must first authenticate with the agLogin method above.  Once authenticated the below operations may be performed. 
getCMSData
This is a generic method used to get all of the data from Agemni CMS. 

                                                                                      

1) The method takes an operation type that specifies which table to retreive data from. 
Input Name                                 
Description                                 
opName
The opName can be the following values:
"accounts"
"appointment"
"area"
"campaigns"
"employee"
"invoice"
"invoice_line_item" **
"invoiceStatusHistory"
"leads"
"loginhistory"
"notes"
"transactions"***
"dnscodes"
"dnscommissions"
"roles"
"promotions"
"inventoryitem"
"equipmentitem"
"equipmentmaster"
"rmadetails"
"syncdatastats"
"basepackage"
"basepackageprice**"
"basepackageprogramming**"
"customerprogramming"
"dnsfunding"
"funding"
"item"
"kitconfigreceivers"
"kitconfigs"
"kits"
"programming"
"programmingcategory"
"promokits"**
"invoicetypes"
"accountupgrades"
"upgradeoptions"
"emergencycontact"
"provider"
"deletedrecords"
"arearights"
"payroll"
"receivertype"
"payrollbatch"
"payrollbatchchecks"***
"TimeClock"
"TechArriveDepart"
The responses root element will be have the operation name you specified.     
2) They will return all data that has been newly created or modified within a certian time frame. If no time frame is specified it will return all records.  If either the start or end time is specified it will return all data from or ending with the specified date.
 
Input Name                                 
Description                                 
startDate
The start date on which the items to be returned either was created or modified.  This must be in a DateTime format.  eq: 10/25/2008 or 10/25/2008 11:30:00 AM.*                         
endDate The end date on which the items to be returned either was created or modified.  This must be in a DateTime format.  eq: 10/25/2008 or 10/25/2008 11:30:00 AM.*
3) This may return 1000s of records so in order to not overload the servers there is a metering mechanism.  Only 1000 records will be returned at a time.  You specify the next set of 1000 by passingin the last ID (see below). 

Input Element Name                                  Description                                 
lastID ** This is the ID of the last record received.  If you have received less than 1000 then there will be no more sent.  Just submit the same startDate and EndDate with the new lastID and you will get the next set.  See the next section for more details.                              

4) This is a list of columns that you want returned.  If nothing is specified then all will be returned. 

Input Element Name                                  Description                                 
includeList This is an array of strings that contain each column that is wanted to be returned.   Remember to replace spaces with underscores for names since XML can not have spaces in element names.
  5) All results will be returned with the following elements or attributes

Output Element / Attribute Name  
Description                                 
StartDateIn
This is what was sent as input for the startDate.                   
EndDateIn This is what was sent as input for the endDate
lastIDIN***** This is what was sent as input for the lastID
Response This contains a list of ResponseResulstSetItems one for each recorde returned in the query.  If there was an error or not values returned it will be empty.
ResponseResulstSetItems Contains the ID as its value (last ID for the last item) and a list elements for all of the items that are in the table for the specific web service call.  XML does not allow spaces in its element names so spaces were repaced with '_'.  If a field had a Null value it will not be included.
ErrorStatus This is returned in all requests and it contains 3 attrbiutes: NumRecords, ErrorMsg, ErrorNumber
NumRecords This indicates the number of ResponseResulstSetItems returned from the query. 
ErrorMsg A detailed error message about a problem that occurred.
ErrorNumber A non zero number indicates an error of some sort occurred.

 * The dates are not required for all operations.  The following ignore the dates:  payrollbatchchecks .       

** Some tables like invoice_line_item is unique from the rest of the tables.  It does not have an ID field.  Uniqueness is determeined from a combination of two values in this case InvoiceID and LineID.  So when specifiying an ID to start your next set of 1000 items to search by or when searching by ID you must specify both of these numbers seperated by a #.  For example if the last item was InoviceID: 1044 and the LineID: 3, the specified ID would be 1044#3.  

*** payrollbatchchecks does not have a unique identifier so we have made a work around in that we create a temporary table with an ID field that we do our selects with.  So even though there is no persistent ID field it requires one for iterating through it.  This table also does not have a last modified date or creation date so because of this you will always get the entire table.  One way to make sure you do not get the same data over and over again is to use the last ID you received and specify that as the last id then you will only get the ones after this.

The following table is a listing of what is the unique identifier for each table.

                                  

Last ID column name
Table(s)                            
id
accountupgrades, appointment, area, arearights, bank, campaings, deletedrecords, dnscodes, dnscommissions, dnsfunding, emergencycontact, employee, equipmentitem, equipmentmaster, funding, inventoryitem, invoice, invoicestatushistory, item, kits, leads, loginhistory, notes, payroll, promotions, rmadetails, roles, syncdatabasestats, upgradeoptions,  payrollbatchchecks*
basepackageid basepackage
programmingid#basepackageid basepackageprogramming
basepackageid#numreceivers basepackageprice
customerprogid customerprogramming
invoiceid#lineid invoice_line_item
none invoicetypes, provider****
kitconfigid#receivernum kitconfigreceivers
kitconfigid kitconfigs
progid programming
categoryid programmingcategory
kitid#promotionid promokits
receivertypeid receivertype
id or invoiceid (which ever is included with id take precedence over invoiceid transactions
batchid
payrollbatch

                                 

* payrollbatchchecks uses ID even thought it is not a persisten field  

*** Transactions table - This table has special behavior.  It will be ordered by either the ID or the invoiceid column depending on which is specified first in the columnlist.  If '*' is specified then the ID will be used.  This is important for iterating through the available row items if they exceed a 1000 records since it will iterate based on the ordered value.

**** The tables invoicetypes and provider are not very large and do not change often.  They do not have an ID so when you sync them you will get all changes every time you ask for items in the table.           

                                       

getCMSDataByCondition

This is a generic method used to get all of the data from Agemni CMS. 

WARNING: If you use this to query on certain fields it may cause performance issues on your database since not all fields are indexed.  If you are concerned about this please contact Agemni Support and tell them how you are using it and we can optimize it for your queries.

                                                                                      

1) The method takes an operation type that specifies which table to retreive data from. 
Input Name                                 
Description                                 
tableName
The tableName can be the following values:
"RMADetails"
The responses root element will be have the operation name you specified.     
2) They will return all data that matches a specific condition.  You tell the column name the condition and the value to check.
 
Input Name                                 
Description                                 
column
The name of the column for the table you are search on.                         
condition This is the condition operator.  Currently only '=' is supported.
value This is the value that you are trying to match.
3) This may return 1000s of records so in order to not overload the servers there is a metering mechanism.  Only 1000 records will be returned at a time.  You specify the next set of 1000 by passingin the last ID (see below). 

Input Element Name                                  Description                                 
lastID This is the ID of the last record received.  If you have received less than 1000 then there will be no more sent.  Just submit the same startDate and EndDate with the new lastID and you will get the next set.  See the next section for more details.                              

4) This is a list of columns that you want returned.  If nothing is specified then all will be returned. 

Input Element Name                                  Description                                 
includeList This is an array of strings that contain each column that is wanted to be returned.   Remember to replace spaces with underscores for names since XML can not have spaces in element names.
  5) All results will be returned with the following elements or attributes

                                                                  

Output Element / Attribute Name  
Description                                 
columnIN
This is what was sent as input for the column.                   
conditionIN This is what was sent as input for the condition.
valueIN This is what was sent as input for the value.
lastIDIN This is what was sent as input for the lastID
Response This contains a list of ResponseResulstSetItems one for each recorde returned in the query.  If there was an error or not values returned it will be empty.
ResponseResulstSetItems Contains the ID as its value (last ID for the last item) and a list elements for all of the items that are in the table for the specific web service call.  XML does not allow spaces in its element names so spaces were repaced with '_'.  If a field had a Null value it will not be included.
ErrorStatus This is returned in all requests and it contains 3 attrbiutes: NumRecords, ErrorMsg, ErrorNumber
NumRecords This indicates the number of ResponseResulstSetItems returned from the query. 
ErrorMsg A detailed error message about a problem that occurred.
ErrorNumber A non zero number indicates an error of some sort occurred.

                                                                                                  

getCMSDataByID

This is a generic method used to get specific items from Agemni CMS by a database ID. 

                                                                                      

1) The method takes an operation type that specifies which table to retreive data from. 
Input Name                                 
Description                                 
opName
The opName can be the following values:
"accounts"
"appointment"
"area"
"campaigns"
"employee"
"invoice"
"invoice_line_item" *
"leads"
"notes"
"transcactions" **
"dnscodes"
"dnscommissions"
"roles"
"promotions"
"inventoryitem"
"equipmentitem"
"equipmentmaster"
"rmadetails"
"syncdatastats"
"basepackage"
"basepackageprice"
"basepackageprogramming"
"customerprogramming"
"dnsfunding"
"funding"
"item"
"kitconfigreceivers"
"kitconfigs"
"kits"
"programming"
"programmingcategory"
"promokits" *
"invoicetypes"
"accountupgrades"
"upgradeoptions"
"emergencycontact"
"deletedrecords"
"arearights"
"payroll"
"receivertype"
"payrollbatch"
"payrollbatchchecks"***
"TimeClock"
"TechArriveDepart"
The responses root element will be have the operation name you specified.     
2) This will return 1 record.  This record will be indicated by the ID passed in.

Input Element Name                                  Description                                 
IDIN * The ID of the record that needs to be returned.                          

                                                                      

3) This is a list of columns that you want returned.  If nothing is specified then all will be returned. 

Input Element Name                                  Description                                 
includeList This is an array of strings that contain each column that is wanted to be returned.   Remember to replace spaces with underscores for names since XML can not have spaces in element names.
4) All results will be returned with the following elements or attributes 
CMSDownload Arguments
Description                                 
IDIN This is what was sent as input for the ID
Response This contains a list of ResponseResulstSetItems one for each record returned in the query.  If there was an error or no values, it will be empty.
ResponseResulstSetItems Contains the ID as its value and an element for the item specified by the ID.  XML does not allow spaces in its element names so spaces were repaced with '_'.  If a field had a Null value it will not be included.
ErrorStatus This is returned in all requests and it contains 3 attrbiutes: NumRecords, ErrorMsg, ErrorNumber
NumRecords This indicates the number of ResponseResulstSetItems returned from the query. 
ErrorMsg A detailed error message about a problem that occurred.
ErrorNumber A non zero number indicates an error of some sort occurred.

* The invoice_line_item table is unique from the rest of the tables.  It does not have an ID field.  Uniqueness is determeined from a combination of the InvoiceID and the LineID.  So when specifiying an ID to start your next set of 1000 items to search by or when searching by ID you must specify both of these numbers seperated by a #.  For example if the last item was InoviceID: 1044 and the LineID: 3, the specified ID would be 1044#3.   Promokits also has special handling.  See the table above under the getCMSData section for the unique id specifications.

** Transactions table - This table has special behavior.  It will be ordered by either the ID or the invoiceid column depending on which is specified first in the columnlist.  If '*' is specified then the ID will be used.  This is important for iterating through the available row items if they exceed a 1000 records since it will iterate based on the ordered value.                       

*** payrollbatchchecks uses an ID field even though it is not a persistent field.

getCMSTables
This is a generic method used to get the list of available tables for CMS Sync. 

                                                                                      

1) The method takes an operation type that specifies which table to retreive data from. 
Input Name                                 
Description                                 
None
No input is specified for this method

2) All results will be returned with the following elements or attributes 

CMSDownload Arguments
Description                                 
Response This contains a list of Table elements one for each table name returned in the query.  If there was an error, it will be empty.
Table This set will contain a name of an available table.
ErrorStatus This is returned in all requests and it contains 3 attrbiutes: NumRecords, ErrorMsg, ErrorNumber
NumRecords This indicates the number of ResponseResulstSetItems returned from the query. 
ErrorMsg A detailed error message about a problem that occurred.
ErrorNumber A non zero number indicates an error of some sort occurred.

                                                                                   

getCMSTableColumns
This is a generic method used to get the column names for a specified table 

                                                                                      

1) The method takes an operation type that specifies which table to retreive data from. 
Input Name                                 
Description                                 
Table
This is the table which you want the column names for.

                                                                            

2) All results will be returned with the following elements or attributes 
CMSDownload Arguments
Description                                 
TableIN This is what was sent as input for the Table
Response This contains a list of column elements, one for each record returned in the query.  If there was an error, it will be empty.
Column Contains the name of the column.
ErrorStatus This is returned in all requests and it contains 3 attrbiutes: NumRecords, ErrorMsg, ErrorNumber
NumRecords This indicates the number of ResponseResulstSetItems returned from the query. 
ErrorMsg A detailed error message about a problem that occurred.
ErrorNumber A non zero number indicates an error of some sort occurred.

                                                                                   

CMSDownload EXE

The CMSDownload.exe is a utility written for those who want to use the CMS Sync but do not have a programmer.  This is a windows executable that performs the same operations as the CMS Sync API but sends the data to a file: XML or Comma Seperated Values (CSV).  This file can be imported into a database or used in any manner choosen.

Download

To get the file click here.  Then unzip the file to get the CMSDownload.exe.

Instructions

This executable is run from a DOS or cmd prompt.  It takes the following arguments.

Output Element / Attribute Name  
Description                                 
-d dn The dn value is specified for the user in Agemni CMS HR->Employee->Services tab.
-u username The username value is the Agemni CMS username that has rights to perform Agemni CMS operations.
-p password The password value is the password of the Agemni CMS username.
-f outputfile The outputfile value is the filename where the data will be sent - if the file exists all of its contents will be replaced.
-m output The output value contains the format: "screen", "xml" or "csv".  A "screen" selection prints the data to the screen.  If you select "csv" then the first line in the csv file will be the matching columns.
-o operation The operation value corresponds to the above APIs: "all", "tables", "columns", "cond" or "byid"  The "all" operation does a getCMSDAta request.  The "byid" operation does a getCMSDataByID request.  The "tables" operation does a getCMSTables request.  The "columns" operation does a getCMSTableColumns request.  The "cond" operation does getCMSDataByCondition.
-t table

The table value is the opName specified in the above API.  The following is a list based on the operation:

all:

"accounts"
"appointment"
"area"
"campaigns"
"employee"
"invoice"
"invoice_line_item"
"invoiceStatusHistory"
"leads"
"LoginHistory"
"notes"
"transactions" *
"dnscodes"
"dnscommissions"
"roles"
"promotions"
"inventoryitem"
"equipmentitem"
"equipmentmaster"
"rmadetails"
"syncdatastats"
"basepackage"
"basepackageprice"
"basepackageprogramming"
"customerprogramming"
"dnsfunding"
"funding"
"item"
"kitconfigreceivers"
"kitconfigs"
"kits"
"programming"
"programmingcategory"
"promokits"
"invoicetypes"
"accountupgrades"
"upgradeoptions"
"emergencycontact"
"provider"
"deletedrecords"
"arearights"
"payroll"
"receivertype"
"payrollbatch"
"payrollbatchchecks"
"TimeClock"
byid:
"accounts"
"appointment"
"area"
"campaigns"
"employee"
"invoice"
"invoice_line_item"
"leads"
"notes"
"dnscodes"
"dnscommissions"
"roles"
"promotions"
"inventoryitem"
"equipmentitem"
"equipmentmaster"
"rmadetails"
"syncdatastats"
"basepackage"
"basepackageprice"
"basepackageprogramming"
"customerprogramming"
"dnsfunding"
"funding"
"item"
"kitconfigreceivers"
"kitconfigs"
"kits"
"programming"
"programmingcategory"
"promokits"
"invoicetypes"
"accountupgrades"
"upgradeoptions"
"emergencycontact"
"deletedrecords"
"arearights"
"payroll"
"receivertype"
"payrollbatch"
"payrollbatchchecks"
"TimeClock"
"TechArriveDepart"
cond:
"RMADetails"
-s startdate The startdate value is optional and can be used when doing "all" operations.  It specifies when to look for records.  It follow the format: mm/dd/yyyy.  This is ignored for "byid" operations.
-e enddate The enddate value is optional and can be used when doing "all" operations.  It specifies when to look for records.  It follow the format: mm/dd/yyyy.  This is ignored for "byid" operations.
-c columnname The columnname value is used with the "cond" operations.  It is not optional for this operation.
-x condition The condition value is the condition operation and currently can only be: "=".  This is used only with the "cond" operation and is required.
-v value The value value is the column name value you are search for.  It is only used with the "cond" operation.
-i id The id value is optional for the "all" operation, but manditory for the "byid" operation.  Yf used with the "all" operation it indicates where to start the next search from because only 1000 records will be returned per request.
-l columnlist

The columnlist value is optional.  If not specified then "*" or all columns will be returned.  If specified it is a comma separated list of desired column names.  If a column has a space in it, the space must be repaced with a "_".

-a This retrieves all of the values.  It loops through each set of 1000 and retreives all of the records specified in the search.  Please use this with caution since ecessive amount of data retrieve can put loads on your sites.
             

* Transactions table - This table has special behavior.  It will be ordered by either the ID or the invoiceid column depending on which is specified first in the columnlist.  If '*' is specified then the ID will be used.  This is important for iterating through the available row items if they exceed a 1000 records since it will iterate based on the ordered value.

Command Line Examples

1) Generate an XML file of all of the data in the accounts table between '01/15/2009 09:13:34 AM' and 01/16/2009.

  CMSDownload -d somedn -u someusername -p somepassword -f c:\temp\out.xml -m xml -o all -t accounts -s '01/15/2009 09:13:34 AM' -e 01/16/2009

2) Generate a CSV file of all of the first and last names of the data in the leads table starting with id 100.

  CMSDownload -d somedn -u someusername -p somepassword -f c:\temp\out.xml -m csv -o all -t leads -i 100 -l fname,lname

3) Generate an XML file of all of the data of the employee identified by employee id 27.

   CMSDownload -d somedn -u someusername -p somepassword -f c:\temp\out.xml -m xml -o byid -t employee -i 27

4)  Generate a CSV file of summary column for a note that has an id of 143

   CMSDownload -d somedn -u someusername -p somepassword -f c:\temp\out.xml -m csv -o byid -t notes -i 143 -l summary

5) Generate output to the screen of the availabe tables.

  CMSDownload -d somedn -u someusername -p somepassword -m screen -o tables 

6) Generate output to the screen of the availabe column names for the table: accounts

   CMSDownload -d somedn -u someusername -p somepassword -m screen -o columns -t accounts

7) Generate output to the screen of the RMADetails rows where the RMAStatus = OP:

   CMSDownload -d somedn -u someusername -p somepassword -m screen -o cond -t RMADetails -c RMAStatus -x = -v PO

8) Script that will create a set of csv files using a dynamic start and end time - 1 hour back and 10 minutes forward.  Put the following script into a file with a .bat extension and you can schedule this to run every hour with the windows task scheduler.  The csv files can be imported into your database.

       

Taylor (Agemni Customer) found some issues with the below code.  I appologize for that but he was kind enough to send a fix that is here in blue for the time caluclation.

set /a mm=%time:~3,2%

set /a hh=%time:~0,2%

if %mm% lss 5 set /a hh=%hh%-1

if %mm% lss 5 set /a mm=%mm%+60

set /a mm=%mm%-5

if %mm% lss 10 set mm=0%mm%

if %hh% equ -1 set hh=23

        

:: set hours and minutes 

SET Now=%Time: =0%
SET Hours=%Now:~0,2%
SET Minutes=%Now:~3,2%
:: set year month day and get today
SET Today=%Date: =0%
SET Year=%Today:~-4%
SET Month=%Today:~-10,2%
SET Day=%Today:~-7,2%
SET Today=%Month%/%Day%/%Year%
set HourBack=%Hours%
Set /a MinForward+=10
Set /a HourBack-=1
:: set start time 1 hour back
set NowMinusOneHour=%HourBack%:%Minutes%
:: send end time 10 minutes forward - for possible times out of sync
set NowPlusTenMin=%Hours%:%MinForward%
::remove : and . from time for the csv files
set tempfileNow=%Now::=%
set tempfileNow=%tempfileNow:.=%
set filename=%Today:/=%%tempfileNow%
cmsdownload -d xxxxxx -u xxxxxx -p xxxxxx -o all -m csv -f invoice%filename%.csv -t invoice -l id,account_id,rep_name,satelliteprovider,saledate -s '%Today% %NowMinusOneHour%' -e '%Today% %NowPlusTenMin%' -a
cmsdownload -d xxxxx -u xxxxxx -p xxxxxxx -o all -m csv -f accounts%filename%.csv -t accounts -l id,fname,lname,areaid -s '%Today% %NowMinusOneHour%' -e '%Today% %NowPlusTenMin%' -a
cmsdownload -d xxxxxx -u  xxxxxxx   -p  xxxxxxx  -o all -m csv -f appointment%filename%.csv -t appointment -l ID,Appointmentdate,techid -s '%Today% %NowMinusOneHour%' -e '%Today% %NowPlusTenMin%' -a

                                                                           

 VB .NET Examples

The following example uses Microsoft Visual Studio 2005.  Create a vb.net Console Application project.  Add 2 web references to:

https://www.agemni.com/_snet/AgemniLogin.asmx

Http://www.agemni.com/_anet/ADBAccess.asmx

                                                                                         

The use the following code in the module1.vb (or whatever you want to call it):

                                                                                        

Imports System.Web
Imports System.Web.Services
Imports System.Web.Services.Protocols
Imports System
Imports System.Xml
Imports System.Xml.Schema
Imports System.IO
Imports System.Text

Module Module1

    Sub Main()

        Dim responseBuilder As StringBuilder
        Dim responseWriter As XmlTextWriter

        responseBuilder = New StringBuilder()
        responseWriter = New XmlTextWriter(New StringWriterWithEncoding(responseBuilder, Encoding.UTF8))

        Dim loginObj As testcmssync.AgemniLogin.AgemniLogin = New testcmssync.AgemniLogin.AgemniLogin

        'create a cookiecontainer or the cookies will not be returned
        loginObj.CookieContainer = New System.Net.CookieContainer

        Dim loginResults As System.Xml.XmlNode = Nothing

        'login to agemni
        loginResults = loginObj.agLogin("somedn", "someuser", "someuserspassword")

        'print out the login results
        loginResults.WriteTo(responseWriter)
        Console.Write(responseBuilder.ToString())

        'get the cookie
        Dim uri As System.Uri = New System.Uri("https://www.agemni.com/_snet/AgemniLogin.asmx")
        Dim cc As System.Net.CookieCollection = loginObj.CookieContainer.GetCookies(uri)

        'print out the cookie
        Console.Write(cc.Item("AGSESSION"))


        Dim adbaccessObj As testcmssync.ADBAccess.ADBAccess = New testcmssync.ADBAccess.ADBAccess

        'set the cookies from the login to the adbaccess object
        adbaccessObj.CookieContainer = loginObj.CookieContainer

        Dim custResults As System.Xml.XmlNode = Nothing
        'get the customer information
        Dim includeList As String() = {"*"}
        custResults = adbaccessObj.getCMSData("accounts", "", DateTime.Now.ToShortDateString(), "", includeList)

        'print out the customer information
        custResults.WriteTo(responseWriter)
        Console.Write(responseBuilder.ToString())

        'get the customer information - but only a few fields

        Dim includeList1 As String() = {"FName", "LName", "SSN", "Phone3", "blah"}
        custResults = adbaccessObj.getCMSData("accounts", "", "", "", includeList1)

        'print out the customer information
        custResults.WriteTo(responseWriter)
        Console.Write(responseBuilder.ToString())

        'get invoice information - but only a few fields

        Dim includeList2 As String() = {"InvoiceType", "Account ID", "Date_Created", "Receivers"}
        custResults = adbaccessObj.getCMSData("invoice", "", "", "", includeList2)

        'print out the invoiceinformation
        custResults.WriteTo(responseWriter)
        Console.Write(responseBuilder.ToString())

        Dim includeList3 As String() = {"*"}
        custResults = adbaccessObj.getCMSData("transactions", "", "", "", includeList3)

        custResults.WriteTo(responseWriter)
        Console.Write(responseBuilder.ToString())

        custResults = adbaccessObj.getCMSData("campaigns", "", "", "", includeList3)

        custResults.WriteTo(responseWriter)
        Console.Write(responseBuilder.ToString())

        custResults = adbaccessObj.getCMSData("leads", "", "", "", includeList3)

        custResults.WriteTo(responseWriter)
        Console.Write(responseBuilder.ToString())

        responseBuilder.Remove(0, responseBuilder.Length)

        custResults = adbaccessObj.getCMSDataByID("employee", 12, includeList3)

        custResults.WriteTo(responseWriter)
        Console.WriteLine(responseBuilder.ToString())
        responseBuilder.Remove(0, responseBuilder.Length)

        custResults = adbaccessObj.getCMSDataByID("notes", 10, includeList3)

        custResults.WriteTo(responseWriter)
        Console.WriteLine(responseBuilder.ToString())
        responseBuilder.Remove(0, responseBuilder.Length)

        custResults = adbaccessObj.getCMSDataByID("campaigns", 10, includeList3)

        custResults.WriteTo(responseWriter)
        Console.WriteLine(responseBuilder.ToString())
        responseBuilder.Remove(0, responseBuilder.Length)

                                                                                   

    End Sub

    Friend Class StringWriterWithEncoding
        Inherits StringWriter


        Private m_encoding As Encoding

        Public Sub New(ByVal sb As StringBuilder, ByVal encoding As Encoding)
            MyBase.New(sb)
            m_encoding = encoding
        End Sub

        Public Overrides ReadOnly Property Encoding() As Encoding
            Get
                Return m_encoding
            End Get
        End Property
    End Class


End Module
 

PHP Example

Here is an example on how to login and transfer cookies and make a call to get data.

   

<?php

$ini = ini_set("soap.wsdl_cache_enabled","1");

   

//Authenticate User

$client = new SoapClient("https://www.agemni.com/_snet/AgemniLogin.asmx?WSDL",array("trace"=> 1, "exceptions" => 0));

$response = $client->agLogin(array(

    'dn' => 'XXXXXXXXXXXX',

    'username' => 'XXXXXX',

    'password' => 'XXXXXXX'

));

   

//Store Authentication Cookie

$cookieTmp = $client->_cookies;

foreach($cookieTmp as $key=>$value)

{

$cookie = $value[0];

}

   

//Connect to ADBAccess

$client = new SoapClient('http://www.agemni.com/_anet/ADBAcces...x?WSDL',array("trace"=> 1, "exceptions" => 0));

$client->__setCookie("AGSESSION",$cookie);

   

//Query Appointment table

$response = $client->getCMSData(array(

'opName' => 'appointment',

    'startDate' => '1/01/2014',

    'endDate' => '2/12/2014',

    'lastID' => '1',

    'includeList' => array('ID','InvoiceID','StartTime', 'EndTime', 'ConfirmInstallation', 'AddDate', 'AppointmentDate', 'Result')

));

   

      $xmltemp = $response->getCMSDataResult;

 $xml = $xmltemp->any;

      $xml = simplexml_load_string($xml);

foreach($xml->Response->ResponseResultSetItem as $appt) {

  

            $output .= 

            "<p>InvoiceID: $appt->InvoiceID, ID: $appt->ID, StartTime: $appt->StartTime, EndTime: $appt->EndTime, ConfirmInstallation: $appt->ConfirmInstallation, AddDate: $appt->AddDate, AppointmentDate: $appt->AppointmentDate, Result: $appt->Result</p>";

      }

//output results

print_r($output);

  

//output debug info

print "<pre>";

print "Request :\n".htmlspecialchars($client->__getLastRequest()) ."\n";

print "Response:\n".htmlspecialchars($client->__getLastResponse())."\n";

print "</pre>";

   

?>

Test project

Attached to this page is a zip containging a test program used to test some aspects of CMS Sync.  It is a MS Visual Stuiod 2005 vb.net project.  In this project there are 2 web services interfaces.  One for the a local instance of CMS Sync (localhost and localhostlogin) and one for the live servers (AgemniAccess and AgemniLogin).  If you decide to use this you must use the live servers since you do not have a version running on your local servers.  You must also set your company's dn, username, and password where the 'xxxxx' are specified for the login.  You can get the project here.

                            

Special Considerations

Custom Fields

In Agemni CMS there is the ability to create custom fields for text, drop downs, radio buttons and check boxes.  The values for these fields are stored in generic fields in the Accounts table for each customer account.  The labels you specify are not stored in the accounts table but in the preference tables.  The fields are stored in order with the following names:                                                                           

Custome Field Type
Database Field Names
Text Box
  
Accounts.Custom1, Accounts.Custom2, Accounts.Custom3, Accounts.Custom4, Accounts.Custom5, Accounts.Custom6, Accounts.Custom7, Accounts.Custom8
Drop Down Accounts.Custom1DD, Accounts.Custom2DD, Accounts.Custom3DD, , Accounts.Custom4DD, Accounts.Custom5DD, Accounts.Custom6DD, Accounts.Custom7DD, Accounts.Custom8DD
Radio Button Accounts.Custom1RB, Accounts.Custom2RB, Accounts.Custom3RB, Accounts.Custom4RB, Accounts.Custom5RB, Accounts.Custom6RB, Accounts.Custom7RB, Accounts.Custom8RB
Check Box Accounts.Custom1CHK, Accounts.Custom2CHK, Accounts.Custom3CHK, Accounts.Custom4CHK, Accounts.Custom5CHK, Accounts.Custom6CHK, Accounts.Custom7CHK, Accounts.Custom8CHK
                                                                                                

                           

DB Schema

The following image shows the most common tables and the schema of these.

                         

AgemniCMSDBSchema.png

Database Diagram.jpg

Tags
none

Files (12)

FileSizeDateAttached by 
 CMSDownload_1_2.zip
No description
18.02 kB17:46, 17 Feb 2009pfelstedActions
 CMSDownload_1_2_1.zip
No description
18.89 kB17:46, 17 Feb 2009pfelstedActions
 CMSDownload_1_2_10 (1).zip
Fixes issues with payrollbatchchecks table since there was no unique id.
22.41 kB18:27, 19 Sep 2012pfelstedActions
 CMSDownload_1_2_2.zip
Added the -a switch to automatically fetch the next 1000 records. Added fixes for handling special cases for invoice_line_item.
21.28 kB17:58, 13 Jul 2009pfelstedActions
 CMSDownload_1_2_3.zip
Fixes a bug with a / in the dn. Also prints out more information on parsing errors.
21.34 kB00:11, 28 Jul 2009pfelstedActions
 CMSDownload_1_2_5.zip
Fixed an issue with the transactions table and iterating over 1000 records
21.52 kB19:02, 17 Feb 2010pfelstedActions
 CMSDownload_1_2_6.zip
fixed issues with promokits, basepackageprogramming, basepackageprice, and a few other issues
23.23 kB16:56, 25 May 2010pfelstedActions
 CMSDownload_1_2_7.zip
Changes delimiter to double quotes and escapes double quotes in the string if used.
22.28 kB16:37, 4 Aug 2010pfelstedActions
 CMSDownload_1_2_8.zip
Escapes special characters - lf, cr, newline, tab, etc.
22.31 kB22:42, 4 Aug 2010pfelstedActions
 CMSDownload_1_2_9.zip
No description
24.34 kB00:22, 28 Jul 2011pfelstedActions
 Diagram.pdf
Database Diagram
1033.08 kB23:13, 24 Sep 2012rsheppickActions
 TESTCMSSYNC.zip
No description
133.97 kB20:23, 30 Mar 2010pfelstedActions
Viewing 1 of 1 comments: view all
I'm a python user and I went through at soaplib. ZSI, SOAPpy and finally landed on Suds. Suds works very well with the Agemni CMS.

---- SIMPLE EXAMPLE ----
#/usr/bin/python

from suds.client import Client

login = Client("http://www.agemni.com/_snet/AgemniLogin.asmx?WSDL")
login.service.agLogin(dn="xxxxx", username="xxxxx", password="xxxxx")

client = Client("https://www.agemni.com/_anet/ADBAccess.asmx?WSDL")
client.options.transport.cookiejar = login.options.transport.cookiejar

accountSet = client.service.getCMSData("accounts","05/05/2010","","",{"string": ["*"]})
Posted 00:39, 26 May 2010 (4 years ago)
Viewing 1 of 1 comments: view all
You must login to post a comment.