private object TakeSnapshot(object[] P) { foreach (Camera Camera in Topology.Source.GetObjects(typeof(Camera), User.AllPrivileges)) { if (!string.IsNullOrEmpty(Camera.CameraUrl) && Camera.CameraWidth > 0 && Camera.CameraHeight > 0) { Log.Information("Requesting photo.", EventLevel.Minor, Camera.Id); HttpResponse Response = HttpSocketClient.GetResource(Camera.CameraUrl); Bitmap Bmp = Response.DecodedObject as Bitmap; CamStorage.NewPhoto(Bmp); } } return(null); }
private static void GetPhotos(object State) { object[] P = (object[])State; int i = (int)P [0]; Camera Camera = (Camera)P [1]; MailMessage Msg = (MailMessage)P [2]; ManualResetEvent Done = (ManualResetEvent)P [3]; DateTime Next = DateTime.Now; try { HttpResponse Response; int ms; int j; for (j = 1; j <= 3; j++) { ms = (int)System.Math.Round((Next - DateTime.Now).TotalMilliseconds); if (ms > 0) { Thread.Sleep(ms); } Log.Information("Requesting photo.", EventLevel.Minor, Camera.Id); Response = HttpSocketClient.GetResource(Camera.CameraUrl); Msg.EmbedObject("cam" + (i + 1).ToString() + "img" + j.ToString(), Response.Header.ContentType, Response.Data); Bitmap Bmp = Response.DecodedObject as Bitmap; CamStorage.NewPhoto(Bmp); Next = Next.AddSeconds(5); } } catch (ThreadAbortException) { Thread.ResetAbort(); } catch (Exception ex) { Log.Exception(ex); } finally { Done.Set(); } }