/// <summary>
 /// Always returns false; this tracking service has no need to reload its tracking profile for a running instance.
 /// </summary>
 /// <param name="workflowType"></param>
 /// <param name="workflowInstanceId"></param>
 /// <param name="profile"></param>
 /// <returns></returns>
 protected override bool TryReloadProfile(Type workflowType, Guid workflowInstanceId, out TrackingProfile profile)
 {
     //
     // There is no reason for this service to ever reload a profile
     profile = null;
     return(false);
 }
Ejemplo n.º 2
0
        public GraywulfTrackingParticipant()
        {
            trackingProfile = new TrackingProfile();

            ActivityStateQuery aq = new ActivityStateQuery();

            aq.ActivityName = "*";
            aq.States.Add("*");
            aq.Arguments.Add("JobGuid");
            aq.Arguments.Add("UserGuid");
            aq.Arguments.Add("EntityGuid");
            aq.Arguments.Add("EntityGuidFrom");
            aq.Arguments.Add("EntityGuidTo");
            trackingProfile.Queries.Add(aq);

            CustomTrackingQuery cq = new CustomTrackingQuery();

            cq.ActivityName = "*";
            trackingProfile.Queries.Add(cq);

            FaultPropagationQuery fq = new FaultPropagationQuery();

            fq.FaultHandlerActivityName = "*";
            fq.FaultSourceActivityName  = "*";
            trackingProfile.Queries.Add(fq);
        }
Ejemplo n.º 3
0
        public static TrackingProfile GetTrackingProfile(string profileName, string scopeName)
        {
            TrackingProfile trackingProfile = null;

            //TrackingSection trackingSection = (TrackingSection)PartialTrustConfigurationManager.GetSection("system.serviceModel/tracking");
            //if (trackingSection == null)
            //{
            //    return null;
            //}

            //foreach (TrackingProfile profile in trackingSection.TrackingProfiles)
            //{
            //    if (profile.Name == profileName)
            //    {
            //        trackingProfile = profile;
            //        break;
            //    }
            //}

            //No matching profile with the specified name was found
            if (trackingProfile == null)
            {
                //return an empty profile
                trackingProfile = new TrackingProfile()
                {
                    ActivityDefinitionId = scopeName
                };
            }

            return(trackingProfile);
        }
Ejemplo n.º 4
0
        //构造函数
        public designerDebugTracking(WorkflowDesigner designer)
        {
            //(1)
            this.designer     = designer;
            this.debugService = designer.DebugManagerView as DebuggerService;;

            //ziyunhx 2013-8-8 add debug status
            DebugStatus debug = new DebugStatus();

            debug.status = 1;

            //(2) TrackingProfile
            TrackingProfile    trackingProfile    = new TrackingProfile();
            ActivityStateQuery activityStateQuery = new ActivityStateQuery()
            {
                ActivityName = "*",
                States       = { ActivityStates.Executing },
                Variables    = { "*" },
                Arguments    = { "*" }
            };

            trackingProfile.Queries.Add(activityStateQuery);

            this.TrackingProfile = trackingProfile;

            //(3)
            clearTrackInfo();

            //(4)
            sourceLocationList = getSourceLocationMap();
            activityMapList    = getActivityMapList(sourceLocationList);
        } //end
Ejemplo n.º 5
0
 /// <summary>
 /// Called to retrieve a tracking profile
 /// </summary>
 /// <param name="workflowType"></param>
 /// <param name="profile"></param>
 /// <returns></returns>
 protected override bool TryGetProfile(
     Type workflowType, out TrackingProfile profile)
 {
     //always return the default profile
     profile = _defaultProfile;
     return(true);
 }
