예제 #1
0
        private void BindData()
        {
            try
            {
                dlRobots.DataSource = null;
                dlRobots.DataBind();

                List <Wink.Robot> robots = new List <Wink.Robot>();

                if (SettingMgmt.getSetting("Hide-Empty-Robots").ToLower() == "true")
                {
                    robots = Wink.myWink.Robots.Where(p => !p.isempty).ToList();
                }
                else
                {
                    robots = Wink.myWink.Robots;
                }

                robots = robots.OrderBy(c => c.position).ThenBy(c => c.displayName).ToList();

                dlRobots.DataSource = robots;
                dlRobots.DataBind();
            }
            catch (Exception ex)
            {
                throw; //EventLog.WriteEntry("WinkAtHome.Robots.BindData", ex.Message, EventLogEntryType.Error);
            }
        }
예제 #2
0
        protected void Page_Load(object sender, EventArgs e)
        {
            try
            {
                hfSettingBase.Value = Request.RawUrl.Substring(Request.RawUrl.LastIndexOf('/') + 1) + "-Shortcuts-MV" + ((Table)Page.Master.FindControl("tblExpand")).Visible.ToString();
                if (!IsPostBack)
                {
                    string columns = SettingMgmt.getSetting(hfSettingBase.Value + "-Columns");
                    if (columns != null)
                    {
                        tbColumns.Text = columns;
                    }

                    string dataVisible = SettingMgmt.getSetting(hfSettingBase.Value + "-Visible");
                    if (dataVisible != null)
                    {
                        bool visible = true;
                        bool.TryParse(dataVisible, out visible);
                        rowData.Visible = visible;
                        cbShow.Checked  = visible;
                    }

                    BindData();
                }
            }
            catch (Exception ex)
            {
                throw; //EventLog.WriteEntry("WinkAtHome.Shortcuts.Page_Load", ex.Message, EventLogEntryType.Error);
            }
        }
예제 #3
0
        protected void Page_Load(object sender, EventArgs e)
        {
            hfSettingBase.Value = Request.RawUrl.Substring(Request.RawUrl.LastIndexOf('/') + 1) + "-Groups-MV" + ((Table)Page.Master.FindControl("tblExpand")).Visible.ToString();
            if (!IsPostBack)
            {
                string columns = SettingMgmt.getSetting(hfSettingBase.Value + "-Columns");
                if (columns != null)
                {
                    tbColumns.Text = columns;
                }

                string dataVisible = SettingMgmt.getSetting(hfSettingBase.Value + "-Visible");
                if (dataVisible != null)
                {
                    bool visible = true;
                    bool.TryParse(dataVisible, out visible);
                    rowData.Visible = visible;
                    cbShow.Checked  = visible;
                }

                string hideEmpty = SettingMgmt.getSetting("Hide-Empty-Groups").ToLower();
                if (hideEmpty != null)
                {
                    bool visible = true;
                    bool.TryParse(hideEmpty, out visible);
                    cbHideEmpty.Checked = visible;
                }

                BindData();
            }
        }
예제 #4
0
        protected void Page_Load(object sender, EventArgs e)
        {
            try
            {
                if (!IsPostBack)
                {
                    hfSettingBase.Value = Request.RawUrl.Substring(Request.RawUrl.LastIndexOf('/') + 1) + "-PubNub-MV" + ((Table)Page.Master.FindControl("tblExpand")).Visible.ToString();

                    bool   visible     = true;
                    string dataVisible = SettingMgmt.getSetting(hfSettingBase.Value + "-Visible");
                    if (dataVisible != null)
                    {
                        bool.TryParse(dataVisible, out visible);
                        rowData.Visible = visible;
                        cbShow.Checked  = visible;
                    }

                    AsyncPostBackTrigger trigger         = new AsyncPostBackTrigger();
                    System.Web.UI.Timer  tmrCheckChanges = (System.Web.UI.Timer)Page.Master.FindControl("tmrCheckChanges");
                    if (tmrCheckChanges != null && visible)
                    {
                        trigger.ControlID = tmrCheckChanges.ID;
                        UpdatePanelPubNub.Triggers.Add(trigger);
                    }
                }
            }
            catch (Exception ex)
            {
                throw; //EventLog.WriteEntry("WinkAtHome.PubNubDisplay.Page_Load", ex.Message, EventLogEntryType.Error);
            }
        }
