public void SendCommitted(EndpointAddress sendTo)
 {
     if (sendTo != null)
     {
         CompletionParticipantProxy proxy = this.state.TryCreateCompletionParticipantProxy(sendTo);
         if (proxy != null)
         {
             try
             {
                 if (DebugTrace.Info)
                 {
                     DebugTrace.Trace(TraceLevel.Info, "Sending Committed to unrecognized completion participant at {0}", Ports.TryGetAddress(proxy));
                 }
                 IAsyncResult ar = proxy.BeginSendCommitted(this.politeSendComplete, proxy);
                 if (ar.CompletedSynchronously)
                 {
                     this.OnSendComplete(ar, null, proxy);
                 }
             }
             finally
             {
                 proxy.Release();
             }
         }
     }
 }
        private X509Certificate2 ReadX509CertificateIdentity(ConfigurationProvider provider)
        {
            X509Certificate2 certificate;
            string           thumbprint = provider.ReadString("X509CertificateIdentity", null);

            if (thumbprint == null)
            {
                certificate = null;
                DebugTrace.Trace(TraceLevel.Warning, "{0} value could not be read", "X509CertificateIdentity");
                return(certificate);
            }
            certificate = this.FindCertificateByThumbprint(thumbprint);
            if (certificate == null)
            {
                ThumbPrintNotFoundRecord.TraceAndLog(thumbprint);
                DebugTrace.Trace(TraceLevel.Warning, "Identity certificate with thumbprint {0} could not be found", thumbprint);
                return(certificate);
            }
            if (!this.ValidateIdentityCertificate(certificate))
            {
                ThumbPrintNotValidatedRecord.TraceAndLog(thumbprint);
                DebugTrace.Trace(TraceLevel.Warning, "Identity certificate with thumbprint {0} could not be validated", thumbprint);
                certificate = null;
            }
            return(certificate);
        }
Exemplo n.º 3
0
        public void Handle(object model)
        {
            // Find the full path to the template file,
            // using current directory if argument isn't fully qualified
            string templatePath = GetTemplatePath();

            DebugTrace.Trace(this, "Rendering:" + templatePath);
            DebugTrace.Trace(this, "Model:" + model.ToString());

            var templateName    = Path.GetFileName(templatePath);
            var templateDirPath = Path.GetDirectoryName(templatePath);

            SparkViewEngine engine = new SparkEngineFactory().GetSparkEngine <TView>(templateDirPath);

            try
            {
                // compile and instantiate the template
                string templateResult = ProcessViewTemplate(engine, templateName, model);

                _fileWriter.Write(templateResult);
            }
            catch (Exception ex)
            {
                throw new SparkReportGenerationException("An exception occurred:" + ex.GetType().Name + "\r\n" +
                                                         ex.Message, ex);
            }
        }
Exemplo n.º 4
0
 private void StartListeners()
 {
     DebugTrace.TraceEnter(this, "StartListeners");
     try
     {
         this.twoPhaseCommitCoordinatorListener.Start();
         this.twoPhaseCommitParticipantListener.Start();
         this.completionCoordinatorListener.Start();
         this.registrationCoordinatorListener.Start();
         this.activationCoordinatorListener.Start();
     }
     catch (MessagingInitializationException exception)
     {
         if (DebugTrace.Error)
         {
             DebugTrace.Trace(TraceLevel.Error, "Error starting a listener: {0}", exception);
         }
         this.CleanupOnFailure();
         throw Microsoft.Transactions.Bridge.DiagnosticUtility.ExceptionUtility.ThrowHelperError(new PluggableProtocolException(exception.Message, exception));
     }
     catch (Exception exception2)
     {
         Microsoft.Transactions.Bridge.DiagnosticUtility.ExceptionUtility.TraceHandledException(exception2, TraceEventType.Error);
         if (DebugTrace.Error)
         {
             DebugTrace.Trace(TraceLevel.Error, "Unknown exception starting a listener: {0}", exception2);
         }
         this.CleanupOnFailure();
         throw;
     }
     DebugTrace.TraceLeave(this, "StartListeners");
 }
