private void UpdateSelectedApplications()
 {
     if (SelectedApplications != null)
     {
         SelectedApplications = SelectedSourceMachine == null || !ConnectionStore.ConfigurationAvailable(SelectedSourceMachine)
                                 ? null
                                 : SelectedApplications
                                .Select(selectedApplication => ConnectionStore.Connections[SelectedSourceMachine].Configuration
                                        .Applications
                                        .Where(application => ConnectionStore.Connections[SelectedSourceMachine].Configuration
                                               .Groups
                                               .Where(group => Comparer.GroupsEqual(group, SelectedGroup))
                                               .SelectMany(group => group.Applications)
                                               .Any(appID => ProcessManager.DataObjects.Comparers.Comparer <Application> .IDObjectsEqual(application, appID)))
                                        .FirstOrDefault(application => Comparer.ApplicationsEqual(application, selectedApplication)))
                                .Where(application => application != null)
                                .Distinct(new ApplicationEqualityComparer())
                                .ToList();
     }
     UpdateLinkLabelApplications();
 }
 private void UpdateSelectedApplications()
 {
     if (SelectedApplications != null)
     {
         SelectedApplications = SelectedMachines == null ? null : SelectedApplications
                                .Select(selectedApplication => SelectedMachines
                                        .Select(machine => ConnectionStore.Connections.Values
                                                .First(connection => ProcessManager.DataObjects.Comparers.Comparer <Machine> .IDObjectsEqual(connection.Machine, machine))
                                                .Configuration)
                                        .SelectMany(configuration => configuration
                                                    .Applications
                                                    .Where(application => configuration
                                                           .Groups
                                                           .Where(group => Comparer.GroupsEqual(group, SelectedGroup))
                                                           .SelectMany(group => group.Applications)
                                                           .Any(appID => ProcessManager.DataObjects.Comparers.Comparer <Application> .IDObjectsEqual(application, appID))))
                                        .FirstOrDefault(application => Comparer.ApplicationsEqual(application, selectedApplication)))
                                .Where(application => application != null)
                                .Distinct(new ApplicationEqualityComparer())
                                .ToList();
     }
     UpdateLinkLabelApplications();
 }
        private void LinkLabelApplications_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e)
        {
            IEnumerable <Tuple <Application, bool> > applications = ConnectionStore.Connections[SelectedSourceMachine]
                                                                    .Configuration
                                                                    .Applications
                                                                    .Where(application => ConnectionStore.Connections[SelectedSourceMachine].Configuration
                                                                           .Groups
                                                                           .Where(group => Comparer.GroupsEqual(group, SelectedGroup))
                                                                           .SelectMany(group => group.Applications)
                                                                           .Any(applicationID => ProcessManager.DataObjects.Comparers.Comparer <Application> .IDObjectsEqual(application, applicationID)))
                                                                    .Distinct(new ApplicationEqualityComparer())
                                                                    .Select(application => new Tuple <Application, bool>(application, SelectedApplications != null &&
                                                                                                                         SelectedApplications.Any(x => Comparer.ApplicationsEqual(application, x))));

            Picker.ShowMultiSelectMenu(linkLabelApplications, applications, ContextMenu_SelectApplications_MenuClosed);
        }
Ejemplo n.º 4
0
        public override bool Equals(object obj)
        {
            Application application = obj as Application;

            return(application != null && Comparer.ApplicationsEqual(this, application));
        }
Ejemplo n.º 5
0
 public bool Equals(string name)
 {
     return(Comparer.ApplicationsEqual(this, name));
 }
        private void UpdateMacroActionBundle()
        {
            ActionBundle.Actions.Clear();
            if (HasValidSelections)
            {
                ActionBundle.Actions.AddRange(SelectedMachines.SelectMany(machine => SelectedApplications
                                                                          .Select(application =>
                {
                    Configuration configuration   = ConnectionStore.Connections[machine].Configuration;
                    Group actualGroup             = configuration.Groups.FirstOrDefault(x => Comparer.GroupsEqual(x, SelectedGroup));
                    Application actualApplication = configuration.Applications.FirstOrDefault(x => Comparer.ApplicationsEqual(x, application));
                    return(actualGroup != null && actualApplication != null ? new MacroProcessAction(ActionBundle.Type, machine.ID, actualGroup.ID, actualApplication.ID) : null);
                })
                                                                          .Where(action => action != null)));
            }

            RaiseMacroActionItemChangedEvent();
        }
