コード例 #1
0
        public String RegisterSPL(String UserID, double SPL, String GPS, String Weather, double Windspeed, int Winddirection)
        {
            int    BossID = Database.GetBossID(UserID);
            string phone;
            string message;

            if (WindDirection.WindDoesNotExist(Winddirection) || BossID <= -1)
            {
                return("Error");
            }

            try { phone = Database.GetManagerPhone(UserID); }
            catch (FormatException ex) { return("Error"); }

            message = "User " + UserID + " has exceeded the safe level of dBa; caution is advised. User Information:\n\n" + Database.GetUserInformation(UserID);

            Database.RecordSPL(UserID, BossID, SPL, GPS, Weather, ref shouldSend, Windspeed, Winddirection);

            if (SPL > OSHA)
            {
                SendToPhone(phone, message);
            }

            if (shouldSend)
            {
                SendToPhone(phone, "User " + UserID + " has continued to stay in location: " + GPS);
            }

            return(Database.GetVibrationBasedOnSPL(BossID, SPL));
        }
コード例 #2
0
        public String RegisterSPL(String UserID, double SPL, String GPS, String Weather, double Windspeed, int Winddirection)
        {
            int    BossID = Database.GetBossID(UserID); // company id
            string phone;                               // managers phonen umber
            string message;                             // message for SMS

            if (WindDirection.WindDoesNotExist(Winddirection))
            {
                return("Error: Wind direction does not exist!");
            }

            if (BossID <= -1)
            {
                return("Error: User is not registered under any company!");
            }

            try { phone = Database.GetManagerPhone(UserID); }
            catch (FormatException ex) { return("Error: Database unavailable!"); }

            message = "User " + UserID + " has exceeded the safe level of dBa; caution is advised. User Information:\n\n" + Database.GetUserInformation(UserID);

            Database.RecordSPL(UserID, BossID, SPL, GPS, Weather, ref shouldSend, Windspeed, Winddirection);

            int companySPL = Database.GetSPL_Type(BossID);

            if (companySPL >= 0 && SPL >= companySPL) // if company has chosen SPL type, and spl has surpassed the limit, send SMS
            {
                new Thread(() => SendToPhone(phone, message)).Start();

                if (shouldSend) // if user in same location twice, send same location message
                {
                    new Thread(() => SendToPhone(phone, "User " + UserID + " has continued to stay in location: " + GPS)).Start();
                }
            }

            // if spl >= companySPL then send fast alert since attention is crucial, otherwise send vibration pattern set by company.
            return(SPL >= companySPL?Vibrations.GetVibrationPattern(Vibrations.VibrationTypes.FastAlert) ?? Database.GetVibrationBasedOnSPL(BossID, SPL) : Database.GetVibrationBasedOnSPL(BossID, SPL));
        }