Ejemplo n.º 6
0
        static void Main(string[] args)
        {
            var fileTrackingProfile = new TrackingProfile();

            fileTrackingProfile.Queries.Add(new WorkflowInstanceQuery
            {
                States = { "*" }
            });

            fileTrackingProfile.Queries.Add(new ActivityStateQuery
            {
                States = { ActivityStates.Executing, ActivityStates.Closed }
            });

            var fileTrackingParticipaint = new FileTrackingParticipant();

            fileTrackingParticipaint.TrackingProfile = fileTrackingProfile;
            var waitHandler = new AutoResetEvent(initialState: false);
            var wfApp       = new WorkflowApplication(new Workflow1());

            wfApp.Unloaded = (wfAppEventArg) => { waitHandler.Set(); };
            wfApp.Extensions.Add(fileTrackingParticipaint);
            wfApp.Run();
            waitHandler.WaitOne();
        }
Ejemplo n.º 7
0
        public LoggingTrackingParticipant(ILoggingTrackingParticipantSettings loggingTrackingParticipantSettings)
        {
            Contract.Assert(null != loggingTrackingParticipantSettings);

            _loggingTrackingParticipantSettings = loggingTrackingParticipantSettings;
            TrackingProfile = loggingTrackingParticipantSettings.TrackingProfile;
        }
 protected override bool TryGetProfile(Type workflowType, out TrackingProfile profile)
 {
     //Depending on the workflowType, service can return different tracking profiles
     //In this sample we're returning the same profile for all running types
     profile = GetProfile();
     return(true);
 }
Ejemplo n.º 9
0
        /// <summary>
        /// Updates the tracking profile for the specified workflow instance.
        /// </summary>
        /// <param name="instanceId">The <see cref="Guid"></see> of the workflow instance.</param>
        /// <param name="updatedProfile">The updated <see cref="TrackingProfile" />.</param>
        public void UpdateTrackingProfile(Guid instanceId, TrackingProfile updatedProfile)
        {
            if (updatedProfile == null)
            {
                throw new ArgumentNullException("updatedProfile");
            }

            using (DbCommand dbCommand = CreateCommand(_nameResolver.ResolveCommandName(TrackingCommandName.UpdateInstanceTrackingProfile), CommandType.StoredProcedure))
            {
                AddParameter(dbCommand, _nameResolver.ResolveParameterName(
                                 TrackingCommandName.UpdateInstanceTrackingProfile,
                                 TrackingParameterName.InstanceId), instanceId,
                             AdoDbType.Guid);

                AddParameter(dbCommand, _nameResolver.ResolveParameterName(
                                 TrackingCommandName.UpdateInstanceTrackingProfile,
                                 TrackingParameterName.Version),
                             updatedProfile.Version.ToString(), AdoDbType.String);

                AddParameter(dbCommand, _nameResolver.ResolveParameterName(
                                 TrackingCommandName.UpdateInstanceTrackingProfile,
                                 TrackingParameterName.TrackingProfile),
                             buildXmlFromProfile(updatedProfile), AdoDbType.Text);

                dbCommand.ExecuteNonQuery();
            }
        }
Ejemplo n.º 10
0
        /// <summary>
        /// Helper method used to retrieve the tracking profile for a specified
        /// workflow instance from the tracking store.
        /// </summary>
        /// <param name="instanceId">The <see cref="Type" /> of the workflow
        /// <see cref="Guid" /> representing the workflow instance's type.
        /// </param>
        /// <returns>
        /// A <see cref="TrackingProfile" /> for the specified workflow instance.
        /// </returns>
        private TrackingProfile getProfile(Guid instanceId)
        {
            TrackingProfile trackingProfile = null;

            using (DbCommand dbCommand = CreateCommand(_nameResolver.ResolveCommandName(TrackingCommandName.GetTrackingProfile), CommandType.StoredProcedure))
            {
                AddParameter(dbCommand, _nameResolver.ResolveParameterName(
                                 TrackingCommandName.GetInstanceTrackingProfile,
                                 TrackingParameterName.InstanceId),
                             instanceId, AdoDbType.Guid);

                AddParameter(dbCommand, _nameResolver.ResolveParameterName(
                                 TrackingCommandName.GetTrackingProfile,
                                 TrackingParameterName.TrackingProfile),
                             AdoDbType.Cursor, ParameterDirection.Output);


                using (IDataReader dataReader = dbCommand.ExecuteReader())
                {
                    if (dataReader.Read())
                    {
                        trackingProfile = buildProfileFromXml(_valueReader.GetString(dataReader, 0));
                    }
                }
            }

            return(trackingProfile);
        }
