Beispiel #1
0
        /// <summary>
        /// Retrieves a <see cref="TrackingWorkflowInstance" /> from the
        /// tracking store based upon the specified instance identifier.
        /// </summary>
        /// <param name="instanceId">
        /// The <see cref="Guid" /> of the workflow instance for which the
        /// tracking data is requested.
        /// </param>
        /// <returns>
        /// A <see cref="TrackingWorkflowInstance" /> containing tracking data
        /// associated with the workflow instance identifier or <c>null</c> if no
        /// data was found in the tracking store.
        /// </returns>
        public TrackingWorkflowInstance GetWorkflow(Guid instanceId)
        {
            using (ITrackingQueryResourceAccessor resourceAccessor = CreateAccessor(resourceProvider))
            {
                TrackingWorkflowInstance trackingWorkflowInstance = resourceAccessor.GetWorkflow(instanceId);
                if (trackingWorkflowInstance != null)
                {
                    trackingWorkflowInstance.QueryManager = this;
                }

                return(trackingWorkflowInstance);
            }
        }
Beispiel #2
0
        /// <summary>
        /// Returns tracking data for a paged set of workflow instances that
        /// match the specified query criteria.
        /// </summary>
        /// <param name="query">
        /// A <see cref="TrackingQuery" /> containing query criteria.
        /// </param>
        /// <param name="startOffset">
        /// <see cref="Int32" /> indicating the start offset in the entire
        /// set of matching workflow instances to begin returning records.
        /// </param>
        /// <param name="maxResults">
        /// <see cref="Int32" /> indicating the maximum number of records
        /// to return from <paramref name="startOffset"/>.
        /// </param>
        /// <returns>
        /// A <see cref="SearchResults{T}" /> containing <see cref="TrackingWorkflowInstance" />
        /// objects that provide access to the tracking data associated with a paged set of
        /// workflow instances that match the specified query criteria.
        /// </returns>
        public SearchResults <TrackingWorkflowInstance> GetWorkflows(TrackingQuery query, Int32 startOffset, Int32 maxResults)
        {
            using (ITrackingQueryResourceAccessor resourceAccessor = CreateAccessor(resourceProvider))
            {
                SearchResults <TrackingWorkflowInstance> searchResults = resourceAccessor.GetWorkflows(query, startOffset, maxResults);
                foreach (TrackingWorkflowInstance trackingWorkflowInstance in searchResults.Results)
                {
                    trackingWorkflowInstance.QueryManager = this;
                }

                return(searchResults);
            }
        }
Beispiel #3
0
        /// <summary>
        /// Attempts to retrieve a <see cref="TrackingWorkflowInstance" /> from
        /// the tracking store based upon the specified instance identifier.
        /// </summary>
        /// <param name="instanceId">
        /// The <see cref="Guid" /> of the workflow instance for which the
        /// tracking data is requested.
        /// </param>
        /// <param name="trackingWorkflowInstance">
        /// When this method returns <c>true</c>, contains a <see cref="TrackingWorkflowInstance" />
        /// that provides access to the tracking data associated with the workflow instance.
        /// This parameter is passed uninitiailized.
        /// </param>
        /// <returns>
        /// <c>true</c> if tracking data is available for the requested workflow
        /// instance, <c>false</c> otherwise.
        /// </returns>
        public Boolean TryGetWorkflow(Guid instanceId, out TrackingWorkflowInstance trackingWorkflowInstance)
        {
            using (ITrackingQueryResourceAccessor resourceAccessor = CreateAccessor(resourceProvider))
            {
                Boolean hasTrackingData = resourceAccessor.TryGetWorkflow(instanceId, out trackingWorkflowInstance);
                if (trackingWorkflowInstance != null)
                {
                    trackingWorkflowInstance.QueryManager = this;
                }

                return(hasTrackingData);
            }
        }
Beispiel #4
0
        /// <summary>
        /// Returns tracking data for the entire set of workflow instances that
        /// match the specified query criteria.
        /// </summary>
        /// <param name="query">
        /// A <see cref="TrackingQuery" /> containing query criteria.
        /// </param>
        /// <returns>
        /// A list containing <see cref="TrackingWorkflowInstance" /> objects
        /// that provide access to the tracking data associated with the set of
        /// workflow instances that match the specified query criteria.
        /// </returns>
        public IList <TrackingWorkflowInstance> GetWorkflows(TrackingQuery query)
        {
            using (ITrackingQueryResourceAccessor resourceAccessor = CreateAccessor(resourceProvider))
            {
                IList <TrackingWorkflowInstance> trackingWorkflowInstances = resourceAccessor.GetWorkflows(query);
                foreach (TrackingWorkflowInstance trackingWorkflowInstance in trackingWorkflowInstances)
                {
                    trackingWorkflowInstance.QueryManager = this;
                }

                return(trackingWorkflowInstances);
            }
        }