Exemplo n.º 5
0
 public void RecoveryBeginning()
 {
     DebugTrace.TraceEnter(this, "RecoveryBeginning");
     if (this.config.NetworkEndpointsEnabled)
     {
         try
         {
             this.coordination = new CoordinationService(this.config.PortConfiguration, this.protocolVersion);
             this.activationCoordinatorListener     = this.coordination.Add(this.activationCoordinator);
             this.registrationCoordinatorListener   = this.coordination.Add(this.registrationCoordinator);
             this.completionCoordinatorListener     = this.coordination.Add(this.completionCoordinator);
             this.twoPhaseCommitCoordinatorListener = this.coordination.Add(this.twoPhaseCommitCoordinator);
             this.twoPhaseCommitParticipantListener = this.coordination.Add(this.twoPhaseCommitParticipant);
         }
         catch (MessagingInitializationException exception)
         {
             if (DebugTrace.Error)
             {
                 DebugTrace.Trace(TraceLevel.Error, "Error initializing CoordinationService: {0}", exception);
             }
             this.CleanupOnFailure();
             throw Microsoft.Transactions.Bridge.DiagnosticUtility.ExceptionUtility.ThrowHelperError(new PluggableProtocolException(exception.Message, exception));
         }
         catch (Exception exception2)
         {
             if (DebugTrace.Error)
             {
                 DebugTrace.Trace(TraceLevel.Error, "Unknown exception initializing CoordinationService: {0}", exception2);
             }
             this.CleanupOnFailure();
             throw;
         }
     }
     DebugTrace.TraceLeave(this, "RecoveryBeginning");
 }
Exemplo n.º 6
0
 public void SendReadOnly(EndpointAddress sendTo)
 {
     if (sendTo != null)
     {
         TwoPhaseCommitCoordinatorProxy proxy = this.state.TryCreateTwoPhaseCommitCoordinatorProxy(sendTo);
         if (proxy != null)
         {
             try
             {
                 if (DebugTrace.Info)
                 {
                     DebugTrace.Trace(TraceLevel.Info, "Sending ReadOnly to unrecognized participant at {0}", Ports.TryGetAddress(proxy));
                 }
                 IAsyncResult ar = proxy.BeginSendReadOnly(this.politeSendComplete, proxy);
                 if (ar.CompletedSynchronously)
                 {
                     this.OnPoliteSendComplete(ar, proxy);
                 }
             }
             finally
             {
                 proxy.Release();
             }
         }
     }
 }
Exemplo n.º 7
0
        public LineStatus ExecuteLine(Scenario scenario, ScenarioContext scenarioContext, string line)
        {
            DebugTrace.Trace("ScenarioLineExecter.ExecuteLine", line);
            InvocationChain chain = GetMatchingChain(scenarioContext, line);

            if (chain == null)
            {
                var suggestion = _implementationHelper.Suggest(line);

                _eventBus.Raise(new LinePending {
                    Scenario = scenario, Line = line, Suggestion = suggestion
                });
                return(LineStatus.Pending);
            }

            if (!ExecuteChain(scenario, scenarioContext, chain, line))
            {
                return(LineStatus.Failed);
            }

            _eventBus.Raise(new LinePassed {
                Scenario = scenario, Line = line
            });

            return(LineStatus.Passed);
        }
        public PerformanceCounterWrapper(string counterName)
        {
            Exception exception;
            string    categoryName = "MSDTC Bridge 4.0.0.0";

            try
            {
                this.counter = new PerformanceCounter(categoryName, counterName, string.Empty, false);
                this.counter.RemoveInstance();
                this.counter = new PerformanceCounter(categoryName, counterName, string.Empty, false);
                exception    = null;
            }
            catch (InvalidOperationException exception2)
            {
                DiagnosticUtility.ExceptionUtility.TraceHandledException(exception2, TraceEventType.Warning);
                exception = exception2;
            }
            catch (Win32Exception exception3)
            {
                DiagnosticUtility.ExceptionUtility.TraceHandledException(exception3, TraceEventType.Warning);
                exception = exception3;
            }
            if (exception != null)
            {
                if (DebugTrace.Error)
                {
                    DebugTrace.Trace(TraceLevel.Error, "Unable to initialize performance counter {0}: {1}", counterName, exception);
                }
                PerformanceCounterInitializationFailureRecord.TraceAndLog(PluggableProtocol10.ProtocolGuid, counterName, exception);
            }
        }
        private void Remove <T, S>(Dictionary <T, S> dictionary, ReaderWriterLock rwLock, T key, S value)
        {
            bool flag = false;

            try
            {
                try
                {
                }
                finally
                {
                    rwLock.AcquireWriterLock(-1);
                    flag = true;
                }
                if (!dictionary.Remove(key))
                {
                    DiagnosticUtility.FailFast("The lookup table does not contain the object");
                }
            }
            finally
            {
                if (flag)
                {
                    rwLock.ReleaseWriterLock();
                }
            }
            if (DebugTrace.Verbose)
            {
                int count = dictionary.Count;
                DebugTrace.Trace(TraceLevel.Verbose, "Removed {0} {1} from lookup table. Table contains {2} object{3}", value.GetType().Name, value, count, (count == 1) ? string.Empty : "s");
            }
        }