예제 #5
0
        protected void btnSettingsClose_Click(object sender, EventArgs e)
        {
            Session["modalshowing"] = "false";

            rowData.Visible = cbShow.Checked;
            SettingMgmt.saveSetting(hfSettingBase.Value + "-Visible", cbShow.Checked.ToString());

            mpeSettings.Hide();
        }
예제 #6
0
        protected void ibSettingsClose_Click(object sender, EventArgs e)
        {
            Session["modalshowing"] = "false";

            rowData.Visible = cbShow.Checked;
            SettingMgmt.saveSetting(hfSettingBase.Value + "-Visible", cbShow.Checked.ToString());

            SettingMgmt.saveSetting(hfSettingBase.Value + "-Columns", tbColumns.Text);

            SettingMgmt.saveSetting("Hide-Empty-Groups", cbHideEmpty.Checked.ToString());

            mpeSettings.Hide();

            BindData();
        }
예제 #7
0
        protected void ibSettingsClose_Click(object sender, EventArgs e)
        {
            Session["modalshowing"] = "false";

            rowData.Visible = cbShow.Checked;
            SettingMgmt.saveSetting(hfSettingBase.Value + "-Visible", cbShow.Checked.ToString());

            SettingMgmt.saveSetting(hfSettingBase.Value + "-Columns", tbColumns.Text);

            SettingMgmt.saveSetting("Hide-Empty-Robots", cbHideEmpty.Checked.ToString());

            SettingMgmt.saveSetting("Robot-Alert-Minutes-Since-Last-Trigger", tbAlertTimeout.Text);

            mpeSettings.Hide();

            BindData();
        }
예제 #8
0
        protected void Page_Load(object sender, EventArgs e)
        {
            try
            {
                hfSettingBase.Value = Request.RawUrl.Substring(Request.RawUrl.LastIndexOf('/') + 1) + "-Robots-MV" + ((Table)Page.Master.FindControl("tblExpand")).Visible.ToString();
                if (!IsPostBack)
                {
                    string columns = SettingMgmt.getSetting(hfSettingBase.Value + "-Columns");
                    if (columns != null)
                    {
                        tbColumns.Text         = columns;
                        dlRobots.RepeatColumns = Convert.ToInt32(tbColumns.Text);
                    }

                    string dataVisible = SettingMgmt.getSetting(hfSettingBase.Value + "-Visible");
                    if (dataVisible != null)
                    {
                        bool visible = true;
                        bool.TryParse(dataVisible, out visible);
                        rowData.Visible = visible;
                        cbShow.Checked  = visible;
                    }

                    string hideEmpty = SettingMgmt.getSetting("Hide-Empty-Robots").ToLower();
                    if (hideEmpty != null)
                    {
                        bool visible = true;
                        bool.TryParse(hideEmpty, out visible);
                        cbHideEmpty.Checked = visible;
                    }

                    string alerttimeout = SettingMgmt.getSetting("Robot-Alert-Minutes-Since-Last-Trigger");
                    if (alerttimeout != null)
                    {
                        tbAlertTimeout.Text = alerttimeout;
                    }


                    BindData();
                }
            }
            catch (Exception ex)
            {
                throw; //EventLog.WriteEntry("WinkAtHome.Robots.Page_Load", ex.Message, EventLogEntryType.Error);
            }
        }
예제 #9
0
        protected void Page_Load(object sender, EventArgs e)
        {
            hfSettingBase.Value = Request.RawUrl.Substring(Request.RawUrl.LastIndexOf('/') + 1) + "-Devices-MV" + ((Table)Page.Master.FindControl("tblExpand")).Visible.ToString() + "-CO" + ControllableOnly.ToString() + "-SO" + SensorsOnly.ToString() + "-Type" + typeToShow;
            if (!IsPostBack)
            {
                if (Request.QueryString["devicetype"] != null)
                {
                    string type = Request.QueryString["devicetype"].ToLower();
                    if (type == "controllable")
                    {
                        ControllableOnly = true;
                    }
                    else if (type == "sensors")
                    {
                        SensorsOnly = true;
                    }
                    else
                    {
                        typeToShow         = type;
                        hfDeviceType.Value = typeToShow;
                    }
                }

                string columns = SettingMgmt.getSetting(hfSettingBase.Value + "-Columns");
                if (columns != null)
                {
                    tbColumns.Text = columns;
                }

                string dataVisible = SettingMgmt.getSetting(hfSettingBase.Value + "-Visible");
                if (dataVisible != null)
                {
                    bool visible = true;
                    bool.TryParse(dataVisible, out visible);
                    rowData.Visible = visible;
                    cbShow.Checked  = visible;
                }

                BindData();
            }
            else
            {
            }
        }
