Exemple #1
0
        public string SetSettings(string mode, int startHourMin, int endHourMin, int suppressionSeconds)
        {
            //if (!doorNotifier.IsValidUser())
            //    return "Incorrect username, password";
            //else
            //{
            string retVal = "";

            try
            {
                AlertSettings settings = new AlertSettings();
                settings.Mode            = (AlertMode)Enum.Parse(typeof(AlertMode), mode, true);
                settings.StartHourMin    = startHourMin;
                settings.EndHourMin      = endHourMin;
                settings.SuppressSeconds = suppressionSeconds;

                doorNotifier.UpdateSettings(settings);
                retVal = "settings changed to " + settings.ToString();
                return(retVal);
            }
            catch (Exception e)
            {
                logger.Log("Got exception in SetSettings: " + e);
                return(retVal);
            }

            // }
        }
        public string SetSettings(string mode, int startHourMin, int endHourMin, int suppressionSeconds)
        {
            //if (!doorNotifier.IsValidUser())
            //    return "Incorrect username, password";
            //else
            //{
            string retVal = "";
            try
            {
                AlertSettings settings = new AlertSettings();
                settings.Mode = (AlertMode)Enum.Parse(typeof(AlertMode), mode, true);
                settings.StartHourMin = startHourMin;
                settings.EndHourMin = endHourMin;
                settings.SuppressSeconds = suppressionSeconds;

                doorNotifier.UpdateSettings(settings);
                retVal= "settings changed to " + settings.ToString();
                return retVal;
            }
            catch (Exception e)
            {
                logger.Log("Got exception in SetSettings: " + e);
                return retVal;
            }
                
           // }
        }
Exemple #3
0
 public void UpdateSettings(AlertSettings settings)
 {
     this.settings = settings;
 }
Exemple #4
0
        ////Email address to receive the alert pictures.
        //string emailAdrs;
        public override void Start()
        {
            logger.Log("Started: {0}", ToString());

            try
            {
                settings = new AlertSettings();

                settings.Mode = (moduleInfo.Args().Length > 0) ?
                                    (AlertMode)Enum.Parse(typeof(AlertMode), moduleInfo.Args()[0], true) :
                                    AlertMode.emailonly;

                settings.StartHourMin = (moduleInfo.Args().Length > 1) ? int.Parse(moduleInfo.Args()[1]) : 0;

                settings.EndHourMin = (moduleInfo.Args().Length > 2) ? int.Parse(moduleInfo.Args()[2]) : 2400;

                settings.SuppressSeconds = (moduleInfo.Args().Length > 3) ? int.Parse(moduleInfo.Args()[3]) : 5;  //AJB shorten suppression

                settings.UserName = (moduleInfo.Args().Length > 4) ? moduleInfo.Args()[4] : "user";

                settings.emailAddress = GetPrivateConfSetting("NotificationEmail");

            }
            catch (Exception exception)
            {
                logger.Log("{0}: error parsing arguments: {1}", exception.ToString(), String.Join(" ", moduleInfo.Args()));
            }

            DoorNotifierSvc service = new DoorNotifierSvc(logger, this);

            //serviceHost = DoorNotifierSvc.CreateServiceHost(
            //    service,
            //    new Uri(moduleInfo.BaseURL()+"/webapp"));

            serviceHost = DoorNotifierSvc.CreateServiceHost(logger, this, service, moduleInfo.BaseURL() + "/webapp");

            serviceHost.Open();

            webUiServer = new WebFileServer(moduleInfo.BinaryDir(), moduleInfo.BaseURL(), logger);

            logger.Log("{0}: service is open for business at {1}", ToString(), moduleInfo.BaseURL());

            //no services are exported by this application

            //..... get the list of current ports from the platform
            IList<VPort> allPortsList = GetAllPortsFromPlatform();

            if (allPortsList != null)
            {
                foreach (VPort port in allPortsList)
                {
                    PortRegistered(port);
                }
            }

            //insert a fake notification for testing
            Alert newAlert = new Alert()
            {
                TimeTriggered = DateTime.Now,
                SensorFriendlyName = "fake sensor",
                SensorLocation = "fake location",
                Value = 1,
                Acknowledged = false,
            };

            InsertAlert(newAlert);
        }
Exemple #5
0
 public void UpdateSettings(AlertSettings settings)
 {
     this.settings = settings;
 }
Exemple #6
0
        ////Email address to receive the alert pictures.
        //string emailAdrs;

        public override void Start()
        {
            logger.Log("Started: {0}", ToString());

            try
            {
                settings = new AlertSettings();


                settings.Mode = (moduleInfo.Args().Length > 0) ?
                                (AlertMode)Enum.Parse(typeof(AlertMode), moduleInfo.Args()[0], true) :
                                AlertMode.emailonly;

                settings.StartHourMin = (moduleInfo.Args().Length > 1) ? int.Parse(moduleInfo.Args()[1]) : 0;

                settings.EndHourMin = (moduleInfo.Args().Length > 2) ? int.Parse(moduleInfo.Args()[2]) : 2400;

                settings.SuppressSeconds = (moduleInfo.Args().Length > 3) ? int.Parse(moduleInfo.Args()[3]) : 5;  //AJB shorten suppression

                settings.UserName = (moduleInfo.Args().Length > 4) ? moduleInfo.Args()[4] : "user";

                settings.emailAddress = GetPrivateConfSetting("NotificationEmail");
            }
            catch (Exception exception)
            {
                logger.Log("{0}: error parsing arguments: {1}", exception.ToString(), String.Join(" ", moduleInfo.Args()));
            }

            picStream  = base.CreateFileDataStream <StrKey, ByteValue>("H2OAlertsPics", true, 0);
            textStream = base.CreateValueDataStream <StrKey, StrValue>("H2OAlertsText", true, 0);

            DoorNotifierSvc service = new DoorNotifierSvc(logger, this);

            //serviceHost = DoorNotifierSvc.CreateServiceHost(
            //    service,
            //    new Uri(moduleInfo.BaseURL()+"/webapp"));

            serviceHost = DoorNotifierSvc.CreateServiceHost(logger, this, service, moduleInfo.BaseURL() + "/webapp");

            serviceHost.Open();

            webUiServer = new WebFileServer(moduleInfo.BinaryDir(), moduleInfo.BaseURL(), logger);

            logger.Log("{0}: service is open for business at {1}", ToString(), moduleInfo.BaseURL());

            //no services are exported by this application

            //..... get the list of current ports from the platform
            IList <VPort> allPortsList = GetAllPortsFromPlatform();

            if (allPortsList != null)
            {
                foreach (VPort port in allPortsList)
                {
                    PortRegistered(port);
                }
            }

            //insert a fake notification for testing
            Alert newAlert = new Alert()
            {
                TimeTriggered      = DateTime.Now,
                SensorFriendlyName = "fake sensor",
                SensorLocation     = "fake location",
                Value        = 1,
                Acknowledged = false,
            };

            InsertAlert(newAlert);
        }