Ejemplo n.º 1
0
        internal static void CreateAndInsertTrackingProfile()
        {
            TrackingProfile profile = new TrackingProfile();

            ActivityTrackPoint activityTrack = new ActivityTrackPoint();
            ActivityTrackingLocation activityLocation = new ActivityTrackingLocation(typeof(Activity));
            activityLocation.MatchDerivedTypes = true;
            IEnumerable<ActivityExecutionStatus> statuses = Enum.GetValues(typeof(ActivityExecutionStatus)) as IEnumerable<ActivityExecutionStatus>;
            foreach (ActivityExecutionStatus status in statuses)
            {
                activityLocation.ExecutionStatusEvents.Add(status);
            }

            activityTrack.MatchingLocations.Add(activityLocation);
            profile.ActivityTrackPoints.Add(activityTrack);
            profile.Version = version;

            WorkflowTrackPoint workflowTrack = new WorkflowTrackPoint();
            WorkflowTrackingLocation workflowLocation = new WorkflowTrackingLocation();
            IEnumerable<TrackingWorkflowEvent> eventStatuses = Enum.GetValues(typeof(TrackingWorkflowEvent)) as IEnumerable<TrackingWorkflowEvent>;
            foreach (TrackingWorkflowEvent status in eventStatuses)
            {
                workflowLocation.Events.Add(status);
            }

            workflowTrack.MatchingLocation = workflowLocation;
            profile.WorkflowTrackPoints.Add(workflowTrack);

            TrackingProfileSerializer serializer = new TrackingProfileSerializer();
            StringWriter writer = new StringWriter(new StringBuilder(), CultureInfo.InvariantCulture);
            serializer.Serialize(writer, profile);
            String trackingprofile = writer.ToString();
            InsertTrackingProfile(trackingprofile);
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Creates and saves a default tracking profile
        /// </summary>
        /// <returns></returns>
        private TrackingProfile BuildDefaultProfile()
        {
            //return a default profile that tracks all possible
            //workflow events and activity status values
            TrackingProfile profile = new TrackingProfile();

            //
            //create a workflow track point and location
            //
            WorkflowTrackPoint workflowPoint
                = new WorkflowTrackPoint();
            //add all possible workflow events
            List <TrackingWorkflowEvent> workflowEvents
                = new List <TrackingWorkflowEvent>();

            workflowEvents.AddRange(
                Enum.GetValues(typeof(TrackingWorkflowEvent))
                as IEnumerable <TrackingWorkflowEvent>);
            WorkflowTrackingLocation workflowLocation
                = new WorkflowTrackingLocation(workflowEvents);

            workflowPoint.MatchingLocation = workflowLocation;
            profile.WorkflowTrackPoints.Add(workflowPoint);

            //
            //create an activity track point and location
            //
            ActivityTrackPoint activityPoint
                = new ActivityTrackPoint();
            //add all possible activity execution status values
            List <ActivityExecutionStatus> activityStatus
                = new List <ActivityExecutionStatus>();

            activityStatus.AddRange(
                Enum.GetValues(typeof(ActivityExecutionStatus))
                as IEnumerable <ActivityExecutionStatus>);
            ActivityTrackingLocation activityLocation
                = new ActivityTrackingLocation(
                      typeof(Activity), true, activityStatus);

            activityPoint.MatchingLocations.Add(activityLocation);
            profile.ActivityTrackPoints.Add(activityPoint);

            //
            //create a user track point and location
            //
            UserTrackPoint       userPoint = new UserTrackPoint();
            UserTrackingLocation userLocation
                = new UserTrackingLocation(
                      typeof(Object), typeof(Activity));

            userLocation.MatchDerivedActivityTypes = true;
            userLocation.MatchDerivedArgumentTypes = true;
            userPoint.MatchingLocations.Add(userLocation);
            profile.UserTrackPoints.Add(userPoint);

            //set the profile version
            profile.Version = new Version(1, 0, 0);
            return(profile);
        }
        private TrackingProfile GetProfile()
        {
            //
            // We shouldn't hit this point without the host ignoring an earlier exception.
            // However if we're here and the source doesn't exist we can't function.
            // Throwing an exception from here will block instance creation
            // but that is better than failing silently on termination
            // and having the admin think everything is OK because the event log is clear.
            if (!sourceExists)
            {
                throw new InvalidOperationException(string.Format(System.Globalization.CultureInfo.InvariantCulture, "EventLog Source with the name '{0}' does not exist", source));
            }

            //
            // The profile for this instance will never change
            if (null == profile)
            {
                lock (typeof(TerminationTrackingService))
                {
                    if (null == profile)
                    {
                        profile         = new TrackingProfile();
                        profile.Version = new Version("3.0.0.0");
                        WorkflowTrackPoint point = new WorkflowTrackPoint();
                        point.MatchingLocation = new WorkflowTrackingLocation();
                        point.MatchingLocation.Events.Add(TrackingWorkflowEvent.Terminated);
                        profile.WorkflowTrackPoints.Add(point);
                    }
                }
            }
            return(profile);
        }
Ejemplo n.º 4
0
        /// <summary>
        /// Loads create a Default profile
        /// </summary>
        /// <returns></returns>
        private static TrackingProfile GetDefaultProfile(Type workflowType)
        {
            TrackingProfile profile = new TrackingProfile();

            profile.Version = new Version(1, 0, 0, 0);

            // all activity events
            ActivityTrackPoint             atp = new ActivityTrackPoint();
            List <ActivityExecutionStatus> executionStatusLists = new List <ActivityExecutionStatus>();

            foreach (ActivityExecutionStatus status in Enum.GetValues(typeof(ActivityExecutionStatus)))
            {
                executionStatusLists.Add(status);
            }
            ActivityTrackingLocation activityTrackingLocation = new ActivityTrackingLocation(typeof(Activity), true, executionStatusLists);

            atp.MatchingLocations.Add(activityTrackingLocation);


            WorkflowDataTrackingExtract we = new WorkflowDataTrackingExtract("SetupId");

            atp.Extracts.Add(we);

            profile.ActivityTrackPoints.Add(atp);

            // all user TrackData events
            UserTrackPoint utp = new UserTrackPoint();

            UserTrackingLocation userTrackingLocation = new UserTrackingLocation();

            userTrackingLocation.ActivityType = typeof(Activity);
            //userTrackingLocation.MatchDerivedActivityTypes = true;
            userTrackingLocation.ArgumentType = typeof(object);
            //userTrackingLocation.MatchDerivedArgumentTypes = true;
            utp.MatchingLocations.Add(userTrackingLocation);

            profile.UserTrackPoints.Add(utp);

            // all workflow events
            WorkflowTrackPoint wftp = new WorkflowTrackPoint();

            foreach (TrackingWorkflowEvent evt in Enum.GetValues(typeof(TrackingWorkflowEvent)))
            {
                wftp.MatchingLocation.Events.Add(evt);
            }
            profile.WorkflowTrackPoints.Add(wftp);

            return(profile);
        }
        // Profile creation
        private static TrackingProfile GetProfile()
        {
            // Create a Tracking Profile
            TrackingProfile profile = new TrackingProfile();

            profile.Version = new Version("3.0.0");

            // Add a TrackPoint to cover all activity status events
            ActivityTrackPoint       activityTrackPoint = new ActivityTrackPoint();
            ActivityTrackingLocation activityLocation   = new ActivityTrackingLocation(typeof(Activity));

            activityLocation.MatchDerivedTypes = true;
            WorkflowTrackingLocation wLocation = new WorkflowTrackingLocation();

            IEnumerable <ActivityExecutionStatus> statuses = Enum.GetValues(typeof(ActivityExecutionStatus)) as IEnumerable <ActivityExecutionStatus>;

            foreach (ActivityExecutionStatus status in statuses)
            {
                activityLocation.ExecutionStatusEvents.Add(status);
            }

            activityTrackPoint.MatchingLocations.Add(activityLocation);
            profile.ActivityTrackPoints.Add(activityTrackPoint);

            // Add a TrackPoint to cover all workflow status events
            WorkflowTrackPoint workflowTrackPoint = new WorkflowTrackPoint();

            workflowTrackPoint.MatchingLocation = new WorkflowTrackingLocation();
            foreach (TrackingWorkflowEvent workflowEvent in Enum.GetValues(typeof(TrackingWorkflowEvent)))
            {
                workflowTrackPoint.MatchingLocation.Events.Add(workflowEvent);
            }
            profile.WorkflowTrackPoints.Add(workflowTrackPoint);

            // Add a TrackPoint to cover all user track points
            UserTrackPoint       userTrackPoint = new UserTrackPoint();
            UserTrackingLocation userLocation   = new UserTrackingLocation();

            userLocation.ActivityType = typeof(Activity);
            userLocation.MatchDerivedActivityTypes = true;
            userLocation.ArgumentType = typeof(object);
            userLocation.MatchDerivedArgumentTypes = true;
            userTrackPoint.MatchingLocations.Add(userLocation);
            profile.UserTrackPoints.Add(userTrackPoint);

            return(profile);
        }
Ejemplo n.º 6
0
        static TrackingProfile GetProfileAllWorkflowEvents()
        {
            TrackingProfile trackingProfile = new TrackingProfile();

            trackingProfile.Version = new Version("1.0.0");

            // Add a TrackPoint to cover all user track points
            WorkflowTrackPoint workflowTrackPoint        = new WorkflowTrackPoint();
            IEnumerable <TrackingWorkflowEvent> statuses = Enum.GetValues(typeof(TrackingWorkflowEvent)) as IEnumerable <TrackingWorkflowEvent>;

            foreach (TrackingWorkflowEvent status in statuses)
            {
                workflowTrackPoint.MatchingLocation.Events.Add(status);
            }
            trackingProfile.WorkflowTrackPoints.Add(workflowTrackPoint);

            return(trackingProfile);
        }