Exemplo n.º 1
0
        internal bool TryGetEntry(string marketplaceAssetID, out ExtensionsCacheEntry extensionCacheEntry)
        {
            ExtensionsCacheEntry extensionsCacheEntry = null;

            if (this.extensionsDictionary.TryGetValue(marketplaceAssetID, out extensionsCacheEntry) && !InstalledExtensionTable.IsUpdateCheckTimeExpired(extensionsCacheEntry.LastUpdateCheckTime))
            {
                extensionCacheEntry = extensionsCacheEntry;
            }
            else
            {
                extensionCacheEntry = null;
            }
            return(extensionCacheEntry != null);
        }
Exemplo n.º 2
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);
        }