public Cache(Cache.CacheOption option) { if (string.IsNullOrEmpty(option.RootPath)) { ExTraceGlobals.TranscodingTracer.TraceError((long)this.GetHashCode(), "ctor: root path is empty."); throw new ArgumentException("ctor: root path is empty."); } this.option = option; this.option.RootPath = Path.Combine(this.option.RootPath, "XCCache"); this.cleanupThread = new Thread(new ThreadStart(this.CleanupThreadProc)); this.cleanupThread.Start(); if (Directory.Exists(this.option.RootPath)) { try { Directory.Delete(this.option.RootPath, true); } catch (IOException arg) { ExTraceGlobals.TranscodingTracer.TraceError <IOException>((long)this.GetHashCode(), "Failed to delete the cache folders when intializing the Cache instance. Exception message: {0}", arg); DirectoryInfo dirInfo = new DirectoryInfo(this.option.RootPath); this.cacheSize = this.GetFolderSize(dirInfo); } catch (UnauthorizedAccessException ex) { OwaDiagnostics.LogEvent(ClientsEventLogConstants.Tuple_TranscodingCacheFolderDeletingAccessDenied, string.Empty, new object[] { ex.Message }); throw new TranscodingFatalFaultException("Failed to delete the cache root folder. Exception message: " + ex.ToString(), ex, this); } } string path = Cache.GenerateGuidString(); this.processFolder = Path.Combine(this.option.RootPath, path); if (Directory.Exists(this.processFolder)) { OwaDiagnostics.LogEvent(ClientsEventLogConstants.Tuple_TranscodingManagerInitializationFailed, string.Empty, new object[] { string.Empty }); throw new TranscodingFatalFaultException("The sub folder for the current OWA process has already existed.", null, this); } SecurityIdentifier identity; SecurityIdentifier identity2; try { identity = new SecurityIdentifier(WellKnownSidType.LocalSystemSid, null); identity2 = new SecurityIdentifier(WellKnownSidType.LocalServiceSid, null); } catch (SystemException ex2) { ExTraceGlobals.TranscodingTracer.TraceError((long)this.GetHashCode(), "Failed to create security identifier in Cache.ctor."); OwaDiagnostics.LogEvent(ClientsEventLogConstants.Tuple_TranscodingManagerInitializationFailed, string.Empty, new object[] { ex2.Message }); throw new TranscodingFatalFaultException("Failed to create security identifier in Cache.ctor.", ex2, this); } this.localServiceReadRule = new FileSystemAccessRule(identity2, FileSystemRights.Read, InheritanceFlags.ContainerInherit | InheritanceFlags.ObjectInherit, PropagationFlags.None, AccessControlType.Allow); this.localServiceWriteRule = new FileSystemAccessRule(identity2, FileSystemRights.Write, InheritanceFlags.ContainerInherit | InheritanceFlags.ObjectInherit, PropagationFlags.None, AccessControlType.Allow); this.localServiceCreateFileRule = new FileSystemAccessRule(identity2, FileSystemRights.WriteData, InheritanceFlags.ContainerInherit | InheritanceFlags.ObjectInherit, PropagationFlags.None, AccessControlType.Allow); this.localServiceDeleteFileRule = new FileSystemAccessRule(identity2, FileSystemRights.Delete, InheritanceFlags.ContainerInherit | InheritanceFlags.ObjectInherit, PropagationFlags.None, AccessControlType.Allow); FileSystemAccessRule rule = new FileSystemAccessRule(identity, FileSystemRights.FullControl, InheritanceFlags.ContainerInherit | InheritanceFlags.ObjectInherit, PropagationFlags.None, AccessControlType.Allow); this.directorySercurity = new DirectorySecurity(); this.directorySercurity.SetAccessRuleProtection(true, false); this.directorySercurity.AddAccessRule(rule); try { if (!Directory.Exists(this.option.RootPath)) { Directory.CreateDirectory(this.option.RootPath, this.directorySercurity); } this.directorySercurity.AddAccessRule(this.localServiceReadRule); this.directorySercurity.AddAccessRule(this.localServiceWriteRule); this.directorySercurity.AddAccessRule(this.localServiceCreateFileRule); this.directorySercurity.AddAccessRule(this.localServiceDeleteFileRule); Directory.CreateDirectory(this.processFolder, this.directorySercurity); } catch (IOException ex3) { OwaDiagnostics.LogEvent(ClientsEventLogConstants.Tuple_TranscodingCacheFolderCreationFailed, string.Empty, new object[] { ex3.Message }); throw new TranscodingFatalFaultException("Failed to create the sub folder and set the ACL for the current OWA process. Exception message: " + ex3.ToString(), ex3, this); } catch (UnauthorizedAccessException ex4) { OwaDiagnostics.LogEvent(ClientsEventLogConstants.Tuple_TranscodingCacheFolderACLSettingAccessDenied, string.Empty, new object[] { ex4.Message }); throw new TranscodingFatalFaultException("Failed to create the sub folder and set the ACL for the current OWA process. Exception message: " + ex4.ToString(), ex4, this); } }
// Token: 0x06001CAD RID: 7341 RVA: 0x000A4D10 File Offset: 0x000A2F10 private TranscodingTaskManager(int maxConversionTime, int maxConversionPerProcess, string rootCachePath, int totalSizeQuota, int rowNumberInExcel, int maxInputSize, int maxOutputSize, bool isImageMode, HtmlFormat htmlFormat, int memoryLimit) { if (maxConversionTime <= 0) { throw new ArgumentException("Invalid maximum conversion time", "maxConversionTime"); } if (maxConversionPerProcess <= 0) { throw new ArgumentException("Invalid maximum conversion number per process", "maxConversionPerProcess"); } if (string.IsNullOrEmpty(rootCachePath)) { throw new ArgumentException("The root path for cache system can not be null or empty", "rootCachePath"); } if (totalSizeQuota <= 0) { throw new ArgumentException("Invalid cache quota", "totalSizeQuota"); } if (rowNumberInExcel <= 0) { throw new ArgumentException("Invalid maximum row/page of excel documents", "rowNumberInExcel"); } if (maxInputSize <= 0) { throw new ArgumentException("Invalid input data threshold", "maxInputSize"); } if (maxOutputSize <= 0) { throw new ArgumentException("Invalid output data threshold", "maxOutputSize"); } if (memoryLimit <= 0) { throw new ArgumentException("Invalid memory limit", "memoryLimit"); } this.rowNumberInExcel = rowNumberInExcel; this.maxOutputSize = maxOutputSize; this.isImageMode = isImageMode; this.htmlFormat = htmlFormat; try { this.transcodingActiveMutex = new Mutex(false, "F7CC98B4-F6F5-489D-98EB-000689C721DE"); } catch (UnauthorizedAccessException e) { this.CreateMutexFailed(e); } catch (IOException e2) { this.CreateMutexFailed(e2); } catch (ApplicationException e3) { this.CreateMutexFailed(e3); } OwaSingleCounters.TotalConversions.RawValue = 0L; OwaSingleCounters.ActiveConversions.RawValue = 0L; OwaSingleCounters.QueuedConversionRequests.RawValue = 0L; OwaSingleCounters.AverageConvertingTime.RawValue = 0L; OwaSingleCounters.AverageConversionQueuingTime.RawValue = 0L; OwaSingleCounters.TotalRejectedConversions.RawValue = 0L; OwaSingleCounters.TotalTimeoutConversions.RawValue = 0L; OwaSingleCounters.TotalErrorConversions.RawValue = 0L; using (RegistryKey registryKey = Registry.LocalMachine.OpenSubKey(string.Format("SOFTWARE\\Classes\\CLSID\\{{{0}}}\\LocalServer32", "F7CC98B4-F6F5-489D-98EB-000689C721DE"))) { if (registryKey == null) { OwaDiagnostics.LogEvent(ClientsEventLogConstants.Tuple_TranscodingWorkerApplicationNotRegistered, string.Empty, new object[0]); throw new TranscodingFatalFaultException("TranscodingService is not registered.", null, this); } this.workProcessPath = ((string)registryKey.GetValue(null)).Trim(new char[] { '"' }); } if (string.IsNullOrEmpty(this.workProcessPath) || !File.Exists(this.workProcessPath)) { OwaDiagnostics.LogEvent(ClientsEventLogConstants.Tuple_TranscodingWorkerApplicationNotFound, string.Empty, new object[0]); throw new TranscodingFatalFaultException("Unable to find the transcoding service application.", null, this); } Cache.CacheOption option = new Cache.CacheOption(rootCachePath, totalSizeQuota, maxInputSize, maxOutputSize); this.cache = new Cache(option); this.blockList = new BlockList(3000, TimeSpan.FromSeconds(86400.0)); ComWorkerConfiguration workerConfiguration = new ComWorkerConfiguration(this.workProcessPath, null, new Guid("F7CC98B4-F6F5-489D-98EB-000689C721DE"), ComWorkerConfiguration.RunAsFlag.RunAsLocalService, this.transcodingActiveMutex, memoryLimit, 7200000, 30000, maxConversionPerProcess, maxConversionTime * 1000, 0); try { this.transcodingProcessManager = new ComProcessManager <ITranscoder>(TranscodingTaskManager.maxWorkProcessNumber, workerConfiguration, ExTraceGlobals.TranscodingTracer); } catch (ComProcessManagerInitializationException innerException) { throw new TranscodingFatalFaultException("Initialize transcoding process manager failed.", innerException, this); } ComProcessManager <ITranscoder> comProcessManager = this.transcodingProcessManager; comProcessManager.CreateWorkerCallback = (ComProcessManager <ITranscoder> .OnCreateWorker)Delegate.Combine(comProcessManager.CreateWorkerCallback, new ComProcessManager <ITranscoder> .OnCreateWorker(this.OnCreateWorkerDelegate)); ComProcessManager <ITranscoder> comProcessManager2 = this.transcodingProcessManager; comProcessManager2.ExecuteRequestCallback = (ComProcessManager <ITranscoder> .OnExecuteRequest)Delegate.Combine(comProcessManager2.ExecuteRequestCallback, new ComProcessManager <ITranscoder> .OnExecuteRequest(this.OnExecuteRequestDelegate)); }