// 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: 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) }); } }
// Token: 0x06000B84 RID: 2948 RVA: 0x0002F08C File Offset: 0x0002D28C protected virtual void InternalFailureCallback(Exception exception = null, string traceMessage = null) { if (exception == null && traceMessage == null) { throw new ArgumentNullException("exception", "exception or traceMessage must be non-null"); } if (exception != null) { BaseAsyncCommand.Tracer.TraceError <Uri, Exception>(0L, "BaseAsyncOmexCommand.InternalFailureCallback: Request: {0} Exception: {1}", this.uri, exception); ExtensionDiagnostics.Logger.LogEvent(ApplicationLogicEventLogConstants.Tuple_RequestFailed, this.periodicKey, new object[] { this.scenario, this.requestId, this.GetLoggedMailboxIdentifier(), this.uri, ExtensionDiagnostics.GetLoggedExceptionString(exception) }); } else { BaseAsyncCommand.Tracer.TraceError <Uri, string>(0L, "BaseAsyncOmexCommand.InternalFailureCallback: Request: {0} Message: {1}", this.uri, traceMessage); ExtensionDiagnostics.Logger.LogEvent(ApplicationLogicEventLogConstants.Tuple_RequestFailed, this.periodicKey, new object[] { this.scenario, this.requestId, this.GetLoggedMailboxIdentifier(), this.uri, traceMessage }); } this.failureCallback(exception); }
protected void LogResponseParsed() { ExtensionDiagnostics.LogToDatacenterOnly(ApplicationLogicEventLogConstants.Tuple_OmexWebServiceResponseParsed, null, new object[] { this.scenario, this.requestId, base.GetLoggedMailboxIdentifier(), this.uri }); }
// Token: 0x06000B54 RID: 2900 RVA: 0x0002DE60 File Offset: 0x0002C060 private static ExchangeService CreateExchangeService(string domain, OrgExtensionTable.RequestData requestData) { Stopwatch stopwatch = new Stopwatch(); stopwatch.Start(); ADUser orgMailbox = OrgExtensionTable.GetOrgMailbox(domain); requestData.OrgMailboxAdUserLookupTime = stopwatch.ElapsedMilliseconds; if (orgMailbox == null) { return(null); } ExchangePrincipal exchangePrincipal; try { exchangePrincipal = ExchangePrincipal.FromADUser(orgMailbox, null); } catch (ObjectNotFoundException exception) { ExtensionDiagnostics.Logger.LogEvent(ApplicationLogicEventLogConstants.Tuple_OrganizationMailboxWebServiceUrlRetrievalFailed, domain, new object[] { "ProcessOrgExtensions", ExtensionDiagnostics.GetLoggedExceptionString(exception) }); return(null); } Uri backEndWebServicesUrl; try { backEndWebServicesUrl = BackEndLocator.GetBackEndWebServicesUrl(exchangePrincipal.MailboxInfo); stopwatch.Stop(); requestData.WebServiceUrlLookupTime = stopwatch.ElapsedMilliseconds - requestData.OrgMailboxAdUserLookupTime; } catch (BackEndLocatorException exception2) { ExtensionDiagnostics.Logger.LogEvent(ApplicationLogicEventLogConstants.Tuple_OrganizationMailboxWebServiceUrlRetrievalFailed, domain, new object[] { "ProcessOrgExtensions", ExtensionDiagnostics.GetLoggedExceptionString(exception2) }); return(null); } ExchangeService exchangeService = new ExchangeService(4); exchangeService.Url = backEndWebServicesUrl; exchangeService.PrivilegedUserId = new PrivilegedUserId(0, 2, orgMailbox.PrimarySmtpAddress.ToString()); exchangeService.PrivilegedUserId.BudgetType = new PrivilegedUserIdBudgetType?(2); RemoteCertificateValidationCallback callback = (object param0, X509Certificate param1, X509Chain param2, SslPolicyErrors param3) => true; CertificateValidationManager.RegisterCallback("Extension.OrgExtensionTable", callback); exchangeService.HttpHeaders.Add(CertificateValidationManager.ComponentIdHeaderName, "Extension.OrgExtensionTable"); return(exchangeService); }
private static void GetKillBitFailureCallback(Exception exception) { if (exception != null) { KillBitHelper.Tracer.TraceWarning <Exception>(0L, "GetKillBit failed with exception: {0}", exception); ExtensionDiagnostics.Logger.LogEvent(ApplicationLogicEventLogConstants.Tuple_DownloadKillbitListFailed, null, new object[] { "GetKillBit", ExtensionDiagnostics.GetLoggedExceptionString(exception) }); } }
private static void HandleFileWatcherException(Exception e) { KillbitWatcher.Tracer.TraceError <string, Exception>(0L, "killbit file system watcher failed because of exception {0}.", KillBitHelper.KillBitDirectory, e); ExtensionDiagnostics.Logger.LogEvent(ApplicationLogicEventLogConstants.Tuple_KillbitFileWatcherFailed, null, new object[] { "ProcessKillBit", ExtensionDiagnostics.GetLoggedExceptionString(e) }); Win32Exception ex = e as Win32Exception; if (ex != null && ex.NativeErrorCode == 5) { return; } ExWatson.HandleException(new UnhandledExceptionEventArgs(e, false), ReportOptions.None); }
public static void TryWatch(KillbitWatcher.ReadKillBitFromFileCallback readKillBitFromFileCallback) { if (!Directory.Exists(KillBitHelper.KillBitDirectory)) { Exception ex = null; try { KillbitWatcher.Tracer.TraceInformation <string>(0, 0L, "Killbit folder {0} is not there. Creating it.", KillBitHelper.KillBitDirectory); ExtensionDiagnostics.Logger.LogEvent(ApplicationLogicEventLogConstants.Tuple_KillbitFolderNotExist, null, new object[] { "ProcessKillBit" }); Directory.CreateDirectory(KillBitHelper.KillBitDirectory); } catch (DirectoryNotFoundException ex2) { ex = ex2; } catch (IOException ex3) { ex = ex3; } catch (UnauthorizedAccessException ex4) { ex = ex4; } if (ex != null) { KillbitWatcher.Tracer.TraceError <string, Exception>(0L, "Cannot created killbit folder {0} due to Exception {1}.", KillBitHelper.KillBitDirectory, ex); ExtensionDiagnostics.Logger.LogEvent(ApplicationLogicEventLogConstants.Tuple_CanNotCreateKillbitFolder, null, new object[] { "ProcessKillBit", ExtensionDiagnostics.GetLoggedExceptionString(ex) }); return; } } try { KillbitWatcher.Watch(readKillBitFromFileCallback); } catch (Exception e) { KillbitWatcher.HandleFileWatcherException(e); } }
// 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(); }
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) }); }
private static string GetContentDeliveryNetworkEndpoint() { try { string text = ConfigurationManager.AppSettings["ContentDeliveryNetworkEndpoint"] ?? string.Empty; return(text.TrimEnd(new char[] { '/' })); } catch (ConfigurationErrorsException ex) { DefaultExtensionTable.Tracer.TraceError <ConfigurationErrorsException>(0L, "Cannot read configuration for ContentDeliveryNetworkEndpoint: {0}", ex); ExtensionDiagnostics.Logger.LogEvent(ApplicationLogicEventLogConstants.Tuple_GetContentDeliveryNetworkEndpointFailed, null, new object[] { DefaultExtensionTable.scenario, ExtensionDiagnostics.GetLoggedExceptionString(ex) }); } return(null); }
public static string GetInstalledOwaVersion() { if (DefaultExtensionTable.owaVersion == null) { Exception ex = null; try { using (RegistryKey registryKey = Registry.LocalMachine.OpenSubKey(OwaConstants.OwaSetupInstallKey)) { DefaultExtensionTable.owaVersion = RegistryReader.Instance.GetValue <string>(registryKey, null, "OwaVersion", string.Empty); DefaultExtensionTable.Tracer.TraceDebug <string>(0L, "Read {0} for owaVersion", DefaultExtensionTable.owaVersion); } } catch (SecurityException ex2) { ex = ex2; } catch (IOException ex3) { ex = ex3; } catch (UnauthorizedAccessException ex4) { ex = ex4; } if (ex != null) { DefaultExtensionTable.Tracer.TraceError <Exception>(0L, "Cannot read owa version from registry due to Exception {0}. Using empty string", ex); ExtensionDiagnostics.Logger.LogEvent(ApplicationLogicEventLogConstants.Tuple_OwaVersionRetrievalFailed, ex.GetType().ToString(), new object[] { "GetInstalledOwaVersion", ExtensionDiagnostics.GetLoggedExceptionString(ex) }); DefaultExtensionTable.owaVersion = string.Empty; } } return(DefaultExtensionTable.owaVersion); }
// Token: 0x06000BF3 RID: 3059 RVA: 0x0003175C File Offset: 0x0002F95C private string GetLoggedMailboxIdentifier() { return(ExtensionDiagnostics.GetLoggedMailboxIdentifier(this.queryContext.ExchangePrincipal)); }
// 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); }
public static MemoryStream DownloadDataFromUri(Uri uri, long expectedMaxResponseSize, Func <long, bool, bool> responseValidationCallback, bool isUrlUserInput = true, bool isBposUser = true) { string text = Guid.NewGuid().ToString(); if (isBposUser && isUrlUserInput && IPAddressUtil.IsIntranetAddress(uri)) { throw new DownloadPermanentException(); } string text2 = uri.OriginalString; if (text2.Contains("?")) { text2 = text2 + "&corr=" + text; } else { text2 = text2 + "?corr=" + text; } uri = new Uri(text2); MemoryStream result = null; HttpWebRequest httpWebRequest = (HttpWebRequest)WebRequest.Create(uri); httpWebRequest.AllowAutoRedirect = true; httpWebRequest.Timeout = 30000; httpWebRequest.CachePolicy = SynchronousDownloadData.NoCachePolicy; try { using (HttpWebResponse httpWebResponse = (HttpWebResponse)httpWebRequest.GetResponse()) { using (Stream responseStream = httpWebResponse.GetResponseStream()) { long num = expectedMaxResponseSize + 1L; if (responseStream.CanSeek) { num = Math.Min(num, responseStream.Length); } byte[] array = new byte[num]; int num2 = 0; int num3; do { num3 = responseStream.Read(array, num2, array.Length - num2); num2 += num3; responseValidationCallback((long)num2, true); }while (num3 > 0); result = new MemoryStream(array, 0, num2); } } } catch (Exception ex) { ExtensionDiagnostics.Logger.LogEvent(ApplicationLogicEventLogConstants.Tuple_DownloadDataFromOfficeMarketPlaceFailed, null, new object[] { "DownloadNewApp", text, uri, ExtensionDiagnostics.GetLoggedExceptionString(ex) }); throw ex; } ExtensionDiagnostics.LogToDatacenterOnly(ApplicationLogicEventLogConstants.Tuple_DownloadDataFromOfficeMarketPlaceSucceeded, null, new object[] { "DownloadNewApp", text, uri }); return(result); }
public static bool TryReadKillBitFile(out int refreshRate, out DateTime lastModifiedTime) { refreshRate = -1; lastModifiedTime = DateTime.UtcNow; Exception ex = null; if (File.Exists(KillBitHelper.KillBitFilePath)) { try { using (Stream stream = File.Open(KillBitHelper.KillBitFilePath, FileMode.Open, FileAccess.Read, FileShare.Read)) { if (stream.Length == 0L) { KillBitHelper.Tracer.TraceError(0L, "The local killbit file is empty."); ExtensionDiagnostics.Logger.LogEvent(ApplicationLogicEventLogConstants.Tuple_EmptyKillbitListLocalFile, null, new object[] { "ProcessKillBit" }); } else { using (XmlReader xmlReader = XmlReader.Create(stream)) { lastModifiedTime = File.GetLastWriteTimeUtc(KillBitHelper.KillBitFilePath); return(KillBitHelper.ReadKillBitXmlContent(xmlReader, out refreshRate)); } } } } catch (SecurityException ex2) { ex = ex2; } catch (FileNotFoundException ex3) { ex = ex3; } catch (UriFormatException ex4) { ex = ex4; } catch (IOException ex5) { ex = ex5; } catch (XmlException ex6) { ex = ex6; } if (ex != null) { KillBitHelper.Tracer.TraceError <Exception>(0L, "Cannot read killbit refresh rate due to Exception {0}", ex); ExtensionDiagnostics.Logger.LogEvent(ApplicationLogicEventLogConstants.Tuple_FailedToReadKillbitList, null, new object[] { "ProcessKillBit", ExtensionDiagnostics.GetLoggedExceptionString(ex) }); return(false); } return(false); } return(false); }
// Token: 0x06000B51 RID: 2897 RVA: 0x0002DA14 File Offset: 0x0002BC14 internal static Dictionary <string, ExtensionData> GetOrgExtensions(StringList requestedExtensionIds, string domain, bool shouldReturnEnabledOnly, bool isUserScope, string userId, StringList userEnabledExtensionIds, StringList userDisabledExtensionIds, out OrgExtensionTable.RequestData requestData, bool isDebug, out string orgMasterTableRawXml, bool retrieveOnly1_0 = false) { Dictionary <string, ExtensionData> dictionary = new Dictionary <string, ExtensionData>(StringComparer.OrdinalIgnoreCase); Collection <ClientExtension> clientExtensions = null; string orgRawXml = null; OrgExtensionTable.RequestData requestDataSave = new OrgExtensionTable.RequestData(); requestData = requestDataSave; OrgExtensionTable.ExecuteWebServicesAction(delegate { Stopwatch stopwatch = new Stopwatch(); stopwatch.Start(); ExchangeService exchangeService = OrgExtensionTable.CreateExchangeServiceDelegate(domain, requestDataSave); if (exchangeService == null) { return; } if (OrgExtensionTable.GetClientExtensionTimeoutIsAllowed()) { exchangeService.Timeout = 30000; } requestDataSave.CreateExchangeServiceTime = stopwatch.ElapsedMilliseconds; GetClientExtensionResponse clientExtension2 = exchangeService.GetClientExtension(requestedExtensionIds, shouldReturnEnabledOnly, isUserScope, userId, userEnabledExtensionIds, userDisabledExtensionIds, isDebug); stopwatch.Stop(); requestDataSave.GetClientExtensionTime = stopwatch.ElapsedMilliseconds - requestDataSave.CreateExchangeServiceTime; requestDataSave.ExchangeServiceUri = exchangeService.Url; string text; if (exchangeService.HttpResponseHeaders.TryGetValue("request-id", out text)) { requestDataSave.EwsRequestId = text.Replace("-", string.Empty); } else { requestDataSave.EwsRequestId = "NotFound"; } clientExtensions = clientExtension2.ClientExtensions; if (isDebug && !string.IsNullOrWhiteSpace(clientExtension2.RawMasterTableXml)) { try { byte[] bytes = Convert.FromBase64String(clientExtension2.RawMasterTableXml); orgRawXml = Encoding.UTF8.GetString(bytes); } catch (FormatException innerException) { throw new OwaExtensionOperationException(innerException); } catch (ArgumentException innerException2) { throw new OwaExtensionOperationException(innerException2); } } }); if (clientExtensions != null) { foreach (ClientExtension clientExtension in clientExtensions) { try { ExtensionData extensionData = ExtensionData.CreateFromClientExtension(clientExtension); if (!retrieveOnly1_0 || !(extensionData.SchemaVersion != SchemaConstants.SchemaVersion1_0)) { ExtensionData extensionData2; if (!dictionary.TryGetValue(extensionData.ExtensionId, out extensionData2) || !(extensionData.SchemaVersion < extensionData2.SchemaVersion)) { dictionary[ExtensionDataHelper.FormatExtensionId(extensionData.ExtensionId)] = extensionData; } } } catch (OwaExtensionOperationException ex) { OrgExtensionTable.Tracer.TraceError <OwaExtensionOperationException>(0L, "skipping an org extension because it cannot be parsed. Exception: {0}", ex); ExtensionDiagnostics.Logger.LogEvent(ApplicationLogicEventLogConstants.Tuple_OrgExtensionParsingFailed, null, new object[] { "ProcessOrgExtensions", ExtensionDiagnostics.GetLoggedExceptionString(ex) }); } } } orgMasterTableRawXml = orgRawXml; return(dictionary); }
private static Dictionary <string, ExtensionData> ReadDefaultExtensionData(IExchangePrincipal exchangePrincipal) { Dictionary <string, ExtensionData> dictionary = new Dictionary <string, ExtensionData>(); string text = ExchangeSetupContext.InstallPath + "ClientAccess\\owa\\" + string.Format("\\prem\\{0}\\ext\\def\\", DefaultExtensionTable.GetInstalledOwaVersion()); string[] array = null; try { if (!Directory.Exists(text)) { DefaultExtensionTable.Tracer.TraceError <string>(0L, "Default extension path {0} does not exist", text); ExtensionDiagnostics.Logger.LogEvent(ApplicationLogicEventLogConstants.Tuple_DefaultExtensionPathNotExist, null, new object[] { DefaultExtensionTable.scenario }); return(dictionary); } array = Directory.GetDirectories(text); } catch (Exception ex) { DefaultExtensionTable.Tracer.TraceError <Exception>(0L, "Failed to access default extension folder. ", ex); ExtensionDiagnostics.Logger.LogEvent(ApplicationLogicEventLogConstants.Tuple_DefaultExtensionFolderAccessFailed, ex.GetType().ToString(), new object[] { DefaultExtensionTable.scenario, ExtensionDiagnostics.GetLoggedExceptionString(ex) }); return(dictionary); } foreach (string text2 in array) { try { string path = text2 + "\\" + "manifest.xml"; if (File.Exists(path)) { using (FileStream fileStream = new FileStream(path, FileMode.Open, FileAccess.Read)) { ExtensionData extensionData = ExtensionData.ParseOsfManifest(fileStream, null, null, ExtensionType.Default, ExtensionInstallScope.Default, true, DisableReasonType.NotDisabled, string.Empty, null); extensionData.ProvidedTo = ClientExtensionProvidedTo.Everyone; extensionData.IsMandatory = false; extensionData.IsEnabledByDefault = true; extensionData.InstalledByVersion = ExchangeSetupContext.InstalledVersion; if (exchangePrincipal != null) { Exception arg = null; if (!DefaultExtensionTable.TryUpdateDefaultExtensionPath(exchangePrincipal, "SourceLocation", extensionData, out arg)) { DefaultExtensionTable.Tracer.TraceError <Exception>(0L, "Skip one default extension because entry point path cannot be updated: {0}", arg); goto IL_22D; } if (!DefaultExtensionTable.TryUpdateDefaultExtensionPath(exchangePrincipal, "IconUrl", extensionData, out arg)) { DefaultExtensionTable.Tracer.TraceError <Exception>(0L, "Skip one default extension because icon path cannot be updated: {0}", arg); goto IL_22D; } if (!DefaultExtensionTable.TryUpdateDefaultExtensionPath(exchangePrincipal, "HighResolutionIconUrl", extensionData, out arg)) { DefaultExtensionTable.Tracer.TraceError <Exception>(0L, "Skip one default extension because hi-res icon path cannot be updated: {0}", arg); goto IL_22D; } } dictionary[ExtensionDataHelper.FormatExtensionId(extensionData.ExtensionId)] = extensionData; } } } catch (Exception ex2) { DefaultExtensionTable.Tracer.TraceError <Exception>(0L, "Skip one default extension because of error. {0}", ex2); ExtensionDiagnostics.Logger.LogEvent(ApplicationLogicEventLogConstants.Tuple_DefaultExtensionRetrievalFailed, text2, new object[] { DefaultExtensionTable.scenario, text2, ExtensionDiagnostics.GetLoggedExceptionString(ex2) }); } IL_22D :; } return(dictionary); }
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); }