Exemple #1
0
        internal void ExecuteUpdateQuery(GetUpdates getUpdates)
        {
            UpdateQueryContext updateQueryContext = null;

            lock (this.queryQueueLockObject)
            {
                if (this.queryQueue.Count > 0)
                {
                    updateQueryContext = this.queryQueue.Dequeue();
                }
                else
                {
                    this.GetUpdatesCount--;
                    if (this.GetUpdatesCount < 0)
                    {
                        throw new InvalidOperationException("GetUpdatesCount can't be less than 0.");
                    }
                    ExtensionsCache.Tracer.TraceDebug <int>(0L, "Query queue is empty. GetUpdates Count {0}", this.GetUpdatesCount);
                }
            }
            if (updateQueryContext != null)
            {
                ExtensionsCache.Tracer.TraceDebug <IExchangePrincipal>(0L, "Starting query for {0}.", updateQueryContext.ExchangePrincipal);
                if (this.SkipSubmitUpdateQueryForTest)
                {
                    this.SubmitCount = updateQueryContext.UpdateRequestAssets.Count;
                    return;
                }
                getUpdates.Execute(updateQueryContext);
            }
        }
Exemple #2
0
        internal void QueueQueryItem(UpdateQueryContext queryContext)
        {
            GetUpdates getUpdates = null;

            lock (this.queryQueueLockObject)
            {
                if (this.queryQueue.Count > 500)
                {
                    ExtensionsCache.Tracer.TraceError <IExchangePrincipal>(0L, "Query for {0} not added to the query queue because queue is full.", queryContext.ExchangePrincipal);
                    ExtensionDiagnostics.Logger.LogEvent(ApplicationLogicEventLogConstants.Tuple_ExtensionUpdateQueryMaxExceeded, null, new object[]
                    {
                        "ProcessUpdates",
                        ExtensionDiagnostics.GetLoggedMailboxIdentifier(queryContext.ExchangePrincipal)
                    });
                    return;
                }
                ExtensionsCache.Tracer.TraceDebug <IExchangePrincipal>(0L, "Adding query for {0} to the query queue.", queryContext.ExchangePrincipal);
                this.queryQueue.Enqueue(queryContext);
                if (this.GetUpdatesCount < 50)
                {
                    getUpdates = new GetUpdates(this.urlsCache, this);
                    this.GetUpdatesCount++;
                    ExtensionsCache.Tracer.TraceDebug <int>(0L, "Creating a new instance of GetUpdates. GetUpdates Count {0}", this.GetUpdatesCount);
                }
                else
                {
                    ExtensionsCache.Tracer.TraceDebug <int>(0L, "Too many GetUpdates commands. Query will be handled from pool. GetUpdates Count {0}", this.GetUpdatesCount);
                }
            }
            if (getUpdates != null)
            {
                this.ExecuteUpdateQuery(getUpdates);
            }
        }
        // Token: 0x06000BEB RID: 3051 RVA: 0x00030E40 File Offset: 0x0002F040
        internal Queue <UpdateRequestAsset> BuildDownloadQueue(List <AppStateResponseAsset> appStateResponses, Uri appStateUri, List <ExtensionData> updates)
        {
            Queue <UpdateRequestAsset> queue = new Queue <UpdateRequestAsset>(appStateResponses.Count);

            foreach (AppStateResponseAsset appStateResponseAsset in appStateResponses)
            {
                UpdateRequestAsset updateRequestAsset = null;
                if (!this.updateRequestAssets.TryGetValue(appStateResponseAsset.MarketplaceAssetID, out updateRequestAsset))
                {
                    GetUpdates.Tracer.TraceError <string, string>(0L, "GetUpdates.GetAppStateSuccessCallback: Asset returned in AppState response will not be downloaded. Asset ID does not match any value requested.  Response Asset ID: {0} Response Extension ID: {1}", appStateResponseAsset.MarketplaceAssetID, appStateResponseAsset.ExtensionID);
                    ExtensionDiagnostics.Logger.LogEvent(ApplicationLogicEventLogConstants.Tuple_InvalidAssetIDReturnedByAppState, appStateResponseAsset.MarketplaceAssetID, new object[]
                    {
                        "ProcessUpdates",
                        this.GetLoggedMailboxIdentifier(),
                        appStateResponseAsset.MarketplaceAssetID,
                        appStateUri
                    });
                }
                else if (!this.CacheSatisfiesRequest(updateRequestAsset, updates))
                {
                    if (appStateResponseAsset.ExtensionID != updateRequestAsset.ExtensionID)
                    {
                        GetUpdates.Tracer.TraceError <string, string, string>(0L, "GetUpdates.GetAppStateSuccessCallback: Asset returned in AppState response will not be downloaded. Extension ID does not match expected value.  Asset ID: {0} Response: {1} Expected: {2}", appStateResponseAsset.MarketplaceAssetID, appStateResponseAsset.ExtensionID, updateRequestAsset.ExtensionID);
                        ExtensionDiagnostics.Logger.LogEvent(ApplicationLogicEventLogConstants.Tuple_MismatchedExtensionIDReturnedByAppState, appStateResponseAsset.MarketplaceAssetID, new object[]
                        {
                            "ProcessUpdates",
                            this.GetLoggedMailboxIdentifier(),
                            appStateResponseAsset.MarketplaceAssetID,
                            appStateUri,
                            updateRequestAsset.ExtensionID,
                            appStateResponseAsset.ExtensionID
                        });
                    }
                    else if (appStateResponseAsset.State != null && appStateResponseAsset.Version != null && (appStateResponseAsset.Version == updateRequestAsset.Version || !GetUpdates.IsValidUpdateState(appStateResponseAsset.State)))
                    {
                        this.extensionsCache.Update(appStateResponseAsset);
                    }
                    else if (GetUpdates.IsValidUpdateState(appStateResponseAsset.State) && appStateResponseAsset.Version != null && appStateResponseAsset.Version > updateRequestAsset.Version)
                    {
                        GetUpdates.Tracer.TraceDebug <string>(0L, "GetUpdates.GetAppStateSuccessCallback: Add asset {0} to download queue", appStateResponseAsset.MarketplaceAssetID);
                        updateRequestAsset.State = appStateResponseAsset.State.Value;
                        queue.Enqueue(updateRequestAsset);
                    }
                    else
                    {
                        GetUpdates.Tracer.TraceDebug <string, OmexConstants.AppState?, Version>(0L, "GetUpdates.GetAppStateSuccessCallback: Asset returned in AppState response will not be downloaded. Asset ID: {0} State: {1} Version: {2}", appStateResponseAsset.MarketplaceAssetID, appStateResponseAsset.State, appStateResponseAsset.Version);
                    }
                }
            }
            return(queue);
        }
