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);
        }
        /// <summary>
        /// Primary constructor
        /// </summary>
        /// <param name="root"></param>
        /// <param name="workflowType"></param>
        /// <param name="profile"></param>
        internal RTTrackingProfile(TrackingProfile profile, Activity root, Type serviceType)
        {
            if (null == profile)
                throw new ArgumentNullException("profile");
            if (null == root)
                throw new ArgumentNullException("root");
            if (null == serviceType)
                throw new ArgumentNullException("serviceType");

            _workflowType = root.GetType();
            _serviceType = serviceType;
            //
            // "Clone" a private copy in case the tracking service holds a reference to 
            // the profile it gave us and attempts to modify it at a later point
            TrackingProfileSerializer tps = new TrackingProfileSerializer();

            StringWriter writer = new StringWriter(System.Globalization.CultureInfo.InvariantCulture);
            StringReader reader = null;

            TrackingProfile privateProfile = null;

            try
            {
                //
                // Let exceptions bubble back to the tracking service - 
                // the profile must be valid per the schema.
                tps.Serialize(writer, profile);
                reader = new StringReader(writer.ToString());
                privateProfile = tps.Deserialize(reader);
            }
            finally
            {
                if (null != reader)
                    reader.Close();

                if (null != writer)
                    writer.Close();
            }
            _profile = privateProfile;

            CheckAllActivities((Activity)root);
        }
Ejemplo n.º 3
0
 static void SerializeTrackingProfileAndWriteToConsole(TrackingProfile trackingProfile)
 {
     TrackingProfileSerializer trackingProfileSerializer = new TrackingProfileSerializer();
     StringBuilder trackingProfileString = new StringBuilder();
     using (StringWriter writer = new StringWriter(trackingProfileString, CultureInfo.InvariantCulture))
     {
         trackingProfileSerializer.Serialize(writer, trackingProfile);
         Console.WriteLine(writer.ToString());
     }
 }
Ejemplo n.º 4
0
        private static void CreateAndInsertTrackingProfile()
        {
            TrackingProfile profile = new TrackingProfile();

            // Create an activity track point, used for tracking data from Code Activities.
            ActivityTrackPoint codeActivityTrackPoint = new ActivityTrackPoint();

            // Create an ActivityTrackingLocation to be added to the track point.
            ActivityTrackingLocation codeActivityTrackingLocation = new ActivityTrackingLocation("CodeActivity");
            codeActivityTrackingLocation.MatchDerivedTypes = true;
            // Add the location "Closed" event to track.
            codeActivityTrackingLocation.ExecutionStatusEvents.Add(ActivityExecutionStatus.Closed);
            codeActivityTrackPoint.MatchingLocations.Add(codeActivityTrackingLocation);

            // Create a WorkflowDataTrackingExtract for extracting data from the Balance property. 
            WorkflowDataTrackingExtract balanceWorkflowTrackingExtract = new WorkflowDataTrackingExtract();
            balanceWorkflowTrackingExtract.Member = "Balance";

            // Create an activity track point, used for tracking data in the custom activity "ServiceCharge".
            ActivityTrackPoint customActivityTrackPoint = new ActivityTrackPoint();
            ActivityTrackingLocation customActivityTrackingLocation = new ActivityTrackingLocation("ServiceCharge");
            // Create an ActivityTrackingLocation to be added to the track point
            customActivityTrackingLocation.ExecutionStatusEvents.Add(ActivityExecutionStatus.Closed);
            customActivityTrackPoint.MatchingLocations.Add(customActivityTrackingLocation);

            // Create an ActivityDataTrackingExtract for extracting Fee property data from the ServiceCharge activity.
            ActivityDataTrackingExtract feeActivityTrackingExtract = new ActivityDataTrackingExtract();
            feeActivityTrackingExtract.Member = "Fee";
            
            // Add extracts to the activity tracking points.
            codeActivityTrackPoint.Extracts.Add(balanceWorkflowTrackingExtract);
            customActivityTrackPoint.Extracts.Add(feeActivityTrackingExtract);

            profile.ActivityTrackPoints.Add(codeActivityTrackPoint);
            profile.ActivityTrackPoints.Add(customActivityTrackPoint);
            profile.Version = new Version("3.0.0.0");

            // Serialize the profile.
            TrackingProfileSerializer serializer = new TrackingProfileSerializer();
            StringWriter writer = new StringWriter(new StringBuilder(), CultureInfo.InvariantCulture);
            serializer.Serialize(writer, profile);
            String trackingprofile = writer.ToString();
            InsertTrackingProfile(trackingprofile);
        }
 internal RTTrackingProfile(TrackingProfile profile, Activity root, Type serviceType)
 {
     this._activities = new Dictionary<string, List<ActivityTrackPointCacheItem>>();
     this._activitiesIgnore = new List<string>();
     this._user = new Dictionary<string, List<UserTrackPoint>>();
     this._userIgnore = new List<string>();
     if (profile == null)
     {
         throw new ArgumentNullException("profile");
     }
     if (root == null)
     {
         throw new ArgumentNullException("root");
     }
     if (null == serviceType)
     {
         throw new ArgumentNullException("serviceType");
     }
     this._workflowType = root.GetType();
     this._serviceType = serviceType;
     TrackingProfileSerializer serializer = new TrackingProfileSerializer();
     StringWriter writer = new StringWriter(CultureInfo.InvariantCulture);
     StringReader reader = null;
     TrackingProfile profile2 = null;
     try
     {
         serializer.Serialize(writer, profile);
         reader = new StringReader(writer.ToString());
         profile2 = serializer.Deserialize(reader);
     }
     finally
     {
         if (reader != null)
         {
             reader.Close();
         }
         if (writer != null)
         {
             writer.Close();
         }
     }
     this._profile = profile2;
     this.CheckAllActivities(root);
 }
