6.3.4 Import

Import is used to import entries into a calendar. The information must be imported from an ICal or VCal file.

Note: If entries are imported to a calendar other than the default one, the corresponding calendar file must exist on the device.

The following the examples for using Import:

Synchronous

calendar_handle.call('Import', {'Type': u'CalendarEntry', 'FileName': u'C:\\data\\input.txt', 'Format': u'VCal'})

Asynchronous

calendar_handle.call('Import', {'Type': u'CalendarEntry', 'FileName': u'C:\\data\\input.txt', 'Format': u'VCal'}, callback= imp_callback))

where, imp_callback is an user defined callback function.

The following table summarizes the specification of Import:

Interface IDataSource
Description Imports the calendar entries from an input file.
Response Model Synchronous and asynchronous.
Pre-condition IDataSource interface is loaded.
Post-condition Nil
Note The specified calendar must exist.

Input Parameters

Input parameter specifies the Type and its details to import. Input parameter properties are Type and Data.

Table 6.44: Input parameters Import
Name Type Range Description
Type unicode string CalendarEntry Performs the operation on calendar entries.
Data map [CalendarName]: unicode string
Buffer or FileName: unicode string
Format: unicode string
Imports entries to a specified calendar or to the default calendar if not specified. CalendarName must be in the format Drivexxx:FileNamexxx.
Either Buffer or FileName can be given. FileName must contain the complete path of the file. For example, C:>\\data\\importfile.txt
Buffer or Filename holds the entries to be imported.
Format specifies the data format of buffer or file. Format can have values ICal or VCal. ICal is supported from Fifth Edition devices onwards.


Output Parameters

Output contains ReturnValue. It also contains ErrorCode, and an ErrorMessage, if the operation fails. ReturnValue contains the Ids of the entries imported.

Table 6.45: Output parameters Import
Name Type Range Description
ErrorCode int NA Service specific error code on failure of the operation.
ErrorMessage string NA Error description in Engineering English.
ReturnValue iterator string An Iterate list of Ids of the entries successfully imported to the specified calendar file.
Note: The Id can repeat in case of Modifying entries.


Errors

The following table lists the errors and their values:

Table 6.46: Error codes
Error code value Description
1000 Invalid service argument
1004 Service not supported


Error Messages

The following table lists the error messages and their description:

Table 6.47: Error messages
Error messages Description
Calendar:Import:CalendarName is invalid Invalid type is passed for CalendarName
Calendar:Import:FileName is invalid Invalid type is passed for FileName or, FileName exceeds 239 characters
Calendar:Import:Buffer is invalid Invalid type is passed for Buffer
Calendar:Import:Type is invalid Import called with invalid Type
Calendar:Import:Data is missing Data parameter is missing
Calendar:Import:Data is invalid Invalid type is passed for Data parameter
Calendar:Import:Format is missing Import Format parameter not specified.
Calendar:Import:FileName is missing FileName is not passed


Example

The following sample code illustrates how to import a calendar entry:

# Load Calendar service
calendar_handle = scriptext.load('Service.Calendar', 'IDataSource')

try:
    calendar_handle.call('Import', {'Type': u'CalendarEntry', 'FileName': u'C:\\Data\\importfile.txt', 'Format': u'VCal' })
except scriptext.ScriptextError:
    print 'Error in servicing the request'
else:
    print "Import request successfully complete!"

See About this document... for information on suggesting changes.