Example #1
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="matchCondition"></param>
        /// <param name="getProcessData"></param>
        /// <param name="getFileData"></param>
        /// <returns></returns>
        public List <libInstrumentation.dto.Service> GetList(string matchCondition, bool getProcessData = false, bool getFileData = false)
        {
            List <libInstrumentation.dto.Service> services = new List <libInstrumentation.dto.Service>();

            ServiceProxy.ServiceCollection svcCol = string.IsNullOrWhiteSpace(matchCondition)
                ? ServiceProxy.GetInstances(m_facade.Scope, (EnumerationOptions)null)
                : ServiceProxy.GetInstances(m_facade.Scope, matchCondition)
            ;

            foreach (ServiceProxy ws in svcCol)
            {
                libInstrumentation.dto.Service s = new libInstrumentation.dto.Service();
                services.Add(s);

                s.Name                    = ws.Name;
                s.DisplayName             = ws.DisplayName;
                s.Caption                 = ws.Caption;
                s.Description             = ws.Description;
                s.FilePath                = ws.PathName;
                s.PID                     = ws.ProcessId;
                s.IsRunning               = ws.Started;
                s.State                   = ws.State;
                s.LifecycleCheckpoint     = ws.CheckPoint;
                s.ErrorcControl           = ws.ErrorControl;
                s.ExitCode                = ws.ExitCode;
                s.ServiceSpecificExitCode = ws.ServiceSpecificExitCode;
                s.InstallDate             = ws.InstallDate;
                s.RunningAsUser           = ws.StartName;
            }

            return(services);
        }
Example #2
0
        public ServiceProxy GetServiceProxy(string serviceName)
        {
            if (string.IsNullOrWhiteSpace(serviceName))
            {
                return(null);
            }

            string condition = "Name=" + serviceName;

            ServiceProxy.ServiceCollection sc = ServiceProxy.GetInstances(m_facade.Scope, condition);

            if (sc.Count > 0)
            {
                foreach (ServiceProxy s in sc)
                {
                    s.StartService();
                    if (s.Name == serviceName)
                    {
                        return(s);
                    }
                }
            }

            return(null);
        }