Exemplo n.º 10
0
        public void Rejoin(Enlistment enlistment, ProtocolProviderCallback callback, object obj)
        {
            DebugTrace.TraceEnter(this, "Rejoin");
            ParticipantEnlistment participant = null;

            try
            {
                participant = this.state.LogEntrySerialization.DeserializeParticipant(enlistment);
            }
            catch (SerializationException exception)
            {
                DiagnosticUtility.ExceptionUtility.TraceHandledException(exception, TraceEventType.Critical);
                if (DebugTrace.Error)
                {
                    DebugTrace.Trace(TraceLevel.Error, "Failed to deserialize log entry for participant: {0}", exception);
                }
                ParticipantRecoveryLogEntryCorruptRecord.TraceAndLog(enlistment.LocalTransactionId, enlistment.RemoteTransactionId, enlistment.GetRecoveryData(), exception);
                DiagnosticUtility.FailFast("A participant recovery log entry could not be deserialized. This is a fatal condition.");
            }
            if (ParticipantRecoveredRecord.ShouldTrace)
            {
                ParticipantRecoveredRecord.Trace(participant.EnlistmentId, participant.Enlistment.RemoteTransactionId, (participant.ParticipantProxy != null) ? participant.ParticipantProxy.To : null, this.state.ProtocolVersion);
            }
            participant.StateMachine.Enqueue(new TmRejoinEvent(participant, callback, obj));
            DebugTrace.TraceLeave(this, "Rejoin");
        }