Ejemplo n.º 6
0
 /// <summary>
 /// Serialize the profile to a text writer
 /// </summary>
 /// <param name="writer"></param>
 public void SerializeProfile(TextWriter writer)
 {
     TrackingProfileSerializer serializer = new TrackingProfileSerializer();
     serializer.Serialize(writer, TrackingProfile);
 }
Ejemplo n.º 7
0
        private static void CreateAndInsertTrackingProfile()
        {
            TrackingProfile profile = new TrackingProfile();

            ActivityTrackPoint trackPoint = new ActivityTrackPoint();
            ActivityTrackingLocation location = new ActivityTrackingLocation(typeof(Activity));
            location.MatchDerivedTypes = true;

            IEnumerable<ActivityExecutionStatus> statuses = Enum.GetValues(typeof(ActivityExecutionStatus)) as IEnumerable<ActivityExecutionStatus>;
            foreach (ActivityExecutionStatus status in statuses)
            {
                location.ExecutionStatusEvents.Add(status);
            }

            trackPoint.MatchingLocations.Add(location);
            profile.ActivityTrackPoints.Add(trackPoint);
            profile.Version = new Version("3.0.0.0");

            
            // Adding a user track point to the tracking profile
            UserTrackPoint utp = new UserTrackPoint();
            
            // Adding a user location to the track point 
            UserTrackingLocation ul = new UserTrackingLocation(typeof(string), typeof(CodeActivity));
            ul.MatchDerivedActivityTypes = true;
            utp.MatchingLocations.Add(ul);
            profile.UserTrackPoints.Add(utp);
            
            
            // Serialize the profile
            TrackingProfileSerializer serializer = new TrackingProfileSerializer();
            StringWriter writer = new StringWriter(new StringBuilder(), CultureInfo.InvariantCulture);
            serializer.Serialize(writer, profile);
            string trackingprofile = writer.ToString();
            InsertTrackingProfile(trackingprofile);
        }