private void DisposeDataSession() { UnifiedPolicySyncNotificationDataProvider unifiedPolicySyncNotificationDataProvider = (UnifiedPolicySyncNotificationDataProvider)base.DataSession; if (unifiedPolicySyncNotificationDataProvider != null) { unifiedPolicySyncNotificationDataProvider.Dispose(); } }
public void EnqueuePendingNotifications() { UnifiedPolicySyncNotificationDataProvider unifiedPolicySyncNotificationDataProvider = null; this.logger.LogOneEntry("NotificationLoader", string.Empty, ExecutionLog.EventType.Verbose, "Entering EnqueuePendingNotifications", null); foreach (ExchangePrincipal exchangePrincipal in this.GetSyncMailboxPrincipals()) { try { unifiedPolicySyncNotificationDataProvider = new UnifiedPolicySyncNotificationDataProvider(exchangePrincipal, "NotificationLoader"); } catch (StoragePermanentException exception) { this.logger.LogOneEntry("NotificationLoader", string.Empty, ExecutionLog.EventType.Error, "EnqueuePendingNotifications: UnifiedPolicySyncNotificationDataProvider ctor failed with StoragePermanentException for " + exchangePrincipal.MailboxInfo.PrimarySmtpAddress, exception); continue; } catch (StorageTransientException exception2) { this.logger.LogOneEntry("NotificationLoader", string.Empty, ExecutionLog.EventType.Error, "EnqueuePendingNotifications: UnifiedPolicySyncNotificationDataProvider ctor failed with StorageTransientException for " + exchangePrincipal.MailboxInfo.PrimarySmtpAddress, exception2); continue; } using (unifiedPolicySyncNotificationDataProvider) { try { IEnumerable <UnifiedPolicyNotificationBase> enumerable = unifiedPolicySyncNotificationDataProvider.FindPaged <UnifiedPolicyNotificationBase>(null, null, false, null, 0); this.logger.LogOneEntry("NotificationLoader", string.Empty, ExecutionLog.EventType.Verbose, string.Format("EnqueuePendingNotifications: found {0} pending notifications on system mailbox {1}", (enumerable != null) ? enumerable.Count <UnifiedPolicyNotificationBase>() : 0, exchangePrincipal.MailboxInfo.PrimarySmtpAddress), null); foreach (UnifiedPolicyNotificationBase unifiedPolicyNotificationBase in enumerable) { try { this.logger.LogOneEntry("NotificationLoader", string.Empty, ExecutionLog.EventType.Verbose, string.Format("EnqueuePendingNotifications: ready to dispatch workitemId: {0}", unifiedPolicyNotificationBase.Identity), null); this.EnqueueWorkItem(unifiedPolicyNotificationBase); } catch (SyncAgentExceptionBase) { this.logger.LogOneEntry("NotificationLoader", string.Empty, ExecutionLog.EventType.Error, string.Format("EnqueuePendingNotifications: EnqueueWorkItem failed to dispatch workitemId: {0}", unifiedPolicyNotificationBase.Identity), null); } } } catch (StoragePermanentException exception3) { this.logger.LogOneEntry("NotificationLoader", string.Empty, ExecutionLog.EventType.Error, "EnqueuePendingNotifications: dataProvider.FindPaged failed with StoragePermanentException for " + exchangePrincipal.MailboxInfo.PrimarySmtpAddress, exception3); } catch (StorageTransientException exception4) { this.logger.LogOneEntry("NotificationLoader", string.Empty, ExecutionLog.EventType.Error, "EnqueuePendingNotifications: dataProvider.FindPaged failed with StorageTransientException for " + exchangePrincipal.MailboxInfo.PrimarySmtpAddress, exception4); } } } this.logger.LogOneEntry("NotificationLoader", string.Empty, ExecutionLog.EventType.Verbose, "Exiting EnqueuePendingNotifications", null); }
public void Update(WorkItemBase item) { if (item == null) { throw new ArgumentException("item is null"); } if (item.WorkItemId == null) { throw new ArgumentException("WorkItemId can't be null inside Update"); } try { using (UnifiedPolicySyncNotificationDataProvider dataProvider = this.GetDataProvider(item.TenantContext.TenantId)) { UnifiedPolicyNotificationBase unifiedPolicyNotificationBase = UnifiedPolicyNotificationFactory.Create(item, dataProvider.MailboxOwner.Id); unifiedPolicyNotificationBase.ResetChangeTracking(true); unifiedPolicyNotificationBase.Version = Guid.NewGuid(); dataProvider.Save(unifiedPolicyNotificationBase); } } catch (ObjectNotFoundException) { } catch (StorageTransientException innerException) { throw new SyncAgentTransientException("Failed to update sync workitem in persistent queue because of StorageTransientException", innerException); } catch (StoragePermanentException innerException2) { throw new SyncAgentPermanentException("Failed to update sync workitem in persistent queue because of StoragePermanentException", innerException2); } catch (TransientException innerException3) { throw new SyncAgentTransientException("Failed to update sync workitem in persistent queue because of TransientException", innerException3); } catch (DataSourceOperationException innerException4) { throw new SyncAgentTransientException("Failed to update sync workitem in persistent queue because of DataSourceOperationException", innerException4); } catch (DataValidationException innerException5) { throw new SyncAgentTransientException("Failed to update sync workitem in persistent queue because of DataValidationException", innerException5); } }
public void Delete(WorkItemBase item) { if (item == null) { throw new ArgumentException("item is null"); } try { VersionedId rootId = VersionedId.Deserialize(item.WorkItemId); using (UnifiedPolicySyncNotificationDataProvider dataProvider = this.GetDataProvider(item.TenantContext.TenantId)) { UnifiedPolicyNotificationBase[] array = (UnifiedPolicyNotificationBase[])dataProvider.Find <UnifiedPolicyNotificationBase>(null, rootId, false, null); if (array != null && array.Length > 0) { dataProvider.Delete(array[0]); } } } catch (ObjectNotFoundException) { } catch (StorageTransientException innerException) { throw new SyncAgentTransientException("Failed to delete sync workitem from persistent queue because of StorageTransientException", innerException); } catch (StoragePermanentException innerException2) { throw new SyncAgentPermanentException("Failed to delete sync workitem from persistent queue because of StoragePermanentException", innerException2); } catch (TransientException innerException3) { throw new SyncAgentTransientException("Failed to delete sync workitem from persistent queue because of TransientException", innerException3); } catch (DataSourceOperationException innerException4) { throw new SyncAgentPermanentException("Failed to delete sync workitem from persistent queue because of DataSourceOperationException", innerException4); } catch (DataValidationException innerException5) { throw new SyncAgentPermanentException("Failed to delete sync workitem from persistent queue because of DataValidationException", innerException5); } }
public WorkItemBase Get(ObjectId identity, Guid tenantId) { try { using (UnifiedPolicySyncNotificationDataProvider dataProvider = this.GetDataProvider(tenantId)) { UnifiedPolicyNotificationBase[] array = (UnifiedPolicyNotificationBase[])dataProvider.Find <UnifiedPolicyNotificationBase>(null, identity, false, null); if (array != null && array.Length > 0) { return(array[0].GetWorkItem()); } } } catch (ObjectNotFoundException) { } catch (StorageTransientException innerException) { throw new SyncAgentTransientException("Failed to get sync workitem in persistent queue because of StorageTransientException", innerException); } catch (StoragePermanentException innerException2) { throw new SyncAgentPermanentException("Failed to get sync workitem in persistent queue because of StoragePermanentException", innerException2); } catch (TransientException innerException3) { throw new SyncAgentTransientException("Failed to get sync workitem in persistent queue because of TransientException", innerException3); } catch (DataSourceOperationException innerException4) { throw new SyncAgentTransientException("Failed to get sync workitem in persistent queue because of DataSourceOperationException", innerException4); } catch (DataValidationException innerException5) { throw new SyncAgentTransientException("Failed to get sync workitem in persistent queue because of DataValidationException", innerException5); } return(null); }
public void Enqueue(WorkItemBase item) { if (item == null) { throw new ArgumentException("item is null"); } try { using (UnifiedPolicySyncNotificationDataProvider dataProvider = this.GetDataProvider(item.TenantContext.TenantId)) { UnifiedPolicyNotificationBase unifiedPolicyNotificationBase = UnifiedPolicyNotificationFactory.Create(item, dataProvider.MailboxOwner.Id); dataProvider.Save(unifiedPolicyNotificationBase); item.HasPersistentBackUp = true; item.WorkItemId = unifiedPolicyNotificationBase.StoreObjectId.ToBase64String(); } } catch (StorageTransientException innerException) { throw new SyncAgentTransientException("Failed to enqueue sync workitem into persistent queue because of StorageTransientException", innerException); } catch (StoragePermanentException innerException2) { throw new SyncAgentPermanentException("Failed to enqueue sync workitem into persistent queue because of StoragePermanentException", innerException2); } catch (TransientException innerException3) { throw new SyncAgentTransientException("Failed to enqueue sync workitem into persistent queue because of TransientException", innerException3); } catch (DataSourceOperationException innerException4) { throw new SyncAgentTransientException("Failed to enqueue sync workitem into persistent queue because of DataSourceOperationException", innerException4); } catch (DataValidationException innerException5) { throw new SyncAgentTransientException("Failed to enqueue sync workitem into persistent queue because of DataValidationException", innerException5); } }