예제 #1
0
        public async static Task ProcessAlertMessage([ServiceBusTrigger("sumppumpalerts")] AlertPayload payload)
        {
            var newAlert = new AlertEntity()
            {
                PartitionKey = payload.DeviceId,
                RowKey       = payload.Timestamp.ToRowKey(),
                Type         = (AlertType)payload.Type,
                WaterLevel   = payload.WaterLevel,
                PumpRunning  = payload.PumpRunning
            };

            AlertRepository.Insert(newAlert);
        }
예제 #2
0
        protected void btnSaveNewAlert_Click(object sender, EventArgs e)
        {
            // Parse the dates
            int From_Year   = Parsers.ParseInt(drpYear_From.Text);
            int From_Month  = Parsers.ParseInt(drpMonth_From.Text);
            int From_Day    = Parsers.ParseInt(txtDay_From.Text);
            int From_Hour   = Parsers.ParseInt(txtHour_From.Text);;
            int From_Minute = Parsers.ParseInt(txtMinute_From.Text);

            DateTime FromDate = new DateTime(From_Year, From_Month, From_Day, From_Hour, From_Minute, 0);

            int To_Year   = Parsers.ParseInt(drpYear_To.Text);
            int To_Month  = Parsers.ParseInt(drpMonth_To.Text);
            int To_Day    = Parsers.ParseInt(txtDay_To.Text);
            int To_Hour   = Parsers.ParseInt(txtHour_To.Text);;
            int To_Minute = Parsers.ParseInt(txtMinute_To.Text);

            DateTime ToDate = new DateTime(To_Year, To_Month, To_Day, To_Hour, To_Minute, 0);

            int    importance_int = Parsers.ParseInt(drpImportance.Text);
            string alertContent   = txtAlertContent.Text;

            AlertImportance importance = AlertImportance.Normal;

            if (importance_int > 0)
            {
                importance = AlertImportance.High;
            }

            if (!string.IsNullOrEmpty(alertContent))
            {
                Alert newAlert = new Alert()
                {
                    Content     = alertContent,
                    DisplayFrom = FromDate,
                    DisplayTo   = ToDate,
                    Importance  = importance
                };

                AlertRepository alertRepo = new AlertRepository();
                alertRepo.Insert(newAlert);
                Response.Redirect(Request.RawUrl);
            }
        }