Beispiel #5
0
        /// <summary>
        /// Updates this <see cref="TrackingWorkflowInstance" /> with the
        /// latest data from the tracking store.
        /// </summary>
        public void Refresh()
        {
            if (_queryManager == null)
            {
                throw new InvalidOperationException("Cannot refresh without a QueryManager.");
            }

            // utilise the internal identifier and a timestamp of when a
            // refresh of the TrackingWorkflowInstance last occurred to
            // add the most recent entries to contained collections and
            // property values. If anything changes we raise the PropertyChanged
            // event in order to update any bound UI with latest data
            ITrackingQueryResourceAccessor resourceAccessor = null;

            try
            {
                // stop the timer while we refresh data
                if (refreshTimer != null)
                {
                    refreshTimer.Change(Timeout.Infinite, Timeout.Infinite);
                }

                // retrieve an ITrackingQueryResourceAccessor to query the data store
                resourceAccessor = _queryManager.CreateAccessor();

                // query for latest workflow instance details
                TrackingWorkflowInstance newTrackingWorkflowInstance = resourceAccessor.GetWorkflow(_id);
                if (newTrackingWorkflowInstance != null)
                {
                    if (_definition != newTrackingWorkflowInstance._definition)
                    {
                        _definition = newTrackingWorkflowInstance._definition;
                        raisePropertyChanged("Definition");
                    }

                    if (_status != newTrackingWorkflowInstance._status)
                    {
                        _status = newTrackingWorkflowInstance._status;
                        raisePropertyChanged("Status");
                    }
                }

                // query latest invoking workflow information
                if (_invokingWorkflowId.HasValue)
                {
                    TrackingWorkflowInstance newInvokingWorkflow = resourceAccessor.GetWorkflow(_invokingWorkflowId.Value);
                    if (newInvokingWorkflow != null)
                    {
                        invokingWorkflow = newInvokingWorkflow;
                        raisePropertyChanged("InvokingWorkflow");
                    }
                }

                // query for latest invoked workflow information
                if (invokedWorkflows == null)
                {
                    invokedWorkflows = new List <TrackingWorkflowInstance>();
                }

                IList <TrackingWorkflowInstance> newInvokedWorkflows = resourceAccessor.GetInvokedWorkflows(_id);
                if (newInvokedWorkflows.Count > 0)
                {
                    invokedWorkflows.AddRange(newInvokedWorkflows);
                    raisePropertyChanged("InvokedWorkflows");
                }

                // query for latest activity events
                if (activityEvents == null)
                {
                    activityEvents = new List <ActivityTrackingRecord>();
                }

                IList <ActivityTrackingRecord> newActivityEvents = resourceAccessor.GetActivityEvents(_internalId, lastRefreshed);
                if (newActivityEvents.Count > 0)
                {
                    activityEvents.AddRange(newActivityEvents);
                    raisePropertyChanged("ActivityEvents");
                }

                // query for latest user events
                if (userEvents == null)
                {
                    userEvents = new List <UserTrackingRecord>();
                }

                IList <UserTrackingRecord> newUserEvents = resourceAccessor.GetUserEvents(_internalId, lastRefreshed);
                if (newUserEvents.Count > 0)
                {
                    userEvents.AddRange(newUserEvents);
                    raisePropertyChanged("UserEvents");
                }

                // query for latest workflow events
                if (workflowEvents == null)
                {
                    workflowEvents = new List <WorkflowTrackingRecord>();
                }

                IList <WorkflowTrackingRecord> newWorkflowEvents = resourceAccessor.GetWorkflowEvents(_internalId, lastRefreshed);
                if (newWorkflowEvents.Count > 0)
                {
                    workflowEvents.AddRange(newWorkflowEvents);
                    raisePropertyChanged("WorkflowEvents");
                }

                lastRefreshed = DateTime.UtcNow;
            }
            finally
            {
                // dispose of the resource accessor
                if (resourceAccessor != null)
                {
                    resourceAccessor.Dispose();
                }

                // restart the timer
                if (refreshTimer != null)
                {
                    refreshTimer.Change(refreshInterval, refreshInterval);
                }
            }
        }