Пример #1
0
        public static Pipeline CreateAndStartTrainingPipeline(string dbGuid, IDiagnosticsSession session, string pipelineDefinitionFile, string pipelineInstanceName, Version pipelineVersion, out PipelineContext trainingPipelineContext)
        {
            Util.ThrowOnNullOrEmptyArgument(dbGuid, "dbGuid");
            Util.ThrowOnNullArgument(session, "session");
            Util.ThrowOnNullOrEmptyArgument(pipelineDefinitionFile, "pipelineDefinitionFile");
            Util.ThrowOnNullOrEmptyArgument(pipelineInstanceName, "pipelineInstanceName");
            Util.ThrowOnNullArgument(pipelineVersion, "pipelineVersion");
            string text = Path.Combine(InferencePipelineUtil.ExecutingAssemblyLocation, pipelineDefinitionFile);

            session.TraceDebug <string>("Loading pipeline definition from {0}", text);
            PipelineDefinition pipelineDefinition = PipelineDefinition.LoadFromFile(text);

            session.TraceDebug <string, int, int>("Loaded pipeline definition with Name = {0}, MaxConcurrency = {1}, Component Count = {2}", pipelineDefinition.Name, pipelineDefinition.MaxConcurrency, pipelineDefinition.Components.Length);
            session.TraceDebug <string>("Creating training pipeline context with version - {0}", pipelineVersion.ToString());
            trainingPipelineContext = new PipelineContext();
            string instance = string.Format("{0}-{1}", pipelineInstanceName, dbGuid);

            trainingPipelineContext.SetProperty <Version>(DocumentSchema.PipelineVersion, pipelineVersion);
            trainingPipelineContext.SetProperty <bool>(InferencePipelineUtil.AbortProcessing, false);
            trainingPipelineContext.SetProperty <string>(DocumentSchema.PipelineInstanceName, pipelineInstanceName);
            session.TraceDebug("Create the training pipeline", new object[0]);
            Pipeline pipeline = new Pipeline(pipelineDefinition, instance, trainingPipelineContext, null);

            session.TraceDebug("Calling prepareToStart", new object[0]);
            IAsyncResult asyncResult = pipeline.BeginPrepareToStart(null, null);

            asyncResult.AsyncWaitHandle.WaitOne();
            pipeline.EndPrepareToStart(asyncResult);
            session.TraceDebug("Calling Start", new object[0]);
            asyncResult = pipeline.BeginStart(null, null);
            asyncResult.AsyncWaitHandle.WaitOne();
            pipeline.EndStart(asyncResult);
            session.TraceDebug("Training pipeline successfully created and started", new object[0]);
            return(pipeline);
        }
Пример #2
0
        internal static IEnumerable <StoreObjectId> GetSubfolders(IDiagnosticsSession tracer, Folder parentFolder, QueryFilter filter)
        {
            XsoUtil.< > c__DisplayClass6 CS$ < > 8__locals1 = new XsoUtil.< > c__DisplayClass6();
            CS$ < > 8__locals1.parentFolder = parentFolder;
            CS$ < > 8__locals1.filter       = filter;
            Util.ThrowOnNullArgument(CS$ < > 8__locals1.parentFolder, "parentFolder");
            Guid mailboxGuid = CS$ < > 8__locals1.parentFolder.Session.MailboxGuid;

            using (QueryResult queryResult = XsoUtil.TranslateXsoExceptionsWithReturnValue <QueryResult>(tracer, Strings.ConnectionToMailboxFailed(mailboxGuid), () => CS$ < > 8__locals1.parentFolder.FolderQuery(FolderQueryFlags.DeepTraversal, CS$ < > 8__locals1.filter, null, new PropertyDefinition[]
            {
                FolderSchema.Id
            })))
            {
                for (;;)
                {
                    object[][] folders = XsoUtil.TranslateXsoExceptionsWithReturnValue <object[][]>(tracer, Strings.ConnectionToMailboxFailed(mailboxGuid), () => queryResult.GetRows(10000));
                    if (folders == null || folders.Length == 0)
                    {
                        break;
                    }
                    foreach (object[] folderProps in folders)
                    {
                        if (folderProps[0] != null && !PropertyError.IsPropertyError(folderProps[0]))
                        {
                            yield return(StoreId.GetStoreObjectId((StoreId)folderProps[0]));
                        }
                    }
                }
            }
            yield break;
        }
 // Token: 0x060014FB RID: 5371 RVA: 0x00078354 File Offset: 0x00076554
 public UserSessionLogger(string userIdentity, IDiagnosticsSession diagnosticsSession)
 {
     Util.ThrowOnNullArgument(userIdentity, "userIdentity");
     Util.ThrowOnNullArgument(diagnosticsSession, "diagnosticsSession");
     this.userMsgPrefix = string.Format(CultureInfo.InvariantCulture, "U={0} - ", new object[]
     {
         userIdentity
     });
     this.diagnosticsSession = diagnosticsSession;
 }