Exemplo n.º 11
0
        public void Replay(Enlistment enlistment, ProtocolProviderCallback callback, object obj)
        {
            DebugTrace.TraceEnter(this, "Replay");
            CoordinatorEnlistment coordinator = null;

            try
            {
                coordinator = this.state.LogEntrySerialization.DeserializeCoordinator(enlistment);
            }
            catch (SerializationException exception)
            {
                DiagnosticUtility.ExceptionUtility.TraceHandledException(exception, TraceEventType.Critical);
                if (DebugTrace.Error)
                {
                    DebugTrace.Trace(TraceLevel.Error, "Failed to deserialize log entry for coordinator: {0}", exception);
                }
                CoordinatorRecoveryLogEntryCorruptRecord.TraceAndLog(enlistment.LocalTransactionId, enlistment.RemoteTransactionId, enlistment.GetRecoveryData(), exception);
                DiagnosticUtility.FailFast("A coordinator recovery log entry could not be deserialized. This is a fatal condition.");
            }
            if (CoordinatorRecoveredRecord.ShouldTrace)
            {
                CoordinatorRecoveredRecord.Trace(coordinator.EnlistmentId, coordinator.Enlistment.RemoteTransactionId, (coordinator.CoordinatorProxy != null) ? coordinator.CoordinatorProxy.To : null, this.state.ProtocolVersion);
            }
            coordinator.StateMachine.Enqueue(new TmReplayEvent(coordinator, callback, obj));
            DebugTrace.TraceLeave(this, "Replay");
        }
        private void Add <T, S>(Dictionary <T, S> dictionary, ReaderWriterLock rwLock, T key, S value)
        {
            bool flag = false;

            try
            {
                try
                {
                }
                finally
                {
                    rwLock.AcquireWriterLock(-1);
                    flag = true;
                }
                dictionary.Add(key, value);
            }
            finally
            {
                if (flag)
                {
                    rwLock.ReleaseWriterLock();
                }
            }
            if (DebugTrace.Verbose)
            {
                int count = dictionary.Count;
                DebugTrace.Trace(TraceLevel.Verbose, "Added {0} {1} to lookup table. Table contains {2} object{3}", value.GetType().Name, value, count, (count == 1) ? string.Empty : "s");
            }
        }
        public void Add(ITimerRecipient recipient, object token)
        {
            int count;

            DebugTrace.TraceEnter(this, "Add");
            TimeSpan span = recipient.NextNotification - this.state.ElapsedTime;

            if ((span <= TimeSpan.Zero) || (span >= this.maxNotificationTime))
            {
                DiagnosticUtility.FailFast("The timer object has an invalid notification time");
            }
            lock (this.timerList.SyncRoot)
            {
                this.AssertState();
                this.timerList.Add(recipient, token);
                count = this.timerList.Count;
                if (count == 1)
                {
                    this.ActivateTimer();
                }
            }
            if (DebugTrace.Verbose)
            {
                DebugTrace.Trace(TraceLevel.Verbose, "Added timer recipient to be reminded in {0} ms", (long)span.TotalMilliseconds);
                DebugTrace.Trace(TraceLevel.Verbose, "Timer list depth at {0}", count);
            }
            DebugTrace.TraceLeave(this, "Add");
        }
 public void SendRollback(EndpointAddress sendTo)
 {
     if (sendTo != null)
     {
         TwoPhaseCommitParticipantProxy proxy = this.state.TryCreateTwoPhaseCommitParticipantProxy(sendTo);
         if (proxy != null)
         {
             try
             {
                 if (DebugTrace.Info)
                 {
                     DebugTrace.Trace(TraceLevel.Info, "Sending Rollback to unrecognized participant at {0}", Ports.TryGetAddress(proxy));
                 }
                 proxy.From = this.CreateForgottenSource();
                 IAsyncResult ar = proxy.BeginSendRollback(this.politeSendComplete, proxy);
                 if (ar.CompletedSynchronously)
                 {
                     this.OnPoliteSendComplete(ar, proxy);
                 }
             }
             finally
             {
                 proxy.Release();
             }
         }
     }
 }
        public void Remove(ITimerRecipient recipient)
        {
            int count;
            int num2;

            DebugTrace.TraceEnter(this, "Remove");
            lock (this.timerList.SyncRoot)
            {
                this.AssertState();
                count = this.timerList.Count;
                this.timerList.Remove(recipient);
                num2 = this.timerList.Count;
                if ((count != num2) && (this.timerList.Count == 0))
                {
                    this.DeactivateTimer();
                }
            }
            if (DebugTrace.Verbose)
            {
                if (count == num2)
                {
                    DebugTrace.Trace(TraceLevel.Verbose, "Timer recipient was not present. Timer list depth is still {0}", num2);
                }
                else
                {
                    DebugTrace.Trace(TraceLevel.Verbose, "Removed timer recipient. Timer list depth is now {0}", num2);
                }
            }
            DebugTrace.TraceLeave(this, "Remove");
        }
        public override void OnEvent(MsgDurablePrepareEvent e)
        {
            CoordinatorEnlistment coordinator = e.Coordinator;
            Exception             exception   = null;

            try
            {
                byte[] data = base.state.LogEntrySerialization.Serialize(coordinator);
                coordinator.Enlistment.SetRecoveryData(data);
                base.state.TransactionManagerSend.Prepare(coordinator);
                e.StateMachine.ChangeState(base.state.States.CoordinatorPreparing);
            }
            catch (SerializationException exception2)
            {
                DiagnosticUtility.ExceptionUtility.TraceHandledException(exception2, TraceEventType.Error);
                exception = exception2;
            }
            if (exception != null)
            {
                if (DebugTrace.Error)
                {
                    DebugTrace.Trace(TraceLevel.Error, "Failed to serialize log entry for coordinator: {0}", exception);
                }
                CoordinatorRecoveryLogEntryCreationFailureRecord.TraceAndLog(coordinator.EnlistmentId, coordinator.Enlistment.RemoteTransactionId, exception.Message, exception);
                base.state.TwoPhaseCommitParticipant.SendDurableAborted(coordinator);
                base.state.TransactionManagerSend.Rollback(coordinator);
                e.StateMachine.ChangeState(base.state.States.DurableAborted);
            }
        }
Exemplo n.º 17
0
        public void WriteResource(string resourceName, string destination, bool overwrite)
        {
            string fileName = Path.Combine(Directory.GetCurrentDirectory(), destination);

            Filesystem.WriteFile(fileName, GetResource(resourceName), overwrite);

            DebugTrace.Trace("Init Job", "Wrote file: " + destination);
        }
