// Token: 0x06000BF7 RID: 3063 RVA: 0x00031E60 File Offset: 0x00030060
        private void WriteAppStatuesToMailbox()
        {
            if (this.appStatuses.Count == 0)
            {
                return;
            }
            GetUpdates.Tracer.TraceDebug <int>(0L, "GetUpdates.ConfigAppStatus: Config app status for {0} extensions.", this.appStatuses.Count);
            Exception ex = InstalledExtensionTable.RunClientExtensionAction(delegate
            {
                using (MailboxSession mailboxSession = MailboxSession.OpenAsSystemService(this.queryContext.ExchangePrincipal, this.queryContext.CultureInfo, this.queryContext.ClientInfoString))
                {
                    using (InstalledExtensionTable installedExtensionTable = InstalledExtensionTable.CreateInstalledExtensionTable(this.queryContext.Domain, this.queryContext.IsUserScope, this.queryContext.OrgEmptyMasterTableCache, mailboxSession))
                    {
                        foreach (KeyValuePair <string, string> keyValuePair in this.appStatuses)
                        {
                            installedExtensionTable.ConfigureAppStatus(keyValuePair.Key, keyValuePair.Value);
                        }
                        installedExtensionTable.SaveXML();
                    }
                }
            });

            if (ex != null)
            {
                GetUpdates.Tracer.TraceError <Exception>(0L, "GetUpdates.ConfigAppStatus: Config app status failed. Exception: {0}", ex);
                ExtensionDiagnostics.Logger.LogEvent(ApplicationLogicEventLogConstants.Tuple_FailedToConfigAppStatus, null, new object[]
                {
                    "ProcessUpdates",
                    ExtensionDiagnostics.GetLoggedMailboxIdentifier(this.queryContext.ExchangePrincipal),
                    ExtensionDiagnostics.GetLoggedExceptionString(ex)
                });
            }
        }
Beispiel #2
0
        // Token: 0x06000B70 RID: 2928 RVA: 0x0002EC1C File Offset: 0x0002CE1C
        internal void QueueQueryItem(TokenRenewQueryContext queryContext)
        {
            GetTokens getTokens = null;

            lock (this.queryQueueLockObject)
            {
                if (this.queryQueue.Count > 500)
                {
                    TokenRenewSubmitter.Tracer.TraceError <IExchangePrincipal>(0L, "Query for {0} not added to the query queue because queue is full.", queryContext.ExchangePrincipal);
                    ExtensionDiagnostics.Logger.LogEvent(ApplicationLogicEventLogConstants.Tuple_ExtensionTokenQueryMaxExceeded, null, new object[]
                    {
                        "ProcessTokenRenew",
                        ExtensionDiagnostics.GetLoggedMailboxIdentifier(queryContext.ExchangePrincipal)
                    });
                    return;
                }
                TokenRenewSubmitter.Tracer.TraceDebug <IExchangePrincipal>(0L, "Adding query for {0} to the query queue.", queryContext.ExchangePrincipal);
                this.queryQueue.Enqueue(queryContext);
                if (this.GetTokensCount < 50)
                {
                    getTokens = new GetTokens(this.urlsCache, this);
                    this.GetTokensCount++;
                    TokenRenewSubmitter.Tracer.TraceDebug <int>(0L, "Creating a new instance of GetTokens. GetTokens Count {0}", this.GetTokensCount);
                }
                else
                {
                    TokenRenewSubmitter.Tracer.TraceDebug <int>(0L, "Too many GetTokens commands. Query will be handled from pool. GetTokens Count {0}", this.GetTokensCount);
                }
            }
            if (getTokens != null)
            {
                this.ExecuteTokenRenewQuery(getTokens);
            }
        }
        // Token: 0x06000BF5 RID: 3061 RVA: 0x00031C20 File Offset: 0x0002FE20
        internal void InstallExtensionUpdates(List <ExtensionData> updates, UpdateQueryContext queryContext)
        {
            GetUpdates.Tracer.TraceDebug <int>(0L, "GetUpdates.InstallExtensionUpdates: Installing {0} extensions.", updates.Count);
            ExtensionData currentExtensionData = null;
            Exception     ex = InstalledExtensionTable.RunClientExtensionAction(delegate
            {
                using (MailboxSession mailboxSession = MailboxSession.OpenAsSystemService(queryContext.ExchangePrincipal, queryContext.CultureInfo, queryContext.ClientInfoString))
                {
                    using (InstalledExtensionTable installedExtensionTable = InstalledExtensionTable.CreateInstalledExtensionTable(queryContext.Domain, queryContext.IsUserScope, queryContext.OrgEmptyMasterTableCache, mailboxSession))
                    {
                        foreach (ExtensionData currentExtensionData in updates)
                        {
                            currentExtensionData = currentExtensionData;
                            GetUpdates.Tracer.TraceDebug <string>(0L, "GetUpdates.InstallExtensionUpdates: Installing asset {0}", currentExtensionData.MarketplaceAssetID);
                            installedExtensionTable.AddExtension(currentExtensionData, true);
                            currentExtensionData = null;
                        }
                        installedExtensionTable.SaveXML();
                    }
                }
            });
            string text = (currentExtensionData == null) ? string.Empty : currentExtensionData.MarketplaceAssetID;

            if (ex != null)
            {
                GetUpdates.Tracer.TraceError <string, Exception>(0L, "GetUpdates.InstallExtensionUpdates: Installation failed for extension {0}. Exception: {1}", text, ex);
                ExtensionDiagnostics.Logger.LogEvent(ApplicationLogicEventLogConstants.Tuple_ExtensionUpdateFailed, null, new object[]
                {
                    "UpdateExtension",
                    ExtensionDiagnostics.GetLoggedMailboxIdentifier(queryContext.ExchangePrincipal),
                    text,
                    ExtensionDiagnostics.GetLoggedExceptionString(ex)
                });
            }
            else
            {
                ExtensionDiagnostics.LogToDatacenterOnly(ApplicationLogicEventLogConstants.Tuple_ExtensionUpdateSuccess, null, new object[]
                {
                    "UpdateExtension",
                    ExtensionDiagnostics.GetLoggedMailboxIdentifier(queryContext.ExchangePrincipal),
                    text
                });
            }
            this.ExecuteNextUpdateQuery();
        }
