public PortReportItem(string port, bool outgoing, bool external, PortTypeConstant portType, string justifier, string justification, BuildSpecificationTypeConstant buildSpecificationType, string buildSpecName) { Port = port; Outgoing = outgoing; External = external; PortType = portType; Justifier = justifier; Justification = justification; BuildSpecificationType = buildSpecificationType; BuildSpecName = buildSpecName; }
public SimplePort(string ports, PortTypeConstant type, bool external, bool outgoing, string justification, long justificationId) { Ports = ports; Type = type; if (outgoing) { Direction = SimplePortDirectionTypeConstant.SendingTrafficToOusidePort; } else if (external) { Direction = SimplePortDirectionTypeConstant.PortListeningToOutsideTraffic; } else { Direction = SimplePortDirectionTypeConstant.PortListeningToInsideTraffic; } Justification = justification; JustificationId = justificationId; }
public async Task AddOrUpdatePorts(long specId, long justificationId, bool external, bool outgoing, PortTypeConstant portType, string portString) { var valid = portString.ValidateDataPorts().Ports; var inDb = _ctx.Ports.ForJustification(justificationId); _ctx.Ports.RemoveRange(inDb); foreach (var p in valid) { p.JustificationId = justificationId; p.PortType = portType; p.BuildSpecificationId = specId; p.IsExternal = external || outgoing; p.IsOutgoing = outgoing; _ctx.Ports.Add(p); } await _ctx.SaveChangesAsync(); }
private static int[] PortsOfType(IDictionary <PortTypeConstant, int[]> ports, PortTypeConstant type) { int[] ret; if (ports.TryGetValue(type, out ret)) { return(ret); } return(new int[0]); }
public async Task <JsonResult> Save(PlatformConstant id, long specId, long?justificationId, SimplePortDirectionTypeConstant direction, PortTypeConstant portType, string justification, string ports) { if (!_justificationFactory.IsValidText(justification)) { return(Json(JsonEnvelope.Error("The Justifcation cannot be empty whitespace."))); } if (!justificationId.HasValue) { Logger.LogInformation($"{UserSecurity.SamAccountName} added a new justification for ports: {justification}"); justificationId = await _justificationFactory.AddJustification(JustificationTypeConstant.Port, specId, justification); } else { Logger.LogInformation($"{UserSecurity.SamAccountName} updated justification {justificationId} for ports: {justification}"); await _justificationFactory.UpdateJustification(justificationId.Value, justification); } await _portFactory.AddOrUpdatePorts(specId, justificationId.Value, direction == SimplePortDirectionTypeConstant.PortListeningToOutsideTraffic, direction == SimplePortDirectionTypeConstant.SendingTrafficToOusidePort, portType, ports); Logger.LogInformation($"{UserSecurity.SamAccountName} added or updated ports for spec {specId} ports are: {ports}"); return(Json(JsonEnvelope.Success(new { url = Url.PartialOnePort(id, specId, justificationId.Value) }))); }