Esempio n. 1
0
        public FileSystemBrowserForm(Machine machine)
        {
            InitializeComponent();

            Machine                  = machine;
            SelectedPath             = string.Empty;
            Description              = "Select a file or folder...";
            BrowserMode              = Mode.File | Mode.Folder;
            Filter                   = DEFAULT_FILTER;
            _machineAvailable        = ConnectionStore.ConnectionCreated(Machine);
            _entryTree               = new Dictionary <IFileSystemEntry, IFileSystemEntry>();
            _entryNodes              = new Dictionary <IFileSystemEntry, FileSystemTreeNode>();
            _entryFilter             = new Dictionary <IFileSystemEntry, string>();
            _entryQueue              = new PrioritizedEntryQueue();
            _pathExpansionQueue      = null;
            _pathExpansionWaitCursor = null;
            _lastAutoExpandedNode    = null;
            _machineNode             = null;

            imageList.Images.Add(IMAGE_LIST_KEY_MACHINE, MakeIconImage(Resources.machine_16));
            imageList.Images.Add(IMAGE_LIST_KEY_FOLDER, MakeIconImage(Resources.folder_16));
            imageList.Images.Add(FileSystemDriveType.RemovableDisk.ToString(), MakeIconImage(Resources.drive_removable_disk_16));
            imageList.Images.Add(FileSystemDriveType.LocalDisk.ToString(), MakeIconImage(Resources.drive_local_disk_16));
            imageList.Images.Add(FileSystemDriveType.NetworkDrive.ToString(), MakeIconImage(Resources.drive_network_16));
            imageList.Images.Add(FileSystemDriveType.CompactDisc.ToString(), MakeIconImage(Resources.drive_compact_disc_16));
        }
        private static string GetActionName(IMacroAction macroAction)
        {
            Group       group       = null;
            Application application = null;

            switch (macroAction.Type)
            {
            case MacroActionType.Start:
            case MacroActionType.Stop:
            case MacroActionType.Restart:
                MacroProcessAction macroProcessAction = (MacroProcessAction)macroAction;
                Machine            machine            = Settings.Client.Machines.FirstOrDefault(x => x.ID == macroProcessAction.MachineID);
                if (machine != null && ConnectionStore.ConnectionCreated(machine))
                {
                    group       = ConnectionStore.Connections[machine].Configuration.Groups.FirstOrDefault(x => x.ID == macroProcessAction.GroupID);
                    application = ConnectionStore.Connections[machine].Configuration.Applications.FirstOrDefault(x => x.ID == macroProcessAction.ApplicationID);
                }
                return(machine == null || group == null || application == null
                                                ? null
                                                : $"{group.Name} / {application.Name}");

            case MacroActionType.Distribute:
                MacroDistributionAction macroDistributionAction = (MacroDistributionAction)macroAction;
                Machine destinationMachine = Settings.Client.Machines.FirstOrDefault(x => x.ID == macroDistributionAction.DestinationMachineID);
                if (destinationMachine == null || !ConnectionStore.ConnectionCreated(destinationMachine))
                {
                    return(null);
                }
                Machine sourceMachine = Settings.Client.Machines.FirstOrDefault(x => x.ID == macroDistributionAction.SourceMachineID);
                if (sourceMachine != null && ConnectionStore.ConnectionCreated(sourceMachine))
                {
                    group       = ConnectionStore.Connections[sourceMachine].Configuration.Groups.FirstOrDefault(x => x.ID == macroDistributionAction.GroupID);
                    application = ConnectionStore.Connections[sourceMachine].Configuration.Applications.FirstOrDefault(x => x.ID == macroDistributionAction.ApplicationID);
                }
                return(sourceMachine == null || group == null || application == null
                                                ? null
                                                : $"{sourceMachine.HostName} / {group.Name} / {application.Name}");

            case MacroActionType.Wait:
                MacroWaitAction macroWaitAction = (MacroWaitAction)macroAction;
                if (!macroWaitAction.IsValid)
                {
                    throw new InvalidOperationException();
                }
                switch (macroWaitAction.WaitForEvent)
                {
                case MacroActionWaitForEvent.Timeout:
                    return($"{macroWaitAction.Type} for timeout, {macroWaitAction.TimeoutMilliseconds} ms");

                case MacroActionWaitForEvent.PreviousActionsCompleted:
                    return($"{macroWaitAction.Type} for previous actions completed");

                default:
                    throw new InvalidOperationException();
                }

            default:
                throw new InvalidOperationException();
            }
        }
