Exemple #1
0
        private static int RunListServicesAndReturnExitCode(ListOptions opts)
        {
            //Check Admin right
            if (!DaemonMasterUtils.IsElevated())
            {
                Console.WriteLine("You must start the program with admin rights.");
                return(1);
            }

            try
            {
                Console.WriteLine("Number:  service name / display name");

                List <DmServiceDefinition> services = RegistryManagement.LoadInstalledServices();
                for (var i = 0; i < services.Count; i++)
                {
                    var sb = new StringBuilder();
                    sb.Append(i);
                    sb.Append(": ");
                    sb.Append(services[i].ServiceName.Contains("DaemonMaster_") ? services[i].ServiceName.Remove(0, 13) : services[i].ServiceName); //Remove internally used prefix TODO: remove that on a later release
                    sb.Append(" / ");
                    sb.Append(services[i].DisplayName);
                    Console.WriteLine(sb);
                }

                return(0);
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.Message);
                return(1);
            }
        }
Exemple #2
0
        private void MenuItem_RefreshListOnClick(object sender, RoutedEventArgs e)
        {
            //Clear the list and refill it so that the event gets fired
            _processCollection.Clear();

            List <ServiceListViewItem> list = RegistryManagement.LoadInstalledServices().ConvertAll(x => new ServiceListViewItem(x.ServiceName, x.DisplayName, x.BinaryPath, Equals(x.Credentials, ServiceCredentials.LocalSystem)));

            foreach (ServiceListViewItem item in list)
            {
                _processCollection.Add(item);
            }

            //Force Update after refresh
            UpdateListView(null, EventArgs.Empty);
        }
Exemple #3
0
        public MainWindow()
        {
            //Initialize GUI
            InitializeComponent();

            //Get the configuration
            _config = ConfigManagement.GetConfig;


            //Fill the list and subs to the event
            _processCollection = new ObservableCollection <ServiceListViewItem>(RegistryManagement.LoadInstalledServices().ConvertAll(x => new ServiceListViewItem(x.ServiceName, x.DisplayName, x.BinaryPath, Equals(x.Credentials, ServiceCredentials.LocalSystem))));
            _processCollection.CollectionChanged += ProcessCollectionOnCollectionChanged;

            //Start ListView updater
            StartListViewUpdateTimer(_config.UpdateInterval);

            //Show the list in the list view
            ListViewDaemons.ItemsSource = _processCollection;
        }