TrackingProfileSerializer Constructor
Definición
Importante
Parte de la información hace referencia a la versión preliminar del producto, que puede haberse modificado sustancialmente antes de lanzar la versión definitiva. Microsoft no otorga ninguna garantía, explícita o implícita, con respecto a la información proporcionada aquí.
Inicializa una nueva instancia de la clase TrackingProfileSerializer.
public:
TrackingProfileSerializer();
public TrackingProfileSerializer ();
Public Sub New ()
Ejemplos
En el siguiente ejemplo de código se muestra la forma de crear TrackingProfileSerializer con el constructor TrackingProfileSerializer a fin de serializar un TrackingProfile. El código también usa el método Serialize.
Este ejemplo de código pertenece a la consulta generada con el ejemplo del SDK de SQLTrackingService del archivo Program.cs. Para obtener más información, vea Consulta mediante SQLTrackingService.
private 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);
}
Shared Sub CreateAndInsertTrackingProfile()
Dim profile As TrackingProfile = New TrackingProfile()
Dim activityTrack As ActivityTrackPoint = New ActivityTrackPoint()
Dim activityLocation As ActivityTrackingLocation = New ActivityTrackingLocation(GetType(Activity))
activityLocation.MatchDerivedTypes = True
Dim statuses As IEnumerable(Of ActivityExecutionStatus) = CType(System.Enum.GetValues(GetType(ActivityExecutionStatus)), IEnumerable(Of ActivityExecutionStatus))
For Each status As ActivityExecutionStatus In statuses
activityLocation.ExecutionStatusEvents.Add(status)
Next
activityTrack.MatchingLocations.Add(activityLocation)
profile.ActivityTrackPoints.Add(activityTrack)
profile.Version = version
Dim workflowTrack As WorkflowTrackPoint = New WorkflowTrackPoint()
Dim workflowLocation As WorkflowTrackingLocation = New WorkflowTrackingLocation()
Dim eventStatuses As IEnumerable(Of TrackingWorkflowEvent) = CType(System.Enum.GetValues(GetType(TrackingWorkflowEvent)), IEnumerable(Of TrackingWorkflowEvent))
For Each status As TrackingWorkflowEvent In eventStatuses
workflowLocation.Events.Add(status)
Next
workflowTrack.MatchingLocation = workflowLocation
profile.WorkflowTrackPoints.Add(workflowTrack)
Dim serializer As TrackingProfileSerializer = New TrackingProfileSerializer()
Dim writer As StringWriter = New StringWriter(New StringBuilder(), CultureInfo.InvariantCulture)
serializer.Serialize(writer, profile)
Dim trackingProfile As String = writer.ToString()
InsertTrackingProfile(trackingProfile)
End Sub