Exemplo n.º 18
0
 public void SendFault(Microsoft.Transactions.Wsat.Messaging.RequestAsyncResult result, Fault fault)
 {
     this.state.Perf.FaultsSentCountPerInterval.Increment();
     if (DebugTrace.Warning)
     {
         DebugTrace.Trace(TraceLevel.Warning, "Sending {0} fault to activation participant", fault.Code.Name);
     }
     ActivationProxy.SendFaultResponse(result, fault);
 }
Exemplo n.º 19
0
 public void Raise <T>(T e)
 {
     DebugTrace.Trace("EventBus", "Raising " + typeof(T).FullName);
     foreach (var handler in GetHandlersForType(typeof(T)).Cast <IHandle <T> >())
     {
         handler.Handle(e);
         DebugTrace.Trace("EventBus", " ... handled by: " + handler.GetType().FullName);
     }
 }
 private void DeactivateTimer()
 {
     DebugTrace.Trace(TraceLevel.Verbose, "Timer list is now empty. Canceling periodic timer notification");
     if (!this.timer.Change(-1, -1) && DebugTrace.Info)
     {
         DebugTrace.Trace(TraceLevel.Info, "TimerManager.DeactivateTimer: Timer.Change returned false");
     }
     this.active = false;
     this.AssertState();
 }
 public void Fault(Message message, MessageFault fault)
 {
     if (this.CheckMessage(message, false) != null)
     {
         this.state.Perf.FaultsReceivedCountPerInterval.Increment();
     }
     if (DebugTrace.Info)
     {
         DebugTrace.Trace(TraceLevel.Info, "Ignoring {0} fault from completion participant at {1}: {2}", Library.GetFaultCodeName(fault), Ports.TryGetFromAddress(message), Library.GetFaultCodeReason(fault));
     }
 }
Exemplo n.º 22
0
        private LogEntry DeserializeLogEntry(byte[] buffer, Guid localTransactionId)
        {
            if (DebugTrace.Verbose)
            {
                DebugTrace.Trace(TraceLevel.Verbose, "Deserializing {0} byte buffer", buffer.Length);
            }
            MemoryStream mem      = new MemoryStream(buffer, 0, buffer.Length, false, true);
            LogEntry     logEntry = this.DeserializeHeader(mem, localTransactionId);

            return(this.CreateDeserializer(mem, logEntry).Deserialize());
        }
Exemplo n.º 23
0
        public void OnTimerNotification(object token)
        {
            TimerInstance objA = (TimerInstance)token;

            lock (this.timerLock)
            {
                if (!this.timer.Active)
                {
                    DebugTrace.Trace(TraceLevel.Verbose, "Notification discarded due to inactive timer");
                    return;
                }
                if (!object.ReferenceEquals(objA, this.timer.Instance))
                {
                    DebugTrace.Trace(TraceLevel.Verbose, "Notification discarded due to mismatched policy");
                    return;
                }
                this.timer.Notifications += 1L;
                if ((this.timer.Policy.MaxNotifications == 0) || (this.timer.Notifications < this.timer.Policy.MaxNotifications))
                {
                    if (this.timer.Notifications == 1L)
                    {
                        this.timer.CurrentInterval = this.timer.Policy.NotificationInterval;
                    }
                    else
                    {
                        int  intervalIncreasePercentage = this.timer.Policy.IntervalIncreasePercentage;
                        long ticks = this.timer.CurrentInterval.Ticks;
                        ticks += (ticks / 100L) * intervalIncreasePercentage;
                        if (ticks < 0L)
                        {
                            ticks = 0x7ffffffffffffffeL;
                        }
                        TimeSpan maxNotificationInterval = new TimeSpan(ticks);
                        if (maxNotificationInterval > this.timer.Policy.MaxNotificationInterval)
                        {
                            maxNotificationInterval = this.timer.Policy.MaxNotificationInterval;
                        }
                        this.timer.CurrentInterval = maxNotificationInterval;
                    }
                    this.timer.NextNotification = this.state.ElapsedTime + this.timer.CurrentInterval;
                    this.state.TimerManager.Add(this, this.timer.Instance);
                }
                else
                {
                    this.timer.Active = false;
                    if (this.timer.Notifications > this.timer.Policy.MaxNotifications)
                    {
                        return;
                    }
                }
            }
            this.OnTimer(objA.Profile);
        }