Beispiel #4
0
        private void WriteTokensToMailbox()
        {
            if (this.downloadedTokens.Count == 0 && this.appStatuses.Count == 0)
            {
                return;
            }
            GetTokens.Tracer.TraceDebug <int, int>(0L, "GetTokens.WriteTokensToMailbox: Writing renewed tokens for {0} apps, failure error codes for {0} apps.", this.downloadedTokens.Count, this.appStatuses.Count);
            Exception ex = InstalledExtensionTable.RunClientExtensionAction(delegate
            {
                using (MailboxSession mailboxSession = MailboxSession.OpenAsSystemService(this.queryContext.ExchangePrincipal, this.queryContext.CultureInfo, this.queryContext.ClientInfoString))
                {
                    using (InstalledExtensionTable installedExtensionTable = InstalledExtensionTable.CreateInstalledExtensionTable(this.queryContext.Domain, this.queryContext.IsUserScope, this.queryContext.OrgEmptyMasterTableCache, mailboxSession))
                    {
                        foreach (KeyValuePair <string, string> keyValuePair in this.downloadedTokens)
                        {
                            installedExtensionTable.ConfigureEtoken(keyValuePair.Key, keyValuePair.Value, true);
                        }
                        foreach (KeyValuePair <string, string> keyValuePair2 in this.appStatuses)
                        {
                            installedExtensionTable.ConfigureAppStatus(keyValuePair2.Key, keyValuePair2.Value);
                        }
                        installedExtensionTable.SaveXML();
                    }
                }
            });

            if (ex != null)
            {
                GetTokens.Tracer.TraceError <Exception>(0L, "GetTokens.WriteTokensToMailbox: Writing renewed tokens failed. Exception: {0}", ex);
                ExtensionDiagnostics.Logger.LogEvent(ApplicationLogicEventLogConstants.Tuple_FailedToWritebackRenewedTokens, null, new object[]
                {
                    "ProcessTokenRenew",
                    ExtensionDiagnostics.GetLoggedMailboxIdentifier(this.queryContext.ExchangePrincipal),
                    ExtensionDiagnostics.GetLoggedExceptionString(ex)
                });
                return;
            }
            ExtensionDiagnostics.LogToDatacenterOnly(ApplicationLogicEventLogConstants.Tuple_ProcessTokenRenewCompleted, null, new object[]
            {
                "ProcessTokenRenew",
                ExtensionDiagnostics.GetLoggedMailboxIdentifier(this.queryContext.ExchangePrincipal)
            });
        }
 // Token: 0x06000BF3 RID: 3059 RVA: 0x0003175C File Offset: 0x0002F95C
 private string GetLoggedMailboxIdentifier()
 {
     return(ExtensionDiagnostics.GetLoggedMailboxIdentifier(this.queryContext.ExchangePrincipal));
 }