Ejemplo n.º 11
0
        ///<summary>
        /// Returns the default tracking profile, qualified by version.
        ///</summary>
        ///<returns>
        ///A <see cref="T:System.Workflow.Runtime.Tracking.TrackingProfile"></see>.
        ///</returns>
        ///<param name="profileVersion">The <see cref="T:System.Version"></see> of the tracking profile.</param>
        public TrackingProfile GetDefaultTrackingProfile(Version profileVersion)
        {
            if (profileVersion == null)
            {
                throw new ArgumentNullException("profileVersion");
            }

            TrackingProfile trackingProfile = null;

            using (DbCommand dbCommand = CreateCommand(_nameResolver.ResolveCommandName(TrackingCommandName.GetCurrentDefaultTrackingProfile), CommandType.StoredProcedure))
            {
                AddParameter(dbCommand, _nameResolver.ResolveParameterName(
                                 TrackingCommandName.GetDefaultTrackingProfile,
                                 TrackingParameterName.Version), profileVersion.ToString(),
                             AdoDbType.String);

                AddParameter(dbCommand, _nameResolver.ResolveParameterName(
                                 TrackingCommandName.GetDefaultTrackingProfile,
                                 TrackingParameterName.TrackingProfile),
                             AdoDbType.Cursor, ParameterDirection.Output);

                using (DbDataReader dataReader = dbCommand.ExecuteReader())
                {
                    if (dataReader.Read())
                    {
                        trackingProfile = buildProfileFromXml(_valueReader.GetString(dataReader, 0));
                    }
                }
            }

            return(trackingProfile);
        }
Ejemplo n.º 12
0
        private void LoadConfig(String profileName)
        {
            TrackingSection ts =
                (TrackingSection)ConfigurationManager.GetSection(
                    "system.serviceModel/tracking");

            if (ts != null && ts.TrackingProfiles != null)
            {
                TrackingProfile profile =
                    (from tp in ts.TrackingProfiles
                     where tp.Name == profileName
                     select tp).SingleOrDefault();
                if (profile != null)
                {
                    Profile = profile;
                }
            }

            if (Profile == null)
            {
                throw new ArgumentException(String.Format(
                                                "Tracking Profile {0} not found in app.config",
                                                profileName));
            }
        }
Ejemplo n.º 13
0
 ///<summary>
 ///Must be overridden in the derived class, and when implemented, retrieves the tracking profile for the specified workflow type if one is available.
 ///</summary>
 ///
 ///<returns>
 ///true if a <see cref="T:System.Workflow.Runtime.Tracking.TrackingProfile"></see> for the specified workflow <see cref="T:System.Type"></see> is available; otherwise, false. If true, the <see cref="T:System.Workflow.Runtime.Tracking.TrackingProfile"></see> is returned in profile.
 ///</returns>
 ///
 ///<param name="workflowType">The <see cref="T:System.Type"></see> of the workflow for which to get the tracking profile.</param>
 ///<param name="profile">When this method returns, contains the <see cref="T:System.Workflow.Runtime.Tracking.TrackingProfile"></see> to load. This parameter is passed un-initialized.</param>
 protected override bool TryGetProfile(Type workflowType, out TrackingProfile profile)
 {
     using (IResourceAccessor resourceAccessor = CreateAccessor(resourceProvider))
     {
         return(resourceAccessor.TryGetProfile(workflowType, out profile));
     }
 }