Exemplo n.º 24
0
        public void Register(object handler)
        {
            if (IsAlreadyRegistered(handler))
            {
                DebugTrace.Trace("EventBus", "Tried to add a handler of type " + handler.GetType() + " but it was already registered.");
                return;
            }

            _handlers.Add(handler);

            AssociateWithHandledEventTypes(handler);
        }
        private bool ValidateIdentityCertificate(X509Certificate2 identity)
        {
            string subject = this.ExtractSubjectName(identity);

            if (!identity.HasPrivateKey)
            {
                SslNoPrivateKeyRecord.TraceAndLog(subject, identity.Thumbprint);
                DebugTrace.Trace(TraceLevel.Warning, "Identity certificate with subject name {0} and thumbprint {1} does not have a private key", subject, identity.Thumbprint);
                return(false);
            }
            try
            {
                AsymmetricAlgorithm privateKey = identity.PrivateKey;
            }
            catch (CryptographicException exception)
            {
                Microsoft.Transactions.Bridge.DiagnosticUtility.ExceptionUtility.TraceHandledException(exception, TraceEventType.Warning);
                SslNoAccessiblePrivateKeyRecord.TraceAndLog(subject, identity.Thumbprint);
                DebugTrace.Trace(TraceLevel.Warning, "Identity certificate with subject name {0} and thumbprint {1} does not have an accessible private key", subject, identity.Thumbprint);
                return(false);
            }
            X509KeyUsageExtension extension = (X509KeyUsageExtension)identity.Extensions["2.5.29.15"];

            if ((extension != null) && ((extension.KeyUsages & (X509KeyUsageFlags.DigitalSignature | X509KeyUsageFlags.KeyEncipherment)) != (X509KeyUsageFlags.DigitalSignature | X509KeyUsageFlags.KeyEncipherment)))
            {
                MissingNecessaryKeyUsageRecord.TraceAndLog(subject, identity.Thumbprint, X509KeyUsageFlags.DigitalSignature | X509KeyUsageFlags.KeyEncipherment);
                DebugTrace.Trace(TraceLevel.Warning, "Identity certificate with subject name {0} and thumbprint {1} does not provide {2} among its KeyUsages", subject, identity.Thumbprint, (X509KeyUsageFlags.DigitalSignature | X509KeyUsageFlags.KeyEncipherment).ToString());
                return(false);
            }
            X509EnhancedKeyUsageExtension extension2 = (X509EnhancedKeyUsageExtension)identity.Extensions["2.5.29.37"];

            if (extension2 != null)
            {
                if (extension2.EnhancedKeyUsages["1.3.6.1.5.5.7.3.2"] == null)
                {
                    MissingNecessaryEnhancedKeyUsageRecord.TraceAndLog(subject, identity.Thumbprint, "1.3.6.1.5.5.7.3.2");
                    DebugTrace.Trace(TraceLevel.Warning, "Identity certificate with subject name {0} and thumbprint {1} does not provide {2} as one of its EnhancedKeyUsages", subject, identity.Thumbprint, "1.3.6.1.5.5.7.3.2");
                    return(false);
                }
                if (extension2.EnhancedKeyUsages["1.3.6.1.5.5.7.3.1"] == null)
                {
                    MissingNecessaryEnhancedKeyUsageRecord.TraceAndLog(subject, identity.Thumbprint, "1.3.6.1.5.5.7.3.1");
                    DebugTrace.Trace(TraceLevel.Warning, "Identity certificate with subject name {0} and thumbprint {1} does not provide {2} as one of its EnhancedKeyUsages", subject, identity.Thumbprint, "1.3.6.1.5.5.7.3.1");
                    return(false);
                }
            }
            if (DebugTrace.Info)
            {
                DebugTrace.Trace(TraceLevel.Info, "Identity certificate was successfully validated");
            }
            return(true);
        }
 private void ActivateTimer()
 {
     if (!this.timer.Change(this.reminderGranularity, this.reminderGranularity) && DebugTrace.Info)
     {
         DebugTrace.Trace(TraceLevel.Info, "TimerManager.ActivateTimer: Timer.Change returned false");
     }
     this.active = true;
     this.AssertState();
     if (DebugTrace.Verbose)
     {
         DebugTrace.Trace(TraceLevel.Verbose, "Activated timer notification to {0} seconds", (int)this.reminderGranularity.TotalSeconds);
     }
 }