Пример #4
0
 // Token: 0x06000FBB RID: 4027 RVA: 0x0005D108 File Offset: 0x0005B308
 public ErrorStatisticsProvider(IDiagnosticsSession diagnosticsSession, Guid mdbGuid, SearchConfig config)
 {
     this.mdbGuid            = mdbGuid;
     this.diagnosticsSession = diagnosticsSession;
     this.parameters         = new FailedItemParameters(FailureMode.Permanent, FieldSet.IndexRepairAssistant);
     this.timeoutCache       = new ExactTimeoutCache <Guid, IFailedItemStorage>(delegate(Guid guid, IFailedItemStorage storage, RemoveReason reason)
     {
         storage.Dispose();
     }, null, null, 1, true);
     this.config         = config;
     this.disposeTracker = this.GetDisposeTracker();
 }
Пример #5
0
        public static void StopAndDisposeTrainingPipeline(IDiagnosticsSession session, Pipeline pipeline)
        {
            Util.ThrowOnNullArgument(session, "session");
            Util.ThrowOnNullArgument(pipeline, "pipeline");
            session.TraceDebug("Calling Stop on the pipeline", new object[0]);
            IAsyncResult asyncResult = pipeline.BeginStop(null, null);

            asyncResult.AsyncWaitHandle.WaitOne();
            pipeline.EndStop(asyncResult);
            session.TraceDebug("Pipeline successfully stopped", new object[0]);
            pipeline.Dispose();
        }
Пример #6
0
            public QueryResultWrapper(IDiagnosticsSession tracer, MailboxSession session, StoreObjectId folderId, PropertyDefinition sortProperty, TSort intervalStart, TSort intervalStop, Predicate <object[]> filterPredicate, PropertyDefinition[] predicateProperties, int maxRowCount)
            {
                Util.ThrowOnNullArgument(session, "session");
                Util.ThrowOnNullArgument(folderId, "folderId");
                Util.ThrowOnNullArgument(sortProperty, "sortProperty");
                int num = 0;

                if (filterPredicate != null)
                {
                    Util.ThrowOnNullArgument(predicateProperties, "predicateProperties");
                    num = predicateProperties.Length;
                }
                else if (predicateProperties != null && predicateProperties.Length > 0)
                {
                    throw new ArgumentException("Predicate properties should not be specified when there's no filter supplied.");
                }
                this.diagnosticsSession     = tracer;
                this.maxRowCount            = maxRowCount;
                this.session                = session;
                this.folderId               = folderId;
                this.sortProperty           = sortProperty;
                this.intervalStart          = intervalStart;
                this.intervalStop           = intervalStop;
                this.filterPredicate        = filterPredicate;
                this.propertiesToRequest    = new PropertyDefinition[3 + num];
                this.propertiesToRequest[0] = ItemSchema.Id;
                this.propertiesToRequest[1] = sortProperty;
                this.propertiesToRequest[2] = ItemSchema.DocumentId;
                for (int i = 0; i < num; i++)
                {
                    this.propertiesToRequest[i + 3] = predicateProperties[i];
                }
                this.isAscending = (this.intervalStart.CompareTo(this.intervalStop) < 0);
                if (this.sortProperty == ItemSchema.DocumentId)
                {
                    this.sortOrder = new SortBy[]
                    {
                        new SortBy(ItemSchema.DocumentId, this.isAscending ? SortOrder.Ascending : SortOrder.Descending)
                    };
                    return;
                }
                this.sortOrder = new SortBy[]
                {
                    new SortBy(sortProperty, this.isAscending ? SortOrder.Ascending : SortOrder.Descending),
                    new SortBy(ItemSchema.DocumentId, SortOrder.Ascending)
                };
            }