Ejemplo n.º 14
0
        static void Main(string[] args)
        {
            var trackingProfile = new TrackingProfile();

            trackingProfile.Queries.Add(new WorkflowInstanceQuery
            {
                States = { "*" }
            });

            trackingProfile.Queries.Add(new ActivityStateQuery
            {
                States = { "*" }
            });

            trackingProfile.Queries.Add(new CustomTrackingQuery
            {
                ActivityName = "*",
                Name         = "*"
            });

            var etwTrackingParticipant = new EtwTrackingParticipant {
                TrackingProfile = trackingProfile
            };
            var waitHandler = new AutoResetEvent(initialState: false);

            var wfApp = new WorkflowApplication(new Workflow1());

            wfApp.Completed = (arg) => { waitHandler.Set(); };
            wfApp.Extensions.Add(etwTrackingParticipant);
            wfApp.Run();
            waitHandler.WaitOne();
        }
        public GrainTrackingParticipant(Logger logger)
        {
            this.logger = logger;

            TrackingProfile = new TrackingProfile();
            TrackingProfile.Queries.Add(new WorkflowInstanceQuery()
            {
                States = { "*" },
            });
            //TrackingProfile.Queries.Add(new ActivityScheduledQuery()
            //{
            //    ActivityName = "*",
            //});
            //TrackingProfile.Queries.Add(new ActivityStateQuery()
            //{
            //    States = { "*" }
            //});
            TrackingProfile.Queries.Add(new BookmarkResumptionQuery()
            {
                Name = "*",
            });
            TrackingProfile.Queries.Add(new CancelRequestedQuery()
            {
                ActivityName = "*",
            });
            TrackingProfile.Queries.Add(new CustomTrackingQuery()
            {
                ActivityName = "*",
                Name         = "*"
            });
            TrackingProfile.Queries.Add(new FaultPropagationQuery()
            {
                FaultSourceActivityName = "*",
            });
        }
Ejemplo n.º 16
0
        /// <summary>
        /// Loads a workflow and profile from the SQL Tracking Database, using the LoadFromStore winform.
        /// </summary>
        /// <param name="workflowType"></param>
        /// <param name="profile"></param>
        public void LoadWorkflowAndProfile(out Type workflowType, out TrackingProfile profile)
        {
            LoadFromStore loadFromStoreForm = new LoadFromStore();

            loadFromStoreForm.WorkflowProfiles = GetWorkflowAndProfiles();
            DialogResult result = loadFromStoreForm.ShowDialog();

            if (result == DialogResult.OK)
            {
                workflowType = loadFromStoreForm.SelectedWorkflow;
                if (workflowType != null)
                {
                    profile = GetWorkflowProfile(workflowType, loadFromStoreForm.SelectedProfileVersion, true);
                }
                else
                {
                    profile = null;
                }
            }
            else
            {
                workflowType = null;
                profile      = null;
                return;
            }
        }
        public virtual void ApplyDispatchBehavior(System.ServiceModel.Description.ServiceDescription serviceDescription, ServiceHostBase serviceHostBase)
        {
            WorkflowServiceHost host = serviceHostBase as WorkflowServiceHost;

            if (host != null)
            {
                string displayName   = host.Activity.DisplayName;
                string hostReference = string.Empty;
                if (AspNetEnvironment.Enabled)
                {
                    VirtualPathExtension extension = serviceHostBase.Extensions.Find <VirtualPathExtension>();
                    if ((extension != null) && (extension.VirtualPath != null))
                    {
                        string str2 = (serviceDescription != null) ? serviceDescription.Name : string.Empty;
                        string applicationVirtualPath = extension.ApplicationVirtualPath;
                        string str4 = extension.VirtualPath.Replace("~", applicationVirtualPath + "|");
                        hostReference = string.Format(CultureInfo.InvariantCulture, "{0}{1}|{2}", new object[] { extension.SiteName, str4, str2 });
                    }
                }
                TrackingProfile trackingProfile = this.GetProfile(this.ProfileName, displayName);
                host.WorkflowExtensions.Add <EtwTrackingParticipant>(() => new EtwTrackingParticipant {
                    ApplicationReference = hostReference, TrackingProfile = trackingProfile
                });
            }
        }
Ejemplo n.º 18
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);
        }
