Пример #1
0
        private void TrackEventTelemetry(string name)
        {
            var telemetry = new EventTelemetry($"FilterCultureBy{name}");

            telemetry.Properties.Add("NameCode", NameCode);
            telemetry.Properties.Add("EnglishName", EnglishName);
            telemetry.Properties.Add("FilterType", FilterType.ToString());
            telemetry.Metrics.Add("NeutralCultures.Count", NeutralCultures.Count());
            telemetry.Metrics.Add("CultureSpecific.Count", CultureSpecific.Count());
            telemetry.Metrics.Add("FilterTime (ms)", _timer.ElapsedMilliseconds);
            telemetry.Metrics.Add("FilterTime (ticks)", _timer.ElapsedTicks);
            _telemetryClient.TrackEvent(telemetry);
        }
Пример #2
0
        private void FilterInfo()
        {
            _timer.Start();
            var telemetryName        = "Nothing";
            var hasNameCodeFilter    = !string.IsNullOrWhiteSpace(NameCode);
            var hasEnglishNameFilter = !string.IsNullOrWhiteSpace(EnglishName);

            if (hasNameCodeFilter && hasEnglishNameFilter)
            {
                if (FilterType == FilterType.And)
                {
                    NeutralCultures = NeutralCultures
                                      .Where(c => c.Name.Contains(NameCode, StringComparison.InvariantCultureIgnoreCase) && c.EnglishName.Contains(EnglishName, StringComparison.InvariantCultureIgnoreCase));
                    CultureSpecific = CultureSpecific
                                      .Where(c => c.Name.Contains(NameCode, StringComparison.InvariantCultureIgnoreCase) && c.EnglishName.Contains(EnglishName, StringComparison.InvariantCultureIgnoreCase));
                    telemetryName = "NameAndEnglishName";
                }
                else
                {
                    NeutralCultures = NeutralCultures
                                      .Where(c => c.Name.Contains(NameCode, StringComparison.InvariantCultureIgnoreCase) || c.EnglishName.Contains(EnglishName, StringComparison.InvariantCultureIgnoreCase));
                    CultureSpecific = CultureSpecific
                                      .Where(c => c.Name.Contains(NameCode, StringComparison.InvariantCultureIgnoreCase) || c.EnglishName.Contains(EnglishName, StringComparison.InvariantCultureIgnoreCase));
                    telemetryName = "NameOrEnglishName";
                }
            }
            else if (hasNameCodeFilter)
            {
                NeutralCultures = NeutralCultures.Where(c => c.Name.Contains(NameCode, StringComparison.InvariantCultureIgnoreCase));
                CultureSpecific = CultureSpecific.Where(c => c.Name.Contains(NameCode, StringComparison.InvariantCultureIgnoreCase));
                telemetryName   = "Name";
            }
            else if (hasEnglishNameFilter)
            {
                NeutralCultures = NeutralCultures.Where(c => c.EnglishName.Contains(EnglishName, StringComparison.InvariantCultureIgnoreCase));
                CultureSpecific = CultureSpecific.Where(c => c.EnglishName.Contains(EnglishName, StringComparison.InvariantCultureIgnoreCase));
                telemetryName   = "EnglishName";
            }
            _timer.Stop();
            TrackEventTelemetry(telemetryName);
        }