Esempio n. 1
0
        protected void SetNewScheduleButton_Click(object sender, EventArgs e)
        {
            string path       = HttpContext.Current.Request.Url.AbsolutePath;
            string devicename = path.Remove(0, path.LastIndexOf('/') + 1);

            int timezoneoffset = ExtraCommands.GetTimeZoneOffsetMinutes(Request);

            ChangeScheduleButton.CssClass = "btn btn-sm inline-blocks pull-right";
            SetNewScheduleButton.Visible  = false;

            newSchedule.Visible = false;

            string offtime = Request.Form[newofftime.UniqueID];
            string ontime  = Request.Form[newontime.UniqueID];

            DatabaseCalls.SetOffTimeValue(offtime, devicename, timezoneoffset);
            DatabaseCalls.SetOnTimeValue(ontime, devicename, timezoneoffset);
        }
Esempio n. 2
0
        protected void UpdateDeviceView(object sender, EventArgs e)
        {
            //add device name
            string path       = HttpContext.Current.Request.Url.AbsolutePath;
            string devicename = path.Remove(0, path.LastIndexOf('/') + 1);

            DeviceNameLabel.Text = devicename;

            //timezone offset
            int timezoneoffset = ExtraCommands.GetTimeZoneOffsetMinutes(Request);

            //TODO Validate if data exists

            try
            {
                //Last Update Time
                DateTime lastupdatetimeutc = DatabaseCalls.GetNewestConnectionDate(devicename);
                LastUpdatedTime.Text = "Last connected at " + lastupdatetimeutc.AddMinutes(timezoneoffset).ToShortTimeString() + " on " + lastupdatetimeutc.AddMinutes(timezoneoffset).ToShortDateString();

                //State
                if (!Page.IsPostBack)
                {
                    if (DatabaseCalls.GetNewestDeviceState(devicename) == "ON")
                    {
                        OnChangeControllerStateButton.CssClass  = "btn btn-lg btn-on";
                        OffChangeControllerStateButton.CssClass = "btn btn-lg";
                    }
                    else
                    {
                        OnChangeControllerStateButton.CssClass  = "btn btn-lg";
                        OffChangeControllerStateButton.CssClass = "btn btn-lg btn-off";
                    }
                }

                //Times
                try
                {
                    DateTime offtime = DatabaseCalls.GetOffTimeValue(devicename, timezoneoffset);
                    DateTime ontime  = DatabaseCalls.GetOnTimeValue(devicename, timezoneoffset);

                    NextTime.Text = "Off from: " + offtime.ToShortTimeString() + " - " + ontime.ToShortTimeString();

                    newofftime.Text = offtime.ToString("HH:mm");
                    newontime.Text  = ontime.ToString("HH:mm");
                }
                catch
                {
                    NextTime.Text = "- None";
                }


                //Power
                CurrentPower.Text = DatabaseCalls.GetNewestPowerValue(devicename).ToString() + " W";

                //Temperature
                CurrentTemperature.Text = DatabaseCalls.GetNewestTemperatureValue(devicename).ToString() + " °C";
            }
            catch
            {
                LastUpdatedTime.CssClass = "alert alert-warning";
                LastUpdatedTime.Text     = "This device with UID: " + DatabaseCalls.GetUIDFromDeviceName(devicename) + " has not connected to our servers yet";
            }
        }
        protected void Page_Load(object sender, EventArgs e)
        {
            int timezoneoffset = ExtraCommands.GetTimeZoneOffsetMinutes(Request);

            TimezoneDisplay.Text = timezoneoffset.ToString();
        }