public SystemActiveResponseMessage ActiveSystem(SystemActiveRequestMessage request) { List<SystemInfoResponseMessage.VMSystem> outSystems = new List<SystemInfoResponseMessage.VMSystem>(); object syncRoot = new object(); Parallel.ForEach(Config.GetInstance("vmware.config").Machines, machine => { VMware manager = new VMware(machine.Address, machine.Username, machine.Password); manager.ActiveSystem(request.Names); }); return new SystemActiveResponseMessage(); }
public SystemInfoResponseMessage GetSystemInfo(SystemInfoRequestMessage request) { List<SystemInfoResponseMessage.VMSystem> outSystems = new List<SystemInfoResponseMessage.VMSystem>(); object syncRoot = new object(); Parallel.ForEach(Config.GetInstance("vmware.config").Machines, machine => { VMware manager = new VMware(machine.Address, machine.Username, machine.Password); List<SystemInfoResponseMessage.VMSystem> systems = manager.GetVMSystems(); lock (syncRoot) { outSystems = outSystems.Concat(systems).ToList(); } }); outSystems = outSystems.OrderBy(d => d.Name).ToList(); ; SystemInfoResponseMessage response = new SystemInfoResponseMessage(); response.VMSystyems = outSystems.Skip((request.pageIndex - 1) * request.pageSize).Take(request.pageSize).ToList(); return response; }