Example #1
0
        public override void Refresh(ObservableCollection <DataObject> objects)
        {
            using (var manager = new RefreshManager <ServiceDataObject>(objects))
            {
                using (NativeSCManager scm = new NativeSCManager(MachineName))
                {
                    foreach (ENUM_SERVICE_STATUS_PROCESS essp in scm.Refresh(ServicesType))
                    {
                        using (NativeService ns = new NativeService(scm, essp.ServiceName))
                        {
                            ServiceDataObject sdo = null;

                            if (manager.Contains(essp.ServiceName, out sdo))
                            {
                                sdo.UpdateFrom(essp);
                            }
                            else
                            {
                                objects.Add(new ServiceDataObject(ns, essp));
                            }
                        }
                    }
                }
            }
        }
Example #2
0
        public override void ApplyTemplateInfo(ActionTemplateInfo ati, BackgroundAction action)
        {
            // default implementation: do nothing
            ServiceDataObject sdo = GetServiceDataObjectByID(ati.ID);

            if (sdo == null)
            {
                Log.ErrorFormat("Unable to find object for ID {0}", ati.ID);
            }
            else
            {
                string expectedStartType = ati["StartTypeString"];
                string actualStartType   = sdo.StartTypeString;
                if (expectedStartType != actualStartType)
                {
                    Log.InfoFormat("=> StartType for {0} needs to change from {1} to {2}",
                                   ati,
                                   actualStartType,
                                   expectedStartType);

                    using (NativeSCManager scm = new NativeSCManager(MachineName))
                    {
                        SC_START_TYPE startType = ServicesLocalisation.ReverseLocalizedStartType(expectedStartType);
                        if (startType != SC_START_TYPE.SERVICE_NO_CHANGE)
                        {
                            sdo.ApplyStartupChanges(scm, startType);
                        }
                    }
                }
                else
                {
                    Log.InfoFormat("=> StartType for {0} identical, no need to change", ati);
                }
            }
        }
Example #3
0
 public ServiceProperties(ServiceDataObject sdo)
 {
     InitializeComponent();
     First = true;
     SDO = sdo;
     ModifiedForeground = new SolidColorBrush(Colors.Blue);
     UnmodifiedForeground = new SolidColorBrush(Colors.Black);
 }
Example #4
0
 public ServiceProperties(ServiceDataObject sdo)
 {
     InitializeComponent();
     First = true;
     SDO   = sdo;
     ModifiedForeground   = new SolidColorBrush(Colors.Blue);
     UnmodifiedForeground = new SolidColorBrush(Colors.Black);
 }