Example #1
0
        /// <summary>
        /// Get the default Event Recording Configuration
        /// </summary>
        /// <returns></returns>
        public static RecorderSetting GetDefaultRecordingConfig()
        {
            RecorderSetting config = new RecorderSetting
            {
                // Set Individual Event
                Events = (from e in EventType.GetInstance().GetKeyValuePairList()
                          select new RecordEntitySetting()
                {
                    Type = RecordEntityType.Event,
                    Id = e.Key,
                    Name = e.Value,
                    IsRecorded = false
                }).ToList(),

                // Set properties
                Properties = (from e in PropertyType.GetInstance().GetKeyValuePairList()
                              select new RecordEntitySetting()
                {
                    Type = RecordEntityType.Property,
                    Id = e.Key,
                    Name = e.Value,
                    IsRecorded = false
                }).ToList(),

                // Set Global event
                IsListeningFocusChangedEvent = true,

                // Individual Event Scope
                ListenScope = ListenScope.Subtree,
            };

            return(config);
        }
        /// <summary>
        /// Populate event configuration
        /// </summary>
        public void PopulateEventConfiguration()
        {
            var configpath = Path.Combine(DirectoryManagement.sUserDataFolderPath, EventConfigFileName);

            try
            {
                var rcfg = RecorderSetting.LoadConfiguration(configpath);
                this.EventConfig = rcfg;
            }
            catch (Exception)
            {
                RecorderSetting.RemoveConfiguration(configpath);
                this.EventConfig = RecorderSetting.LoadConfiguration(configpath);
            }
        }
Example #3
0
        /// <summary>
        /// Populate event configuration
        /// </summary>
        public void PopulateEventConfiguration()
        {
            MigrateEventConfigurationFile();
            var configpath = Path.Combine(SettingsProvider.ConfigurationFolderPath, EventConfigFileName);
            try
            {
                var rcfg = RecorderSetting.LoadConfiguration(configpath);
                this.EventConfig = rcfg;
            }
#pragma warning disable CA1031 // Do not catch general exception types
            catch (Exception e)
            {
                e.ReportException();
                RecorderSetting.RemoveConfiguration(configpath);
                this.EventConfig = RecorderSetting.LoadConfiguration(configpath);
            }
#pragma warning restore CA1031 // Do not catch general exception types
        }
Example #4
0
        public static RecorderSetting LoadConfiguration(string path)
        {
            // Get Recorder configuration from local location. but if it is not available, get it from default location.
            RecorderSetting config = new RecorderSetting();

            config = RecorderSetting.LoadFromJSON <RecorderSetting>(path);
            if (config == null)
            {
                config = GetDefaultRecordingConfig();
                config.SerializeInJSON(path);
            }
            else
            {
                // check whether there is any new events to be added into configuration.
                var events = EventType.GetInstance();
                var ms     = from e in events.GetKeyValuePairList()
                             where IsNotInList(e.Key, config.Events)
                             select e;

                if (ms.Any())
                {
                    foreach (var m in ms)
                    {
                        config.Events.Add(new RecordEntitySetting()
                        {
                            Id         = m.Key,
                            Name       = m.Value,
                            IsRecorded = false,
                            Type       = RecordEntityType.Event,
                        });
                    }
                    config.SerializeInJSON(path);
                }
                config.IsListeningAllEvents = false;
            }

            return(config);
        }