Fixed issue #1740 - Exchange is limited to 1000 entries and wont sync more.
This commit is contained in:
parent
8300887bae
commit
0ea8dd7c45
1 changed files with 40 additions and 14 deletions
|
@ -13,25 +13,51 @@ class Sequencer
|
||||||
return if ews_folder_ids.blank?
|
return if ews_folder_ids.blank?
|
||||||
|
|
||||||
ews_folder_ids.each do |folder_id|
|
ews_folder_ids.each do |folder_id|
|
||||||
folder = ews_folder.find(folder_id)
|
folder = ews_folder.find(folder_id)
|
||||||
display_path = ews_folder.display_path(folder)
|
paginated_item_sequence(folder)
|
||||||
|
|
||||||
sequence_resources(folder.items) do |parameters|
|
|
||||||
|
|
||||||
item = parameters[:resource]
|
|
||||||
|
|
||||||
logger.debug("Extracting attributes from Exchange item: #{item.get_all_properties!.inspect}")
|
|
||||||
|
|
||||||
parameters.merge(
|
|
||||||
resource: ::Import::Exchange::ItemAttributes.extract(item),
|
|
||||||
ews_folder_name: display_path,
|
|
||||||
)
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
private
|
private
|
||||||
|
|
||||||
|
def paginated_item_sequence(folder)
|
||||||
|
|
||||||
|
total = folder.total_count
|
||||||
|
per_page = 1000
|
||||||
|
pages = (total.to_f / per_page.to_f).ceil
|
||||||
|
|
||||||
|
display_path = ews_folder.display_path(folder)
|
||||||
|
(1..pages).each do |page|
|
||||||
|
|
||||||
|
offset = (page - 1) * per_page
|
||||||
|
|
||||||
|
opts = {
|
||||||
|
indexed_page_item_view: {
|
||||||
|
max_entries_returned: per_page,
|
||||||
|
offset: offset,
|
||||||
|
base_point: 'Beginning'
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
logger.debug "Fetching and processing #{per_page} items (page: #{page}, offset: #{offset}) from Exchange folder '#{display_path}' (total: #{total})"
|
||||||
|
|
||||||
|
folder.items(opts).each do |item|
|
||||||
|
|
||||||
|
sequence_resource(item) do |parameters|
|
||||||
|
|
||||||
|
item = parameters[:resource]
|
||||||
|
|
||||||
|
logger.debug "Extracting attributes from Exchange item: #{item.get_all_properties!.inspect}"
|
||||||
|
|
||||||
|
parameters.merge(
|
||||||
|
resource: ::Import::Exchange::ItemAttributes.extract(item),
|
||||||
|
ews_folder_name: display_path,
|
||||||
|
)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
def sequence
|
def sequence
|
||||||
'Import::Exchange::FolderContact'
|
'Import::Exchange::FolderContact'
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in a new issue