/// <summary> /// Create a new SwitchModule object. /// </summary> /// <param name="id">Initial value of the Id property.</param> /// <param name="number">Initial value of the Number property.</param> /// <param name="switchId">Initial value of the SwitchId property.</param> public static SwitchModule CreateSwitchModule(global::System.Int32 id, global::System.Int32 number, global::System.Int32 switchId) { SwitchModule switchModule = new SwitchModule(); switchModule.Id = id; switchModule.Number = number; switchModule.SwitchId = switchId; return switchModule; }
/// <summary> /// Deprecated Method for adding a new object to the SwitchModules EntitySet. Consider using the .Add method of the associated ObjectSet<T> property instead. /// </summary> public void AddToSwitchModules(SwitchModule switchModule) { base.AddObject("SwitchModules", switchModule); }
public CommunicationAction ResolveRequest(int requestId, string switchIPAddress, string switchName, int? switchNumber, int? switchModuleNumber, int? switchPortNumber, string serverIPAddress, string notes) { var action = AssignCommunicationEngineer(requestId, notes); var securityAction = GetLastSecurityAction(action.Request); if(securityAction == null || !securityAction.Assigned || securityAction.Approved != true || securityAction.Vlan == null) { throw new VlanException("The request is not approved by the security team."); } var serverIP = action.ServerIP = new ServerIP(); serverIP.Virtualization = action.Request.Virtualization; serverIP.IP = CreateIP(IPAddress.Parse(serverIPAddress)); if (serverIP.IP.Segment == null || serverIP.IP.Segment.Vlan == null || serverIP.IP.Segment.Vlan.Id != securityAction.Vlan.Id) { throw new VlanException("The assigned IP address is not within the Vlan approved by the security team."); } if (action.Request.Virtualization.Server.ServerType.Id == (int)ServerTypes.Standalone) { if ((switchName != null && !string.IsNullOrEmpty(switchName.Trim()) && switchIPAddress != null && !string.IsNullOrEmpty(switchIPAddress.Trim())) && switchModuleNumber.HasValue && switchPortNumber.HasValue) { var switchIP = IPAddress.Parse(switchIPAddress); var switchIPAddressArr = switchIP.GetAddressBytes(); var newSwitch = db.Switches.SingleOrDefault(i => i.IP.Address == switchIPAddressArr && i.StackableNumber.Equals(switchNumber)); if (newSwitch == null) { newSwitch = new Switch(); newSwitch.IP = CreateIP(switchIP); } newSwitch.Name = switchName; newSwitch.StackableNumber = switchNumber; var switchModule = newSwitch.SwitchModules.SingleOrDefault(x => x.Number == switchModuleNumber.Value); if (switchModule == null) { switchModule = new SwitchModule(); switchModule.Number = switchModuleNumber.Value; switchModule.Switch = newSwitch; } var switchPort = switchModule.SwitchPorts.SingleOrDefault(x => x.Port == switchPortNumber.Value); if (switchPort == null) { switchPort = new SwitchPort(); switchPort.Port = switchPortNumber.Value; switchPort.SwitchModule = switchModule; } serverIP.SwitchPort = switchPort; action.Completed = true; } else { action.Completed = false; } } else { action.Completed = true; } db.CommunicationActions.AddObject(action); return action; }