예제 #10
0
        private void BindData()
        {
            dlGroups.DataSource = null;
            dlGroups.DataBind();

            List <Wink.Group> groups;

            if (SettingMgmt.getSetting("Hide-Empty-Groups").ToLower() == "true")
            {
                groups = Wink.myWink.Groups.Where(p => !p.isempty).ToList();
            }
            else
            {
                groups = Wink.myWink.Groups;
            }

            groups = groups.OrderBy(c => c.position).ThenBy(c => c.displayName).ToList();

            dlGroups.DataSource = groups;
            dlGroups.DataBind();
        }
예제 #11
0
        protected void dlRobots_ItemDataBound(object sender, DataListItemEventArgs e)
        {
            try
            {
                if (e.Item.ItemType == ListItemType.Item || e.Item.ItemType == ListItemType.AlternatingItem)
                {
                    Wink.Robot robot = ((Wink.Robot)e.Item.DataItem);

                    //BIND INFO BUTTON
                    var props      = typeof(Wink.Robot).GetProperties();
                    var properties = new List <KeyValuePair <string, string> >();
                    foreach (var prop in props)
                    {
                        if (prop.Name != "json")
                        {
                            TextInfo textInfo = new CultureInfo("en-US", false).TextInfo;

                            string propname  = textInfo.ToTitleCase(prop.Name.Replace("_", " "));
                            var    propvalue = prop.GetValue(robot, null);
                            if (propvalue != null)
                            {
                                properties.Add(new KeyValuePair <string, string>(propname, propvalue.ToString()));
                            }
                        }
                    }
                    DataList dlProperties = (DataList)e.Item.FindControl("dlProperties");
                    if (dlProperties != null)
                    {
                        var displayprops = properties.Where(p => p.Value.ToLower() != "schedules only");

                        dlProperties.DataSource = displayprops;
                        dlProperties.DataBind();
                    }

                    TextBox tbPosition = (TextBox)e.Item.FindControl("tbPosition");
                    tbPosition.Text = robot.position > 1000 ? "" : (robot.position).ToString();

                    TextBox tbDisplayName = (TextBox)e.Item.FindControl("tbDisplayName");
                    tbDisplayName.Text = robot.displayName;

                    //Assign Image
                    ImageButton imgIcon = (ImageButton)e.Item.FindControl("imgIcon");
                    imgIcon.ImageUrl = "~/Images/Robots/" + (robot.isschedule ? "schedule" : "robot") + robot.enabled + ".png";

                    if (robot.isschedule)
                    {
                        imgIcon.Enabled = false;
                    }


                    //Set Last/Next Trigger Time
                    string tooltip = "Last Triggered: " + robot.last_fired;
                    if (robot.isschedule)
                    {
                        tooltip += Environment.NewLine + "Next Scheduled Run: " + robot.next_run;
                    }

                    TextBox tbName = (TextBox)e.Item.FindControl("tbName");
                    tbName.ToolTip = tooltip;

                    //Resize for long names
                    int i       = tbName.Text.Length;
                    int rowsize = (i / 23) + 2;
                    tbName.Rows = rowsize;

                    //Set Alert icon
                    DateTime lastalert = DateTime.MinValue;
                    if (DateTime.TryParse(robot.last_fired, out lastalert))
                    {
                        string alertTimeout = SettingMgmt.getSetting("Robot-Alert-Minutes-Since-Last-Trigger");
                        Int32  timeout      = 60;
                        Int32.TryParse(alertTimeout, out timeout);

                        DateTime lastTrigger = lastalert;
                        DateTime dateAlert   = DateTime.Now.AddMinutes(timeout * -1);

                        if (lastTrigger > dateAlert)
                        {
                            Image imgAlert = (Image)e.Item.FindControl("imgAlert");
                            imgAlert.Visible = true;
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                throw; //EventLog.WriteEntry("WinkAtHome.Robots.dlRobots_ItemDataBound", ex.Message, EventLogEntryType.Error);
            }
        }