/////////////////////////////////////////////////////////////// public void setImageStream(NoxHistoryItem thisEvent) { string cameras = ""; string[] splitCameras; //Get a list of valid cameras try { cameras = NoxHelper.getNoxData(Host, "cameraList", false, new NoxApiParameter("zone", thisEvent.zone)); splitCameras = cameras.Split(Environment.NewLine.ToCharArray()); } catch (Exception) { return; } List<string> cameraNames = new List<string>(); foreach (string cameraLine in splitCameras) { if (cameraLine != "") { if (cameraLine.StartsWith("name|")) { cameraNames.Add(cameraLine.Substring(cameraLine.IndexOf("|") + 1)); //break; } } } //For every camera, try to find images until you find them. They are in there somewhere... trust me. foreach (string camera in cameraNames) { string images = ""; try { images = NoxHelper.getNoxData(Host, "videoList", false, new NoxApiParameter("camera", camera), new NoxApiParameter("beginDate", thisEvent.BeginTime.ToString()), new NoxApiParameter("endDate", thisEvent.EndTime.ToString())); } catch (Exception e) { String ret = e.Message; return; } if (images != "") { //We found them! //Thread loadImages = new Thread(new ParameterizedThreadStart(loadImagesFromStream)); loadImagesFromStream(images); m_videoId.zone = thisEvent.zone; m_videoId.time = thisEvent.time; break; } } //tmrVideoFrame.Interval = 1; }
/////////////////////////////////////////////////////////////// private NoxHistoryItem getNextHistoryEventId(string id) { string history = ""; string[] splitHistory; NoxHistoryItem priorityEvent = new NoxHistoryItem(); NoxHistoryItem thisEvent = new NoxHistoryItem(); try { history = NoxHelper.getNoxData(Host, "historyList", false, new NoxApiParameter("data", id), new NoxApiParameter("max", "30"), new NoxApiParameter("eventType", "present"), new NoxApiParameter("videoExistsOnly","true")); splitHistory = history.Split(Environment.NewLine.ToCharArray()); } catch (Exception) { return thisEvent; } List<NoxHistoryItem> eventList = new List<NoxHistoryItem>(); foreach (string historyLine in splitHistory) { if (historyLine != "") { string value = historyLine.Substring(historyLine.IndexOf("|") + 1); if (historyLine.StartsWith("id|")) { if (thisEvent.eventId != "") { if(thisEvent.thumbnail != "none" && thisEvent.thumbnail != "unknown" && thisEvent.thumbnail != "") { eventList.Add(thisEvent); } thisEvent = new NoxHistoryItem(); } thisEvent.eventId = value; } else if (historyLine.StartsWith("zone|")) { thisEvent.zone = value; } else if (historyLine.StartsWith("dataName|")) { thisEvent.name = value; } else if (historyLine.StartsWith("date|")) { thisEvent.time = value; } else if (historyLine.StartsWith("thumbnail|")) { thisEvent.thumbnail = value; } } } //add to event list if (thisEvent.eventId != "" && thisEvent.thumbnail != "none" && thisEvent.thumbnail != "unknown" && thisEvent.thumbnail != "") { eventList.Add(thisEvent); } if (eventList.Count > 0) priorityEvent = eventList[0]; foreach (NoxHistoryItem historyEvent in eventList) { if (historyEvent.zone != Zone) { priorityEvent = historyEvent; break; } } priorityEvent.secondsPre = secondsPre; priorityEvent.secondsPost = secondsPost; return priorityEvent; }
/////////////////////////////////////////////////////////////// private List<NoxHistoryItem> getHistory(string id) { string history = ""; string[] splitHistory; List<NoxHistoryItem> eventList = new List<NoxHistoryItem>(); List<NoxHistoryItem> bList = new List<NoxHistoryItem>(); try { history = NoxHelper.getNoxData(m_host, "historyList", false, new NoxApiParameter("data", id), new NoxApiParameter("max", "30"), new NoxApiParameter("eventType", "present"), new NoxApiParameter("videoExistsOnly", "true")); splitHistory = history.Split(Environment.NewLine.ToCharArray()); } catch (Exception) { return eventList; } NoxHistoryItem thisEvent = new NoxHistoryItem(); foreach (string historyLine in splitHistory) { if (historyLine != "") { string value = historyLine.Substring(historyLine.IndexOf("|") + 1); if (historyLine.StartsWith("id|")) { if (thisEvent.eventId != "") { if (thisEvent.thumbnail != "none" && thisEvent.thumbnail != "unknown" && thisEvent.thumbnail != "") { eventList.Add(thisEvent); } thisEvent = new NoxHistoryItem(); } thisEvent.eventId = value; } else if (historyLine.StartsWith("zone|")) { thisEvent.zone = value; } else if (historyLine.StartsWith("dataName|")) { thisEvent.name = value; } else if (historyLine.StartsWith("date|")) { thisEvent.time = value; } else if (historyLine.StartsWith("thumbnail|")) { thisEvent.thumbnail = value; } } } //add last event to event list if (thisEvent.eventId != "" && thisEvent.thumbnail != "none" && thisEvent.thumbnail != "unknown" && thisEvent.thumbnail != "") { if (thisEvent.zone != m_touchZone) { eventList.Add(thisEvent); } else { bList.Add(thisEvent); } } //add the bList stuff foreach (NoxHistoryItem bI in bList) { eventList.Add(bI); } return eventList; }