protected override void InternalSave(ConfigurableObject instance) { if (instance == null) { throw new ArgumentNullException("instance"); } App owaExtension = instance as App; if (owaExtension == null) { throw new NotSupportedException("Save: " + instance.GetType().FullName); } OWAExtensionDataProvider.RunAction(delegate { using (InstalledExtensionTable installedExtensionTable = InstalledExtensionTable.CreateInstalledExtensionTable(this.domain, this.isUserScope, null, this.MailboxSession)) { switch (owaExtension.ObjectState) { case ObjectState.New: if (!owaExtension.IsDownloadOnly) { installedExtensionTable.InstallExtension(owaExtension.GetExtensionDataForInstall(this.adRecipientSession), false); } break; case ObjectState.Changed: if (this.isUserScope) { installedExtensionTable.ConfigureUserExtension(owaExtension.AppId, owaExtension.Enabled); } else { OrgApp orgApp = instance as OrgApp; if (orgApp == null) { throw new NotSupportedException("Save: " + instance.GetType().FullName); } installedExtensionTable.ConfigureOrgExtension(orgApp.AppId, orgApp.Enabled, orgApp.DefaultStateForUser == DefaultStateForUser.AlwaysEnabled, orgApp.DefaultStateForUser == DefaultStateForUser.Enabled, orgApp.ProvidedTo, OrgApp.ConvertPresentationFormatToWireUserList(this.adRecipientSession, orgApp.UserList)); } break; } } }); }
protected override void InternalDelete(ConfigurableObject instance) { if (instance == null) { throw new ArgumentNullException("instance"); } App owaExtension = instance as App; if (owaExtension == null) { throw new NotSupportedException("Save: " + instance.GetType().FullName); } OWAExtensionDataProvider.RunAction(delegate { using (InstalledExtensionTable installedExtensionTable = InstalledExtensionTable.CreateInstalledExtensionTable(this.domain, this.isUserScope, null, this.MailboxSession)) { if (this.isUserScope) { if (ExtensionInstallScope.User != owaExtension.Scope) { throw new OwaExtensionOperationException(Strings.ErrorUninstallProvidedExtension(owaExtension.DisplayName)); } if (this.TryRemovePerExtensionFai(owaExtension.AppId, owaExtension.AppVersion)) { installedExtensionTable.UninstallExtension(owaExtension.AppId); } else { installedExtensionTable.ConfigureUserExtension(owaExtension.AppId, false); } } else { if (ExtensionInstallScope.Default == owaExtension.Scope) { throw new OwaExtensionOperationException(Strings.ErrorUninstallDefaultExtension(owaExtension.DisplayName)); } installedExtensionTable.UninstallExtension(owaExtension.AppId); } } }); }