Exemple #4
0
        internal void Update(AppStateResponseAsset appStateResponseAsset)
        {
            if (appStateResponseAsset == null)
            {
                throw new ArgumentNullException("appStateResponseAsset");
            }
            if (appStateResponseAsset.State == null)
            {
                throw new ArgumentNullException("appStateResponseAsset.State");
            }
            if (appStateResponseAsset.Version == null)
            {
                throw new ArgumentNullException("appStateResponseAsset.Version");
            }
            byte[] manifest = null;
            RequestedCapabilities?requestedCapabilities = null;
            ExtensionsCacheEntry  extensionsCacheEntry  = null;

            if (this.extensionsDictionary.TryGetValue(appStateResponseAsset.MarketplaceAssetID, out extensionsCacheEntry) && extensionsCacheEntry.Version == appStateResponseAsset.Version)
            {
                ExtensionsCache.Tracer.TraceDebug <string>(0L, "ExtensionsCache.Update: Since version is unchanged, getting properties from extension entry {0} for add", appStateResponseAsset.MarketplaceAssetID);
                requestedCapabilities = extensionsCacheEntry.RequestedCapabilities;
                if (GetUpdates.IsValidUpdateState(new OmexConstants.AppState?(appStateResponseAsset.State.Value)))
                {
                    manifest = extensionsCacheEntry.Manifest;
                }
                else
                {
                    manifest = null;
                }
            }
            ExtensionsCache.Tracer.TraceDebug <string>(0L, "ExtensionsCache.Update: Adding extension {0} from AppStateResponse", appStateResponseAsset.MarketplaceAssetID);
            ExtensionsCacheEntry entry = new ExtensionsCacheEntry(appStateResponseAsset.MarketplaceAssetID, appStateResponseAsset.ExtensionID, appStateResponseAsset.Version, requestedCapabilities, appStateResponseAsset.State.Value, manifest);

            this.AddExtension(entry);
        }
        // Token: 0x06000BED RID: 3053 RVA: 0x00031178 File Offset: 0x0002F378
        internal bool CacheSatisfiesRequest(UpdateRequestAsset requestAsset, List <ExtensionData> updates)
        {
            bool result = false;
            ExtensionsCacheEntry extensionsCacheEntry = null;

            if (this.extensionsCache.TryGetEntry(requestAsset.MarketplaceAssetID, out extensionsCacheEntry) && requestAsset.Version <= extensionsCacheEntry.Version && extensionsCacheEntry.Manifest != null)
            {
                if (requestAsset.ExtensionID != extensionsCacheEntry.ExtensionID)
                {
                    GetUpdates.Tracer.TraceError <string, string, string>(0L, "GetUpdates.CacheSatisfiesRequest: Asset {0} extension ID {1} does not match the cache entry {2}", requestAsset.MarketplaceAssetID, requestAsset.ExtensionID, extensionsCacheEntry.ExtensionID);
                    ExtensionDiagnostics.Logger.LogEvent(ApplicationLogicEventLogConstants.Tuple_MismatchedCacheMailboxExtensionId, requestAsset.MarketplaceAssetID, new object[]
                    {
                        "ProcessUpdates",
                        this.GetLoggedMailboxIdentifier(),
                        requestAsset.MarketplaceAssetID,
                        requestAsset.ExtensionID,
                        extensionsCacheEntry.ExtensionID
                    });
                    result = true;
                }
                else if (requestAsset.Version == extensionsCacheEntry.Version)
                {
                    GetUpdates.Tracer.TraceDebug <string>(0L, "GetUpdates.CacheSatisfiesRequest: Asset {0} version matches the cache entry", requestAsset.MarketplaceAssetID);
                    result = true;
                }
                else if (requestAsset.Version < extensionsCacheEntry.Version && extensionsCacheEntry.Manifest != null)
                {
                    if (ExtensionData.CompareCapabilities(extensionsCacheEntry.RequestedCapabilities.Value, requestAsset.RequestedCapabilities) > 0)
                    {
                        GetUpdates.Tracer.TraceDebug <string, RequestedCapabilities, RequestedCapabilities>(0L, "GetUpdates.CacheSatisfiesRequest: Asset cache entry requires more capabilities than installed asset.  Asset ID: {0} Update: {1} Installed: {2}", requestAsset.MarketplaceAssetID, extensionsCacheEntry.RequestedCapabilities.Value, requestAsset.RequestedCapabilities);
                        ExtensionDiagnostics.Logger.LogEvent(ApplicationLogicEventLogConstants.Tuple_MoreCapabilitiesSkipUpdate, requestAsset.MarketplaceAssetID, new object[]
                        {
                            "ProcessUpdates",
                            this.GetLoggedMailboxIdentifier(),
                            requestAsset.MarketplaceAssetID,
                            requestAsset.RequestedCapabilities,
                            extensionsCacheEntry.RequestedCapabilities.Value
                        });
                        result = true;
                    }
                    else if (!GetUpdates.IsValidUpdateState(new OmexConstants.AppState?(extensionsCacheEntry.State)))
                    {
                        GetUpdates.Tracer.TraceDebug <string, OmexConstants.AppState>(0L, "GetUpdates.CacheSatisfiesRequest: Asset {0} cache entry AppState {1} is not valid for updates", requestAsset.MarketplaceAssetID, extensionsCacheEntry.State);
                        ExtensionDiagnostics.Logger.LogEvent(ApplicationLogicEventLogConstants.Tuple_InvalidStateSkipUpdate, requestAsset.MarketplaceAssetID, new object[]
                        {
                            "ProcessUpdates",
                            this.GetLoggedMailboxIdentifier(),
                            requestAsset.MarketplaceAssetID,
                            extensionsCacheEntry.State
                        });
                        result = true;
                    }
                    else
                    {
                        GetUpdates.Tracer.TraceDebug <string>(0L, "GetUpdates.CacheSatisfiesRequest: Asset {0} will be updated from the cache", requestAsset.MarketplaceAssetID);
                        ExtensionData updatedExtension = null;
                        Exception     ex = InstalledExtensionTable.RunClientExtensionAction(delegate
                        {
                            updatedExtension = ExtensionData.ParseOsfManifest(extensionsCacheEntry.Manifest, extensionsCacheEntry.Manifest.Length, requestAsset.MarketplaceAssetID, requestAsset.MarketplaceContentMarket, ExtensionType.MarketPlace, requestAsset.Scope, requestAsset.Enabled, requestAsset.DisableReason, string.Empty, requestAsset.Etoken);
                        });
                        if (ex == null)
                        {
                            updates.Add(updatedExtension);
                            result = true;
                        }
                        else
                        {
                            GetUpdates.Tracer.TraceError <string, Exception>(0L, "GetUpdates.CacheSatisfiesRequest: Parse of manifest failed for extension {0}. Exception: {1}", requestAsset.MarketplaceAssetID, ex);
                            ExtensionDiagnostics.Logger.LogEvent(ApplicationLogicEventLogConstants.Tuple_CachedManifestParseFailed, requestAsset.MarketplaceAssetID, new object[]
                            {
                                "ProcessUpdates",
                                requestAsset.MarketplaceAssetID,
                                ExtensionDiagnostics.GetLoggedExceptionString(ex)
                            });
                        }
                    }
                }
            }
            return(result);
        }