Exemplo n.º 27
0
        public void Write(string s)
        {
            if (_overwrite && File.Exists(OutputFile))
            {
                File.Delete(OutputFile);
            }

            DebugTrace.Trace("FileWriter", "writing file: " + OutputFile);
            using (var stream = File.AppendText(OutputFile))
            {
                stream.Write(s);
            }
        }
Exemplo n.º 28
0
 private byte[] SerializeLogEntry(LogEntry logEntry)
 {
     byte[] buffer = new WsATv1LogEntrySerializer(logEntry, this.protocolVersion).Serialize();
     if (DebugTrace.Verbose)
     {
         DebugTrace.Trace(TraceLevel.Verbose, "Serialized {0} byte buffer", buffer.Length);
     }
     if (buffer.Length > this.maxLogEntrySize)
     {
         throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new SerializationException(Microsoft.Transactions.SR.GetString("SerializationLogEntryTooBig", new object[] { buffer.Length })));
     }
     return(buffer);
 }
 private void ReadDiagnosticTracingConfiguration(ConfigurationProvider provider)
 {
     this.tracePii             = provider.ReadInteger("DiagnosticTracingTracePII", 0) != 0;
     DebugTrace.Pii            = this.tracePii;
     this.diagnosticTraceLevel = this.ReadTraceSourceLevel(provider, "DiagnosticTracing", this.diagnosticTraceLevel);
     if (this.diagnosticTraceLevel != SourceLevels.Off)
     {
         bool flag = provider.ReadInteger("DiagnosticTracingActivityTracing", 0) != 0;
         if (flag)
         {
             this.diagnosticTraceLevel |= SourceLevels.ActivityTracing;
         }
         try
         {
             Microsoft.Transactions.Bridge.DiagnosticUtility.InitializeTransactionSource(this.diagnosticTraceLevel);
         }
         catch (SystemException exception)
         {
             Microsoft.Transactions.Bridge.DiagnosticUtility.ExceptionUtility.TraceHandledException(exception, TraceEventType.Warning);
             if (DebugTrace.Warning)
             {
                 DebugTrace.Trace(TraceLevel.Warning, "WS-AT diagnostic tracing will be disabled : {0}", exception.Message);
             }
             this.diagnosticTraceLevel = SourceLevels.Off;
         }
         Microsoft.Transactions.Bridge.DiagnosticUtility.Level = this.diagnosticTraceLevel;
         this.serviceModelDiagnosticTraceLevel = this.ReadTraceSourceLevel(provider, "ServiceModelDiagnosticTracing", this.serviceModelDiagnosticTraceLevel);
         if (this.serviceModelDiagnosticTraceLevel != SourceLevels.Off)
         {
             bool propagateActivity = provider.ReadInteger("DiagnosticTracingPropagateActivity", 0) != 0;
             if (flag)
             {
                 this.serviceModelDiagnosticTraceLevel |= SourceLevels.ActivityTracing;
             }
             try
             {
                 Microsoft.Transactions.Bridge.DiagnosticUtility.InitializeServiceModelSource(this.serviceModelDiagnosticTraceLevel, propagateActivity, this.tracePii);
             }
             catch (SystemException exception2)
             {
                 Microsoft.Transactions.Bridge.DiagnosticUtility.ExceptionUtility.TraceHandledException(exception2, TraceEventType.Warning);
                 if (DebugTrace.Warning)
                 {
                     DebugTrace.Trace(TraceLevel.Warning, "ServiceModel diagnostic tracing will be disabled : {0}", exception2.Message);
                 }
                 this.serviceModelDiagnosticTraceLevel = SourceLevels.Off;
             }
             System.ServiceModel.DiagnosticUtility.Level = this.serviceModelDiagnosticTraceLevel;
         }
     }
 }
 public ClusterRegistryConfigurationProvider(SafeHResource hResource)
 {
     this.hKey = Microsoft.Transactions.Wsat.Clusters.SafeNativeMethods.GetClusterResourceKey(hResource, RegistryRights.ExecuteKey);
     if (this.hKey.IsInvalid)
     {
         int num = Marshal.GetLastWin32Error();
         this.hKey.SetHandleAsInvalid();
         throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new ConfigurationProviderException(Microsoft.Transactions.SR.GetString("GetClusterResourceKeyFailed", new object[] { num })));
     }
     if (DebugTrace.Verbose)
     {
         DebugTrace.Trace(TraceLevel.Verbose, "Opened cluster resource key");
     }
 }