Ejemplo n.º 7
0
        public Configuration CopyTo(Configuration configuration, ConfigurationParts configurationParts)
        {
            IDictionary <Guid, Guid> applicationIDMappings = new Dictionary <Guid, Guid>();
            List <Group>             oldGroups             = configuration.Groups;
            List <Application>       oldApplications       = configuration.Applications;

            if ((configurationParts & ConfigurationParts.Groups) != 0)
            {
                configuration.Groups = new List <Group>(Groups.Select(group => group.Clone()));
                configuration.Groups.ForEach(group =>
                {
                    Group oldGroup = oldGroups.FirstOrDefault(x => Comparer.GroupsEqual(x, group));
                    group.ID       = oldGroup?.ID ?? Guid.NewGuid();
                });
            }

            if ((configurationParts & ConfigurationParts.Applications) != 0)
            {
                configuration.Applications = new List <Application>(Applications.Select(application => application.Clone()));
                configuration.Applications.ForEach(application =>
                {
                    Application oldApplication = oldApplications.FirstOrDefault(x => Comparer.ApplicationsEqual(x, application));
                    Guid updatedApplicationID  = oldApplication?.ID ?? Guid.NewGuid();
                    applicationIDMappings.Add(application.ID, updatedApplicationID);
                    application.ID = updatedApplicationID;
                    application.Sources.ForEach(source => source.ID = Guid.NewGuid());
                });
            }

            // update application references of groups to match existing applications
            if (configurationParts == ConfigurationParts.All)
            {
                foreach (Group group in configuration.Groups)
                {
                    List <Guid> toRemove = new List <Guid>(), toAdd = new List <Guid>();
                    foreach (Guid applicationID in group.Applications.Where(applicationID => applicationIDMappings.ContainsKey(applicationID)))
                    {
                        toRemove.Add(applicationID);
                        toAdd.Add(applicationIDMappings[applicationID]);
                    }
                    toRemove.ForEach(id => group.Applications.Remove(id));
                    toAdd.ForEach(id => group.Applications.Add(id));
                }
            }
            else if (configurationParts == ConfigurationParts.Groups)
            {
                foreach (Group group in configuration.Groups)
                {
                    List <Guid> toRemove = new List <Guid>(), toAdd = new List <Guid>();
                    foreach (Application sourceApplication in group.Applications.Select(applicationID => Applications.First(application => application.ID == applicationID)))
                    {
                        toRemove.Add(sourceApplication.ID);
                        Application existingApplication = configuration.Applications.FirstOrDefault(application => Comparer.ApplicationsEqual(application, sourceApplication));
                        if (existingApplication != null)
                        {
                            toAdd.Add(existingApplication.ID);
                        }
                    }
                    toRemove.ForEach(id => group.Applications.Remove(id));
                    toAdd.ForEach(id => group.Applications.Add(id));
                }
            }
            else if (configurationParts == ConfigurationParts.Applications)
            {
                // remove references to applications that do not exist anymore
                foreach (Group group in configuration.Groups)
                {
                    group.Applications
                    .Select(applicationID => oldApplications.First(oldApplication => oldApplication.ID == applicationID))
                    .Where(oldApplication => !configuration.Applications.Any(x => Comparer.ApplicationsEqual(x, oldApplication)))
                    .ToList()
                    .ForEach(oldApplication => group.Applications.Remove(oldApplication.ID));
                }
                // add references to new application based on source references
                foreach (Application application in configuration.Applications.Where(application => oldApplications.All(oldApplication => oldApplication.ID != application.ID)))
                {
                    Guid sourceApplicationID = applicationIDMappings
                                               .Where(x => x.Value == application.ID)
                                               .Select(x => x.Key)
                                               .First();
                    List <Group> referringSourceGroups = Groups
                                                         .Where(group => group.Applications.Any(applicationID => applicationID == sourceApplicationID))
                                                         .ToList();
                    configuration.Groups
                    .Where(group => referringSourceGroups.Any(refGroup => Comparer.GroupsEqual(refGroup, group)))
                    //.Where(group => group.Applications.All(applicationID => applicationID != application.ID))
                    .ToList()
                    .ForEach(group => group.Applications.Add(application.ID));
                }
            }

            return(configuration);
        }