Exemplo n.º 1
0
        internal static List <ApplicationGroup> UpdateApplicationGroups()
        {
            using (MiniProfiler.Current.Step("UpdateApplicationGroups() - All Stores"))
            {
                lock (_updateLock) // In the case of multiple stores, it's off to the races.
                {
                    var result = ApplicationGroups;
                    var apps   = ExceptionsModule.Stores.SelectMany(s => s.Applications?.Data ?? Enumerable.Empty <Application>()).ToList();
                    // Loop through all configured groups and hook up applications returned from the queries
                    foreach (var g in result)
                    {
                        for (var i = 0; i < g.Applications.Count; i++)
                        {
                            var a = g.Applications[i];
                            foreach (var app in apps)
                            {
                                if (app.Name == a.Name)
                                {
                                    g.Applications[i] = app;
                                    break;
                                }
                            }
                        }
                    }
                    // Clear all dynamic apps from the CatchAll group
                    CatchAll.Applications.RemoveAll(a => !KnownApplications.Contains(a.Name));
                    // Check for the any dyanmic/unconfigured apps
                    foreach (var app in apps.OrderBy(a => a.Name))
                    {
                        if (!KnownApplications.Contains(app.Name))
                        {
                            // This dynamic app needs a home!
                            CatchAll.Applications.Add(app);
                        }
                    }
                    // Cleanout those with no errors right now
                    var foundNames = apps.Select(a => a.Name).ToHashSet();
                    foreach (var a in result.SelectMany(g => g.Applications))
                    {
                        if (!foundNames.Contains(a.Name))
                        {
                            a.ClearCounts();
                        }
                    }

                    Applications      = apps;
                    ApplicationGroups = result;
                    return(result);
                }
            }
        }
Exemplo n.º 2
0
        internal List <ApplicationGroup> UpdateApplicationGroups()
        {
            using (MiniProfiler.Current.Step(nameof(UpdateApplicationGroups)))
            {
                var result = ApplicationGroups;
                var apps   = Applications.Data;
                // Loop through all configured groups and hook up applications returned from the queries
                foreach (var g in result)
                {
                    for (var i = 0; i < g.Applications.Count; i++)
                    {
                        var a = g.Applications[i];
                        foreach (var app in apps)
                        {
                            if (app.Name == a.Name)
                            {
                                g.Applications[i] = app;
                                break;
                            }
                        }
                    }
                }
                // Clear all dynamic apps from the CatchAll group unless we found them again (minimal delta)
                // Doing this atomically to minimize enumeration conflicts
                CatchAll.Applications.RemoveAll(a => !apps.Any(ap => ap.Name == a.Name) && !KnownApplications.Contains(a.Name));

                // Check for the any dyanmic/unconfigured apps that we need to add to the all group
                foreach (var app in apps)
                {
                    if (!KnownApplications.Contains(app.Name) && !CatchAll.Applications.Any(a => a.Name == app.Name))
                    {
                        // This dynamic app needs a home!
                        CatchAll.Applications.Add(app);
                    }
                }
                CatchAll.Applications.Sort((a, b) => a.Name.CompareTo(b.Name));

                // Cleanout those with no errors right now
                var foundNames = apps.Select(a => a.Name).ToHashSet();
                foreach (var a in result.SelectMany(g => g.Applications))
                {
                    if (!foundNames.Contains(a.Name))
                    {
                        a.ClearCounts();
                    }
                }

                ApplicationGroups = result;
                return(result);
            }
        }
Exemplo n.º 3
0
 internal static List <ApplicationGroup> UpdateApplicationGroups()
 {
     using (MiniProfiler.Current.Step("UpdateApplicationGroups() - All Stores"))
         lock (_updateLock)
         {
             var result = _applicationGroups ?? GetConfiguredApplicationGroups();
             var apps   = Stores.SelectMany(s => s.Applications?.Data ?? Enumerable.Empty <Application>()).ToList();
             // Loop through all configured groups and hook up applications returned from the queries
             foreach (var g in result)
             {
                 for (var i = 0; i < g.Applications.Count; i++)
                 {
                     var a        = g.Applications[i];
                     var matching = apps.FirstOrDefault(sapp => a.Name == sapp.Name);
                     if (matching != null)
                     {
                         g.Applications[i] = matching;
                     }
                 }
             }
             // Clear all dynamic apps from the CatchAll group
             CatchAll.Applications.RemoveAll(a => !KnownApplications.Contains(a.Name));
             // Check for the any dyanmic/unconfigured apps
             foreach (var app in apps.OrderBy(a => a.Name))
             {
                 if (!KnownApplications.Contains(app.Name))
                 {
                     // This dynamic app needs a home!
                     CatchAll.Applications.Add(app);
                 }
             }
             Applications       = apps;
             _applicationGroups = result;
             return(result);
         }
 }