Ejemplo n.º 1
0
        internal TrackingRecord Match(TrackingRecord record, bool shouldClone)
        {
            TrackingQuery resultQuery = null;

            if (record is WorkflowInstanceRecord)
            {
                resultQuery = Match((WorkflowInstanceRecord)record);
            }
            else if (record is ActivityStateRecord)
            {
                resultQuery = Match((ActivityStateRecord)record);
            }
            else if (record is BookmarkResumptionRecord)
            {
                resultQuery = Match((BookmarkResumptionRecord)record);
            }
            else if (record is CustomTrackingRecord)
            {
                resultQuery = Match((CustomTrackingRecord)record);
            }
            else if (record is ActivityScheduledRecord)
            {
                resultQuery = Match((ActivityScheduledRecord)record);
            }
            else if (record is CancelRequestedRecord)
            {
                resultQuery = Match((CancelRequestedRecord)record);
            }
            else if (record is FaultPropagationRecord)
            {
                resultQuery = Match((FaultPropagationRecord)record);
            }

            return(resultQuery == null ? null : PrepareRecord(record, resultQuery, shouldClone));
        }
Ejemplo n.º 2
0
 public TrackAsyncResult(TrackingParticipant participant, TrackingRecord record, TimeSpan timeout, AsyncCallback callback, object state)
     : base(callback, state)
 {
     _participant = participant;
     _record      = record;
     _timeout     = timeout;
     ActionItem.Schedule(s_asyncExecuteTrack, this);
 }
Ejemplo n.º 3
0
        public void AddRecord(TrackingRecord record)
        {
            if (_pendingTrackingRecords == null)
            {
                _pendingTrackingRecords = new List <TrackingRecord>();
            }

            record.RecordNumber = GetNextRecordNumber();
            _pendingTrackingRecords.Add(record);
        }
Ejemplo n.º 4
0
 protected TrackingRecord(TrackingRecord record)
 {
     this.InstanceId   = record.InstanceId;
     this.RecordNumber = record.RecordNumber;
     this.EventTime    = record.EventTime;
     this.Level        = record.Level;
     if (record.HasAnnotations)
     {
         Dictionary <string, string> copy = new Dictionary <string, string>(record._annotations);
         _annotations = new ReadOnlyDictionary <string, string>(copy);
     }
 }
Ejemplo n.º 5
0
        public void FlushPendingRecords(TimeSpan timeout)
        {
            try
            {
                if (this.HasPendingRecords)
                {
                    TimeoutHelper helper = new TimeoutHelper(timeout);
                    for (int i = 0; i < _trackingParticipants.Count; i++)
                    {
                        TrackingParticipant    participant    = _trackingParticipants[i];
                        RuntimeTrackingProfile runtimeProfile = GetRuntimeTrackingProfile(participant);

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

                                TrackingRecord preparedRecord = null;
                                bool           shouldClone    = _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();
            }
        }
Ejemplo n.º 6
0
            private bool PostTrackingRecord(TrackingParticipant participant, RuntimeTrackingProfile runtimeProfile)
            {
                TrackingRecord originalRecord = _provider._pendingTrackingRecords[_currentRecord];

                _currentRecord++;
                bool isSuccessful = false;

                try
                {
                    TrackingRecord preparedRecord = null;
                    bool           shouldClone    = _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, _timeoutHelper.RemainingTime(), PrepareAsyncCompletion(s_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)
                    {
                        _provider.ClearPendingRecords();
                    }
                }
                return(true);
            }
Ejemplo n.º 7
0
        private static TrackingRecord PrepareRecord(TrackingRecord record, TrackingQuery query, bool shouldClone)
        {
            TrackingRecord preparedRecord = shouldClone ? record.Clone() : record;

            if (query.HasAnnotations)
            {
                preparedRecord.Annotations = new ReadOnlyDictionary <string, string>(query.QueryAnnotations);
            }

            if (query is ActivityStateQuery)
            {
                ExtractArguments((ActivityStateRecord)preparedRecord, (ActivityStateQuery)query);
                ExtractVariables((ActivityStateRecord)preparedRecord, (ActivityStateQuery)query);
            }
            return(preparedRecord);
        }
Ejemplo n.º 8
0
 protected internal abstract void Track(TrackingRecord record, TimeSpan timeout);
Ejemplo n.º 9
0
 protected internal virtual IAsyncResult BeginTrack(TrackingRecord record, TimeSpan timeout, AsyncCallback callback, object state)
 {
     return(new TrackAsyncResult(this, record, timeout, callback, state));
 }