def batch_create (self, sync_list, src_dbid, items): """See the documentation in folder.Folder""" my_dbid = self.get_dbid() c = self.get_config() pname = sync_list.get_pname() src_sync_tag = c.make_sync_label(pname, src_dbid) dst_sync_tag = c.make_sync_label(pname, my_dbid) success = True for item in items: olc = OLContact(self, con=item) rid = item.get_itemid() olc.update_sync_tags(src_sync_tag, rid) ## FIXME: I strongly suspect this is not the most efficient way to ## do this. We should test by importing items in bulk into ## Outlook and measure performance, and fix this if needed. try: eid = olc.save() logging.info('Successfully created outlook entry for %30s (%s)', olc.get_disp_name(), olc.get_itemid()) except Exception, e: logging.error('Could not save contact (%s) due to: %s', olc.get_disp_name(), str(e)) logging.debug('Contact Entry: %s', olc) logging.debug(traceback.format_exc()) success = False continue iid = olc.get_itemid() item.update_sync_tags(dst_sync_tag, iid)
def batch_create(self, sync_list, src_dbid, items): """See the documentation in folder.Folder""" my_dbid = self.get_dbid() c = self.get_config() pname = sync_list.get_pname() src_sync_tag = c.make_sync_label(pname, src_dbid) dst_sync_tag = c.make_sync_label(pname, my_dbid) success = True for item in items: olc = OLContact(self, con=item) rid = item.get_itemid() olc.update_sync_tags(src_sync_tag, rid) ## FIXME: I strongly suspect this is not the most efficient way to ## do this. We should test by importing items in bulk into ## Outlook and measure performance, and fix this if needed. try: eid = olc.save() logging.info( 'Successfully created outlook entry for %30s (%s)', olc.get_disp_name(), olc.get_itemid()) except Exception, e: logging.error('Could not save contact (%s) due to: %s', olc.get_disp_name(), str(e)) logging.debug('Contact Entry: %s', olc) logging.debug(traceback.format_exc()) success = False continue iid = olc.get_itemid() item.update_sync_tags(dst_sync_tag, iid)
def batch_update(self, sync_list, src_dbid, items): """See the documentation in folder.Folder""" pname = sync_list.get_pname() src_tag = self.get_config().make_sync_label(pname, src_dbid) store = self.get_msgstore().get_obj() success = True for item in items: con_itemid = item.get_itemid_from_synctags(pname, 'ol') olc = OLContact(self, con=item, con_itemid=con_itemid) ## We lose the sync tag as well when we blow everything. To ensure ## this gets recreated, put it back in. olc.update_sync_tags(src_tag, item.get_itemid()) olprops = olc.get_olprops() oli = olc.get_olitem() ## Wipe out the sucker try: def_cols = oli.GetPropList(mapi.MAPI_UNICODE) hr, ps = oli.DeleteProps(def_cols) except Exception, e: logging.error( '%s: Could not clear our MAPI props for: %s (%s)', 'ol:batch_update()', item.get_name(), e) logging.debug(traceback.format_exc()) success = False continue ## Now shove the new property set in try: hr, ps = oli.SetProps(olprops) oli.SaveChanges(mapi.KEEP_OPEN_READWRITE) logging.info('Successfully updated changes to Outlook for %s', item.get_disp_name()) except Exception, e: logging.error('%s: Could not set new props set for: %s (%s)', 'ol:batch_update()', item.get_disp_name(), e) success = False continue
def batch_update (self, sync_list, src_dbid, items): """See the documentation in folder.Folder""" pname = sync_list.get_pname() src_tag = self.get_config().make_sync_label(pname, src_dbid) store = self.get_msgstore().get_obj() success = True for item in items: olc = OLContact(self, con=item) ## We lose the sync tag as well when we blow everything. To ensure ## this gets recreated, put it back in. olc.update_sync_tags(src_tag, item.get_itemid()) olprops = olc.get_olprops() oli = olc.get_olitem() ## Wipe out the sucker try: def_cols = oli.GetPropList(mapi.MAPI_UNICODE) print def_cols hr, ps = oli.DeleteProps(def_cols) except Exception, e: logging.error('%s: Could not clear our MAPI props for: %s (%s)', 'gc:batch_update()', item.get_name(), e) logging.debug(traceback.format_exc()) success = False continue ## Now shove the new property set in try: hr, ps = oli.SetProps(olprops) oli.SaveChanges(mapi.KEEP_OPEN_READWRITE) logging.info('Successfully updated changes to Outlook for %s', item.get_name()) except Exception, e: logging.error('%s: Could not set new props set for: %s (%s)', 'gc:batch_update()', item.get_name(), e) success = False continue