/// <summary>
        /// Loads the default settings, from values in the database
        /// </summary>
        public void LoadDefaults()
        {

            var db = new CaptureDb(ConfigurationManager.ConnectionStrings["LOCALDB"].ConnectionString);
            DataTable dt = db.ReturnMotionSettingDefaults();

            //iterate over the properties in this object, and the properties in the Datatable until a match is found
            foreach(DataRow dr in dt.Rows)
            {
                foreach (PropertyInfo property in typeof(MotionSensorSettings).GetProperties())
                {
                    if (property.Name.Equals(dr["settingTypeName"].ToString()))
                    {
                        if(property.PropertyType.ToString() == "System.Decimal")
                        {
                            property.SetValue(this, dr["value"].ToString().StringToDec());
                        }
                        else if(property.PropertyType.ToString() == "System.Int32")
                        {
                            property.SetValue(this, dr["value"].ToString().StringToInt());
                        }
                        else if (property.PropertyType.ToString() == "System.Boolean")
                        {
                            property.SetValue(this, dr["value"].ToString().StringToBool());
                        }
                    }
                }

            }//foreach datarow
        }
Ejemplo n.º 2
0
        public void TestAddCapture()
        {
            ImageSaver imageSaver = new ImageSaver(@"d:\motion", "movement", 0);

            ICaptureDb db = new CaptureDb(ConfigurationManager.ConnectionStrings["LOCALDB"].ConnectionString);
            db.CreateCaptureSession(imageSaver.captureId, imageSaver.SaveDirectory);
            Assert.IsTrue(db.CaptureIdExists(imageSaver.captureId));

            Exception ex = null;
            try
            {
                db.CreateCaptureSession(imageSaver.captureId, imageSaver.SaveDirectory);
            }
            catch(Exception exc)
            {
                ex = exc;
            }

            Assert.IsNotNull(ex);

        }