Beispiel #6
0
        internal void SubmitUpdateQuery(ICollection <ExtensionData> extensions, UpdateQueryContext queryContext)
        {
            if (extensions == null)
            {
                throw new ArgumentNullException("extensions");
            }
            if (extensions.Count == 0)
            {
                throw new ArgumentException("extensions must contain one or more extensions");
            }
            if (this.SkipSubmitUpdateQueryForTest)
            {
                this.SubmitCount = 0;
            }
            Dictionary <string, UpdateRequestAsset> dictionary = new Dictionary <string, UpdateRequestAsset>(extensions.Count);

            foreach (ExtensionData extensionData in extensions)
            {
                if (extensionData.Version == null)
                {
                    ExtensionsCache.Tracer.TraceDebug <string>(0L, "ExtensionsCache.SubmitUpdateQuery: Extension {0} not added to query list because version is invalid", extensionData.MarketplaceAssetID);
                    ExtensionDiagnostics.Logger.LogEvent(ApplicationLogicEventLogConstants.Tuple_InvalidVersionSubmitUpdateQuery, extensionData.MarketplaceAssetID, new object[]
                    {
                        "ProcessUpdates",
                        ExtensionDiagnostics.GetLoggedMailboxIdentifier(queryContext.ExchangePrincipal),
                        extensionData.MarketplaceAssetID
                    });
                }
                else
                {
                    if (extensionData.Scope == null)
                    {
                        throw new ArgumentNullException("extensionData.Scope");
                    }
                    if (extensionData.RequestedCapabilities == null)
                    {
                        throw new ArgumentNullException("extensionData.RequestedCapabilities");
                    }
                    ExtensionsCacheEntry extensionsCacheEntry = null;
                    if (this.extensionsDictionary.TryGetValue(extensionData.MarketplaceAssetID, out extensionsCacheEntry) && !InstalledExtensionTable.IsUpdateCheckTimeExpired(extensionsCacheEntry.LastUpdateCheckTime) && extensionsCacheEntry.Version == extensionData.Version)
                    {
                        ExtensionsCache.Tracer.TraceDebug <string>(0L, "ExtensionsCache.SubmitUpdateQuery: Extension {0} not added to query list because version matches recent cache entry", extensionData.MarketplaceAssetID);
                    }
                    else
                    {
                        UpdateRequestAsset updateRequestAsset = null;
                        if (dictionary.TryGetValue(extensionData.MarketplaceAssetID, out updateRequestAsset))
                        {
                            ExtensionsCache.Tracer.TraceDebug <string, string, string>(0L, "ExtensionsCache.SubmitUpdateQuery: Extension {0} not added to query list because asset with same MarketplaceAssetID is already in list. ExtensionIds with same asset id: {1} {2}", extensionData.MarketplaceAssetID, extensionData.ExtensionId, updateRequestAsset.ExtensionID);
                        }
                        else
                        {
                            dictionary.Add(extensionData.MarketplaceAssetID, new UpdateRequestAsset
                            {
                                MarketplaceContentMarket = extensionData.MarketplaceContentMarket,
                                ExtensionID           = extensionData.ExtensionId,
                                MarketplaceAssetID    = extensionData.MarketplaceAssetID,
                                RequestedCapabilities = extensionData.RequestedCapabilities.Value,
                                Version       = extensionData.Version,
                                DisableReason = extensionData.DisableReason,
                                Enabled       = extensionData.Enabled,
                                Scope         = extensionData.Scope.Value,
                                Etoken        = extensionData.Etoken
                            });
                        }
                    }
                }
            }
            if (dictionary.Count == 0)
            {
                ExtensionsCache.Tracer.TraceDebug(0L, "ExtensionsCache.SubmitUpdateQuery: UpdateRequestAssets count is 0. Updates query will not be started.");
                return;
            }
            queryContext.UpdateRequestAssets = dictionary;
            queryContext.DeploymentId        = ExtensionDataHelper.GetDeploymentId(queryContext.Domain);
            this.QueueQueryItem(queryContext);
        }