public async Task <IActionResult> Post( [FromServices] PnPServerContext dbContext, [FromBody] NetworkDeviceType networkDeviceType ) { if (networkDeviceType == null) { return(BadRequest()); } var existingRecord = await dbContext.NetworkDeviceTypes .Where(x => x.Name.Equals(networkDeviceType.Name, StringComparison.OrdinalIgnoreCase) ) .FirstOrDefaultAsync(); if (existingRecord != null) { // TODO : Make it so bed request explains duplicate record return(BadRequest()); } await dbContext.NetworkDeviceTypes.AddAsync(networkDeviceType); await dbContext.SaveChangesAsync(); return(new CreatedAtRouteResult("GetNetworkDeviceType", new { id = networkDeviceType.Id }, networkDeviceType)); }
public NetworkDataReader(string instanceName, NetworkDeviceType type, bool logDownload, bool logUpload, bool logStatus) { this.networkInterfaceName = instanceName; //contains invalid characters this.networkInterfaceMappedName = ConvertToInstanceName(this.networkInterfaceName); //replaces invalid characters this.logDownload = logDownload; this.logUpload = logUpload; this.deviceType = type; this.logStatus = logStatus; if (logUpload) { uploadPerfCounter = new PerformanceCounter("Network Interface", "Bytes Sent/sec", instanceName); upload = new UploadData(); } if (logDownload) { downloadPerfCounter = new PerformanceCounter("Network Interface", "Bytes Received/sec", instanceName); download = new DownloadData(); } if (logStatus) { oQuery = new System.Management.ObjectQuery("select * from Win32_PnPEntity "); devicesSearcher = new ManagementObjectSearcher(oQuery); isActive = new StatusData(); } }
/// <summary> /// Creates a ScoutResponsePacket given a device name and type /// </summary> /// <param name="deviceName"></param> /// <param name="deviceType"></param> public ScoutResponsePacket(string deviceName, NetworkDeviceType deviceType) { PacketType = "_SCA"; PacketBuffer buffer = new PacketBuffer(); buffer.WriteString(deviceName); buffer.WriteByte((byte)deviceType); PacketData = buffer.ToArray(); }
private Image GetCorrentDeviceIcon(NetworkDeviceType type) { switch (type) { case NetworkDeviceType.Desktop: return(Properties.Resources.icon_desktop_dark); case NetworkDeviceType.MobilePhone: return(Properties.Resources.icon_phone_dark); default: return(null); } }
/// <summary> /// Returns the icon image associated with the specified device type /// </summary> /// <param name="dType"></param> /// <returns></returns> private Image GetCorrectDeviceIcon(NetworkDeviceType dType) { switch (dType) { case NetworkDeviceType.Desktop: return(Resources.icon_desktop); case NetworkDeviceType.MobilePhone: return(Resources.icon_phone); default: return(null); } }