Пример #7
0
 private static void CallXsoAndMapExceptions(IDiagnosticsSession tracer, Guid mailboxGuid, MdbDocumentAdapter.CallXso xsoCall)
 {
     try
     {
         xsoCall();
     }
     catch (ConnectionFailedTransientException ex)
     {
         tracer.TraceError <Guid, ConnectionFailedTransientException>("Failed to connect to mailbox {0}, exception: {1}", mailboxGuid, ex);
         throw new ComponentFailedTransientException(Strings.ConnectionToMailboxFailed(mailboxGuid), ex);
     }
     catch (ConnectionFailedPermanentException ex2)
     {
         tracer.TraceError <Guid, ConnectionFailedPermanentException>("Failed to connect to mailbox {0}, exception: {1}", mailboxGuid, ex2);
         throw new ComponentFailedPermanentException(Strings.ConnectionToMailboxFailed(mailboxGuid), ex2);
     }
     catch (ObjectNotFoundException ex3)
     {
         tracer.TraceDebug <Guid, ObjectNotFoundException>("Got exception from XSO (MDB: {0}): {1}", mailboxGuid, ex3);
         throw new DocumentFailureException(ex3);
     }
     catch (CorruptDataException ex4)
     {
         tracer.TraceDebug <Guid, CorruptDataException>("Got exception from XSO (MDB: {0}): {1}", mailboxGuid, ex4);
         throw new DocumentFailureException(ex4);
     }
     catch (PropertyErrorException ex5)
     {
         tracer.TraceDebug <Guid, PropertyErrorException>("Got exception from XSO (MDB: {0}): {1}", mailboxGuid, ex5);
         throw new DocumentFailureException(ex5);
     }
     catch (MailboxUnavailableException ex6)
     {
         tracer.TraceDebug <Guid, MailboxUnavailableException>("Got exception from XSO (MDB: {0}): {1}", mailboxGuid, ex6);
         throw new DocumentFailureException(ex6);
     }
     catch (StoragePermanentException innerException)
     {
         throw new ComponentFailedPermanentException(innerException);
     }
     catch (StorageTransientException innerException2)
     {
         throw new ComponentFailedTransientException(innerException2);
     }
 }
Пример #8
0
        private static TReturnValue CallXsoAndMapExceptionsWithReturnValue <TReturnValue>(IDiagnosticsSession tracer, Guid mailboxGuid, MdbDocumentAdapter.CallXsoWithReturnValue <TReturnValue> xsoCall)
        {
            TReturnValue result = default(TReturnValue);

            MdbDocumentAdapter.CallXsoAndMapExceptions(tracer, mailboxGuid, delegate
            {
                result = xsoCall();
            });
            return(result);
        }
Пример #9
0
 public InferenceClassificationAgent(SmtpServer server, Pipeline pipeline, bool isEnabled, bool isPipelineEnabled, IDiagnosticsSession diagnosticsSession, InferenceClassificationAgentLogger classificationAgentLogger, InferenceClassificationComparisonLogger classificationComparisonLogger)
 {
     if (!isEnabled)
     {
         return;
     }
     this.isPipelineEnabled              = isPipelineEnabled;
     this.pipeline                       = pipeline;
     this.server                         = server;
     this.modelConfiguration             = ServerModelConfigurationWrapper.CurrentWrapper;
     this.diagnosticsSession             = diagnosticsSession;
     this.classificationAgentLogger      = classificationAgentLogger;
     this.classificationComparisonLogger = classificationComparisonLogger;
     base.OnPromotedMessage             += this.OnPromotedMessageHandler;
     base.OnDeliveredMessage            += this.OnDeliveredMessageHandler;
     base.OnCompletedMessage            += this.OnCompletedMessageHandler;
 }
