private static void OnDataRecived(object sender, DetectingEventArgs e) { e.PrintConsole(); lock (locker) { SaveToDatabase(e); } }
public static void PrintConsole(this DetectingEventArgs e) { Console.WriteLine(); Console.WriteLine("Source " + e.DataSource + " Motions " + e.AverageMotions + " Count " + e.TotalCount + " Time " + e.TimeStart.Hour + ":" + e.TimeStart.Minute + ":" + e.TimeStart.Second ); }
private void SendData() { DetectingEventArgs data = new DetectingEventArgs { AverageMotions = (int)average_motions, AveragePixels = average_pixels, TimeStart = _cycleStart, TimeFinish = DateTime.Now, TotalCount = total_count, DataSource = _connectionString }; DataRecived?.Invoke(this, data); //если есть подписчик, то передаем ему данные }
public static void SaveToDatabase(DetectingEventArgs e) { using (JournalDbCobtext db = new JournalDbCobtext()) { db.Logs.Add(new Log() { AverageMotions = e.AverageMotions, TimeStart = e.TimeStart, TimeFinish = e.TimeFinish, TotalCount = e.TotalCount, Camera = db.Cameras.Where(x => x.Source == e.DataSource).SingleOrDefault() }); db.SaveChanges(); } }
private void OnFrameProcessed(object sender, DetectingEventArgs e) { try { Label source_label = (Label)ActiveForm.Controls.Find("l_source", true).Where(x => x.Text == e.DataSource).Single(); Control contr = source_label.Parent.Controls["l_out"]; _action = new MethodInvoker(() => contr.Text = e.TotalCount.ToString()); if (contr.InvokeRequired) { contr.Invoke(_action); } else { _action(); } } catch { } }
private void OnControllerDataRecived(object sender, DetectingEventArgs e) { DataRecived?.Invoke(this, e); }
private void Detector_FrameProcessed(object sender, DetectingEventArgs e) { //e.DataSource, e.TotalCount FrameProcessed?.Invoke(this, e); }