public void ChangeComputer(string MonitorGuid, string NewComputerGuid, DateTime Date, string ExtendedInfo) { Monitor monitor = Monitor.FindByGUID(DS, MonitorGuid); string oldCompGuid = null; if (monitor != null && monitor.ComputerGuid != NewComputerGuid) { oldCompGuid = monitor.ComputerGuid; ManagerMonitor MM = new ManagerMonitor(DS); MM.DisconectComputer(MonitorGuid, Date, ExtendedInfo); if (NewComputerGuid != "") { Computer comp = Computer.FindByGUID(DS, NewComputerGuid); ManagerComputer MC = new ManagerComputer(DS); if (comp != null && comp.MonitorGUID != null && comp.MonitorGUID != "") //Проверяем есть ли у подключаемого системника моник и отключаем его еси есть { MC.DisconectMonitor(NewComputerGuid, Date, ExtendedInfo); //Отключаем новый системник от монитора MC.ChangeMonitor(comp, MonitorGuid, Date, ExtendedInfo); } else if (comp.MonitorGUID == "" || comp.MonitorGUID == null)// Если моника нет, то устанавливаем новый системник { MC.SetMonitor(comp.GUID, monitor.GUID, Date, ExtendedInfo); } } monitor.ComputerGuid = NewComputerGuid; WriteEvent("Подключение компьютера", Date, monitor, ExtendedInfo); } }
public void ChangeMonitor(Computer comp, string NewMonitorGuid, DateTime Date, string ExtendedInfo) { string OldMonitorGUID = null; if (comp != null && comp.MonitorGUID != NewMonitorGuid) { OldMonitorGUID = comp.MonitorGUID; ManagerComputer MC = new ManagerComputer(DS); MC.DisconectMonitor(comp.GUID, Date, ExtendedInfo); if (NewMonitorGuid != "") { Monitor monitor = Monitor.FindByGUID(DS, NewMonitorGuid); // подключаемый монитор ManagerMonitor MM = new ManagerMonitor(DS); if (monitor != null && monitor.ComputerGuid != null && monitor.ComputerGuid != "") //Проверяем есть ли у подключаемого монитора системник и отключаем его если есть { MM.DisconectComputer(NewMonitorGuid, Date, ExtendedInfo); MM.ChangeComputer(NewMonitorGuid, comp.GUID, Date, ExtendedInfo); } else if (monitor.ComputerGuid == "" || monitor.ComputerGuid == null) { MM.SetComputer(NewMonitorGuid, comp.GUID, Date, ExtendedInfo); } } comp.MonitorGUID = NewMonitorGuid; WriteEvent("Подключение монитора", Date, comp, ExtendedInfo); } }
public void DisconectComputer(Monitor monitor, DateTime Date, string ExtendedInfo) { if (monitor != null) { if (monitor.ComputerGuid != null && monitor.ComputerGuid != "") { string oldCompGuid = monitor.ComputerGuid; monitor.ComputerGuid = ""; Computer comp = Computer.FindByGUID(DS, oldCompGuid); ManagerComputer MC = new ManagerComputer(DS); MC.DisconectMonitor(oldCompGuid, Date, ExtendedInfo); } } }