/// <summary> /// Deprecated Method for adding a new object to the RequestPorts EntitySet. Consider using the .Add method of the associated ObjectSet<T> property instead. /// </summary> public void AddToRequestPorts(RequestPort requestPort) { base.AddObject("RequestPorts", requestPort); }
public Request CreateRequest(string businessService, string applicationName, int[] applicationTypeId, string netBIOSName, string dnsName, int locationId, int serverTypeId, int? bladeChassisId, string bladeSwitchLocation, bool? bladeTeaming, int operatingSystemId, string notes, int? oldRequestId) { BladeChassis bladeChassis = null; if (serverTypeId == (int)ServerTypes.Blades) { bladeChassis = CreateBladeChassis(bladeSwitchLocation, bladeTeaming.Value); } var server = new Server { ServerTypeId = serverTypeId, LocationId = locationId, BladeChassi = bladeChassis }; var vir = new Virtualization { OperatingSystemId = operatingSystemId, NetBIOSName = netBIOSName, DNSName = dnsName, Server = server }; var oldRequest = oldRequestId.HasValue ? GetRequestById(oldRequestId.Value) : null; var user = GetCurrentUser(); var owner = (oldRequest != null) ? oldRequest.Owner : user; var request = new Request { Owner = owner, User = user, BusinessService = businessService, ApplicationName = applicationName, Virtualization = vir, SubmissionDate = System.DateTime.Now, OldRequestId = oldRequestId, Notes = notes }; if(oldRequest != null) { request.OriginalRequest = oldRequest.OriginalRequest; } else { //request.OriginalRequest = request; } if (oldRequest != null && user.Id != owner.Id) { var inheritedPorts = oldRequest.RequestPorts.Where(x => x.Port.UserId != user.Id); foreach (var port in inheritedPorts) { var requestPort = new RequestPort { Request = request, Port = port.Port }; db.RequestPorts.AddObject(requestPort); } } for (int i = 0; i < applicationTypeId.Length; i++) { var appType = new RequestApplicationType { ApplicationTypeId = applicationTypeId[i], Request = request }; } db.Requests.AddObject(request); return request; }
/// <summary> /// Create a new RequestPort object. /// </summary> /// <param name="id">Initial value of the Id property.</param> /// <param name="requestId">Initial value of the RequestId property.</param> /// <param name="portId">Initial value of the PortId property.</param> public static RequestPort CreateRequestPort(global::System.Int32 id, global::System.Int32 requestId, global::System.Int32 portId) { RequestPort requestPort = new RequestPort(); requestPort.Id = id; requestPort.RequestId = requestId; requestPort.PortId = portId; return requestPort; }
public Port CreatePort(Request request, int portId, IPAddress ipAddress, int? subnetMask, int portTypeId, int startPortNumber, int? endPortNumber, int portDirectionId, DateTime? startDate, DateTime? endDate) { if (portDirectionId == (int)PortDirections.UserToRequestedServer || portDirectionId == (int)PortDirections.RequestedServerToUser) { foreach (var serverIP in serversIPs) { if (ipAddress.ToString().StartsWith(serverIP)) { throw new IPAddressException("Either the IPAddress is invalid or the PortDirection"); } } } var port = db.Ports.SingleOrDefault(x => x.Id == portId); var changed = false; if (port != null) { if (!port.IP.Address.SequenceEqual(ipAddress.GetAddressBytes()) || portTypeId != port.PortTypeId || startPortNumber != port.StartPortNumber || endPortNumber != port.EndPortNumber || portDirectionId != port.PortDirectionId) { changed = true; } if (subnetMask.HasValue) { if (port.SubnetMaskId.HasValue) { if (!port.SubnetMask.Address.SequenceEqual(CommonFunctions.SubnetMaskFromMaskBits(subnetMask.Value).GetAddressBytes())) { changed = true; } } else { changed = true; } } else if (port.SubnetMaskId.HasValue) { changed = true; } if (startDate.HasValue) { if (port.StartDate.HasValue) { if (!startDate.Value.Date.Equals(port.StartDate.Value)) { changed = true; } } else { changed = true; } } else if (port.StartDate.HasValue) { changed = true; } if (endDate.HasValue) { if (port.EndDate.HasValue) { if (!endDate.Value.Date.Equals(port.EndDate.Value)) { changed = true; } } else { changed = true; } } else if (port.EndDate.HasValue) { changed = true; } } else { changed = true; } if (changed) { port = new Port { PortTypeId = portTypeId, StartPortNumber = startPortNumber, EndPortNumber = endPortNumber, PortDirectionId = portDirectionId, IP = CreateIP(ipAddress), StartDate = startDate, EndDate = endDate, User = GetCurrentUser() }; if (port.IP.Segment == null) { throw new IPAddressException("The IP address doesn't have a segment"); } if (subnetMask.HasValue) { port.SubnetMask = CreateSubnetMask(subnetMask.Value); } db.Ports.AddObject(port); } var requestPort = new RequestPort { Request = request, Port = port }; db.RequestPorts.AddObject(requestPort); return port; }