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);
        }
        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));
            }
        }
Example #3
0
            public Collection <TrackingProfile> ReadProfiles()
            {
                if (this.trackingProfiles != null)
                {
                    return(this.trackingProfiles);
                }

                TrackingSection trackingSection = null;

                try
                {
                    trackingSection =
                        (TrackingSection)ConfigurationHelpers.GetSection(ConfigurationHelpers.GetSectionPath(TrackingConfigurationStrings.Tracking));
                }
                catch (ConfigurationErrorsException e)
                {
                    if (!Fx.IsFatal(e))
                    {
                        FxTrace.Exception.TraceUnhandledException(e);
                    }

                    throw;
                }

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

                // Configuration elements are never null, collections are empty
                // and single elements are constructed with the property IsPresent=false
                this.trackingProfiles = new Collection <TrackingProfile>();

                foreach (ProfileElement profileElement in trackingSection.Profiles)
                {
                    if (profileElement.Workflows != null)
                    {
                        foreach (ProfileWorkflowElement workflowElement in profileElement.Workflows)
                        {
                            TrackingProfile profile = new TrackingProfile()
                            {
                                Name = profileElement.Name,
                                ImplementationVisibility = profileElement.ImplementationVisibility,
                                ActivityDefinitionId     = workflowElement.ActivityDefinitionId
                            };

                            workflowElement.AddQueries(profile.Queries);

                            this.trackingProfiles.Add(profile);
                        }
                    }
                }

                return(this.trackingProfiles);
            }
 public Collection <TrackingProfile> ReadProfiles()
 {
     if (this.trackingProfiles == null)
     {
         TrackingSection section = null;
         try
         {
             section = (TrackingSection)ConfigurationHelpers.GetSection(ConfigurationHelpers.GetSectionPath("tracking"));
         }
         catch (ConfigurationErrorsException exception)
         {
             if (!Fx.IsFatal(exception))
             {
                 FxTrace.Exception.TraceUnhandledException(exception);
             }
             throw;
         }
         if (section == null)
         {
             return(null);
         }
         this.trackingProfiles = new Collection <TrackingProfile>();
         foreach (ProfileElement element in section.Profiles)
         {
             if (element.Workflows != null)
             {
                 foreach (ProfileWorkflowElement element2 in element.Workflows)
                 {
                     TrackingProfile item = new TrackingProfile {
                         Name = element.Name,
                         ImplementationVisibility = element.ImplementationVisibility,
                         ActivityDefinitionId     = element2.ActivityDefinitionId
                     };
                     element2.AddQueries(item.Queries);
                     this.trackingProfiles.Add(item);
                 }
             }
         }
     }
     return(this.trackingProfiles);
 }
Example #5
0
        TrackingProfile GetProfile(string profileName, string profileTarget)
        {
            TrackingSection trackingSection =
                (TrackingSection)ConfigurationManager.GetSection("system.serviceModel/tracking");

            TrackingProfile bestMatch = null;

            foreach (TrackingProfile profile in trackingSection.TrackingProfiles)
            {
                // Check the profile matches the requested name, and scope type
                if (string.Compare(profileName, profile.Name, StringComparison.OrdinalIgnoreCase) == 0)
                {
                    // If we find a global scope profile, use it as the default profile
                    if (string.Compare("*", profile.ActivityDefinitionId, StringComparison.OrdinalIgnoreCase) == 0)
                    {
                        if (bestMatch == null)
                        {
                            bestMatch = profile;
                        }
                    }
                    else if (string.Compare(profileTarget, profile.ActivityDefinitionId, StringComparison.OrdinalIgnoreCase) == 0)
                    {
                        //specific profile for scopetarget found.
                        bestMatch = profile;
                        break;
                    }
                }
            }
            if (bestMatch == null)
            {
                //If the profile is not found in config, return an empty profile to suppress
                //events. If .config does not have profiles, return null.
                bestMatch = new TrackingProfile()
                {
                    ActivityDefinitionId = profileTarget,
                };
            }

            return(bestMatch);
        }
        TrackingProfile GetProfile(string profileName)
        {
            TrackingProfile profile         = new TrackingProfile();
            TrackingSection trackingSection = (TrackingSection)ConfigurationManager.GetSection("system.serviceModel/tracking");

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

            var match = from p in new List <TrackingProfile>(trackingSection.TrackingProfiles)
                        where p.Name == profileName
                        select p;

            if (match.Count() == 0)
            {
                throw new ConfigurationErrorsException(string.Format("Could not find a profile with name '{0}'", profileName));
            }
            else
            {
                return(match.First());
            }
        }
        TrackingProfile GetProfile(string profileName, string displayName)
        {
            TrackingProfile trackingProfile = null;
            TrackingSection trackingSection = (TrackingSection)WebConfigurationManager.GetSection("system.serviceModel/tracking");

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

            //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
                        select p;

            if (match.Count() == 0)
            {
                throw new ConfigurationErrorsException(string.Format("Could not find a profile with name '{0}'", profileName));
            }
            else
            {
                trackingProfile = match.First();
            }

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

            return(trackingProfile);
        }