Exemple #6
0
        internal bool TryGetExtensionUpdate(ExtensionData extensionData, out byte[] manifestBytes)
        {
            manifestBytes = null;
            this.CleanupCache();
            ExtensionsCacheEntry extensionsCacheEntry = null;

            if (this.extensionsDictionary.TryGetValue(extensionData.MarketplaceAssetID, out extensionsCacheEntry))
            {
                if (extensionData.ExtensionId != extensionsCacheEntry.ExtensionID)
                {
                    ExtensionsCache.Tracer.TraceError <string, string, string>(0L, "ExtensionsCache.TryGetExtensionUpdate: Extension {0} ExtensionID property {1} does not match cache entry value {2}.", extensionData.MarketplaceAssetID, extensionData.ExtensionId, extensionsCacheEntry.ExtensionID);
                    ExtensionDiagnostics.Logger.LogEvent(ApplicationLogicEventLogConstants.Tuple_MismatchedCacheMailboxExtensionId, extensionData.MarketplaceAssetID, new object[]
                    {
                        "ProcessUpdates",
                        extensionData.MarketplaceAssetID,
                        extensionData.ExtensionId,
                        extensionsCacheEntry.ExtensionID
                    });
                }
                else if (extensionData.Version != null && extensionsCacheEntry.RequestedCapabilities != null && extensionsCacheEntry.Manifest != null && extensionData.Version < extensionsCacheEntry.Version && ExtensionData.CompareCapabilities(extensionsCacheEntry.RequestedCapabilities.Value, extensionData.RequestedCapabilities.Value) <= 0 && GetUpdates.IsValidUpdateState(new OmexConstants.AppState?(extensionsCacheEntry.State)))
                {
                    manifestBytes = extensionsCacheEntry.Manifest;
                }
            }
            return(manifestBytes != null);
        }