Esempio n. 3
0
        public DistributionSourcesForm(Machine machine, Application application, Func <IEnumerable <Group> > getAllGroups)
        {
            InitializeComponent();

            Machine                    = machine;
            Application                = application;
            DistributionSources        = new List <DistributionSource>(application.Sources.Select(source => source.Clone()));
            DistributionSourcesChanged = false;
            _getAllGroups              = getAllGroups;
            _machineAvailable          = ConnectionStore.ConnectionCreated(Machine);
            _selectedSource            = null;
            _disableStateChangedEvents = false;
        }
Esempio n. 4
0
        public static void ConnectMachines()
        {
            if (!IsInitialized)
            {
                throw new InvalidOperationException("ServiceHelper not initialized");
            }

            ConnectionStore.Connections.Keys.Where(machine => !Settings.Client.Machines.Contains(machine)).ToList().ForEach(ConnectionStore.RemoveConnection);

            if (Settings.Client.Machines.Any(machine => !ConnectionStore.ConnectionCreated(machine)))
            {
                Worker.Do("Connecting to machines...", () =>
                {
                    foreach (Machine machine in Settings.Client.Machines.Where(machine => !ConnectionStore.ConnectionCreated(machine)))
                    {
                        MachineConnection connection = ConnectionStore.CreateConnection(ProcessManagerEventHandler, machine);
                        connection.ServiceHandler.Initialize();
                    }
                });
            }
        }
Esempio n. 5
0
        private static IAction CreateAction(IMacroAction macroAction)
        {
            switch (macroAction.Type)
            {
            case MacroActionType.Start:
            case MacroActionType.Stop:
            case MacroActionType.Restart:
            {
                MacroProcessAction macroProcessAction = (MacroProcessAction)macroAction;
                Machine            machine            = Settings.Client.Machines.FirstOrDefault(x => x.ID == macroProcessAction.MachineID);
                if (machine != null && ConnectionStore.ConnectionCreated(machine))
                {
                    Group       group       = ConnectionStore.Connections[machine].Configuration.Groups.FirstOrDefault(x => x.ID == macroProcessAction.GroupID);
                    Application application = ConnectionStore.Connections[machine].Configuration.Applications.FirstOrDefault(x => x.ID == macroProcessAction.ApplicationID);
                    return(new ProcessAction(Convert(macroAction.Type), machine, @group, application));
                }
                return(null);
            }

            case MacroActionType.Distribute:
            {
                MacroDistributionAction macroDistributionAction = (MacroDistributionAction)macroAction;
                Machine sourceMachine      = Settings.Client.Machines.FirstOrDefault(x => x.ID == macroDistributionAction.SourceMachineID);
                Machine destinationMachine = Settings.Client.Machines.FirstOrDefault(x => x.ID == macroDistributionAction.DestinationMachineID);
                if (sourceMachine != null && ConnectionStore.ConnectionCreated(sourceMachine))
                {
                    Group       group       = ConnectionStore.Connections[sourceMachine].Configuration.Groups.FirstOrDefault(x => x.ID == macroDistributionAction.GroupID);
                    Application application = ConnectionStore.Connections[sourceMachine].Configuration.Applications.FirstOrDefault(x => x.ID == macroDistributionAction.ApplicationID);
                    return(new DistributionAction(Convert(macroAction.Type), sourceMachine, group, application, destinationMachine));
                }
                return(null);
            }

            default:
                return(null);
            }
        }