Ejemplo n.º 19
0
        public void BookmarkResumptionTracking()
        {
            Console.WriteLine();
            Console.WriteLine("*** BookmarkResumptionTracking ***");
            Console.WriteLine();
            MyTrackingParticipant participant;

            // First, let's just get all bookmarks tracked.
            TrackingProfile         profile = new TrackingProfile();
            BookmarkResumptionQuery query   = new BookmarkResumptionQuery();

            query.Name = "*";
            profile.Queries.Add(query);
            RunWorkflow(profile, out participant);
            Assert.True(participant.BookmarkResumptionRecords.Contains(bookmarkName + ":" + bookmarkData));

            // Now lets test filtering.

            profile    = new TrackingProfile();
            query      = new BookmarkResumptionQuery();
            query.Name = bookmarkName;
            profile.Queries.Add(query);
            RunWorkflow(profile, out participant);
            Assert.True(participant.BookmarkResumptionRecords.Contains(bookmarkName + ":" + bookmarkData));

            profile    = new TrackingProfile();
            query      = new BookmarkResumptionQuery();
            query.Name = "some bogus bookmark name";
            profile.Queries.Add(query);
            RunWorkflow(profile, out participant);
            Assert.True(!participant.BookmarkResumptionRecords.Contains(bookmarkName + ":" + bookmarkData));
        }
Ejemplo n.º 20
0
        private void cmdUpdateTrackingProfile_Click(Object sender, EventArgs e)
        {
            ConnectionStringSettings trackingConnectionString = cboTrackingService.SelectedItem as ConnectionStringSettings;

            // update the default tracking profile
            GenericTrackingProfileManager profileManager = new AdoTrackingProfileManager(trackingConnectionString);
            TrackingProfile trackingProfile = profileManager.GetDefaultTrackingProfile();

            foreach (ActivityTrackPoint trackPoint in trackingProfile.ActivityTrackPoints)
            {
                trackPoint.Annotations.Add("Annotation added on " + DateTime.UtcNow);
                TrackingExtract trackingExtract = new ActivityDataTrackingExtract("Name");
                trackingExtract.Annotations.Add("Tracking Data Item added on " + DateTime.UtcNow);
                trackPoint.Extracts.Add(trackingExtract);
            }

            trackingProfile.Version = new Version(
                trackingProfile.Version.Major,
                trackingProfile.Version.Minor + 1, 0, 0);

            if (profileManager.GetTrackingProfile(typeof(SequentialWorkFlow)) != null)
            {
                profileManager.UpdateTrackingProfile(typeof(SequentialWorkFlow), trackingProfile);
            }

            profileManager.UpdateDefaultTrackingProfile(trackingProfile);
        }
Ejemplo n.º 21
0
        public void InstanceTracking()
        {
            Console.WriteLine();
            Console.WriteLine("*** InstanceTracking ***");
            Console.WriteLine();
            MyTrackingParticipant participant;

            // First, let's just get all instance states tracked.
            TrackingProfile       profile = new TrackingProfile();
            WorkflowInstanceQuery query   = new WorkflowInstanceQuery();

            query.States.Add("*");
            profile.Queries.Add(query);
            RunWorkflow(profile, out participant);
            Assert.True(participant.InstanceStates.Contains("Started"));
            Assert.True(participant.InstanceStates.Contains("Idle"));
            Assert.True(participant.InstanceStates.Contains("Completed"));

            // Now lets test filtering. Only ask for Idle and Unloaded.
            // We should only get Idle.

            profile = new TrackingProfile();
            query   = new WorkflowInstanceQuery();
            query.States.Add("Idle");
            query.States.Add("Unloaded");
            profile.Queries.Add(query);

            RunWorkflow(profile, out participant);
            Assert.True(!participant.InstanceStates.Contains("Started"));
            Assert.True(participant.InstanceStates.Contains("Idle"));
            Assert.True(!participant.InstanceStates.Contains("Completed"));
            // Even though we asked for Unloaded records, there shouldn't be any.
            Assert.True(!participant.InstanceStates.Contains("Unloaded"));
        }
Ejemplo n.º 22
0
        private static TrackingProfile CreateTrace(List <string> argumentNames, List <string> variableNames)
        {
            var trackingProfile = new TrackingProfile()
            {
                ImplementationVisibility = ImplementationVisibility.All,
                Name    = "CustomTrackingProfile",
                Queries =
                {
                    new CustomTrackingQuery()
                    {
                        Name         = "*",
                        ActivityName = "*"
                    },
                    new WorkflowInstanceQuery()
                    {
                        // Limit workflow instance tracking records for started and completed workflow states
                        States ={ WorkflowInstanceStates.Started,              WorkflowInstanceStates.Completed },
                    }
                }
            };

            trackingProfile.Queries.Add(GetActivityQueryState(argumentNames, variableNames));

            return(trackingProfile);
        }
        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.º 24