Пример #10
0
 internal static TReturnValue TranslateXsoExceptionsWithReturnValue <TReturnValue>(IDiagnosticsSession tracer, LocalizedString errorString, Func <TReturnValue> xsoCall)
 {
     return(XsoUtil.TranslateXsoExceptionsWithReturnValue <TReturnValue>(tracer, errorString, XsoUtil.XsoExceptionHandlingFlags.None, xsoCall));
 }
 // Token: 0x060014A4 RID: 5284 RVA: 0x00076AF0 File Offset: 0x00074CF0
 internal void ProcessMailbox(MailboxSession session, IDiagnosticsSession diagnosticsSession, bool isRecipientInfoBasedRelevanceEnabled = false)
 {
     Util.ThrowOnNullArgument(session, "session");
     Util.ThrowOnNullArgument(diagnosticsSession, "diagnosticsSession");
     PeopleRelevanceFeeder.Tracer.TraceDebug <Guid>((long)this.GetHashCode(), "Processing Mailbox {0}", session.MailboxGuid);
     if (string.IsNullOrEmpty(session.MailboxOwner.MailboxInfo.PrimarySmtpAddress.ToString()))
     {
         diagnosticsSession.LogDiagnosticsInfo(DiagnosticsLoggingTag.Warnings, "Skipping mailbox {0} because owner's primary SMTP address is blank.", new object[]
         {
             session
         });
         return;
     }
     try
     {
         try
         {
             Stopwatch stopwatch = new Stopwatch();
             stopwatch.Start();
             PeopleModelItem modelData = MdbPeopleModelDataBinderFactory.Current.CreateInstance(session).GetModelData();
             PeopleRelevanceFeeder.Tracer.TraceDebug <bool, Version, DateTime>((long)this.GetHashCode(), "Got people inference model item. Default Model = {0} Version = {1} LastModifiedTime = {2} ", modelData.IsDefaultModel, modelData.Version, modelData.LastModifiedTime);
             IDocument document = null;
             IEnumerable <IRecipientInfo> enumerable = null;
             int num  = 0;
             int num2 = 0;
             int num3;
             if (isRecipientInfoBasedRelevanceEnabled)
             {
                 PeopleRelevanceFeeder.Tracer.TraceDebug((long)this.GetHashCode(), "Querying recipients' usage metrics");
                 enumerable = this.recipientInfoGenerator.RunTrainingQuery(session);
                 num3       = enumerable.Count <IRecipientInfo>();
             }
             else
             {
                 PeopleRelevanceFeeder.Tracer.TraceDebug((long)this.GetHashCode(), "Running the training query from SentItems");
                 document = this.sentItemsGenerator.RunTrainingQuery(session, modelData);
                 num3     = document.NestedDocuments.Count;
             }
             if (num3 > 0)
             {
                 IDocument document2 = PeopleRelevanceDocumentFactory.Current.CreatePeopleRelevanceDocument(modelData, document, session.MailboxGuid, session.MailboxOwner.Alias);
                 ExAssert.RetailAssert(document2 != null, "People Relevance document is null");
                 if (isRecipientInfoBasedRelevanceEnabled)
                 {
                     document2.SetProperty(PeopleRelevanceSchema.RecipientInfoEnumerable, enumerable);
                 }
                 document2.SetProperty(PeopleRelevanceSchema.IsBasedOnRecipientInfoData, isRecipientInfoBasedRelevanceEnabled);
                 document2.SetProperty(PeopleRelevanceSchema.MailboxOwner, new MdbRecipient(session.MailboxOwner, session.PreferedCulture));
                 PeopleRelevanceFeeder.Tracer.TraceDebug <IIdentity>((long)this.GetHashCode(), "Created a people relevance document Identity - {0}", document2.Identity);
                 this.peopleRelevanceProcessingPipeline.ProcessDocument(document2, new DocumentProcessingContext(session));
                 stopwatch.Stop();
                 if (isRecipientInfoBasedRelevanceEnabled)
                 {
                     object obj;
                     if (document2.TryGetProperty(PeopleRelevanceSchema.ContactList, out obj))
                     {
                         num = (obj as IDictionary <string, IInferenceRecipient>).Count <KeyValuePair <string, IInferenceRecipient> >();
                     }
                 }
                 else
                 {
                     num = document.NestedDocuments.Count;
                 }
                 num2 = num3 - num;
                 Globals.Logger.LogEvent(InfoWorkerEventLogConstants.Tuple_ProcessingStatisticsForPeopleRelevanceFeeder, null, new object[]
                 {
                     session.MailboxOwner.LegacyDn,
                     num3,
                     num,
                     num2,
                     stopwatch.Elapsed.TotalMilliseconds
                 });
             }
             else
             {
                 stopwatch.Stop();
             }
             PeopleRelevanceFeeder.Tracer.TraceDebug((long)this.GetHashCode(), "The people and time feeder for mailbox {0} picked {1} {2} to process. Number of {2} successfully processed {3} and number of items failed to be processed {4}. Total time taken to process this mailbox {5}.", new object[]
             {
                 session.MailboxOwner.LegacyDn,
                 num3,
                 isRecipientInfoBasedRelevanceEnabled ? "usage metrics" : "sent items",
                 num,
                 num2,
                 stopwatch.Elapsed.TotalMilliseconds
             });
         }
         catch (MessageSubmissionExceededException ex)
         {
             diagnosticsSession.LogDiagnosticsInfo(DiagnosticsLoggingTag.Warnings, "Failed to save model because it's too large.  Exception: {0}", new object[]
             {
                 ex
             });
         }
         catch (QuotaExceededException ex2)
         {
             diagnosticsSession.LogDiagnosticsInfo(DiagnosticsLoggingTag.Warnings, "Failed to reset model or to run training query because mailbox is full.  Exception: {0}", new object[]
             {
                 ex2
             });
         }
         catch (NestedDocumentCountZeroException ex3)
         {
             diagnosticsSession.LogDiagnosticsInfo(DiagnosticsLoggingTag.Failures, "Failed to process training document because it's corrupt.  Nested document count is ZERO.  Exception: {0}", new object[]
             {
                 ex3
             });
             throw;
         }
         catch (ObjectNotFoundException ex4)
         {
             diagnosticsSession.LogDiagnosticsInfo(DiagnosticsLoggingTag.Failures, "Failed to validate recipient cache.  Exception: {0}", new object[]
             {
                 ex4
             });
         }
         catch (StorageTransientException ex5)
         {
             if (!(ex5.InnerException is MapiExceptionTimeout))
             {
                 if (ex5.InnerException is MapiExceptionNetworkError)
                 {
                     diagnosticsSession.LogDiagnosticsInfo(DiagnosticsLoggingTag.Warnings, "Failed to read model because of network error.", new object[0]);
                 }
                 throw;
             }
             diagnosticsSession.LogDiagnosticsInfo(DiagnosticsLoggingTag.Warnings, "Failed to read model because of I/O timeout.  Exception: {0}", new object[]
             {
                 ex5
             });
         }
         catch (StoragePermanentException ex6)
         {
             if (ex6.InnerException is MapiExceptionDatabaseError)
             {
                 diagnosticsSession.LogDiagnosticsInfo(DiagnosticsLoggingTag.Warnings, "Failed to read model because of database-level error.  Exception: {0}", new object[]
                 {
                     ex6
                 });
                 throw;
             }
             if (!(ex6.InnerException is MapiExceptionMaxObjsExceeded))
             {
                 throw;
             }
             diagnosticsSession.LogDiagnosticsInfo(DiagnosticsLoggingTag.Warnings, "Failed to reset model because cannot create user configuration message.  Exception: {0}", new object[]
             {
                 ex6
             });
         }
     }
     catch (ComponentException ex7)
     {
         if (ex7.InnerException == null)
         {
             throw;
         }
         if (ex7.InnerException is ObjectNotFoundException)
         {
             diagnosticsSession.TraceError <ComponentException>("Received ObjectNotFoundException from the main pipeline.  Exception: {0} ", ex7);
         }
         else if (ex7.InnerException is CorruptDataException)
         {
             diagnosticsSession.TraceError <ComponentException>("Received CorruptDataException from the main pipeline.  Exception: {0}", ex7);
         }
         else
         {
             if (typeof(StoragePermanentException).IsAssignableFrom(ex7.InnerException.GetType()) || typeof(StorageTransientException).IsAssignableFrom(ex7.InnerException.GetType()) || typeof(DataSourceTransientException).IsAssignableFrom(ex7.InnerException.GetType()))
             {
                 diagnosticsSession.TraceError <Exception>("Received storage or data source exception from the main pipeline.  Exception: {0}", ex7.InnerException);
                 throw ex7.InnerException;
             }
             throw;
         }
     }
 }
 // Token: 0x060014FE RID: 5374 RVA: 0x00078418 File Offset: 0x00076618
 public ILogger CreateLogger(string userIdentity, IDiagnosticsSession diagnosticsSession)
 {
     return(new UserSessionLogger(userIdentity, diagnosticsSession));
 }
