示例#1
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);
        }
示例#2
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);
        }