Ejemplo n.º 1
0
        protected override IEnumerable <T> InternalFindPaged <T>(QueryFilter filter, ObjectId rootId, bool deepSearch, SortBy sortBy, int pageSize)
        {
            AppId owaExtensionId = rootId as AppId;

            if (sortBy != null)
            {
                throw new NotSupportedException("sortBy");
            }
            if (rootId != null && owaExtensionId == null)
            {
                throw new NotSupportedException("rootId");
            }
            InstalledExtensionTable installedList = null;

            OWAExtensionDataProvider.RunAction(delegate
            {
                installedList = InstalledExtensionTable.CreateInstalledExtensionTable(this.domain, this.isUserScope, null, this.MailboxSession);
            });
            if (owaExtensionId == null || (owaExtensionId.DisplayName == null && owaExtensionId.AppIdValue == null))
            {
                List <ExtensionData> extensions = null;
                OWAExtensionDataProvider.RunAction(delegate
                {
                    extensions             = installedList.GetExtensions(null, false, this.isDebug, out this.rawOrgMasterTableXml);
                    this.rawMasterTableXml = (this.isDebug ? installedList.MasterTableXml.InnerXml : string.Empty);
                });
                foreach (ExtensionData extensionData2 in extensions)
                {
                    yield return((T)((object)this.ConvertStoreObjectToPresentationObject(extensionData2)));
                }
            }
            else if (!string.IsNullOrEmpty(owaExtensionId.AppIdValue))
            {
                ExtensionData extensionData = null;
                OWAExtensionDataProvider.RunAction(delegate
                {
                    installedList.TryGetExtension(owaExtensionId.AppIdValue, out extensionData, this.isDebug, out this.rawOrgMasterTableXml);
                    this.rawMasterTableXml = (this.isDebug ? installedList.MasterTableXml.InnerXml : string.Empty);
                });
                if (extensionData != null)
                {
                    yield return((T)((object)this.ConvertStoreObjectToPresentationObject(extensionData)));
                }
            }
            yield break;
            yield break;
        }
        protected IEnumerable <T> InternalFindPaged <T>(QueryFilter filter, ObjectId rootId, bool deepSearch, SortBy sortBy, int pageSize)
        {
            AppId owaExtensionId = rootId as AppId;

            if (sortBy != null)
            {
                throw new NotSupportedException("sortBy");
            }
            if (rootId != null && owaExtensionId == null)
            {
                throw new NotSupportedException("rootId");
            }
            if (owaExtensionId == null || (owaExtensionId.DisplayName == null && owaExtensionId.AppIdValue == null))
            {
                List <ExtensionData> extensions = new List <ExtensionData>();
                OWAExtensionDataProvider.RunAction(delegate
                {
                    Dictionary <string, ExtensionData> providedExtensions = this.GetProvidedExtensions(null, this.domain, false);
                    foreach (ExtensionData item in providedExtensions.Values)
                    {
                        extensions.Add(item);
                    }
                });
                foreach (ExtensionData extensionData2 in extensions)
                {
                    yield return((T)((object)this.ConvertStoreObjectToPresentationObject(extensionData2)));
                }
            }
            else if (!string.IsNullOrEmpty(owaExtensionId.AppIdValue))
            {
                ExtensionData extensionData = null;
                OWAExtensionDataProvider.RunAction(delegate
                {
                    Dictionary <string, ExtensionData> providedExtensions = this.GetProvidedExtensions(new HashSet <string>(StringComparer.OrdinalIgnoreCase)
                    {
                        owaExtensionId.AppIdValue
                    }, null, false);
                    providedExtensions.TryGetValue(owaExtensionId.AppIdValue, out extensionData);
                });
                if (extensionData != null)
                {
                    yield return((T)((object)this.ConvertStoreObjectToPresentationObject(extensionData)));
                }
            }
            yield break;
        }
Ejemplo n.º 3
0
        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 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
            {
                switch (owaExtension.ObjectState)
                {
                case ObjectState.New:
                    if (!owaExtension.IsDownloadOnly)
                    {
                        OrgExtensionTable.SetOrgExtension(this.domain, 0, null, owaExtension.GetExtensionDataForInstall(this.adRecipientSession));
                        return;
                    }
                    break;

                case ObjectState.Unchanged:
                    break;

                case ObjectState.Changed:
                    {
                        OrgApp orgApp = instance as OrgApp;
                        if (orgApp == null)
                        {
                            throw new NotSupportedException("Save: " + instance.GetType().FullName);
                        }
                        OrgExtensionTable.ConfigureOrgExtension(this.domain, orgApp.AppId, orgApp.Enabled, orgApp.DefaultStateForUser == DefaultStateForUser.AlwaysEnabled, orgApp.DefaultStateForUser == DefaultStateForUser.Enabled, orgApp.ProvidedTo, OrgApp.ConvertPresentationFormatToWireUserList(this.adRecipientSession, orgApp.UserList));
                        break;
                    }

                default:
                    return;
                }
            });
        }
Ejemplo n.º 5
0
        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);
                    }
                }
            });
        }