0
        TrackingProfile GetProfile(string profileName, string displayName)
        {
            TrackingProfile trackingProfile = null;
            TrackingSection trackingSection = (TrackingSection)WebConfigurationManager.GetSection("system.serviceModel/tracking");

            if (trackingSection == null)
            {
                return(null);
            }

            if (profileName == null)
            {
                profileName = "";
            }

            //Find the profile with the specified profile name in the list of profile found in config
            var match = from p in new List <TrackingProfile>(trackingSection.TrackingProfiles)
                        where (p.Name == profileName) && ((p.ActivityDefinitionId == displayName) || (p.ActivityDefinitionId == "*"))
                        select p;

            if (match.Count() == 0)
            {
                //return an empty profile
                trackingProfile = new TrackingProfile()
                {
                    ActivityDefinitionId = displayName
                };
            }
            else
            {
                trackingProfile = match.First();
            }

            return(trackingProfile);
        }
Ejemplo n.º 25
0
 private void ImportPreferences()
 {
     drawOnPlay    = PreferencesManager.PlayerPreferences.DrawOnPlay;
     defaultFading = new InfosFading(0, 0);
     //defaultFading = PreferencesManager.PlayerPreferences.DefaultFading;
     trackingProfile = PreferencesManager.PlayerPreferences.TrackingProfile;
 }
Ejemplo n.º 26
0
        public virtual void ApplyDispatchBehavior(ServiceDescription serviceDescription, ServiceHostBase serviceHostBase)
        {
            WorkflowServiceHost workflowServiceHost = serviceHostBase as WorkflowServiceHost;

            if (null != workflowServiceHost)
            {
                string workflowDisplayName = workflowServiceHost.Activity.DisplayName;
                string hostReference       = string.Empty;

                if (AspNetEnvironment.Enabled)
                {
                    VirtualPathExtension virtualPathExtension = serviceHostBase.Extensions.Find <VirtualPathExtension>();
                    if (virtualPathExtension != null && virtualPathExtension.VirtualPath != null)
                    {
                        //Format Website name\Application Virtual Path|\relative service virtual path|serviceName
                        string name        = serviceDescription != null ? serviceDescription.Name : string.Empty;
                        string application = virtualPathExtension.ApplicationVirtualPath;

                        //If the application is the root, do not include it in servicePath
                        string servicePath = virtualPathExtension.VirtualPath.Replace("~", application + "|");
                        hostReference = string.Format(CultureInfo.InvariantCulture, "{0}{1}|{2}", virtualPathExtension.SiteName, servicePath, name);
                    }
                }

                TrackingProfile trackingProfile = this.GetProfile(this.ProfileName, workflowDisplayName);
                workflowServiceHost.WorkflowExtensions.Add(
                    () => new EtwTrackingParticipant
                {
                    ApplicationReference = hostReference,
                    TrackingProfile      = trackingProfile
                });
            }
        }
        private void InitializeProfileDesigner(Type workflowType, TrackingProfile profile)
        {
            this.toolStrip1.Visible = true;
            if (workflowType != null)
            {
                profileManager = new TrackingProfileManager();
                if (profile != null)
                {
                    profileManager.TrackingProfile = profile;
                }
                this.workflowDesignerControl1.WorkflowType = workflowType;
            }

            this.workflowDesignerControl1.SelectionChanged += this.OnActivitySelected;

            //Once a workflow is loaded, ensure our glyph provider is added
            IDesignerGlyphProviderService glyphManager = this.workflowDesignerControl1.GetService(typeof(IDesignerGlyphProviderService)) as IDesignerGlyphProviderService;

            if (glyphManager == null)
            {
                MessageBox.Show("There was an error loading the workflow type " + workflowType.AssemblyQualifiedName);
                return;
            }
            glyphManager.AddGlyphProvider(new TrackingGlyphProvider(profileManager));

            WorkflowType = workflowType;
        }
