private static Image GetImage(string username, string password, string url, string webpage, int port) { HttpWebResponse cameraHttpResponse = HttpBasicAuthenticationBypassService .DoWebRequest(username, password, url, webpage, port); Image image = GetImageFromHttpWebResponse(cameraHttpResponse); return(image); }
public static Result ExecutePtzCommand(string ptzCmd, string ptzParameters, string webCamUsername, string webCamPassword, string url, int port) { string ptzCmdCgiPath; try { ptzCmdCgiPath = CreatePtzCmdCgiPath(ptzCmd, ptzParameters); } catch (Exception e) { return(new Result { Success = false, Message = $"PTZ command {ptzCmd}/{ptzParameters} had path creation problem: {e.Message}" }); } HttpWebResponse httpWebResponse; try { httpWebResponse = HttpBasicAuthenticationBypassService.DoWebRequest(webCamUsername, webCamPassword, url, ptzCmdCgiPath, port, "GET", "application/json"); } catch (Exception ex) { string exceptionMessage = "PTZ: " + ptzCmdCgiPath + " Error: Could not execute " + url + " " + port + " " + ptzCmd + " Error: " + ex.Message; return(new Result { Success = false, Message = exceptionMessage, Error = ex }); } string ptzMessage = httpWebResponse == null ? $"PTZ: {ptzCmd}/{ptzParameters} Error: Could not execute " + url + " " + port + " " + ptzCmd : $"PTZ: {ptzCmd}/{ptzParameters} Status: " + httpWebResponse.StatusCode; return(new Result { Success = httpWebResponse != null, Message = ptzMessage, StatusCode = httpWebResponse?.StatusCode ?? HttpStatusCode.Ambiguous }); }