示例#1
0
 public bool SetSetting(int id)
 {
     var db = new FacesDBDataContext(_connectionString);
     var temp = db.DetectionSettings.Where(x => x.SettingID == id).SingleOrDefault();
     if (temp != null) _currentSetting = temp;
     return temp != null;
 }
示例#2
0
 public ActionResult EditDetections(FormCollection collection)
 {
     try
     {
         DetectionSetting det = new DetectionSetting();
         if (TryUpdateModel(det))
         {
             var OldDetection = System.Web.HttpContext.Current.Application["Detection"] as DetectionSetting;
             System.Web.HttpContext.Current.Application["Detection"] = det;
             var analyzers = System.Web.HttpContext.Current.Application["Analyzers"] as List <VideoAnalyzer>;
             foreach (var analyzer in analyzers)
             {
                 analyzer.UpdateDetection(det);
             }
             var d = DateTime.Now;
             db.UpdateDetections(det, detectionPath);
             db.UpdateDetections(OldDetection, $"{rootPath}\\Connections\\OldSetUp\\Detections_{d.Day}_{d.Month}_{d.Year}_{d.Hour}_{d.Minute}.txt");
             return(RedirectToAction("Index"));
         }
         else
         {
             ViewBag.Error = "Model doesn't fit";
             return(RedirectToAction("EditDetections"));
         }
     }
     catch (Exception ex)
     {
         ViewBag.Error = "Generic Error occured\n" + ex.Message;
         return(RedirectToAction("EditDetections"));
     }
 }
        private void CreateAnalyzers()
        {
            object locker;

            if (System.Web.HttpContext.Current.Application["lockCreation"] == null)
            {
                System.Web.HttpContext.Current.Application["lockCreation"] = new object();
            }
            locker = System.Web.HttpContext.Current.Application["lockCreation"];

            lock (locker)
            {
                if (System.Web.HttpContext.Current.Application["Analyzers"] == null)
                {
                    //Setting Strings
                    string root           = System.Web.HttpContext.Current.Server.MapPath("~/Settings");
                    var    ConnectionPath = string.Format("{0}\\{1}\\{2}", root, "Connections", "Connections.txt");
                    var    DetectionPath  = string.Format("{0}\\{1}\\{2}", root, "Connections", "DetectionSetting.txt");
                    var    CameraPath     = string.Format("{0}\\{1}\\{2}", root, "Connections", "CameraData.txt");


                    if (System.Web.HttpContext.Current.Application["ConnectionPath"] == null)
                    {
                        System.Web.HttpContext.Current.Application["ConnectionPath"] = ConnectionPath;
                    }

                    if (System.Web.HttpContext.Current.Application["DetectionPath"] == null)
                    {
                        System.Web.HttpContext.Current.Application["DetectionPath"] = DetectionPath;
                    }
                    if (System.Web.HttpContext.Current.Application["CameraPath"] == null)
                    {
                        System.Web.HttpContext.Current.Application["CameraPath"] = CameraPath;
                    }


                    //Setting Connection
                    connections = db.ReadConnections(ConnectionPath);
                    System.Web.HttpContext.Current.Application["Connections"] = connections;

                    //Setting DB
                    if (System.Web.HttpContext.Current.Application["DbManager"] == null)
                    {
                        db.SetConnection(connections);
                        System.Web.HttpContext.Current.Application["DbManager"] = db;
                    }

                    //Setting detectionSettings
                    detectionSetting = db.ReadDetections(DetectionPath);
                    System.Web.HttpContext.Current.Application["Detection"] = detectionSetting;

                    //Setting cameras and Analyzer
                    cameras   = db.ReadCamera(CameraPath);
                    Analyzers = new List <VideoAnalyzer>();
                    foreach (var camera in cameras)
                    {
                        Analyzers.Add(
                            new VideoAnalyzer(camera, connections, detectionSetting)
                            );
                    }
                    System.Web.HttpContext.Current.Application["Cameras"]   = cameras;
                    System.Web.HttpContext.Current.Application["Analyzers"] = Analyzers;
                }
            }
        }