Ejemplo n.º 28
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.º 29
0
        ///<summary>
        ///Must be overridden in the derived class, and when implemented, retrieves the tracking profile for the specified workflow type if one is available.
        ///</summary>
        ///
        ///<returns>
        ///true if a <see cref="T:System.Workflow.Runtime.Tracking.TrackingProfile"></see> for the specified workflow <see cref="T:System.Type"></see> is available; otherwise, false. If true, the <see cref="T:System.Workflow.Runtime.Tracking.TrackingProfile"></see> is returned in profile.
        ///</returns>
        ///
        ///<param name="workflowType">The <see cref="T:System.Type"></see> of the workflow for which to get the tracking profile.</param>
        ///<param name="profile">When this method returns, contains the <see cref="T:System.Workflow.Runtime.Tracking.TrackingProfile"></see> to load. This parameter is passed un-initialized.</param>
        protected override bool TryGetProfile(Type workflowType, out TrackingProfile profile)
        {
            TraceHelper.Trace();

            try
            {
                using (ITrackingServiceResourceAccessor resourceAccessor = CreateAccessor(resourceProvider))
                {
                    return(resourceAccessor.TryGetTrackingProfile(workflowType, out profile));
                }
            }
            catch (Exception e)
            {
                string errorMessage = RM.Get_Error_TrackingServiceException(e.ToString());

                TraceHelper.Trace(errorMessage);

                TrackingException trackingException =
                    new TrackingException(errorMessage, e);

                base.RaiseServicesExceptionNotHandledEvent(
                    trackingException, Guid.Empty);

                throw trackingException;
            }
        }
Ejemplo n.º 30
0
        private static Version GetTrackingProfileVersion(Version version)
        {
            TrackingProfile profile = null;
            SqlDataReader reader = null;
            using (SqlCommand command = new SqlCommand())
            {
                command.CommandType = CommandType.StoredProcedure;
                command.CommandText = "dbo.GetTrackingProfile";
                command.Connection = new SqlConnection(connectionString);
                SqlParameter typeFullName = new SqlParameter();
                typeFullName.ParameterName = "@TypeFullName";
                typeFullName.SqlDbType = SqlDbType.NVarChar;
                typeFullName.SqlValue = typeof(SimpleWorkflow).FullName;
                command.Parameters.Add(typeFullName);

                SqlParameter assemblyFullName = new SqlParameter();
                assemblyFullName.ParameterName = "@AssemblyFullName";
                assemblyFullName.SqlDbType = SqlDbType.NVarChar;
                assemblyFullName.SqlValue = typeof(SimpleWorkflow).Assembly.FullName;
                command.Parameters.Add(assemblyFullName);

                SqlParameter versionId = new SqlParameter();
                versionId.ParameterName = "@Version";
                versionId.SqlDbType = SqlDbType.VarChar;
                command.Parameters.Add(versionId);

                SqlParameter createDefault = new SqlParameter();
                createDefault.ParameterName = "@CreateDefault";
                createDefault.SqlDbType = SqlDbType.Bit;
                createDefault.SqlValue = 0;
                command.Parameters.Add(createDefault);

                command.Connection.Open();
                reader = command.ExecuteReader();
                if (reader.Read())
                {
                    string profileXml = reader[0] as string;
                    if (null != profileXml)
                    {
                        TrackingProfileSerializer serializer = new TrackingProfileSerializer();
                        StringReader stringReader = null;
                        try
                        {
                            stringReader = new StringReader(profileXml);
                            profile = serializer.Deserialize(stringReader);
                        }
                        finally
                        {
                            if (stringReader != null)
                                stringReader.Close();
                        }
                    }
                }
            }
            if (profile != null)
                return new Version(profile.Version.Major, profile.Version.MajorRevision, profile.Version.Minor, profile.Version.MinorRevision + 1);
            else
                return new Version(version.Major, version.MajorRevision, version.Minor, version.MinorRevision + 1);
        }