Пример #13
0
 internal static void TranslateXsoExceptions(IDiagnosticsSession tracer, LocalizedString errorString, Action xsoCall)
 {
     XsoUtil.TranslateXsoExceptions(tracer, errorString, XsoUtil.XsoExceptionHandlingFlags.None, xsoCall);
 }
Пример #14
0
 internal static void TranslateXsoExceptions(IDiagnosticsSession tracer, LocalizedString errorString, XsoUtil.XsoExceptionHandlingFlags flags, Action xsoCall)
 {
     try
     {
         xsoCall();
     }
     catch (ConnectionFailedTransientException ex)
     {
         XsoUtil.TraceAndThrowTransientException(tracer, errorString, ex);
     }
     catch (ConnectionFailedPermanentException ex2)
     {
         XsoUtil.TraceAndThrowPermanentException(tracer, errorString, ex2);
     }
     catch (MailboxUnavailableException ex3)
     {
         XsoUtil.TraceAndThrowPermanentException(tracer, errorString, ex3);
     }
     catch (ObjectNotFoundException ex4)
     {
         if ((flags & XsoUtil.XsoExceptionHandlingFlags.DoNotExpectObjectNotFound) == XsoUtil.XsoExceptionHandlingFlags.DoNotExpectObjectNotFound)
         {
             tracer.SendInformationalWatsonReport(ex4, null);
             if ((flags & XsoUtil.XsoExceptionHandlingFlags.RethrowUnexpectedExceptions) == XsoUtil.XsoExceptionHandlingFlags.RethrowUnexpectedExceptions)
             {
                 XsoUtil.TraceAndThrowPermanentException(tracer, errorString, ex4);
             }
         }
         else
         {
             tracer.TraceDebug <LocalizedString, ObjectNotFoundException>("Error: {0}, exception: {1}", errorString, ex4);
         }
     }
     catch (CorruptDataException ex5)
     {
         if ((flags & XsoUtil.XsoExceptionHandlingFlags.DoNotExpectCorruptData) == XsoUtil.XsoExceptionHandlingFlags.DoNotExpectCorruptData)
         {
             tracer.SendInformationalWatsonReport(ex5, null);
             if ((flags & XsoUtil.XsoExceptionHandlingFlags.RethrowUnexpectedExceptions) == XsoUtil.XsoExceptionHandlingFlags.RethrowUnexpectedExceptions)
             {
                 XsoUtil.TraceAndThrowPermanentException(tracer, errorString, ex5);
             }
         }
         else
         {
             tracer.TraceDebug <LocalizedString, CorruptDataException>("Error: {0}, exception: {1}", errorString, ex5);
         }
     }
     catch (AccessDeniedException ex6)
     {
         tracer.SendWatsonReport(ex6);
         XsoUtil.TraceAndThrowPermanentException(tracer, errorString, ex6);
     }
     catch (StoragePermanentException ex7)
     {
         if (ex7.GetType() != typeof(StoragePermanentException))
         {
             tracer.SendInformationalWatsonReport(ex7, null);
         }
         if ((flags & XsoUtil.XsoExceptionHandlingFlags.RethrowUnexpectedExceptions) == XsoUtil.XsoExceptionHandlingFlags.RethrowUnexpectedExceptions)
         {
             XsoUtil.TraceAndThrowPermanentException(tracer, errorString, ex7);
         }
     }
     catch (StorageTransientException ex8)
     {
         if (ex8.GetType() != typeof(StorageTransientException))
         {
             tracer.SendInformationalWatsonReport(ex8, null);
         }
         if ((flags & XsoUtil.XsoExceptionHandlingFlags.RethrowUnexpectedExceptions) == XsoUtil.XsoExceptionHandlingFlags.RethrowUnexpectedExceptions)
         {
             XsoUtil.TraceAndThrowPermanentException(tracer, errorString, ex8);
         }
     }
 }
