protected override void ExecuteCore()
        {
            try
            {
                foreach (var channelContact in channel.GetContacts())
                {
                    channelContact.Person.SourceChannelId = config.ChannelId;
                    channelContact.Profile.SourceChannelId = config.ChannelId;

                    EventBroker.Publish(AppEvents.ContactReceived, channelContact);
                }

                channel.Dispose();

                // Save last run time
                ChannelContext.Current.ClientContext.SaveSetting("LastSyncContactsDate", DateTime.Now);

                EventBroker.Publish(AppEvents.SyncContactsFinished);
            }
            finally
            {
                channel = null;
            }
        }
        protected override void ExecuteCore()
        {
            try
            {
                foreach (var channelContact in channel.GetContacts())
                {
                    channelContact.Person.SourceChannelId  = config.ChannelId;
                    channelContact.Profile.SourceChannelId = config.ChannelId;

                    EventBroker.Publish(AppEvents.ContactReceived, channelContact);
                }

                channel.Dispose();

                // Save last run time
                ChannelContext.Current.ClientContext.SaveSetting("LastSyncContactsDate", DateTime.Now);

                EventBroker.Publish(AppEvents.SyncContactsFinished);
            }
            finally
            {
                channel = null;
            }
        }
 public SyncContactsTask(ChannelConfiguration config, IClientContactsChannel channel)
 {
     this.config = config;
     this.channel = channel;
 }
 public SyncContactsTask(ChannelConfiguration config, IClientContactsChannel channel)
 {
     this.config  = config;
     this.channel = channel;
 }