Пример #1
0
 private void UpdateGridRow(WcfServiceAppDomain appDomain, DataGridViewRow gridRow)
 {
     gridRow.Tag = appDomain;
     if (gridRow.Cells.Count == 0)
     {
         for (int i = 0; i < 4; i++)
         {
             gridRow.Cells.Add(new DataGridViewTextBoxCell());
         }
     }
     gridRow.Cells[0].Value = appDomain.Name;
     gridRow.Cells[1].Value = appDomain.LogMessageAtServiceLevel;
     gridRow.Cells[2].Value = appDomain.TraceLevel;
     gridRow.Cells[3].Value = appDomain.ActivityTracing;
 }
Пример #2
0
        private List <WcfServiceProcess> GetWcfServiceProcesses(
            IReadOnlyList <ProcessInfo> processInfo)
        {
            var connection = new ConnectionOptions
            {
                Authentication = AuthenticationLevel.PacketPrivacy
            };

            const string wcfNamespace = @"\\localhost\Root\ServiceModel";

            var scope = new ManagementScope(wcfNamespace, connection);

            scope.Connect();

            var oQuery   = new ObjectQuery("SELECT * FROM AppDomainInfo");
            var searcher = new ManagementObjectSearcher(scope, oQuery);

            var listOfProcesses = new List <WcfServiceProcess>();

            try
            {
                foreach (ManagementObject mo in searcher.Get())
                {
                    int pid = (int)mo["ProcessId"];

                    var serviceProcess =
                        listOfProcesses.FirstOrDefault(x => x.Process.ProcessId == pid);
                    if (serviceProcess == null)
                    {
                        serviceProcess = new WcfServiceProcess
                        {
                            Process = processInfo.First(x => x.ProcessId == pid)
                        };
                        listOfProcesses.Add(serviceProcess);
                    }

                    var instance = new WcfServiceAppDomain(mo);
                    serviceProcess.Services.Add(instance);
                }
            }
            catch (ManagementException)
            {
            }
            return(listOfProcesses);
        }