Пример #15
0
        internal static TReturnValue TranslateXsoExceptionsWithReturnValue <TReturnValue>(IDiagnosticsSession tracer, LocalizedString errorString, XsoUtil.XsoExceptionHandlingFlags flags, Func <TReturnValue> xsoCall)
        {
            TReturnValue result = default(TReturnValue);

            XsoUtil.TranslateXsoExceptions(tracer, errorString, flags, delegate()
            {
                result = xsoCall();
            });
            return(result);
        }
 public static bool ConfigTryParseHelper <T>(IPipelineComponentConfig config, InferenceCommonUtility.TryParseFunction <T> tryParseFunction, string keyName, out T value, IDiagnosticsSession trace)
 {
     value = default(T);
     if (config == null || !tryParseFunction(config[keyName], out value))
     {
         if (trace != null)
         {
             trace.TraceDebug <string>("Failed to parse config value referenced by keyName: {0}.", keyName);
         }
         return(false);
     }
     return(true);
 }
Пример #17
0
 private static void TraceAndThrowPermanentException(IDiagnosticsSession tracer, LocalizedString errorString, LocalizedException ex)
 {
     tracer.TraceError <LocalizedString, LocalizedException>("Error: {0}, exception: {1}", errorString, ex);
     throw new ComponentFailedPermanentException(errorString, ex);
 }
 public static bool ConfigTryParseHelper <T>(IPipelineComponentConfig config, InferenceCommonUtility.TryParseFunction <T> tryParseFunction, string keyName, out T value, IDiagnosticsSession trace, T defaultValue)
 {
     if (!InferenceCommonUtility.ConfigTryParseHelper <T>(config, tryParseFunction, keyName, out value, trace))
     {
         value = defaultValue;
         if (trace != null)
         {
             trace.TraceDebug <string, T>("Defaulting config value referenced by keyName: {0} to: {1}", keyName, defaultValue);
         }
         return(false);
     }
     return(true);
 }
