public TrackingMessage(TrackingRecord trackingRecord)
 {
     RecordType = trackingRecord.GetType().Name;
     InstanceId = trackingRecord.InstanceId.ToString();
     RecordNumber = trackingRecord.RecordNumber;
     EventTime = trackingRecord.EventTime;
     Content = trackingRecord.ToString().Replace("<null>", "null");
     if (trackingRecord is WorkflowInstanceRecord) {
         ActivityDefinitionId = ((WorkflowInstanceRecord)trackingRecord).ActivityDefinitionId;
         State = ((WorkflowInstanceRecord)trackingRecord).State;
     }
     if (trackingRecord is ActivityScheduledRecord) {
         Activity = ((ActivityScheduledRecord)trackingRecord).Activity.Name;
         ChildActivity = ((ActivityScheduledRecord)trackingRecord).Child.Name;
     }
     if (trackingRecord is ActivityStateRecord) {
         Activity = ((ActivityStateRecord)trackingRecord).Activity.Name;
         State = ((ActivityStateRecord)trackingRecord).State;
         Variables = ((ActivityStateRecord)trackingRecord).Variables.ToDictionary(kvp => kvp.Key, kvp => kvp.Value == null ? null : kvp.Value.ToString());
         Arguments = ((ActivityStateRecord)trackingRecord).Arguments.ToDictionary(kvp => kvp.Key, kvp => kvp.Value == null ? null : kvp.Value.ToString());
     }
     if (trackingRecord is CustomTrackingRecord) {
         Activity = ((CustomTrackingRecord)trackingRecord).Activity.Name;
         Name = ((CustomTrackingRecord)trackingRecord).Name;
         Data = string.Join(", ", ((CustomTrackingRecord)trackingRecord).Data.Select(kvp => string.Format("{0} = {1}", kvp.Key, kvp.Value)));
     }
     if (trackingRecord is WorkflowInstanceUnhandledExceptionRecord) {
         Activity = ((WorkflowInstanceUnhandledExceptionRecord)trackingRecord).FaultSource.Name;
         Data = ((WorkflowInstanceUnhandledExceptionRecord)trackingRecord).UnhandledException.ToString();
     }
 }
 protected override void Track(TrackingRecord record, TimeSpan timeout)
 {
     fileName = @"D:\" + record.InstanceId + ".tracking";
     using (StreamWriter sw = File.AppendText(fileName)) {
         sw.WriteLine("----------Tracking Started-----------");
         sw.WriteLine(record.ToString());
         sw.WriteLine("----------Tracking End---------------");
     }
 }
Пример #3
0
        protected override void Track(TrackingRecord record, TimeSpan timeout)
        {
            // get the tracking path
            string fileName = IOHelper.GetTrackingFilePath(record.InstanceId);

            // create a writer and open the file
            using (StreamWriter tw = File.AppendText(fileName))
            {
                // write a line of text to the file
                tw.WriteLine(record.ToString());
            }
        }
Пример #4
0
        public void FlushPendingRecords(TimeSpan timeout)
        {
            try
            {
                if (this.HasPendingRecords)
                {
                    TimeoutHelper helper = new TimeoutHelper(timeout);
                    for (int i = 0; i < this.trackingParticipants.Count; i++)
                    {
                        TrackingParticipant    participant    = this.trackingParticipants[i];
                        RuntimeTrackingProfile runtimeProfile = GetRuntimeTrackingProfile(participant);

                        // HasPendingRecords can be true for the sole purpose of populating our initial profiles, so check again here
                        if (this.pendingTrackingRecords != null)
                        {
                            for (int j = 0; j < this.pendingTrackingRecords.Count; j++)
                            {
                                TrackingRecord currentRecord = this.pendingTrackingRecords[j];
                                Fx.Assert(currentRecord != null, "We should never come across a null context.");

                                TrackingRecord preparedRecord = null;
                                bool           shouldClone    = this.trackingParticipants.Count > 1;
                                if (runtimeProfile == null)
                                {
                                    preparedRecord = shouldClone ? currentRecord.Clone() : currentRecord;
                                }
                                else
                                {
                                    preparedRecord = runtimeProfile.Match(currentRecord, shouldClone);
                                }

                                if (preparedRecord != null)
                                {
                                    participant.Track(preparedRecord, helper.RemainingTime());
                                    if (TD.TrackingRecordRaisedIsEnabled())
                                    {
                                        TD.TrackingRecordRaised(preparedRecord.ToString(), participant.GetType().ToString());
                                    }
                                }
                            }
                        }
                    }
                }
            }
            finally
            {
                // Note that if we fail to track yet the workflow manages to recover
                // we will attempt to track those records again.
                ClearPendingRecords();
            }
        }