Пример #19
0
        internal static UserConfiguration ResetModel(string userConfigurationName, UserConfigurationTypes userConfigType, MailboxSession session, bool deleteOld, IDiagnosticsSession diagnosticSession)
        {
            StoreId         defaultFolderId = session.GetDefaultFolderId(DefaultFolderType.Inbox);
            OperationResult operationResult = OperationResult.Succeeded;
            Exception       ex = null;

            if (deleteOld)
            {
                try
                {
                    operationResult = session.UserConfigurationManager.DeleteFolderConfigurations(defaultFolderId, new string[]
                    {
                        userConfigurationName
                    });
                }
                catch (ObjectNotFoundException ex2)
                {
                    ex = ex2;
                    if (diagnosticSession != null)
                    {
                        diagnosticSession.TraceDebug <string, ObjectNotFoundException>("FAI message '{0}' is missing. Exception: {1}", userConfigurationName, ex2);
                    }
                }
                if (operationResult != OperationResult.Succeeded && ex == null)
                {
                    if (diagnosticSession != null)
                    {
                        diagnosticSession.TraceError(string.Format("Deletion of user configuration (userConfiguration Name = {0}) failed. OperationResult = {1}. ObjectNotFoundException = {2}", userConfigurationName, operationResult.ToString(), ex), new object[0]);
                    }
                    throw new DeleteItemsException(string.Format("Deletion of user configuration (userConfiguration Name = {0}) failed. OperationResult = {1}. ObjectNotFoundException = {2}", userConfigurationName, operationResult.ToString(), ex));
                }
            }
            UserConfiguration userConfiguration = null;

            try
            {
                userConfiguration = session.UserConfigurationManager.CreateFolderConfiguration(userConfigurationName, userConfigType, defaultFolderId);
                userConfiguration.Save();
            }
            catch (Exception ex3)
            {
                if (diagnosticSession != null && !(ex3 is QuotaExceededException))
                {
                    if (ex3 is StoragePermanentException)
                    {
                        diagnosticSession.SendInformationalWatsonReport(ex3, string.Format("Creation of user configuration failed (userConfiguration Name = {0}) deleteOld flag was {1}. Result of deletion of user configuration OperationResult = {2}. ObjectNotFoundException = {3}", new object[]
                        {
                            userConfigurationName,
                            deleteOld,
                            deleteOld ? operationResult.ToString() : "Not Applicable",
                            ex
                        }));
                    }
                    else
                    {
                        diagnosticSession.TraceError("Creation of user configuration failed (userConfiguration Name = {0}) deleteOld flag was {1}. Result of deletion of user configuration OperationResult = {2}. ObjectNotFoundException = {3}. Exception = {4}", new object[]
                        {
                            userConfigurationName,
                            deleteOld,
                            deleteOld ? operationResult.ToString() : "Not Applicable",
                            ex,
                            ex3.ToString()
                        });
                    }
                }
                if (userConfiguration != null)
                {
                    userConfiguration.Dispose();
                }
                throw;
            }
            return(userConfiguration);
        }