Пример #5
0
            bool PostTrackingRecord(TrackingParticipant participant, RuntimeTrackingProfile runtimeProfile)
            {
                TrackingRecord originalRecord = this.provider.pendingTrackingRecords[this.currentRecord];

                this.currentRecord++;
                bool isSuccessful = false;

                try
                {
                    TrackingRecord preparedRecord = null;
                    bool           shouldClone    = this.provider.trackingParticipants.Count > 1;
                    if (runtimeProfile == null)
                    {
                        preparedRecord = shouldClone ? originalRecord.Clone() : originalRecord;
                    }
                    else
                    {
                        preparedRecord = runtimeProfile.Match(originalRecord, shouldClone);
                    }

                    if (preparedRecord != null)
                    {
                        IAsyncResult result = participant.BeginTrack(preparedRecord, this.timeoutHelper.RemainingTime(), PrepareAsyncCompletion(trackingCompleteCallback), this);
                        if (TD.TrackingRecordRaisedIsEnabled())
                        {
                            TD.TrackingRecordRaised(preparedRecord.ToString(), participant.GetType().ToString());
                        }
                        if (result.CompletedSynchronously)
                        {
                            participant.EndTrack(result);
                        }
                        else
                        {
                            isSuccessful = true;
                            return(false);
                        }
                    }
                    isSuccessful = true;
                }
                finally
                {
                    if (!isSuccessful)
                    {
                        this.provider.ClearPendingRecords();
                    }
                }
                return(true);
            }
 public void FlushPendingRecords(TimeSpan timeout)
 {
     try
     {
         if (this.HasPendingRecords)
         {
             TimeoutHelper helper = new TimeoutHelper(timeout);
             for (int i = 0; i < this.trackingParticipants.Count; i++)
             {
                 TrackingParticipant    participant            = this.trackingParticipants[i];
                 RuntimeTrackingProfile runtimeTrackingProfile = this.GetRuntimeTrackingProfile(participant);
                 if (this.pendingTrackingRecords != null)
                 {
                     for (int j = 0; j < this.pendingTrackingRecords.Count; j++)
                     {
                         TrackingRecord record      = this.pendingTrackingRecords[j];
                         TrackingRecord record2     = null;
                         bool           shouldClone = this.trackingParticipants.Count > 1;
                         if (runtimeTrackingProfile == null)
                         {
                             record2 = shouldClone ? record.Clone() : record;
                         }
                         else
                         {
                             record2 = runtimeTrackingProfile.Match(record, shouldClone);
                         }
                         if (record2 != null)
                         {
                             participant.Track(record2, helper.RemainingTime());
                             if (TD.TrackingRecordRaisedIsEnabled())
                             {
                                 TD.TrackingRecordRaised(record2.ToString(), participant.GetType().ToString());
                             }
                         }
                     }
                 }
             }
         }
     }
     finally
     {
         this.ClearPendingRecords();
     }
 }
            private bool PostTrackingRecord(TrackingParticipant participant, RuntimeTrackingProfile runtimeProfile)
            {
                TrackingRecord record = this.provider.pendingTrackingRecords[this.currentRecord];

                this.currentRecord++;
                bool flag = false;

                try
                {
                    TrackingRecord record2     = null;
                    bool           shouldClone = this.provider.trackingParticipants.Count > 1;
                    if (runtimeProfile == null)
                    {
                        record2 = shouldClone ? record.Clone() : record;
                    }
                    else
                    {
                        record2 = runtimeProfile.Match(record, shouldClone);
                    }
                    if (record2 != null)
                    {
                        IAsyncResult result = participant.BeginTrack(record2, this.timeoutHelper.RemainingTime(), base.PrepareAsyncCompletion(trackingCompleteCallback), this);
                        if (TD.TrackingRecordRaisedIsEnabled())
                        {
                            TD.TrackingRecordRaised(record2.ToString(), participant.GetType().ToString());
                        }
                        if (!result.CompletedSynchronously)
                        {
                            flag = true;
                            return(false);
                        }
                        participant.EndTrack(result);
                    }
                    flag = true;
                }
                finally
                {
                    if (!flag)
                    {
                        this.provider.ClearPendingRecords();
                    }
                }
                return(true);
            }
Пример #8
0
 protected override void Track(TrackingRecord record, TimeSpan timeout)
 {
     Console.WriteLine();
        IDictionary<string, string> annotations= record.Annotations;
     Console.WriteLine(record.ToString());
 }
 protected override void Track(TrackingRecord record, TimeSpan timeout) {
     Debug.WriteLine(string.Format("Workflow Id:{0} RecordType: {1} Record Details: {2}", record.InstanceId,
                                   record.GetType().Name, record.ToString()));
 }
 protected override Task TrackAsync(TrackingRecord record, TimeSpan timeout)
 {
     logger.Info(record.ToString());
     return Task.CompletedTask;
 }